Skip to content

Commit fac2283

Browse files
committed
#219 show receipt/invoice link only for the new orders
1 parent 64fa057 commit fac2283

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/main/java/alfio/controller/InvoiceReceiptController.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public InvoiceReceiptController(EventRepository eventRepository,
6060
}
6161

6262
private ResponseEntity<Void> handleReservationWith(String eventName, String reservationId, HttpServletResponse response, BiFunction<Event, TicketReservation, ResponseEntity<Void>> with) {
63-
ResponseEntity<Void> notFound = ResponseEntity.<Void>notFound().build();
63+
ResponseEntity<Void> notFound = ResponseEntity.notFound().build();
6464
return eventRepository.findOptionalByShortName(eventName).map(event -> {
6565
return ticketReservationManager.findById(reservationId).map(ticketReservation -> {
6666
return with.apply(event, ticketReservation);
@@ -93,7 +93,7 @@ public ResponseEntity<Void> getReceipt(@PathVariable("eventName") String eventNa
9393
@PathVariable("reservationId") String reservationId,
9494
HttpServletResponse response) {
9595
return handleReservationWith(eventName, reservationId, response, (event, reservation) -> {
96-
if(reservation.getInvoiceNumber() != null) {
96+
if(reservation.getInvoiceNumber() != null || !reservation.getHasInvoiceOrReceiptDocument()) {
9797
return ResponseEntity.notFound().build();
9898
}
9999

@@ -108,7 +108,7 @@ public void getInvoice(@PathVariable("eventName") String eventName,
108108
@PathVariable("reservationId") String reservationId,
109109
HttpServletResponse response) {
110110
handleReservationWith(eventName, reservationId, response, (event, reservation) -> {
111-
if(reservation.getInvoiceNumber() == null) {
111+
if(reservation.getInvoiceNumber() == null || !reservation.getHasInvoiceOrReceiptDocument()) {
112112
return ResponseEntity.notFound().build();
113113
}
114114

src/main/java/alfio/model/TicketReservation.java

+4
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,8 @@ public String getFullName() {
113113
public boolean getHasInvoiceNumber() {
114114
return invoiceNumber != null;
115115
}
116+
117+
public boolean getHasInvoiceOrReceiptDocument() {
118+
return invoiceModel != null;
119+
}
116120
}

src/main/webapp/WEB-INF/templates/event/reservation-page-complete.ms

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<div class="text-center">
9999
{{#i18n}}reservation-page-complete.order-information [{{reservation.id}}] [{{reservation.fullName}}]{{/i18n}}
100100
</div>
101+
{{#reservation.hasInvoiceOrReceiptDocument}}
101102
<div class="text-center">
102103
{{#reservation.hasInvoiceNumber}}
103104
<a href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/invoice" target="_blank">{{#i18n}}reservation-page-complete.download-your-invoice{{/i18n}}</a>
@@ -106,6 +107,7 @@
106107
<a href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/receipt" target="_blank">{{#i18n}}reservation-page-complete.download-your-receipt{{/i18n}}</a>
107108
{{/reservation.hasInvoiceNumber}}
108109
</div>
110+
{{/reservation.hasInvoiceOrReceiptDocument}}
109111
<div class="text-center wMarginTop30px">
110112
<span class="text-muted"><a href="https://alf.io" title="{{#i18n}}alfio.credits{{/i18n}}" target="_blank">{{#i18n}}alfio.credits{{/i18n}}</a></span>
111113
</div>

src/main/webapp/WEB-INF/templates/event/reservation-waiting-for-payment.ms

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<div class="text-center wMarginTop">
2020
<h4>{{#i18n}}reservation-page-waiting.questions [{{emailAddress}}] [{{reservation.id}}]{{/i18n}}</h4>
2121
</div>
22+
{{#reservation.hasInvoiceOrReceiptDocument}}
2223
<div class="text-center">
2324
<h4>
2425
{{#reservation.hasInvoiceNumber}}
@@ -29,6 +30,7 @@
2930
{{/reservation.hasInvoiceNumber}}
3031
</h4>
3132
</div>
33+
{{/reservation.hasInvoiceOrReceiptDocument}}
3234
<div class="wMarginBottom">&nbsp;</div>
3335
<div class="container-fluid" id="back-to-event-site">
3436
<div class="pull-left"><a href="{{event.websiteUrl}}" class="btn btn-default">{{#i18n}}to-event-site{{/i18n}}</a></div>

0 commit comments

Comments
 (0)