3472-supplier_summary isFarmer #833
|
@ -101,6 +101,11 @@ module.exports = Self => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
let supplier = await Self.app.models.Supplier.findOne(filter);
|
let supplier = await Self.app.models.Supplier.findOne(filter);
|
||||||
|
|
||||||
|
const farmerCode = 2;
|
||||||
|
if (supplier.sageWithholdingFk == farmerCode)
|
||||||
|
supplier.isFarmer = true;
|
||||||
|
|
||||||
return supplier;
|
return supplier;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,4 +25,12 @@ describe('Supplier getSummary()', () => {
|
||||||
|
|
||||||
expect(payMethod.name).toEqual('PayMethod one');
|
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() {
|
getSummary() {
|
||||||
return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
|
return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => {
|
||||||
this.summary = response.data;
|
this.summary = response.data;
|
||||||
this.isFarmer(response.data.sageWithholdingFk);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isFarmer(sageWithholdingFk) {
|
|
||||||
const farmerCode = 2;
|
|
||||||
|
|
||||||
if (sageWithholdingFk == farmerCode)
|
|
||||||
this.summary.isFarmer = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnSupplierSummary', {
|
ngModule.vnComponent('vnSupplierSummary', {
|
||||||
|
|
|
@ -27,18 +27,6 @@ describe('Supplier', () => {
|
||||||
|
|
||||||
expect(controller.summary).toEqual({id: 1});
|
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