refactor(supplier.summary): separate isFarmer()
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
19a6b55a72
commit
a528161b93
|
@ -17,12 +17,16 @@ 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);
|
||||||
this.summary.isFarmer = false;
|
|
||||||
if(response.data.sageWithholdingFk == 2)
|
|
||||||
this.summary.isFarmer = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFarmer(sageWithholdingFk) {
|
||||||
|
const farmerCode = 2;
|
||||||
|
|
||||||
|
if (sageWithholdingFk == farmerCode)
|
||||||
|
this.summary.isFarmer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnSupplierSummary', {
|
ngModule.vnComponent('vnSupplierSummary', {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import './index';
|
import './index';
|
||||||
|
|
||||||
describe('Supplier', () => {
|
fdescribe('Supplier', () => {
|
||||||
describe('Component vnSupplierSummary', () => {
|
describe('Component vnSupplierSummary', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
@ -15,7 +15,7 @@ describe('Supplier', () => {
|
||||||
controller = $componentController('vnSupplierSummary', {$element, $scope});
|
controller = $componentController('vnSupplierSummary', {$element, $scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('getSummary()', () => {
|
fdescribe('getSummary()', () => {
|
||||||
it('should perform a get asking for the supplier data', () => {
|
it('should perform a get asking for the supplier data', () => {
|
||||||
controller.supplier = {id: 1};
|
controller.supplier = {id: 1};
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ describe('Supplier', () => {
|
||||||
controller.getSummary();
|
controller.getSummary();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.summary).toEqual({id: 1, isFarmer: false});
|
expect(controller.summary).toEqual({id: 1});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get if supplier is farmer by sageWithholdingFk', () => {
|
it('should get if supplier is farmer by sageWithholdingFk', () => {
|
||||||
controller.supplier = {id: 2};
|
controller.supplier = {id: 2, sageWithholdingFk: 2};
|
||||||
|
|
||||||
const query = `Suppliers/${controller.supplier.id}/getSummary`;
|
const query = `Suppliers/${controller.supplier.id}/getSummary`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue