This commit is contained in:
Javi Gallego 2021-07-03 09:19:03 +02:00
parent 9054aa0885
commit 2ec2a89f88
6 changed files with 42 additions and 21 deletions

View File

@ -87,6 +87,7 @@ module.exports = Self => {
}; };
let summaryObj = await Self.app.models.InvoiceIn.findById(id, filter, myOptions); let summaryObj = await Self.app.models.InvoiceIn.findById(id, filter, myOptions);
summaryObj.totals = await getTotals(id); summaryObj.totals = await getTotals(id);
return summaryObj; return summaryObj;
}; };

View File

@ -46,12 +46,13 @@
</vn-vertical> </vn-vertical>
</vn-one> </vn-one>
<vn-one tbody class="taxes"> <vn-one tbody class="taxes">
<span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.summary.totals.totalTaxableBase | currency: 'EUR':2}}</spant> <span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.summary.totals.totalTaxableBase | currency: 'EUR':2}}</span>
<p><vn-label translate>Total</vn-label> {{$ctrl.summary.totals.totalVat | currency: 'EUR':2}}</p> <p><vn-label translate>Total</vn-label> {{$ctrl.summary.totals.totalVat | currency: 'EUR':2}}</p>
<vn-label translate>Due day</vn-label> <vn-label translate>Due day</vn-label>
<vn-chip <vn-chip
class="transparent" class="transparent"
translate-attr="$ctrl.amountsNotMatch ? {title: 'Do not match'} : {title: 'Due day'}" ng-class="{'alert': $ctrl.amountsNotMatch}"
translate-attr="{title: $ctrl.amountsNotMatch ? 'Do not match' : 'Due day'}"
>{{$ctrl.summary.totals.totalDueDay | currency: 'EUR':2}} >{{$ctrl.summary.totals.totalDueDay | currency: 'EUR':2}}
</vn-chip> </vn-chip>
</vn-one> </vn-one>

View File

@ -18,10 +18,10 @@ class Controller extends Summary {
.then(res => this.summary = res.data); .then(res => this.summary = res.data);
} }
// ng-class="{'alert': $ctrl.amountsNotMatch()}" get amountsNotMatch() {
amountsNotMatch() { if (!this.summary) return false;
const total = this.summary.totals; const total = this.summary.totals;
console.log(total.totalDueDay != total.totalTaxableBase && total.totalDueDay != total.totalVat);
return total.totalDueDay != total.totalTaxableBase && total.totalDueDay != total.totalVat; return total.totalDueDay != total.totalTaxableBase && total.totalDueDay != total.totalVat;
} }
} }

View File

@ -1,6 +1,6 @@
import './index.js'; import './index.js';
describe('InvoiceIn', () => { fdescribe('InvoiceIn', () => {
describe('Component summary', () => { describe('Component summary', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
@ -25,5 +25,34 @@ describe('InvoiceIn', () => {
expect(controller.summary).toEqual('the data you are looking for'); 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');
});
});
}); });
}); });

View File

@ -13,21 +13,11 @@
data="$ctrl.taxes" data="$ctrl.taxes"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-crud-model
url="SageTaxTypes"
data="sageTaxTypes"
auto-load="true">
</vn-crud-model>
<vn-crud-model <vn-crud-model
url="Expenses" url="Expenses"
data="expenses" data="expenses"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-crud-model
url="SageTransactionTypes"
data="sageTransactionType"
auto-load="true">
</vn-crud-model>
<vn-watcher <vn-watcher
vn-id="watcher" vn-id="watcher"
data="$ctrl.taxes" data="$ctrl.taxes"
@ -57,7 +47,7 @@
vn-id="taxTypeSage" vn-id="taxTypeSage"
label="Sage tax" label="Sage tax"
ng-model="invoiceInTax.taxTypeSageFk" ng-model="invoiceInTax.taxTypeSageFk"
data="sageTaxTypes" url="SageTaxTypes"
show-field="vat" show-field="vat"
search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}" search-function="{or: [{id: $search}, {vat: {like: '%'+ $search +'%'}}]}"
selection="$ctrl.taxRateSelection" selection="$ctrl.taxRateSelection"
@ -67,7 +57,7 @@
<vn-autocomplete vn-three <vn-autocomplete vn-three
label="Sage transaction" label="Sage transaction"
ng-model="invoiceInTax.transactionTypeSageFk" ng-model="invoiceInTax.transactionTypeSageFk"
data="sageTransactionType" url="SageTransactionTypes"
show-field="transaction" show-field="transaction"
search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}" search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}"
rule> rule>

View File

@ -31,11 +31,11 @@ describe('InvoiceIn', () => {
$scope.taxTypeSage.selection = taxTypeSage; $scope.taxTypeSage.selection = taxTypeSage;
$scope.taxableBase = {}; $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);
}); });
}); });