diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index 29b9e1232..f09be4add 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -87,6 +87,7 @@ module.exports = Self => { }; let summaryObj = await Self.app.models.InvoiceIn.findById(id, filter, myOptions); + summaryObj.totals = await getTotals(id); return summaryObj; }; diff --git a/modules/invoiceIn/front/summary/index.html b/modules/invoiceIn/front/summary/index.html index 90c0b475b..3176bffd6 100644 --- a/modules/invoiceIn/front/summary/index.html +++ b/modules/invoiceIn/front/summary/index.html @@ -46,12 +46,13 @@ - Taxable base {{$ctrl.summary.totals.totalTaxableBase | currency: 'EUR':2}} + Taxable base {{$ctrl.summary.totals.totalTaxableBase | currency: 'EUR':2}}

Total {{$ctrl.summary.totals.totalVat | currency: 'EUR':2}}

Due day {{$ctrl.summary.totals.totalDueDay | currency: 'EUR':2}}
diff --git a/modules/invoiceIn/front/summary/index.js b/modules/invoiceIn/front/summary/index.js index ad88da278..b4c61beef 100644 --- a/modules/invoiceIn/front/summary/index.js +++ b/modules/invoiceIn/front/summary/index.js @@ -18,10 +18,10 @@ class Controller extends Summary { .then(res => this.summary = res.data); } - // ng-class="{'alert': $ctrl.amountsNotMatch()}" - amountsNotMatch() { + get amountsNotMatch() { + if (!this.summary) return false; + const total = this.summary.totals; - console.log(total.totalDueDay != total.totalTaxableBase && total.totalDueDay != total.totalVat); return total.totalDueDay != total.totalTaxableBase && total.totalDueDay != total.totalVat; } } diff --git a/modules/invoiceIn/front/summary/index.spec.js b/modules/invoiceIn/front/summary/index.spec.js index 56bfe9f4a..18e946075 100644 --- a/modules/invoiceIn/front/summary/index.spec.js +++ b/modules/invoiceIn/front/summary/index.spec.js @@ -1,6 +1,6 @@ import './index.js'; -describe('InvoiceIn', () => { +fdescribe('InvoiceIn', () => { describe('Component summary', () => { let controller; let $httpBackend; @@ -25,5 +25,34 @@ describe('InvoiceIn', () => { expect(controller.summary).toEqual('the data you are looking for'); }); }); + + describe('amountsNotMatch getter()', () => { + it('should get false when taxamount match with due day amount', () => { + controller.summary = + { + totals: { + totalDueDay: 1, + totalTaxableBase: 1, + totalVat: 2 + } + }; + + expect(controller.amountsNotMatch).toEqual('false'); + }); + + it('should get true when taxamount does not match with due day amount', () => { + controller.summary = + { + totals: { + totalDueDay: 1, + totalTaxableBase: 2, + totalVat: 3 + } + }; + console.log(controller); + + expect(controller.amountsNotMatch).toEqual('true'); + }); + }); }); }); diff --git a/modules/invoiceIn/front/tax/index.html b/modules/invoiceIn/front/tax/index.html index 1834708cc..6e0987319 100644 --- a/modules/invoiceIn/front/tax/index.html +++ b/modules/invoiceIn/front/tax/index.html @@ -13,21 +13,11 @@ data="$ctrl.taxes" auto-load="true"> - - - - diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js index 3780d91f1..50fedaeb5 100644 --- a/modules/invoiceIn/front/tax/index.spec.js +++ b/modules/invoiceIn/front/tax/index.spec.js @@ -31,11 +31,11 @@ describe('InvoiceIn', () => { $scope.taxTypeSage.selection = taxTypeSage; $scope.taxableBase = {}; - $scope.taxableBase.value = 100; + $scope.taxableBase.value = 200; - controller.setTaxRate = 0; + controller.taxRateSelection = 0; - expect(controller.taxRate).toEqual(21); + expect(controller.taxRate).toEqual(42); }); });