Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2037_getWorkedHours_db_test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
0f3ceea653
|
@ -1,46 +1,53 @@
|
|||
{
|
||||
"name": "Province",
|
||||
"description": "Provinces of every country",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "province"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
"name": "Province",
|
||||
"description": "Provinces of every country",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "province"
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"country": {
|
||||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
"relations": {
|
||||
"country": {
|
||||
"type": "belongsTo",
|
||||
"model": "Country",
|
||||
"foreignKey": "countryFk"
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
},
|
||||
"zone": {
|
||||
"type": "belongsTo",
|
||||
"model": "Zone",
|
||||
"foreignKey": "zoneFk"
|
||||
}
|
||||
},
|
||||
"zone": {
|
||||
"type": "belongsTo",
|
||||
"model": "Zone",
|
||||
"foreignKey": "zoneFk"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
"scopes": {
|
||||
"location": {
|
||||
"include": {
|
||||
"relation": "country"
|
||||
}
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES ('EntryLog', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -197,14 +197,16 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`)
|
|||
(1, 'Valencia', 1),
|
||||
(2, 'Silla', 1),
|
||||
(3, 'Algemesi', 1),
|
||||
(4, 'Alzira', 1);
|
||||
(4, 'Alzira', 1),
|
||||
(5, 'Quito', 5);
|
||||
|
||||
INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`)
|
||||
VALUES
|
||||
('46000', 1, 6),
|
||||
('46460', 2, 6),
|
||||
('46680', 3, 6),
|
||||
('46600', 4, 7);
|
||||
('46600', 4, 7),
|
||||
('EC170150', 5, 8);
|
||||
|
||||
INSERT INTO `vn`.`clientType`(`id`, `code`, `type`)
|
||||
VALUES
|
||||
|
@ -554,30 +556,30 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
|
|||
|
||||
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`)
|
||||
VALUES
|
||||
(1, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
|
||||
(2, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
|
||||
(3, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH)),
|
||||
(4, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH)),
|
||||
(5, 16, 18, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)),
|
||||
(6, 16, 18, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)),
|
||||
(7, 10, 18, CURDATE()),
|
||||
(8, 5, 19, CURDATE()),
|
||||
(9, 5, 19, CURDATE()),
|
||||
(10, 5, 19, CURDATE()),
|
||||
(11, 3, 19, CURDATE()),
|
||||
(12, 3, 19, CURDATE()),
|
||||
(13, 3, 19, CURDATE()),
|
||||
(14, 3, 19, CURDATE()),
|
||||
(15, 3, 19, CURDATE()),
|
||||
(16, 3, 19, CURDATE()),
|
||||
(17, 3, 19, CURDATE()),
|
||||
(18, 3, 19, CURDATE()),
|
||||
(19, 17, 19, CURDATE()),
|
||||
(20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||
(21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||
(22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||
(23, 16, 21, CURDATE()),
|
||||
(24, 16, 21, CURDATE());
|
||||
(1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)),
|
||||
(2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)),
|
||||
(3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)),
|
||||
(4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)),
|
||||
(5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)),
|
||||
(6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)),
|
||||
(7, 10, 18, NOW()),
|
||||
(8, 5, 19, NOW()),
|
||||
(9, 5, 19, NOW()),
|
||||
(10, 5, 19, NOW()),
|
||||
(11, 3, 19, NOW()),
|
||||
(12, 3, 19, NOW()),
|
||||
(13, 3, 19, NOW()),
|
||||
(14, 3, 19, NOW()),
|
||||
(15, 3, 19, NOW()),
|
||||
(16, 3, 19, NOW()),
|
||||
(17, 3, 19, NOW()),
|
||||
(18, 3, 19, NOW()),
|
||||
(19, 17, 19, NOW()),
|
||||
(20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
(21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
(22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)),
|
||||
(23, 16, 21, NOW()),
|
||||
(24, 16, 21, NOW());
|
||||
|
||||
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
|
||||
VALUES
|
||||
|
|
|
@ -44,8 +44,8 @@ export default {
|
|||
taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]',
|
||||
socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]',
|
||||
street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]',
|
||||
postcode: 'vn-client-create vn-textfield[ng-model="$ctrl.client.postcode"]',
|
||||
city: 'vn-client-create vn-textfield[ng-model="$ctrl.client.city"]',
|
||||
postcode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"]',
|
||||
city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]',
|
||||
province: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
|
||||
country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
|
||||
userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]',
|
||||
|
@ -76,8 +76,8 @@ export default {
|
|||
equalizationTaxCheckbox: 'vn-client-fiscal-data vn-check[ng-model="$ctrl.client.isEqualizated"]',
|
||||
acceptPropagationButton: '.vn-confirm.shown button[response=accept]',
|
||||
address: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.street"]',
|
||||
postcode: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.postcode"]',
|
||||
city: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.city"]',
|
||||
postcode: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.postcode"]',
|
||||
city: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.city"]',
|
||||
province: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
|
||||
country: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
|
||||
activeCheckbox: 'vn-client-fiscal-data vn-check[label="Active"]',
|
||||
|
@ -114,8 +114,8 @@ export default {
|
|||
defaultCheckbox: 'vn-check[label="Default"]',
|
||||
consignee: 'vn-textfield[ng-model="$ctrl.address.nickname"]',
|
||||
streetAddress: 'vn-textfield[ng-model="$ctrl.address.street"]',
|
||||
postcode: 'vn-textfield[ng-model="$ctrl.address.postalCode"]',
|
||||
city: 'vn-textfield[ng-model="$ctrl.address.city"]',
|
||||
postcode: 'vn-datalist[ng-model="$ctrl.address.postalCode"]',
|
||||
city: 'vn-datalist[ng-model="$ctrl.address.city"]',
|
||||
province: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]',
|
||||
agency: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]',
|
||||
phone: 'vn-textfield[ng-model="$ctrl.address.phone"]',
|
||||
|
|
|
@ -87,7 +87,7 @@ describe('Client create path', async() => {
|
|||
.waitToGetProperty(selectors.createClientView.country, 'value');
|
||||
|
||||
expect(clientCity).toEqual('Valencia');
|
||||
expect(clientProvince).toEqual('Province one');
|
||||
expect(clientProvince).toContain('Province one');
|
||||
expect(clientCountry).toEqual('España');
|
||||
});
|
||||
|
||||
|
|
|
@ -198,11 +198,10 @@ describe('Client Edit fiscalData path', () => {
|
|||
expect(result).toEqual('Valencia');
|
||||
});
|
||||
|
||||
|
||||
it(`should confirm the province have been autocompleted`, async() => {
|
||||
const result = await page.waitToGetProperty(selectors.clientFiscalData.province, 'value');
|
||||
|
||||
expect(result).toEqual('Province one');
|
||||
expect(result).toContain('Province one');
|
||||
});
|
||||
|
||||
it('should confirm the country have been autocompleted', async() => {
|
||||
|
|
|
@ -25,9 +25,7 @@ describe('Client Add address path', () => {
|
|||
|
||||
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
|
||||
await page.waitToClick(selectors.clientAddresses.defaultCheckbox);
|
||||
await page.autocompleteSearch(selectors.clientAddresses.province, 'Province five');
|
||||
await page.write(selectors.clientAddresses.city, 'Valencia');
|
||||
await page.write(selectors.clientAddresses.postcode, '46000');
|
||||
await page.write(selectors.clientAddresses.postcode, 'EC170150');
|
||||
await page.autocompleteSearch(selectors.clientAddresses.agency, 'Entanglement');
|
||||
await page.write(selectors.clientAddresses.phone, '999887744');
|
||||
await page.write(selectors.clientAddresses.mobileInput, '999887744');
|
||||
|
@ -37,6 +35,16 @@ describe('Client Add address path', () => {
|
|||
expect(result).toEqual('Some fields are invalid');
|
||||
});
|
||||
|
||||
it('should confirm that the city and province are propertly filled', async() => {
|
||||
const city = await page
|
||||
.waitToGetProperty(selectors.clientAddresses.city, 'value');
|
||||
|
||||
const province = await page
|
||||
.waitToGetProperty(selectors.clientAddresses.province, 'value');
|
||||
|
||||
expect(city).toEqual('Quito');
|
||||
expect(province).toContain('Province five');
|
||||
});
|
||||
|
||||
it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => {
|
||||
await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner');
|
||||
|
|
|
@ -27,7 +27,7 @@ export default class Datalist extends Textfield {
|
|||
value = value == '' || value == null ? null : value;
|
||||
oldValue = oldValue == '' || oldValue == null ? null : oldValue;
|
||||
|
||||
this.refreshSelection();
|
||||
if (oldValue === undefined) this.refreshSelection();
|
||||
|
||||
if (!value || value === oldValue && this.modelData != null) return;
|
||||
|
||||
|
@ -52,7 +52,14 @@ export default class Datalist extends Textfield {
|
|||
|
||||
validSelection(selection) {
|
||||
return this.modelData && this.modelData.find(item => {
|
||||
return item[this.valueField] == selection;
|
||||
let dataValue = item[this.valueField];
|
||||
if (typeof(dataValue) === 'string')
|
||||
dataValue = dataValue.toLowerCase();
|
||||
|
||||
if (typeof(selection) === 'string')
|
||||
selection = selection.toLowerCase();
|
||||
|
||||
return dataValue == selection;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -64,5 +64,6 @@
|
|||
"Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member",
|
||||
"Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member",
|
||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}"
|
||||
"Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}",
|
||||
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment"
|
||||
}
|
|
@ -39,61 +39,53 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="province"
|
||||
ng-model="$ctrl.address.provinceId"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="Towns"
|
||||
fields="['id', 'name']"
|
||||
where="{provinceFk: province.selection.id}"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
ng-model="$ctrl.address.city">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
url="Postcodes/location"
|
||||
fields="['code', 'townFk']"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
selection="$ctrl.postcodeSelection"
|
||||
search-function="{code: $search}"
|
||||
where="{townFk: town.selection.id}"
|
||||
order="code, townFk"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
<tpl-item>
|
||||
{{code}}, {{town.name}} - {{town.province.name}}
|
||||
({{town.province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-autocomplete> -->
|
||||
<vn-textfield
|
||||
vn-one
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!--
|
||||
<vn-icon-button
|
||||
vn-auto
|
||||
class="vn-my-md"
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
-->
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.country}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.address.provinceId"
|
||||
url="Provinces/location"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
|
|
|
@ -11,26 +11,6 @@ export default class Controller extends Component {
|
|||
};
|
||||
}
|
||||
|
||||
get postcodeSelection() {
|
||||
return this._postcodeSelection;
|
||||
}
|
||||
|
||||
set postcodeSelection(selection) {
|
||||
this._postcodeSelection = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
|
||||
this.address.city = town.name;
|
||||
this.address.provinceFk = province.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit().then(res => {
|
||||
if (this.address.isDefaultAddress)
|
||||
|
@ -51,6 +31,46 @@ export default class Controller extends Component {
|
|||
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
|
||||
.then(res => this.address.customsAgentFk = res.data.id);
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
this._town = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const province = selection.province;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
this.address.provinceId = province.id;
|
||||
|
||||
if (postcodes.length === 1)
|
||||
this.address.postalCode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
|
||||
this.address.city = town.name;
|
||||
this.address.provinceId = province.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
|
|
@ -53,9 +53,48 @@ describe('Client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('postcodeSelection() setter', () => {
|
||||
it(`should set the town, province and contry properties`, () => {
|
||||
controller.postcodeSelection = {
|
||||
describe('town() setter', () => {
|
||||
it(`should set provinceId property`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: []
|
||||
};
|
||||
|
||||
expect(controller.address.provinceId).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should set provinceId property and fill the postalCode if there's just one`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: [{code: '46001'}]
|
||||
};
|
||||
|
||||
expect(controller.address.provinceId).toEqual(1);
|
||||
expect(controller.address.postalCode).toEqual('46001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('postcode() setter', () => {
|
||||
it(`should set the town and province properties`, () => {
|
||||
controller.postcode = {
|
||||
townFk: 1,
|
||||
code: 46001,
|
||||
town: {
|
||||
|
@ -73,7 +112,7 @@ describe('Client', () => {
|
|||
};
|
||||
|
||||
expect(controller.address.city).toEqual('New York');
|
||||
expect(controller.address.provinceFk).toEqual(1);
|
||||
expect(controller.address.provinceId).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -56,58 +56,53 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="province"
|
||||
ng-model="$ctrl.address.provinceFk"
|
||||
url="Provinces"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!--
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="Towns"
|
||||
fields="['id', 'name']"
|
||||
where="{provinceFk: province.selection.id}"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
ng-model="$ctrl.address.city">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
url="Postcodes/location"
|
||||
fields="['code', 'townFk']"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
where="{townFk: town.selection.id}"
|
||||
search-function="{code: $search}"
|
||||
order="code, townFk"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
</vn-autocomplete>
|
||||
-->
|
||||
<vn-textfield
|
||||
vn-one
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.address.postalCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
|
||||
<!-- <vn-icon-button
|
||||
vn-auto
|
||||
class="vn-my-md"
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
-->
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.country}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.address.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.address.provinceFk"
|
||||
url="Provinces/location"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
|
|
|
@ -15,10 +15,6 @@ export default class Controller extends Component {
|
|||
this.$state.go('client.card.address.index');
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.submit()
|
||||
.then(() => this.$.model.save(true))
|
||||
|
@ -39,6 +35,48 @@ export default class Controller extends Component {
|
|||
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
|
||||
.then(res => this.address.customsAgentFk = res.data.id);
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
const oldValue = this._town;
|
||||
this._town = selection;
|
||||
|
||||
if (!oldValue) return;
|
||||
|
||||
const province = selection.province;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
this.address.provinceFk = province.id;
|
||||
|
||||
if (postcodes.length === 1)
|
||||
this.address.postalCode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
const oldValue = this._postcode;
|
||||
this._postcode = selection;
|
||||
|
||||
if (!oldValue) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
|
||||
this.address.city = town.name;
|
||||
this.address.provinceFk = province.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.address.postalCode = response.code;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnClientAddressEdit', {
|
||||
|
|
|
@ -49,76 +49,63 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-id="country"
|
||||
vn-one
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.country}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.client.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.client.provinceFk"
|
||||
selection="$ctrl.province"
|
||||
url="Provinces/location"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-id="country" vn-one
|
||||
ng-model="$ctrl.client.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
value-field="id"
|
||||
label="Country">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-id="province"
|
||||
vn-one
|
||||
url="Provinces"
|
||||
ng-model="$ctrl.client.provinceFk"
|
||||
where="{countryFk: country.selection.id}"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.client.city"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!--
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="Towns"
|
||||
fields="['id', 'name']"
|
||||
where="{provinceFk: province.selection.id}"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
ng-model="$ctrl.client.city">
|
||||
</vn-autocomplete>
|
||||
<vn-icon-button
|
||||
vn-auto
|
||||
class="vn-my-md"
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
-->
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!--
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
url="Postcodes/location"
|
||||
fields="['code', 'townFk']"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
selection="$ctrl.postcodeSelection"
|
||||
search-function="{code: $search}"
|
||||
where="{townFk: town.selection.id}"
|
||||
order="code, townFk"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
<tpl-item>
|
||||
{{code}}, {{town.name}} - {{town.province.name}}
|
||||
({{town.province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
-->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
|
|
|
@ -12,12 +12,55 @@ export default class Controller {
|
|||
};
|
||||
}
|
||||
|
||||
get postcodeSelection() {
|
||||
return this._postcodeSelection;
|
||||
onSubmit() {
|
||||
return this.$.watcher.submit().then(
|
||||
json => this.$state.go('client.card.basicData', {id: json.data.id})
|
||||
);
|
||||
}
|
||||
|
||||
set postcodeSelection(selection) {
|
||||
this._postcodeSelection = selection;
|
||||
get province() {
|
||||
return this._province;
|
||||
}
|
||||
|
||||
// Province auto complete
|
||||
set province(selection) {
|
||||
this._province = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const country = selection.country;
|
||||
|
||||
this.client.countryFk = country.id;
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
this._town = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
const province = selection.province;
|
||||
const country = province.country;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
this.client.provinceFk = province.id;
|
||||
this.client.countryFk = country.id;
|
||||
|
||||
if (postcodes.length === 1)
|
||||
this.client.postcode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection) return;
|
||||
|
||||
|
@ -33,13 +76,8 @@ export default class Controller {
|
|||
onResponse(response) {
|
||||
this.client.postcode = response.code;
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
return this.$.watcher.submit().then(
|
||||
json => this.$state.go('client.card.basicData', {id: json.data.id})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp'];
|
||||
|
||||
ngModule.component('vnClientCreate', {
|
||||
|
|
|
@ -40,9 +40,63 @@ describe('Client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('postcodeSelection() setter', () => {
|
||||
it(`should set the town, province and contry properties`, () => {
|
||||
controller.postcodeSelection = {
|
||||
describe('province() setter', () => {
|
||||
it(`should set countryFk property`, () => {
|
||||
controller.province = {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.client.countryFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('town() setter', () => {
|
||||
it(`should set provinceFk property`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: []
|
||||
};
|
||||
|
||||
expect(controller.client.provinceFk).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: [{code: '46001'}]
|
||||
};
|
||||
|
||||
expect(controller.client.provinceFk).toEqual(1);
|
||||
expect(controller.client.postcode).toEqual('46001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('postcode() setter', () => {
|
||||
it(`should set the town, provinceFk and contryFk properties`, () => {
|
||||
controller.postcode = {
|
||||
townFk: 1,
|
||||
code: 46001,
|
||||
town: {
|
||||
|
|
|
@ -33,9 +33,57 @@
|
|||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="country"
|
||||
<vn-datalist vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
fields="['code','townFk']"
|
||||
order="code, townFk"
|
||||
value-field="code"
|
||||
show-field="code"
|
||||
rule>
|
||||
<tpl-item>
|
||||
{{code}} - {{town.name}} ({{town.province.name}},
|
||||
{{town.province.country.country}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()"
|
||||
vn-acl="deliveryBoss"
|
||||
vn-acl-action="remove">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-datalist>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.client.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
fields="['id', 'name', 'provinceFk']"
|
||||
show-field="name"
|
||||
value-field="name">
|
||||
<tpl-item>
|
||||
{{name}}, {{province.name}}
|
||||
({{province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
label="Province"
|
||||
ng-model="$ctrl.client.provinceFk"
|
||||
selection="$ctrl.province"
|
||||
url="Provinces/location"
|
||||
fields="['id', 'name', 'countryFk']"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
rule>
|
||||
<tpl-item>{{name}} ({{country.country}})</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-id="country" vn-one
|
||||
ng-model="$ctrl.client.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
|
@ -43,51 +91,6 @@
|
|||
label="Country"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="province"
|
||||
ng-model="$ctrl.client.provinceFk"
|
||||
url="Provinces"
|
||||
where="{countryFk: country.selection.id}"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Province"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="City"
|
||||
ng-model="$ctrl.client.city"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Postcode"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="Towns"
|
||||
fields="['id', 'name']"
|
||||
where="{provinceFk: province.selection.id}"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
ng-model="$ctrl.client.city">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-id="postcode" vn-one
|
||||
url="Postcodes/location"
|
||||
fields="['code', 'townFk']"
|
||||
ng-model="$ctrl.client.postcode"
|
||||
search-function="{code: $search}"
|
||||
where="{townFk: town.selection.id}"
|
||||
order="code, townFk"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
</vn-autocomplete> -->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
|
@ -157,3 +160,8 @@
|
|||
message="Found a client with this data"
|
||||
on-accept="$ctrl.onAcceptDuplication()">
|
||||
</vn-confirm>
|
||||
<!-- New postcode dialog -->
|
||||
<vn-client-postcode
|
||||
vn-id="postcode"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
</vn-client-postcode>
|
|
@ -5,16 +5,29 @@ export default class Controller extends Component {
|
|||
onSubmit() {
|
||||
const orgData = this.$.watcher.orgData;
|
||||
delete this.client.despiteOfClient;
|
||||
if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked)
|
||||
|
||||
const hasContactData = this.client.email || this.client.phone || this.client.mobile;
|
||||
const hasChangedTaxData = !orgData.isTaxDataChecked && this.client.isTaxDataChecked;
|
||||
if (hasChangedTaxData && hasContactData)
|
||||
this.checkExistingClient();
|
||||
else this.save();
|
||||
}
|
||||
|
||||
checkExistingClient() {
|
||||
const findParams = [];
|
||||
if (this.client.email)
|
||||
findParams.push({email: this.client.email});
|
||||
|
||||
if (this.client.phone)
|
||||
findParams.push({phone: this.client.phone});
|
||||
|
||||
if (this.client.mobile)
|
||||
findParams.push({mobile: this.client.mobile});
|
||||
|
||||
const filterObj = {
|
||||
where: {
|
||||
and: [
|
||||
{or: [{email: this.client.email}, {phone: this.client.phone}]},
|
||||
{or: findParams},
|
||||
{id: {neq: this.client.id}}
|
||||
]
|
||||
}
|
||||
|
@ -77,6 +90,68 @@ export default class Controller extends Component {
|
|||
|
||||
this.$.$apply();
|
||||
}
|
||||
|
||||
get province() {
|
||||
return this._province;
|
||||
}
|
||||
|
||||
// Province auto complete
|
||||
set province(selection) {
|
||||
const oldValue = this._province;
|
||||
this._province = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const country = selection.country;
|
||||
|
||||
this.client.countryFk = country.id;
|
||||
}
|
||||
|
||||
get town() {
|
||||
return this._town;
|
||||
}
|
||||
|
||||
// Town auto complete
|
||||
set town(selection) {
|
||||
const oldValue = this._town;
|
||||
this._town = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const province = selection.province;
|
||||
const country = province.country;
|
||||
const postcodes = selection.postcodes;
|
||||
|
||||
this.client.provinceFk = province.id;
|
||||
this.client.countryFk = country.id;
|
||||
|
||||
if (postcodes.length === 1)
|
||||
this.client.postcode = postcodes[0].code;
|
||||
}
|
||||
|
||||
get postcode() {
|
||||
return this._postcode;
|
||||
}
|
||||
|
||||
// Postcode auto complete
|
||||
set postcode(selection) {
|
||||
const oldValue = this._postcode;
|
||||
this._postcode = selection;
|
||||
|
||||
if (!selection || !oldValue) return;
|
||||
|
||||
const town = selection.town;
|
||||
const province = town.province;
|
||||
const country = province.country;
|
||||
|
||||
this.client.city = town.name;
|
||||
this.client.provinceFk = province.id;
|
||||
this.client.countryFk = country.id;
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
this.client.postcode = response.code;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnClientFiscalData', {
|
||||
|
|
|
@ -25,6 +25,10 @@ describe('Client', () => {
|
|||
isEqualizated: false,
|
||||
isTaxDataChecked: false
|
||||
};
|
||||
|
||||
controller.province = {};
|
||||
controller.town = {};
|
||||
controller.postcode = {};
|
||||
}));
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
|
@ -49,9 +53,31 @@ describe('Client', () => {
|
|||
});
|
||||
|
||||
describe('checkExistingClient()', () => {
|
||||
it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => {
|
||||
it(`should make a HTTP GET query filtering by email, phone and mobile`, () => {
|
||||
controller.client.mobile = 222222222;
|
||||
const filterObj = {
|
||||
where: {
|
||||
and: [
|
||||
{or: [
|
||||
{email: controller.client.email},
|
||||
{phone: controller.client.phone},
|
||||
{mobile: controller.client.mobile}
|
||||
]},
|
||||
{id: {neq: controller.client.id}}
|
||||
]
|
||||
}
|
||||
};
|
||||
const expectedClient = {id: 102};
|
||||
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
||||
$httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(expectedClient);
|
||||
controller.checkExistingClient();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it(`should show a save confirmation and then set the despiteOfClient property`, () => {
|
||||
controller.$.confirmDuplicatedClient = {show: () => {}};
|
||||
jest.spyOn(controller.$.confirmDuplicatedClient, 'show');
|
||||
|
||||
const filterObj = {
|
||||
where: {
|
||||
and: [
|
||||
|
@ -107,5 +133,84 @@ describe('Client', () => {
|
|||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
||||
describe('province() setter', () => {
|
||||
it(`should set countryFk property`, () => {
|
||||
controller.province = {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.client.countryFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('town() setter', () => {
|
||||
it(`should set provinceFk property`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: []
|
||||
};
|
||||
|
||||
expect(controller.client.provinceFk).toEqual(1);
|
||||
});
|
||||
|
||||
it(`should set provinceFk property and fill the postalCode if there's just one`, () => {
|
||||
controller.town = {
|
||||
provinceFk: 1,
|
||||
code: 46001,
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
},
|
||||
postcodes: [{code: '46001'}]
|
||||
};
|
||||
|
||||
expect(controller.client.provinceFk).toEqual(1);
|
||||
expect(controller.client.postcode).toEqual('46001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('postcode() setter', () => {
|
||||
it(`should set the town, provinceFk and contryFk properties`, () => {
|
||||
controller.postcode = {
|
||||
townFk: 1,
|
||||
code: 46001,
|
||||
town: {
|
||||
id: 1,
|
||||
name: 'New York',
|
||||
province: {
|
||||
id: 1,
|
||||
name: 'New york',
|
||||
country: {
|
||||
id: 2,
|
||||
name: 'USA'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(controller.client.city).toEqual('New York');
|
||||
expect(controller.client.provinceFk).toEqual(1);
|
||||
expect(controller.client.countryFk).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn-dialog class="edit"
|
||||
vn-id="postcodeDialog"
|
||||
on-open="$ctrl.onOpen()"
|
||||
on-response="$ctrl.onResponse($response)">
|
||||
on-accept="$ctrl.onAccept()">
|
||||
<tpl-body>
|
||||
<h5 class="vn-py-sm" translate>New postcode</h5>
|
||||
<p translate>Please, ensure you put the correct data!</p>
|
||||
|
|
|
@ -35,25 +35,20 @@ class Controller extends Component {
|
|||
this.$.postcode.focus();
|
||||
}
|
||||
|
||||
onResponse(response) {
|
||||
if (response == 'accept') {
|
||||
try {
|
||||
if (!this.data.code)
|
||||
throw new Error(`The postcode can't be empty`);
|
||||
if (!this.data.townFk)
|
||||
throw new Error(`The town can't be empty`);
|
||||
onAccept() {
|
||||
try {
|
||||
if (!this.data.code)
|
||||
throw new Error(`The postcode can't be empty`);
|
||||
if (!this.data.townFk)
|
||||
throw new Error(`The town can't be empty`);
|
||||
|
||||
this.$http.patch(`postcodes`, this.data).then(response => {
|
||||
if (response.data) {
|
||||
this.vnApp.showMessage(this.$translate.instant('The postcode has been saved'));
|
||||
|
||||
this.emit('response', {response: response.data});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$translate.instant(e.message));
|
||||
return false;
|
||||
}
|
||||
this.$http.patch(`postcodes`, this.data).then(res => {
|
||||
this.vnApp.showMessage(this.$translate.instant('The postcode has been saved'));
|
||||
this.emit('response', {$response: res.data});
|
||||
});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$translate.instant(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('Client', () => {
|
|||
controller.client = {id: 101};
|
||||
}));
|
||||
|
||||
describe('onResponse()', () => {
|
||||
describe('onAccept()', () => {
|
||||
it('should perform a POST query and show a success snackbar', () => {
|
||||
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||
|
@ -24,7 +24,7 @@ describe('Client', () => {
|
|||
$httpBackend.when('PATCH', `postcodes`, params).respond(200, params);
|
||||
$httpBackend.expect('PATCH', `postcodes`, params).respond(params);
|
||||
|
||||
controller.onResponse('accept');
|
||||
controller.onAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved');
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"Entry": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"EntryLog": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "EntryLog",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "entryLog"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "Number"
|
||||
},
|
||||
"originFk": {
|
||||
"type": "Number",
|
||||
"required": true
|
||||
},
|
||||
"userFk": {
|
||||
"type": "Number"
|
||||
},
|
||||
"action": {
|
||||
"type": "String",
|
||||
"required": true
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "Date"
|
||||
},
|
||||
"description": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "Account",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"order": ["creationDate DESC", "id DESC"]
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "Entry",
|
||||
"base": "VnModel",
|
||||
"log": {
|
||||
"model":"EntryLog"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "entry"
|
||||
|
|
|
@ -6,3 +6,4 @@ import './search-panel';
|
|||
import './descriptor';
|
||||
import './card';
|
||||
import './summary';
|
||||
import './log';
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<vn-log url="EntryLogs" origin-id="$ctrl.$stateParams.id"></vn-log>
|
|
@ -0,0 +1,15 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $stateParams) {
|
||||
this.$scope = $scope;
|
||||
this.$stateParams = $stateParams;
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$stateParams'];
|
||||
|
||||
ngModule.component('vnEntryLog', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
Date: Fecha
|
|
@ -9,6 +9,7 @@
|
|||
{"state": "entry.index", "icon": "icon-entry"}
|
||||
],
|
||||
"card": [
|
||||
{"state": "entry.card.log", "icon": "history"}
|
||||
]
|
||||
},
|
||||
"routes": [
|
||||
|
@ -36,6 +37,11 @@
|
|||
"params": {
|
||||
"entry": "$ctrl.entry"
|
||||
}
|
||||
}, {
|
||||
"url" : "/log",
|
||||
"state": "entry.card.log",
|
||||
"component": "vn-entry-log",
|
||||
"description": "Log"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -3,13 +3,22 @@ const app = require('vn-loopback/server/server');
|
|||
describe('ticket makeInvoice()', () => {
|
||||
let invoice;
|
||||
let ticketId = 11;
|
||||
const okState = 3;
|
||||
|
||||
afterAll(async done => {
|
||||
let ticket = await app.models.Ticket.findById(11);
|
||||
await ticket.updateAttributes({refFk: null});
|
||||
|
||||
let ticketTracking = await app.models.TicketTracking.findOne({order: 'id DESC', limit: 1});
|
||||
await ticketTracking.destroy();
|
||||
let ticketTrackings = await app.models.TicketTracking.find({
|
||||
where: {
|
||||
ticketFk: ticketId,
|
||||
stateFk: {neq: okState}
|
||||
},
|
||||
order: 'id DESC'
|
||||
});
|
||||
|
||||
for (let state of ticketTrackings)
|
||||
await state.destroy();
|
||||
|
||||
let invoiceOut = await app.models.InvoiceOut.findById(invoice.invoiceFk);
|
||||
await invoiceOut.destroy();
|
||||
|
|
|
@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('createThermograph', {
|
||||
description: 'Upload and attach a document',
|
||||
description: 'Creates a new travel thermograph',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
|
|
|
@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error');
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateThermograph', {
|
||||
description: 'updates a file properties or file',
|
||||
description: 'Updates a travel thermograph',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
{
|
||||
"Travel": {
|
||||
"dataSource": "vn"
|
||||
},"TravelLog": {
|
||||
},
|
||||
"TravelLog": {
|
||||
"dataSource": "vn"
|
||||
},"Currency": {
|
||||
},
|
||||
"Currency": {
|
||||
"dataSource": "vn"
|
||||
},"Thermograph": {
|
||||
},
|
||||
"Thermograph": {
|
||||
"dataSource": "vn"
|
||||
},"TravelThermograph": {
|
||||
},
|
||||
"TravelThermograph": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue