Skip to content

Commit cbcb620

Browse files
author
DIVYAM TAYAL
authored
fix: Hide currency when amount is 0 (#5447)
1 parent 1e65f0a commit cbcb620

File tree

9 files changed

+35
-17
lines changed

9 files changed

+35
-17
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{#if (gt @amount 0)}}{{currency-symbol @currency}}{{/if}} {{format-money @amount}}

app/templates/components/events/view/overview/event-tickets.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</tr>
1616
<tr>
1717
<td>{{t 'Sales (amount)'}}</td>
18-
<td>{{currency-symbol this.data.event.paymentCurrency}} {{format-money this.sales}}</td>
18+
<td><CurrencyAmount @currency={{this.data.event.paymentCurrency}} @amount={{this.sales}}/></td>
1919
</tr>
2020
</tbody>
2121
</table>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{#if (eq @ticket.type 'free')}}
22
{{t "Free"}}
33
{{else}}
4-
{{currency-symbol @currency}} {{format-money @amount}}
4+
<CurrencyAmount @currency={{@currency}} @amount={{@amount}}/>
55
{{/if}}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@
5656
</div>
5757
{{#if ticket.discount}}
5858
<div>
59-
{{currency-symbol this.eventCurrency}} {{format-money (sub ticket.price ticket.discount)}}
59+
<CurrencyAmount @currency={{this.eventCurrency}} @amount={{sub ticket.price ticket.discount}}/>
6060
</div>
6161
{{/if}}
6262
{{/if}}
6363
{{#if (and this.taxInfo (not-eq ticket.type 'free'))}}
6464
<p>
6565
{{#if this.taxInfo.isTaxIncludedInPrice}}
6666
<small class="ui gray-text small">
67-
{{t 'includes'}} {{currency-symbol this.eventCurrency}} {{format-money ticket.includedTaxAmount}}
67+
{{t 'includes'}} <CurrencyAmount @currency={{this.eventCurrency}} @amount={{ticket.includedTaxAmount}}/>
6868
</small>
6969
{{else}}
7070
<small class="ui gray-text small">
71-
+ {{currency-symbol this.eventCurrency}} {{format-money (sub ticket.ticketPriceWithTax ticket.price)}}
71+
+ <CurrencyAmount @currency={{this.eventCurrency}} @amount={{sub ticket.ticketPriceWithTax ticket.price}}/>
7272
</small>
7373
{{/if}}
7474
<span>
@@ -116,22 +116,22 @@
116116
<table class="ui small" style="float: right;">
117117
<tbody>
118118
{{#if orderAmount.tax}}
119-
<tr><td>{{t 'Sub-Total'}}</td><td>{{currency-symbol this.eventCurrency}} {{format-money this.orderAmount.sub_total}}</td></tr>
119+
<tr><td>{{t 'Sub-Total'}}</td><td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.sub_total}}/></td></tr>
120120
<tr>
121121
<td>
122122
<div>{{t 'Tax'}} ({{this.orderAmount.tax.percent}}% {{this.orderAmount.tax.name}})</div>
123123
{{#if orderAmount.tax.included}}
124124
<small class="ui gray-text small">Included in Total</small>
125125
{{/if}}
126126
</td>
127-
<td>{{currency-symbol this.eventCurrency}} {{this.orderAmount.tax.amount}}</td>
127+
<td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.tax.amount}}/></td>
128128
</tr>
129129
{{/if}}
130130
<tr><td>{{t 'Total'}}</td>
131131
{{#if this.amountEditable}}
132-
<td>{{currency-symbol this.eventCurrency}}</td> <td><Input @value={{this.overridenAmount}} placeholder="Total" /></td>
132+
<td>{{#if this.overridenAmount}}{{currency-symbol this.eventCurrency}}{{/if}}</td><td><Input @value={{this.overridenAmount}} placeholder="Total" /></td>
133133
{{else}}
134-
<td>{{currency-symbol this.eventCurrency}} {{format-money this.orderAmount.total}}</td>
134+
<td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.total}}/></td>
135135
{{/if}}
136136
</tr>
137137
</tbody>

app/templates/components/ui-table/cell/events/view/tickets/attendees/cell-price.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="weight-400">
2-
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{format-money this.record}}
2+
<CurrencyAmount @currency={{this.extraRecords.event.paymentCurrency}} @amount={{this.record}}/>
33
</div>
44
{{#if this.extraRecords.discountCode.code}}
55
<div class="ui mini yellow label">

app/templates/components/ui-table/cell/events/view/tickets/discount-codes/cell-value.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
{{#if (eq this.extraRecords.type 'percent')}}
33
{{this.record}} %
44
{{else if (eq this.extraRecords.type 'amount')}}
5-
{{this.currency-symbol this.extraRecords.event.paymentCurrency}}{{this.record}}
5+
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{this.record}}
66
{{/if}}
77
</span>

app/templates/components/ui-table/cell/events/view/tickets/orders/cell-amount.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="weight-400">
2-
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{format-money this.record}}
2+
<CurrencyAmount @currency={{this.extraRecords.event.paymentCurrency}} @amount={{this.record}}/>
33
</div>
44
{{#if this.extraRecords.discountCode.code}}
55
<div class="ui mini yellow label">

app/templates/events/view/tickets/index.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</div>
55
<div class="ui {{if this.device.isMobile 'horizontal'}} three statistics">
66
<div class="statistic"><div class="value">{{this.totalOrders}}</div><div class="label">{{t 'Orders'}}</div></div>
7-
<div class="statistic"><div class="value">{{this.totalAmount}}</div><div class="label">{{t 'Sales'}}({{currency-symbol this.model.eventDetail.paymentCurrency}})</div></div>
7+
<div class="statistic"><div class="value">{{this.totalAmount}}</div><div class="label">{{t 'Sales'}}{{#if this.totalAmount}}({{currency-symbol this.model.eventDetail.paymentCurrency}}){{/if}}</div></div>
88
<div class="statistic"><div class="value">{{this.totalSales}}</div><div class="label">{{t 'Tickets sold'}}</div></div>
99
</div>
1010
</div>
@@ -22,7 +22,7 @@
2222
<th>{{t 'Order Status'}}</th>
2323
<th class="right aligned">{{t 'Total Tickets'}}</th>
2424
<th class="right aligned">{{t 'Total Orders'}}</th>
25-
<th class="right aligned">{{t 'Total Sales' }}({{currency-symbol this.model.eventDetail.paymentCurrency}}) </th>
25+
<th class="right aligned">{{t 'Total Sales' }}{{#if this.totalAmount}}({{currency-symbol this.model.eventDetail.paymentCurrency}}){{/if}} </th>
2626
<th>{{t 'View Reports'}}</th>
2727
</tr>
2828
<tr>
@@ -144,15 +144,15 @@
144144
{{#unless this.device.isMobile}}
145145
<td class="right aligned">{{ticket.orderStatistics.tickets.completed}}</td>
146146
{{/unless}}
147-
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.completed ticket.price}}</td>
147+
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.completed ticket.price}}/></td>
148148
{{#unless this.device.isMobile}}
149149
<td class="right aligned">{{ticket.orderStatistics.tickets.placed}}</td>
150150
{{/unless}}
151-
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.placed ticket.price}}</td>
151+
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.placed ticket.price}}/></td>
152152
{{#unless this.device.isMobile}}
153153
<td class="right aligned">{{ticket.orderStatistics.tickets.pending}}</td>
154154
{{/unless}}
155-
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.pending ticket.price}}</td>
155+
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.pending ticket.price}}/></td>
156156
</tr>
157157
{{/each}}
158158
</tbody>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import hbs from 'htmlbars-inline-precompile';
5+
6+
module('Integration | Component | currency-amount', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
11+
await render(hbs`<CurrencyAmount @amount={{14}} @currency={{'INR'}}/>`);
12+
assert.equal(this.element.textContent.trim(), '₹ 14.00');
13+
14+
await render(hbs`<CurrencyAmount @amount={{0}} @currency={{'INR'}}/>`);
15+
assert.equal(this.element.textContent.trim(), '0.00');
16+
});
17+
});

0 commit comments

Comments
 (0)