test(client_defaulter): getBalanceDueTotal tested
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
15f8a261d2
commit
5e586bf1d0
|
@ -15,10 +15,7 @@ export default function currency($translate) {
|
|||
maximumFractionDigits: fractionSize
|
||||
};
|
||||
|
||||
let lang = $translate.use();
|
||||
if (lang == 'es')
|
||||
lang = 'de';
|
||||
|
||||
const lang = $translate.use() == 'es' ? 'de' : $translate.use();
|
||||
if (typeof input == 'number') {
|
||||
return new Intl.NumberFormat(lang, options)
|
||||
.format(input);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<h6 translate>Total</h6>
|
||||
<vn-label-value
|
||||
label="Balance due"
|
||||
value="{{::$ctrl.balanceDueTotal | currency: 'EUR': 2}}">
|
||||
value="{{$ctrl.balanceDueTotal | currency: 'EUR': 2}}">
|
||||
</vn-label-value>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -54,15 +54,7 @@ export default class Controller extends Section {
|
|||
]
|
||||
};
|
||||
|
||||
this.$http.get('Defaulters/filter')
|
||||
.then(res => {
|
||||
if (!res.data) return 0;
|
||||
|
||||
this.balanceDueTotal = res.data.reduce(
|
||||
(accumulator, currentValue) => {
|
||||
return accumulator + (currentValue['amount'] || 0);
|
||||
}, 0);
|
||||
});
|
||||
this.getBalanceDueTotal();
|
||||
}
|
||||
|
||||
get checked() {
|
||||
|
@ -76,6 +68,18 @@ export default class Controller extends Section {
|
|||
return checkedLines;
|
||||
}
|
||||
|
||||
getBalanceDueTotal() {
|
||||
this.$http.get('Defaulters/filter')
|
||||
.then(res => {
|
||||
if (!res.data) return 0;
|
||||
|
||||
this.balanceDueTotal = res.data.reduce(
|
||||
(accumulator, currentValue) => {
|
||||
return accumulator + (currentValue['amount'] || 0);
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
||||
chipColor(date) {
|
||||
const day = 24 * 60 * 60 * 1000;
|
||||
const today = new Date();
|
||||
|
|
|
@ -105,5 +105,17 @@ describe('client defaulter', () => {
|
|||
expect(expr).toEqual({'d.clientFk': '5'});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBalanceDueTotal()', () => {
|
||||
it('should return balance due total', () => {
|
||||
const defaulters = controller.$.model.data;
|
||||
$httpBackend.when('GET', `Defaulters/filter`).respond(defaulters);
|
||||
|
||||
controller.getBalanceDueTotal();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.balanceDueTotal).toEqual(875);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue