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() {
|
loadData() {
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
include: [
|
||||||
{
|
{relation: 'supplier'},
|
||||||
relation: 'company',
|
{relation: 'invoiceInDueDay'},
|
||||||
|
{relation: 'company',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'code']
|
fields: ['id', 'code']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.getData(`InvoiceIns/${this.id}`, {filter})
|
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() {
|
checkToBook() {
|
||||||
|
|
|
@ -12,12 +12,25 @@ describe('vnInvoiceInDescriptor', () => {
|
||||||
|
|
||||||
controller = $componentController('vnInvoiceInDescriptor', {$element});
|
controller = $componentController('vnInvoiceInDescriptor', {$element});
|
||||||
controller.invoiceIn = {id: 1};
|
controller.invoiceIn = {id: 1};
|
||||||
$httpBackend.when('GET', `InvoiceIns/${controller.invoiceIn.id}`).respond({id: 1});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('loadData()', () => {
|
describe('loadData()', () => {
|
||||||
it(`should perform a get query to store the invoice in data into the controller`, () => {
|
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