Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide currency when amount is 0 #5447

Merged
merged 11 commits into from
Nov 5, 2020
Merged
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/templates/components/currency-amount.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{#if (gt @amount 0)}}
{{currency-symbol @currency}}
{{/if}}
{{format-money @amount}}
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
</tr>
<tr>
<td>{{t 'Sales (amount)'}}</td>
<td>{{currency-symbol this.data.event.paymentCurrency}} {{format-money this.sales}}</td>
<td><CurrencyAmount @currency={{this.data.event.paymentCurrency}} @amount={{this.sales}}/></td>
</tr>
</tbody>
</table>
2 changes: 1 addition & 1 deletion app/templates/components/orders/ticket-price.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if (eq @ticket.type 'free')}}
{{t "Free"}}
{{else}}
{{currency-symbol @currency}} {{format-money @amount}}
<CurrencyAmount @currency={{@currency}} @amount={{@amount}}/>
{{/if}}
14 changes: 7 additions & 7 deletions app/templates/components/public/ticket-list.hbs
Original file line number Diff line number Diff line change
@@ -56,19 +56,19 @@
</div>
{{#if ticket.discount}}
<div>
{{currency-symbol this.eventCurrency}} {{format-money (sub ticket.price ticket.discount)}}
<CurrencyAmount @currency={{this.eventCurrency}} @amount={{sub ticket.price ticket.discount}}/>
</div>
{{/if}}
{{/if}}
{{#if (and this.taxInfo (not-eq ticket.type 'free'))}}
<p>
{{#if this.taxInfo.isTaxIncludedInPrice}}
<small class="ui gray-text small">
{{t 'includes'}} {{currency-symbol this.eventCurrency}} {{format-money ticket.includedTaxAmount}}
{{t 'includes'}} <CurrencyAmount @currency={{this.eventCurrency}} @amount={{ticket.includedTaxAmount}}/>
</small>
{{else}}
<small class="ui gray-text small">
+ {{currency-symbol this.eventCurrency}} {{format-money (sub ticket.ticketPriceWithTax ticket.price)}}
+ <CurrencyAmount @currency={{this.eventCurrency}} @amount={{sub ticket.ticketPriceWithTax ticket.price}}/>
</small>
{{/if}}
<span>
@@ -116,22 +116,22 @@
<table class="ui small" style="float: right;">
<tbody>
{{#if orderAmount.tax}}
<tr><td>{{t 'Sub-Total'}}</td><td>{{currency-symbol this.eventCurrency}} {{format-money this.orderAmount.sub_total}}</td></tr>
<tr><td>{{t 'Sub-Total'}}</td><td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.sub_total}}/></td></tr>
<tr>
<td>
<div>{{t 'Tax'}} ({{this.orderAmount.tax.percent}}% {{this.orderAmount.tax.name}})</div>
{{#if orderAmount.tax.included}}
<small class="ui gray-text small">Included in Total</small>
{{/if}}
</td>
<td>{{currency-symbol this.eventCurrency}} {{this.orderAmount.tax.amount}}</td>
<td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.tax.amount}}/></td>
</tr>
{{/if}}
<tr><td>{{t 'Total'}}</td>
{{#if this.amountEditable}}
<td>{{currency-symbol this.eventCurrency}}</td> <td><Input @value={{this.overridenAmount}} placeholder="Total" /></td>
<td>{{#if this.overridenAmount}}{{currency-symbol this.eventCurrency}}{{/if}}</td><td><Input @value={{this.overridenAmount}} placeholder="Total" /></td>
{{else}}
<td>{{currency-symbol this.eventCurrency}} {{format-money this.orderAmount.total}}</td>
<td><CurrencyAmount @currency={{this.eventCurrency}} @amount={{this.orderAmount.total}}/></td>
{{/if}}
</tr>
</tbody>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="weight-400">
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{format-money this.record}}
<CurrencyAmount @currency={{this.extraRecords.event.paymentCurrency}} @amount={{this.record}}/>
</div>
{{#if this.extraRecords.discountCode.code}}
<div class="ui mini yellow label">
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@
{{#if (eq this.extraRecords.type 'percent')}}
{{this.record}} %
{{else if (eq this.extraRecords.type 'amount')}}
{{this.currency-symbol this.extraRecords.event.paymentCurrency}}{{this.record}}
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{this.record}}
{{/if}}
</span>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="weight-400">
{{currency-symbol this.extraRecords.event.paymentCurrency}} {{format-money this.record}}
<CurrencyAmount @currency={{this.extraRecords.event.paymentCurrency}} @amount={{this.record}}/>
</div>
{{#if this.extraRecords.discountCode.code}}
<div class="ui mini yellow label">
10 changes: 5 additions & 5 deletions app/templates/events/view/tickets/index.hbs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
</div>
<div class="ui {{if this.device.isMobile 'horizontal'}} three statistics">
<div class="statistic"><div class="value">{{this.totalOrders}}</div><div class="label">{{t 'Orders'}}</div></div>
<div class="statistic"><div class="value">{{this.totalAmount}}</div><div class="label">{{t 'Sales'}}({{currency-symbol this.model.eventDetail.paymentCurrency}})</div></div>
<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>
<div class="statistic"><div class="value">{{this.totalSales}}</div><div class="label">{{t 'Tickets sold'}}</div></div>
</div>
</div>
@@ -22,7 +22,7 @@
<th>{{t 'Order Status'}}</th>
<th class="right aligned">{{t 'Total Tickets'}}</th>
<th class="right aligned">{{t 'Total Orders'}}</th>
<th class="right aligned">{{t 'Total Sales' }}({{currency-symbol this.model.eventDetail.paymentCurrency}}) </th>
<th class="right aligned">{{t 'Total Sales' }}{{#if this.totalAmount}}({{currency-symbol this.model.eventDetail.paymentCurrency}}){{/if}} </th>
<th>{{t 'View Reports'}}</th>
</tr>
<tr>
@@ -144,15 +144,15 @@
{{#unless this.device.isMobile}}
<td class="right aligned">{{ticket.orderStatistics.tickets.completed}}</td>
{{/unless}}
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.completed ticket.price}}</td>
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.completed ticket.price}}/></td>
{{#unless this.device.isMobile}}
<td class="right aligned">{{ticket.orderStatistics.tickets.placed}}</td>
{{/unless}}
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.placed ticket.price}}</td>
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.placed ticket.price}}/></td>
{{#unless this.device.isMobile}}
<td class="right aligned">{{ticket.orderStatistics.tickets.pending}}</td>
{{/unless}}
<td class="right aligned">{{currency-symbol this.model.eventDetail.paymentCurrency}} {{mult ticket.orderStatistics.tickets.pending ticket.price}}</td>
<td class="right aligned"><CurrencyAmount @currency={{this.model.eventDetail.paymentCurrency}} @amount={{mult ticket.orderStatistics.tickets.pending ticket.price}}/></td>
</tr>
{{/each}}
</tbody>
18 changes: 18 additions & 0 deletions tests/integration/components/currency-amount-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | currency-amount', function(hooks) {
setupRenderingTest(hooks);

test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`{{currency-amount}}`);

assert.equal(this.element.textContent.trim(), '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for different cases

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok and rest changes in file is ok?


});
});