diff --git a/front/package.json b/front/package.json
index 6b1ded2aa..bcbe3c77c 100644
--- a/front/package.json
+++ b/front/package.json
@@ -1,7 +1,7 @@
{
"name": "salix-front",
"version": "1.0.0",
- "author": "Verdnatura Levante SL",
+ "author": "Verdnatura Levante SL",
"description": "Salix frontend",
"license": "GPL-3.0",
"repository": {
diff --git a/loopback/locale/en.json b/loopback/locale/en.json
index b94e67a0c..baf8326ab 100644
--- a/loopback/locale/en.json
+++ b/loopback/locale/en.json
@@ -31,5 +31,6 @@
"Worker cannot be blank": "Worker cannot be blank",
"You must delete the claim id %d first": "You must delete the claim id %d first",
"You don't have enough privileges": "You don't have enough privileges",
- "Tag value cannot be blank": "Tag value cannot be blank"
+ "Tag value cannot be blank": "Tag value cannot be blank",
+ "You don't have enough privileges to do that": "You don't have enough privileges to do that"
}
\ No newline at end of file
diff --git a/loopback/locale/es.json b/loopback/locale/es.json
index da4100a5a..7ef74e67f 100644
--- a/loopback/locale/es.json
+++ b/loopback/locale/es.json
@@ -66,5 +66,6 @@
"You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado",
"You can't create a ticket for a inactive client": "No puedes crear un ticket para un cliente inactivo",
"Tag value cannot be blank": "El valor del tag no puede quedar en blanco",
- "ORDER_EMPTY": "Cesta vacía"
+ "ORDER_EMPTY": "Cesta vacía",
+ "You don't have enough privileges to do that": "No tienes permisos para cambiar esto"
}
\ No newline at end of file
diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json
index c53b61699..90144e52b 100644
--- a/modules/client/back/models/client.json
+++ b/modules/client/back/models/client.json
@@ -168,6 +168,11 @@
"model": "CreditClassification",
"foreignKey": "client"
},
+ "defaultAddress": {
+ "type": "belongsTo",
+ "model": "Address",
+ "foreignKey": "defaultAddressFk"
+ },
"contacts": {
"type": "hasMany",
"model": "ClientContact",
@@ -178,20 +183,20 @@
"model": "BankEntity",
"foreignKey": "bankEntityFk"
},
- "defaulters": {
- "type": "hasMany",
- "model": "Defaulter",
- "foreignKey": "clientFk"
- },
- "clientRisks": {
- "type": "hasMany",
- "model": "ClientRisk",
- "foreignKey": "clientFk"
- },
- "claimsRatio": {
- "type": "hasMany",
- "model": "ClaimRatio",
- "foreignKey": "clientFk"
- }
+ "defaulters": {
+ "type": "hasMany",
+ "model": "Defaulter",
+ "foreignKey": "clientFk"
+ },
+ "clientRisks": {
+ "type": "hasMany",
+ "model": "ClientRisk",
+ "foreignKey": "clientFk"
+ },
+ "claimsRatio": {
+ "type": "hasMany",
+ "model": "ClaimRatio",
+ "foreignKey": "clientFk"
+ }
}
}
\ No newline at end of file
diff --git a/modules/order/back/methods/order/updateBasicData.js b/modules/order/back/methods/order/updateBasicData.js
index 873bbc1f3..821f5c836 100644
--- a/modules/order/back/methods/order/updateBasicData.js
+++ b/modules/order/back/methods/order/updateBasicData.js
@@ -37,8 +37,9 @@ module.exports = Self => {
let validUpdateParams = [
'clientFk',
- 'companyFk',
+ 'address_id',
'landed',
+ 'agency_id',
'note',
];
diff --git a/modules/order/back/models/order.json b/modules/order/back/models/order.json
index e50e404cf..00cff995a 100644
--- a/modules/order/back/models/order.json
+++ b/modules/order/back/models/order.json
@@ -14,6 +14,7 @@
},
"landed": {
"type": "date",
+ "required": true,
"mysql": {
"columnName": "date_send"
}
@@ -27,6 +28,7 @@
},
"companyFk": {
"type": "Number",
+ "required": true,
"mysql": {
"columnName": "company_id"
}
@@ -73,6 +75,7 @@
},
"address": {
"type": "belongsTo",
+ "required": true,
"model": "Address",
"foreignKey": "address_id"
},
diff --git a/modules/order/front/basic-data/index.html b/modules/order/front/basic-data/index.html
index f52fbfc42..bcfd8eb0f 100644
--- a/modules/order/front/basic-data/index.html
+++ b/modules/order/front/basic-data/index.html
@@ -1,4 +1,11 @@
+
+
- {{id}}: {{name}}
+ selection="$ctrl.selection"
+ fields="['defaultAddressFk']">
+ {{::id}}: {{::name}}
+ field="$ctrl.order.address_id">
+ {{::nickname}}
+
+
+
+ {{::id}}: {{::name}}
+
{
+ if (newValue) {
+ $scope.addressModel.where = {clientFk: newValue.id};
+ $scope.addressModel.refresh();
+ if (isDirty)
+ this.order.address_id = newValue.defaultAddressFk;
+ isDirty = true;
+ } else {
+ $scope.addressModel.clear();
+ if (isDirty)
+ this.order.address_id = null;
+ }
+ });
+ }
+}
+
+Controller.$inject = ['$scope'];
+
ngModule.component('vnOrderBasicData', {
+ controller: Controller,
template: require('./index.html'),
bindings: {
order: '<'
diff --git a/modules/order/front/basic-data/index.spec.js b/modules/order/front/basic-data/index.spec.js
new file mode 100644
index 000000000..1b4516530
--- /dev/null
+++ b/modules/order/front/basic-data/index.spec.js
@@ -0,0 +1,35 @@
+import './index.js';
+
+describe('Order', () => {
+ describe('Component vnOrderBasicData', () => {
+ let $httpBackend;
+ let controller;
+ let $scope;
+
+ beforeEach(ngModule('order'));
+
+ beforeEach(angular.mock.inject(($compile, _$httpBackend_, $rootScope) => {
+ $httpBackend = _$httpBackend_;
+ $scope = $rootScope.$new();
+
+ $httpBackend.whenGET(/^\/api\/Addresses/)
+ .respond([{id: 2, nickname: 'address 2'}]);
+ $httpBackend.whenGET(/^\/api\/Clients/)
+ .respond([{id: 1, defaultAddressFk: 1}]);
+ $scope.order = {clientFk: 1, address_id: 1};
+
+ let $element = $compile('')($scope);
+ $httpBackend.flush();
+ controller = $element.controller('vnOrderBasicData');
+ }));
+
+ describe('constructor()', () => {
+ it('should update the address after the client changes', async() => {
+ controller.selection = {id: 2, defaultAddressFk: 2};
+ $scope.$digest();
+
+ expect(controller.order.address_id).toEqual(2);
+ });
+ });
+ });
+});
diff --git a/package-lock.json b/package-lock.json
index 5b72e253f..2be9a1ed9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3762,7 +3762,7 @@
"dot-prop": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
- "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==",
+ "integrity": "sha1-HxngwuGqDjJ5fEl5nyg3rGr2nFc=",
"dev": true,
"requires": {
"is-obj": "^1.0.0"
@@ -3935,7 +3935,7 @@
},
"jsonfile": {
"version": "2.4.0",
- "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"dev": true,
"requires": {
@@ -7863,7 +7863,7 @@
"karma-chrome-launcher": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
- "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
+ "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
"dev": true,
"requires": {
"fs-access": "^1.0.0",
@@ -13367,7 +13367,7 @@
"split2": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz",
- "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==",
+ "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=",
"dev": true,
"requires": {
"through2": "^2.0.2"
@@ -14368,7 +14368,7 @@
"touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
- "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
+ "integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=",
"dev": true,
"requires": {
"nopt": "~1.0.10"
@@ -15966,7 +15966,7 @@
"write-file-atomic": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz",
- "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==",
+ "integrity": "sha1-H/YVdcLipOjlENb6TiQ8zhg5mas=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.11",