fix(invoiceIn_descriptor): add necessary relations to filter
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
19df1fe382
commit
7a17fe2cba
|
@ -39,17 +39,25 @@ class Controller extends Descriptor {
|
|||
loadData() {
|
||||
const filter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'company',
|
||||
{relation: 'supplier'},
|
||||
{relation: 'invoiceInDueDay'},
|
||||
{relation: 'company',
|
||||
scope: {
|
||||
fields: ['id', 'code']
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
};
|
||||
|
||||
return this.getData(`InvoiceIns/${this.id}`, {filter})
|
||||
.then(res => this.entity = res.data);
|
||||
.then(res => {
|
||||
this.entity = res.data;
|
||||
this.invoiceIn.amount = res.data.invoiceInDueDay.reduce(
|
||||
(accumulator, currentValue) => {
|
||||
return accumulator + (currentValue['amount'] || 0);
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
||||
checkToBook() {
|
||||
|
|
|
@ -12,12 +12,25 @@ describe('vnInvoiceInDescriptor', () => {
|
|||
|
||||
controller = $componentController('vnInvoiceInDescriptor', {$element});
|
||||
controller.invoiceIn = {id: 1};
|
||||
$httpBackend.when('GET', `InvoiceIns/${controller.invoiceIn.id}`).respond({id: 1});
|
||||
}));
|
||||
|
||||
describe('loadData()', () => {
|
||||
it(`should perform a get query to store the invoice in data into the controller`, () => {
|
||||
expect(controller.invoiceIn).toEqual({id: 1});
|
||||
const invoiceIn = {
|
||||
id: 1,
|
||||
invoiceInDueDay: [
|
||||
{amount: 1},
|
||||
{amount: 2}
|
||||
]
|
||||
};
|
||||
const expectedAmount = invoiceIn.invoiceInDueDay[0].amount + invoiceIn.invoiceInDueDay[1].amount;
|
||||
|
||||
$httpBackend.when('GET', `InvoiceIns/${controller.invoiceIn.id}`).respond(invoiceIn);
|
||||
controller.loadData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.invoiceIn.id).toEqual(invoiceIn.id);
|
||||
expect(controller.invoiceIn.amount).toEqual(expectedAmount);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue