Skip to content

Commit

Permalink
#449 - do not download invoices for cancelled reservations
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed May 22, 2018
1 parent 6ea42cd commit 4c35e61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/alfio/controller/InvoiceReceiptController.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ResponseEntity<Void> getReceipt(@PathVariable("eventName") String eventNa
@PathVariable("reservationId") String reservationId,
HttpServletResponse response) {
return handleReservationWith(eventName, reservationId, (event, reservation) -> {
if(reservation.getInvoiceNumber() != null || !reservation.getHasInvoiceOrReceiptDocument()) {
if(reservation.getInvoiceNumber() != null || !reservation.getHasInvoiceOrReceiptDocument() || reservation.isCancelled()) {
return ResponseEntity.notFound().build();
}

Expand All @@ -107,7 +107,7 @@ public void getInvoice(@PathVariable("eventName") String eventName,
@PathVariable("reservationId") String reservationId,
HttpServletResponse response) {
handleReservationWith(eventName, reservationId, (event, reservation) -> {
if(reservation.getInvoiceNumber() == null || !reservation.getHasInvoiceOrReceiptDocument()) {
if(reservation.getInvoiceNumber() == null || !reservation.getHasInvoiceOrReceiptDocument() || reservation.isCancelled()) {
return ResponseEntity.notFound().build();
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/alfio/model/TicketReservation.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public List<String> getLineSplittedBillingAddress() {
return Arrays.asList(StringUtils.split(billingAddress, '\n'));
}

public boolean isCancelled() {
return status == TicketReservationStatus.CANCELLED;
}

@JsonIgnore
public String getPaidAmount() {
//this is a hack, for the payment cases where we don't have a remote call like paypal/stripe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int postponePayment(@Bind("reservationId") String reservationId, @Bind("validity
@Query("update tickets_reservation set invoice_number = :invoiceNumber where id = :reservationId")
int setInvoiceNumber(@Bind("reservationId") String reservationId, @Bind("invoiceNumber") String invoiceNumber);

@Query("select * from tickets_reservation where invoice_number is not null and event_id_fk = :eventId order by confirmation_ts desc, validity desc")
@Query("select * from tickets_reservation where invoice_number is not null and status <> 'CANCELLED' and event_id_fk = :eventId order by confirmation_ts desc, validity desc")
List<TicketReservation> findAllReservationsWithInvoices(@Bind("eventId") int eventId);

@Query("select count(*) from tickets_reservation where invoice_number is not null and event_id_fk = :eventId")
Expand Down

0 comments on commit 4c35e61

Please sign in to comment.