Skip to content

Commit

Permalink
Showing 7 changed files with 29 additions and 30 deletions.
12 changes: 8 additions & 4 deletions src/main/java/alfio/manager/TicketReservationManager.java
Original file line number Diff line number Diff line change
@@ -708,9 +708,12 @@ List<SummaryRow> extractSummary(String reservationId, Event event, Locale locale
.collect(Collectors.groupingBy(TicketPriceContainer::getCategoryId))
.forEach((categoryId, ticketsByCategory) -> {
final int subTotal = ticketsByCategory.stream().mapToInt(TicketPriceContainer::getSrcPriceCts).sum();
final int ticketPriceCts = ticketsByCategory.get(0).getSrcPriceCts();
final int subTotalBeforeVat = ticketsByCategory.stream().mapToInt(t -> t.getFinalPriceCts() - t.getVatCts()).sum();
TicketPriceContainer firstTicket = ticketsByCategory.get(0);
final int ticketPriceCts = firstTicket.getSrcPriceCts();
final int priceBeforeVat = firstTicket.getFinalPriceCts() - firstTicket.getVatCts();
String categoryName = ticketCategoryRepository.getById(categoryId, event.getId()).getName();
summary.add(new SummaryRow(categoryName, formatCents(ticketPriceCts), ticketsByCategory.size(), formatCents(subTotal), subTotal, SummaryRow.SummaryType.TICKET));
summary.add(new SummaryRow(categoryName, formatCents(ticketPriceCts), formatCents(priceBeforeVat), ticketsByCategory.size(), formatCents(subTotal), formatCents(subTotalBeforeVat), subTotal, SummaryRow.SummaryType.TICKET));
});

summary.addAll(collectAdditionalServiceItems(reservationId, event)
@@ -723,15 +726,16 @@ List<SummaryRow> extractSummary(String reservationId, Event event, Locale locale
List<AdditionalServiceItemPriceContainer> prices = generateASIPriceContainers(event, null).apply(entry).collect(toList());
AdditionalServiceItemPriceContainer first = prices.get(0);
final int subtotal = prices.stream().mapToInt(AdditionalServiceItemPriceContainer::getSrcPriceCts).sum();
return new SummaryRow(title.getValue(), formatCents(first.getSrcPriceCts()), prices.size(), formatCents(subtotal), subtotal, SummaryRow.SummaryType.ADDITIONAL_SERVICE);
return new SummaryRow(title.getValue(), formatCents(first.getSrcPriceCts()), formatCents(first.getSrcPriceCts()), prices.size(), formatCents(subtotal), formatCents(subtotal), subtotal, SummaryRow.SummaryType.ADDITIONAL_SERVICE);
}).collect(Collectors.toList()));

Optional.ofNullable(promoCodeDiscount).ifPresent(promo -> {
String formattedSingleAmount = "-" + (promo.getDiscountType() == DiscountType.FIXED_AMOUNT ? formatCents(promo.getDiscountAmount()) : (promo.getDiscountAmount()+"%"));
summary.add(new SummaryRow(formatPromoCode(promo, ticketRepository.findTicketsInReservation(reservationId)),
formattedSingleAmount,
formattedSingleAmount,
reservationCost.getDiscountAppliedCount(),
formatCents(reservationCost.getDiscount()), reservationCost.getDiscount(), SummaryRow.SummaryType.PROMOTION_CODE));
formatCents(reservationCost.getDiscount()), formatCents(reservationCost.getDiscount()), reservationCost.getDiscount(), SummaryRow.SummaryType.PROMOTION_CODE));
});
return summary;
}
2 changes: 2 additions & 0 deletions src/main/java/alfio/model/SummaryRow.java
Original file line number Diff line number Diff line change
@@ -22,8 +22,10 @@
public class SummaryRow {
private final String name;
private final String price;
private final String priceBeforeVat;
private final int amount;
private final String subTotal;
private final String subTotalBeforeVat;
private final int originalSubTotal;
private final SummaryType type;

12 changes: 6 additions & 6 deletions src/main/java/alfio/model/system/ConfigurationKeys.java
Original file line number Diff line number Diff line change
@@ -32,11 +32,10 @@ public enum ConfigurationKeys {
SUPPORTED_LANGUAGES("supported languages", false, SettingCategory.GENERAL, ComponentType.LIST, true, EnumSet.of(SYSTEM), true),

BASE_URL("Base application url", false, SettingCategory.GENERAL, ComponentType.TEXT, true, EnumSet.of(SYSTEM), true),
VAT_NR("VAT number", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), true),


MAPS_SERVER_API_KEY("Google maps' server api key", false, SettingCategory.GENERAL, ComponentType.TEXT, true, EnumSet.of(SYSTEM), true),
MAPS_CLIENT_API_KEY("Google maps' client api key", false, SettingCategory.GENERAL, ComponentType.TEXT, true, EnumSet.of(SYSTEM), true),

STRIPE_SECRET_KEY("Stripe's secret key", false, SettingCategory.PAYMENT_STRIPE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), false),
STRIPE_PUBLIC_KEY("Stripe's public key", false, SettingCategory.PAYMENT_STRIPE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), false),

@@ -69,7 +68,7 @@ public enum ConfigurationKeys {
BANK_ACCOUNT_OWNER("Bank Account owner", false, SettingCategory.PAYMENT_OFFLINE, ComponentType.TEXTAREA, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), false),
PARTIAL_RESERVATION_ID_LENGTH("Partial reservationID length", false, SettingCategory.PAYMENT_OFFLINE, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true),
//

//mailgun configuration related info
MAILGUN_KEY("Mailgun key", false, SettingCategory.MAIL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true),
MAILGUN_DOMAIN("Mailgun domain", false, SettingCategory.MAIL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true),
@@ -80,7 +79,7 @@ public enum ConfigurationKeys {
MAILJET_APIKEY_PRIVATE("Mailjet private api key", false, SettingCategory.MAIL, ComponentType.TEXT, false, EnumSet.of(SYSTEM), true),
MAILJET_FROM("Mailjet E-Mail sender", false, SettingCategory.MAIL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
//

GOOGLE_ANALYTICS_KEY("Google Analytics tracking ID", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
GOOGLE_ANALYTICS_ANONYMOUS_MODE("Run Google Analytics without cookies and scrambling the client IP address (default true)", false, SettingCategory.GENERAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM), true),

@@ -90,7 +89,7 @@ public enum ConfigurationKeys {
ENABLE_PRE_REGISTRATION("Enable pre-registration (default false)", false, SettingCategory.GENERAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
ENABLE_WAITING_QUEUE_NOTIFICATION("Do you want to receive an e-mail when someone subscribes to the waiting queue? (default: false)", false, SettingCategory.GENERAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
WAITING_QUEUE_RESERVATION_TIMEOUT("The maximum time, in hours, before the \"waiting queue\" reservation would expire (default: 4)", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),

//
MAIL_ATTEMPTS_COUNT("The number of attempts when trying to sending an email (default: 10)", false, SettingCategory.MAIL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),

@@ -101,6 +100,7 @@ public enum ConfigurationKeys {
//

//
VAT_NR("VAT number", false, SettingCategory.INVOICE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), true),
INVOICE_NUMBER_PATTERN("Invoice number pattern, example: INVOICE-%d", false, SettingCategory.INVOICE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
INVOICE_ADDRESS("Invoice address", false, SettingCategory.INVOICE, ComponentType.TEXTAREA, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true);
//
2 changes: 1 addition & 1 deletion src/main/java/alfio/util/TemplateResource.java
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ private static Map<String, Object> prepareSampleDataForConfirmationEmail(Organiz
Optional<String> vat = Optional.of("VAT-NR");
List<Ticket> tickets = Collections.singletonList(sampleTicket());
OrderSummary orderSummary = new OrderSummary(new TotalPrice(1000, 80, 0, 0),
Collections.singletonList(new SummaryRow("Ticket", "10.00", 1, "10.00", 1000, SummaryRow.SummaryType.TICKET)), false, "10.00", "0.80", false, false, "8");
Collections.singletonList(new SummaryRow("Ticket", "10.00", "9.20", 1, "9.20", "9.20", 1000, SummaryRow.SummaryType.TICKET)), false, "10.00", "0.80", false, false, "8");
String reservationUrl = "http://your-domain.tld/reservation-url/";
String reservationShortId = "597e7e7b";
return prepareModelForConfirmationEmail(organization, event, reservation, vat, tickets, orderSummary, reservationUrl, reservationShortId, Optional.of("My Invoice\nAddress"), Optional.empty(), Optional.empty());
11 changes: 3 additions & 8 deletions src/main/resources/alfio/templates/invoice.ms
Original file line number Diff line number Diff line change
@@ -146,22 +146,17 @@
<tr>
<td class="text-center">{{amount}}</td>
<td>{{name}}</td>
<td class="text-right">{{price}}</td>
<td class="text-right">{{subTotal}}</td>
<td class="text-right">{{priceBeforeVat}}</td>
<td class="text-right">{{subTotalBeforeVat}}</td>
</tr>
{{/orderSummary.summary}}
</tbody>
<tfoot>
{{^orderSummary.free}}
{{^event.vatIncluded}}
<tr><th colspan="3" class="no-padding">{{#i18n}}reservation-page.vat [{{event.vat}}]{{/i18n}}</th><th class="text-right">{{orderSummary.totalVAT}}</th></tr>
{{/event.vatIncluded}}
<tr><th colspan="3" class="no-padding">{{#i18n}}reservation-page.vat [{{event.vat}}]{{/i18n}}</th><th class="text-right">{{orderSummary.totalVAT}}</th></tr>
{{/orderSummary.free}}
<tr><th colspan="3" class="strong" class="no-padding">{{#i18n}}reservation-page.total{{/i18n}}</th><th class="text-right strong">{{event.currency}} {{orderSummary.totalPrice}}</th></tr>
{{^orderSummary.free}}
{{#event.vatIncluded}}
<tr><th colspan="3" class="no-padding">{{#i18n}}reservation-page.vat-included [{{event.vat}}]{{/i18n}}</th><th class="text-right">{{orderSummary.totalVAT}}</th></tr>
{{/event.vatIncluded}}
{{/orderSummary.free}}
</tfoot>
</table>
Original file line number Diff line number Diff line change
@@ -60,9 +60,16 @@
<div class="row">
<div class="col-sm-12">
<form action="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/re-send-email" method="post" class="form-inline text-align-right">
<button type="submit" class="btn btn-default">{{#i18n}}reservation-page-complete.resend-reservation-email{{/i18n}}</button>
<button type="submit" class="btn btn-default"><i class="fa fa-envelope-o"></i> {{#i18n}}reservation-page-complete.resend-reservation-email{{/i18n}}</button>
{{#reservation.hasInvoiceNumber}}
<a class="btn btn-default" href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/invoice" target="_blank"><i class="fa fa-download"></i> {{#i18n}}reservation-page-complete.download-your-invoice{{/i18n}}</a>
{{/reservation.hasInvoiceNumber}}
{{^reservation.hasInvoiceNumber}}
<a class="btn btn-default" href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/receipt" target="_blank"><i class="fa fa-download"></i> {{#i18n}}reservation-page-complete.download-your-receipt{{/i18n}}</a>
{{/reservation.hasInvoiceNumber}}
<input type="hidden" name="{{_csrf.parameterName}}" value="{{_csrf.token}}">
</form>

</div>
</div>
</div>
@@ -98,16 +105,6 @@
<div class="text-center">
{{#i18n}}reservation-page-complete.order-information [{{reservation.id}}] [{{reservation.fullName}}]{{/i18n}}
</div>
{{#reservation.hasInvoiceOrReceiptDocument}}
<div class="text-center">
{{#reservation.hasInvoiceNumber}}
<a href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/invoice" target="_blank">{{#i18n}}reservation-page-complete.download-your-invoice{{/i18n}}</a>
{{/reservation.hasInvoiceNumber}}
{{^reservation.hasInvoiceNumber}}
<a href="{{request.contextPath}}/event/{{event.shortName}}/reservation/{{reservationId}}/receipt" target="_blank">{{#i18n}}reservation-page-complete.download-your-receipt{{/i18n}}</a>
{{/reservation.hasInvoiceNumber}}
</div>
{{/reservation.hasInvoiceOrReceiptDocument}}
<div class="text-center wMarginTop30px">
<span class="text-muted"><a href="https://alf.io" title="{{#i18n}}alfio.credits{{/i18n}}" target="_blank">{{#i18n}}alfio.credits{{/i18n}}</a></span>
</div>
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ <h2>E-Mail</h2>
<div class="page-header">
<h2>Invoice settings</h2>
</div>
<div class="alert alert-info"><i class="fa fa-info-circle"></i> You must fill all the fields below (<i>VAT number, Invoice number pattern, Invoice address</i>), otherwise invoices won't be generated.</div>
<div>
<div data-ng-repeat="setting in organizationConf.settings.INVOICE">
<setting data-obj="setting" data-display-delete-if-needed="true" data-delete-handler="organizationConf.delete(config)" data-ng-class="{'system-setting': setting.configurationPathLevel === 'SYSTEM'}"></setting>

0 comments on commit c0e47ec

Please sign in to comment.