Skip to content

Commit 7c2231c

Browse files
authored
fix: Resolve broken discount codes for tax inclusive tickets (#3321)
1 parent cd69694 commit 7c2231c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

app/components/public/ticket-list.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default Component.extend(FormMixin, {
6262
total: computed('[email protected]', '[email protected]', '[email protected]', function() {
6363
if (this.taxInfo !== null) {
6464
return sumBy(this.tickets.toArray(),
65-
ticket => (ticket.ticketPriceWithTax || 0) * (ticket.orderQuantity || 0)
65+
ticket => ((ticket.ticketPriceWithTax || 0) - (ticket.discount || 0)) * (ticket.orderQuantity || 0)
6666
);
6767
}
6868
return sumBy(this.tickets.toArray(),
@@ -123,9 +123,7 @@ export default Component.extend(FormMixin, {
123123
this.set('invalidPromotionalCode', true);
124124
}
125125
try {
126-
let discountCode = await this.store.findRecord('discount-code', this.promotionalCode, {
127-
include: 'tickets'
128-
});
126+
let discountCode = await this.store.queryRecord('discount-code', { eventIdentifier: this.event.id, code: this.promotionalCode });
129127
let discountCodeEvent = await discountCode.get('event');
130128
if (this.currentEventIdentifier === discountCodeEvent.identifier) {
131129
let discountType = discountCode.get('type');
@@ -151,6 +149,7 @@ export default Component.extend(FormMixin, {
151149
this.set('invalidPromotionalCode', true);
152150
}
153151
} catch (e) {
152+
console.warn(e);
154153
if (this.invalidPromotionalCode) {
155154
this.set('invalidPromotionalCode', true);
156155
}

app/templates/components/public/ticket-list.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
</td>
9191
<td id='{{ticket.id}}_subtotal' class="ui right aligned">
9292
{{#if taxInfo}}
93-
{{currency-symbol eventCurrency}} {{format-number (mult ticket.ticketPriceWithTax ticket.orderQuantity)}}
93+
{{currency-symbol eventCurrency}} {{format-number (mult (sub ticket.ticketPriceWithTax ticket.discount) ticket.orderQuantity)}}
9494
{{else}}
9595
{{currency-symbol eventCurrency}} {{format-number (mult (sub ticket.price ticket.discount) ticket.orderQuantity)}}
9696
{{/if}}

0 commit comments

Comments
 (0)