refactor(supplier): add isFarmer in getSummary
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4f799d3e00
commit
94a2d3cc16
|
@ -101,6 +101,11 @@ module.exports = Self => {
|
|||
]
|
||||
};
|
||||
let supplier = await Self.app.models.Supplier.findOne(filter);
|
||||
|
||||
const farmerCode = 2;
|
||||
if (supplier.sageWithholdingFk == farmerCode)
|
||||
supplier.isFarmer = true;
|
||||
|
||||
return supplier;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -25,4 +25,12 @@ describe('Supplier getSummary()', () => {
|
|||
|
||||
expect(payMethod.name).toEqual('PayMethod one');
|
||||
});
|
||||
|
||||
it(`should get if supplier is farmer by sageWithholdingFk`, async() => {
|
||||
const supplier = await app.models.Supplier.findById(2);
|
||||
const supplierSummary = await app.models.Supplier.getSummary(2);
|
||||
|
||||
expect(supplier.isFarmer).toBeUndefined();
|
||||
expect(supplierSummary.isFarmer).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,16 +17,8 @@ class Controller extends Summary {
|
|||
getSummary() {
|
||||
return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
|
||||
this.summary = response.data;
|
||||
this.isFarmer(response.data.sageWithholdingFk);
|
||||
});
|
||||
}
|
||||
|
||||
isFarmer(sageWithholdingFk) {
|
||||
const farmerCode = 2;
|
||||
|
||||
if (sageWithholdingFk == farmerCode)
|
||||
this.summary.isFarmer = true;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnSupplierSummary', {
|
||||
|
|
|
@ -27,18 +27,6 @@ describe('Supplier', () => {
|
|||
|
||||
expect(controller.summary).toEqual({id: 1});
|
||||
});
|
||||
|
||||
it('should get if supplier is farmer by sageWithholdingFk', () => {
|
||||
controller.supplier = {id: 2, sageWithholdingFk: 2};
|
||||
|
||||
const query = `Suppliers/${controller.supplier.id}/getSummary`;
|
||||
|
||||
$httpBackend.expectGET(query).respond({id: 2, sageWithholdingFk: 2});
|
||||
controller.getSummary();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.summary).toEqual({id: 2, isFarmer: true, sageWithholdingFk: 2});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue