diff --git a/.vscode/settings.json b/.vscode/settings.json
index 36b7e21d8..03479d27a 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -16,6 +16,7 @@
},
"cSpell.words": [
"salix",
- "fdescribe"
+ "fdescribe",
+ "Loggable"
]
}
diff --git a/back/methods/vn-user/privileges.js b/back/methods/vn-user/privileges.js
index 08cfaaae8..9f936c29b 100644
--- a/back/methods/vn-user/privileges.js
+++ b/back/methods/vn-user/privileges.js
@@ -68,7 +68,7 @@ module.exports = Self => {
userToUpdate.hasGrant = hasGrant;
if (roleFk) {
- const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions);
+ const role = await models.VnRole.findById(roleFk, {fields: ['name']}, myOptions);
const hasRole = await Self.hasRole(userId, role.name, myOptions);
if (!hasRole)
diff --git a/back/methods/vn-user/specs/privileges.spec.js b/back/methods/vn-user/specs/privileges.spec.js
index 3d25eecf9..04d9c09ff 100644
--- a/back/methods/vn-user/specs/privileges.spec.js
+++ b/back/methods/vn-user/specs/privileges.spec.js
@@ -70,7 +70,7 @@ describe('VnUser privileges()', () => {
const tx = await models.VnUser.beginTransaction({});
const options = {transaction: tx};
- const agency = await models.Role.findOne({
+ const agency = await models.VnRole.findOne({
where: {
name: 'agency'
}
diff --git a/back/model-config.json b/back/model-config.json
index 856167757..740f9a3f9 100644
--- a/back/model-config.json
+++ b/back/model-config.json
@@ -145,9 +145,6 @@
"Warehouse": {
"dataSource": "vn"
},
- "VnUser": {
- "dataSource": "vn"
- },
"OsTicket": {
"dataSource": "osticket"
},
@@ -162,6 +159,12 @@
},
"ViaexpressConfig": {
"dataSource": "vn"
+ },
+ "VnUser": {
+ "dataSource": "vn"
+ },
+ "VnRole": {
+ "dataSource": "vn"
}
}
diff --git a/back/models/dms-type.json b/back/models/dms-type.json
index de3d564b4..8d7195132 100644
--- a/back/models/dms-type.json
+++ b/back/models/dms-type.json
@@ -29,12 +29,12 @@
"relations": {
"readRole": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "readRoleFk"
},
"writeRole": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "writeRoleFk"
}
},
diff --git a/back/models/image-collection.json b/back/models/image-collection.json
index 186ab0208..ae0e0adcd 100644
--- a/back/models/image-collection.json
+++ b/back/models/image-collection.json
@@ -46,12 +46,12 @@
},
"readRole": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "readRoleFk"
},
"writeRole": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "writeRoleFk"
}
},
@@ -64,4 +64,3 @@
}
]
}
-
\ No newline at end of file
diff --git a/back/models/notificationAcl.json b/back/models/notificationAcl.json
index a20187961..9ab85530f 100644
--- a/back/models/notificationAcl.json
+++ b/back/models/notificationAcl.json
@@ -24,8 +24,8 @@
},
"role": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "roleFk"
}
}
-}
\ No newline at end of file
+}
diff --git a/back/models/vn-role.json b/back/models/vn-role.json
new file mode 100644
index 000000000..c7d7e172b
--- /dev/null
+++ b/back/models/vn-role.json
@@ -0,0 +1,13 @@
+{
+ "name": "VnRole",
+ "base": "Role",
+ "validateUpsert": true,
+ "options": {
+ "mysql": {
+ "table": "account.role"
+ }
+ },
+ "mixins": {
+ "Loggable": true
+ }
+}
diff --git a/back/models/vn-user.json b/back/models/vn-user.json
index d0687098d..639603643 100644
--- a/back/models/vn-user.json
+++ b/back/models/vn-user.json
@@ -7,6 +7,9 @@
"table": "account.user"
}
},
+ "mixins": {
+ "Loggable": true
+ },
"resetPasswordTokenTTL": "604800",
"properties": {
"id": {
@@ -63,7 +66,7 @@
"relations": {
"role": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "roleFk"
},
"roles": {
diff --git a/db/changes/235001/00-updateACL_Role_VnRole.sql b/db/changes/235001/00-updateACL_Role_VnRole.sql
new file mode 100644
index 000000000..b08a44138
--- /dev/null
+++ b/db/changes/235001/00-updateACL_Role_VnRole.sql
@@ -0,0 +1,6 @@
+INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES
+ ('VnRole','*','READ','ALLOW','ROLE','employee'),
+ ('VnRole','*','WRITE','ALLOW','ROLE','it');
+
+DELETE FROM`salix`.`ACL` WHERE model='Role';
+
diff --git a/front/core/directives/rule.js b/front/core/directives/rule.js
index f65efe176..34781c2aa 100644
--- a/front/core/directives/rule.js
+++ b/front/core/directives/rule.js
@@ -23,7 +23,6 @@ export function directive($translate, $window) {
let rule = $attrs.rule.split('.');
let modelName = rule.shift();
let fieldName = rule.shift();
-
let split = $attrs.ngModel.split('.');
if (!fieldName) fieldName = split.pop() || null;
if (!modelName) modelName = firstUpper(split.pop() || '');
diff --git a/loopback/common/mixins/loggable.js b/loopback/common/mixins/loggable.js
new file mode 100644
index 000000000..760fdf60a
--- /dev/null
+++ b/loopback/common/mixins/loggable.js
@@ -0,0 +1,12 @@
+const LoopBackContext = require('loopback-context');
+async function handleObserve(ctx) {
+ ctx.options.httpCtx = LoopBackContext.getCurrentContext();
+}
+module.exports = function(Self) {
+ let Mixin = {
+ 'before save': handleObserve,
+ 'before delete': handleObserve,
+ };
+ for (const [listener, handler] of Object.entries(Mixin))
+ Self.observe(listener, handler);
+};
diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js
deleted file mode 100644
index 360c84566..000000000
--- a/loopback/common/models/loggable.js
+++ /dev/null
@@ -1,15 +0,0 @@
-const LoopBackContext = require('loopback-context');
-
-module.exports = function(Self) {
- Self.setup = function() {
- Self.super_.setup.call(this);
- };
-
- Self.observe('before save', async function(ctx) {
- ctx.options.httpCtx = LoopBackContext.getCurrentContext();
- });
-
- Self.observe('before delete', async function(ctx) {
- ctx.options.httpCtx = LoopBackContext.getCurrentContext();
- });
-};
diff --git a/loopback/common/models/loggable.json b/loopback/common/models/loggable.json
deleted file mode 100644
index 9101532a3..000000000
--- a/loopback/common/models/loggable.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "Loggable",
- "base": "VnModel",
- "validateUpsert": true
-}
diff --git a/loopback/server/model-config.json b/loopback/server/model-config.json
index 33ef3797d..56b5360e8 100644
--- a/loopback/server/model-config.json
+++ b/loopback/server/model-config.json
@@ -25,20 +25,19 @@
"FieldAcl": {
"dataSource": "vn"
},
- "Role": {
- "dataSource": "vn",
- "options": {
- "mysql": {
- "table": "salix.Role"
- }
- }
- },
"RoleMapping": {
"dataSource": "vn",
"options": {
"mysql": {
"table": "salix.RoleMapping"
}
+ },
+ "relations": {
+ "role": {
+ "type": "belongsTo",
+ "model": "VnRole",
+ "foreignKey": "roleId"
+ }
}
},
"Schema": {
diff --git a/modules/account/back/models/account.json b/modules/account/back/models/account.json
index 3c22521cb..6c2784696 100644
--- a/modules/account/back/models/account.json
+++ b/modules/account/back/models/account.json
@@ -1,49 +1,49 @@
{
- "name": "Account",
- "base": "VnModel",
- "options": {
- "mysql": {
- "table": "account.account"
- }
- },
- "properties": {
- "id": {
- "id": true
- }
- },
- "relations": {
- "user": {
- "type": "belongsTo",
- "model": "VnUser",
- "foreignKey": "id"
- },
- "aliases": {
- "type": "hasMany",
- "model": "MailAliasAccount",
- "foreignKey": "account"
- }
- },
- "acls": [
- {
- "property": "login",
- "accessType": "EXECUTE",
- "principalType": "ROLE",
- "principalId": "$everyone",
- "permission": "ALLOW"
+ "name": "Account",
+ "base": "VnModel",
+ "options": {
+ "mysql": {
+ "table": "account.account"
+ }
+ },
+ "properties": {
+ "id": {
+ "id": true
+ }
+ },
+ "relations": {
+ "user": {
+ "type": "belongsTo",
+ "model": "VnUser",
+ "foreignKey": "id"
},
- {
+ "aliases": {
+ "type": "hasMany",
+ "model": "MailAliasAccount",
+ "foreignKey": "account"
+ }
+ },
+ "acls": [
+ {
+ "property": "login",
+ "accessType": "EXECUTE",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ },
+ {
"property": "logout",
- "accessType": "EXECUTE",
- "principalType": "ROLE",
- "principalId": "$authenticated",
- "permission": "ALLOW"
- },
- {
+ "accessType": "EXECUTE",
+ "principalType": "ROLE",
+ "principalId": "$authenticated",
+ "permission": "ALLOW"
+ },
+ {
"property": "changePassword",
- "accessType": "EXECUTE",
- "principalType": "ROLE",
- "principalId": "$everyone",
- "permission": "ALLOW"
- }
- ]
+ "accessType": "EXECUTE",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ }
+ ]
}
diff --git a/modules/account/back/models/ldap-config.js b/modules/account/back/models/ldap-config.js
index b557d243c..89f0add48 100644
--- a/modules/account/back/models/ldap-config.js
+++ b/modules/account/back/models/ldap-config.js
@@ -239,7 +239,7 @@ module.exports = Self => {
// Prepare data
- let roles = await $.Role.find({
+ let roles = await $.VnRole.find({
fields: ['id', 'name', 'description']
});
let roleRoles = await $.RoleRole.find({
diff --git a/modules/account/back/models/role-inherit.json b/modules/account/back/models/role-inherit.json
index 4b69ffdc2..a89f47b77 100644
--- a/modules/account/back/models/role-inherit.json
+++ b/modules/account/back/models/role-inherit.json
@@ -15,12 +15,12 @@
"relations": {
"owner": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "role"
},
"inherits": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "inheritsFrom"
}
}
diff --git a/modules/account/back/models/role-role.json b/modules/account/back/models/role-role.json
index 77df7a920..e59351c59 100644
--- a/modules/account/back/models/role-role.json
+++ b/modules/account/back/models/role-role.json
@@ -14,12 +14,12 @@
"relations": {
"owner": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "role"
},
"inherits": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "inheritsFrom"
}
}
diff --git a/modules/account/front/acl/create/index.html b/modules/account/front/acl/create/index.html
index 7f4fa9e46..14332f737 100644
--- a/modules/account/front/acl/create/index.html
+++ b/modules/account/front/acl/create/index.html
@@ -15,7 +15,7 @@
@@ -32,7 +32,7 @@
diff --git a/modules/account/front/acl/search-panel/index.html b/modules/account/front/acl/search-panel/index.html
index b83b9c255..a3efab440 100644
--- a/modules/account/front/acl/search-panel/index.html
+++ b/modules/account/front/acl/search-panel/index.html
@@ -4,7 +4,7 @@
-
\ No newline at end of file
+
diff --git a/modules/account/front/create/index.html b/modules/account/front/create/index.html
index acc07d346..70a518885 100644
--- a/modules/account/front/create/index.html
+++ b/modules/account/front/create/index.html
@@ -30,7 +30,7 @@
+ url="VnRoles">
diff --git a/modules/account/front/role/basic-data/index.html b/modules/account/front/role/basic-data/index.html
index 749927186..846f8b455 100644
--- a/modules/account/front/role/basic-data/index.html
+++ b/modules/account/front/role/basic-data/index.html
@@ -1,25 +1,27 @@
\ No newline at end of file
+
diff --git a/modules/account/front/role/card/index.js b/modules/account/front/role/card/index.js
index 6f888211d..3c7c758ef 100644
--- a/modules/account/front/role/card/index.js
+++ b/modules/account/front/role/card/index.js
@@ -3,7 +3,7 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
- this.$http.get(`Roles/${this.$params.id}`)
+ this.$http.get(`VnRoles/${this.$params.id}`)
.then(res => this.role = res.data);
}
}
diff --git a/modules/account/front/role/card/index.spec.js b/modules/account/front/role/card/index.spec.js
index f39840e5f..f02c08f28 100644
--- a/modules/account/front/role/card/index.spec.js
+++ b/modules/account/front/role/card/index.spec.js
@@ -1,6 +1,6 @@
import './index';
-describe('component vnRoleCard', () => {
+fdescribe('component vnRoleCard', () => {
let controller;
let $httpBackend;
@@ -15,7 +15,7 @@ describe('component vnRoleCard', () => {
it('should reload the controller data', () => {
controller.$params.id = 1;
- $httpBackend.expectGET('Roles/1').respond('foo');
+ $httpBackend.expectGET('VnRoles/1').respond('foo');
controller.reload();
$httpBackend.flush();
diff --git a/modules/account/front/role/create/index.html b/modules/account/front/role/create/index.html
index 02900d580..77d6fc2c1 100644
--- a/modules/account/front/role/create/index.html
+++ b/modules/account/front/role/create/index.html
@@ -1,6 +1,6 @@
@@ -12,15 +12,15 @@
+ rule="VnRole.description">
diff --git a/modules/account/front/role/descriptor/index.html b/modules/account/front/role/descriptor/index.html
index 4cd4ac822..d8bf4857a 100644
--- a/modules/account/front/role/descriptor/index.html
+++ b/modules/account/front/role/descriptor/index.html
@@ -24,4 +24,4 @@
on-accept="$ctrl.onDelete()"
question="Are you sure you want to continue?"
message="Role will be removed">
-
\ No newline at end of file
+
diff --git a/modules/account/front/role/descriptor/index.js b/modules/account/front/role/descriptor/index.js
index a1b578133..17b585cb7 100644
--- a/modules/account/front/role/descriptor/index.js
+++ b/modules/account/front/role/descriptor/index.js
@@ -11,7 +11,7 @@ class Controller extends Descriptor {
}
onDelete() {
- return this.$http.delete(`Roles/${this.id}`)
+ return this.$http.delete(`VnRoles/${this.id}`)
.then(() => this.$state.go('account.role'))
.then(() => this.vnApp.showSuccess(this.$t('Role removed')));
}
diff --git a/modules/account/front/role/descriptor/index.spec.js b/modules/account/front/role/descriptor/index.spec.js
index e2761c639..eafb96727 100644
--- a/modules/account/front/role/descriptor/index.spec.js
+++ b/modules/account/front/role/descriptor/index.spec.js
@@ -1,6 +1,6 @@
import './index';
-describe('component vnRoleDescriptor', () => {
+fdescribe('component vnRoleDescriptor', () => {
let controller;
let $httpBackend;
@@ -18,7 +18,7 @@ describe('component vnRoleDescriptor', () => {
controller.$state.go = jest.fn();
jest.spyOn(controller.vnApp, 'showSuccess');
- $httpBackend.expectDELETE('Roles/1').respond();
+ $httpBackend.expectDELETE('VnRoles/1').respond();
controller.onDelete();
$httpBackend.flush();
diff --git a/modules/account/front/role/main/index.html b/modules/account/front/role/main/index.html
index 9d7e6e053..cfef28e57 100644
--- a/modules/account/front/role/main/index.html
+++ b/modules/account/front/role/main/index.html
@@ -1,6 +1,6 @@
@@ -15,4 +15,4 @@
-
\ No newline at end of file
+
diff --git a/modules/account/front/role/subroles/index.html b/modules/account/front/role/subroles/index.html
index bc554b9f9..eba1002b0 100644
--- a/modules/account/front/role/subroles/index.html
+++ b/modules/account/front/role/subroles/index.html
@@ -33,14 +33,14 @@
ng-click="$ctrl.onAddClick()"
fixed-bottom-right>
-
@@ -49,7 +49,7 @@
- this.$.summary = res.data);
}
diff --git a/modules/account/front/search-panel/index.html b/modules/account/front/search-panel/index.html
index f80b537aa..a539d9657 100644
--- a/modules/account/front/search-panel/index.html
+++ b/modules/account/front/search-panel/index.html
@@ -19,7 +19,7 @@
vn-one
label="Role"
ng-model="filter.roleFk"
- url="Roles"
+ url="VnRoles"
value-field="id"
show-field="name">
@@ -28,4 +28,4 @@
-
\ No newline at end of file
+
diff --git a/modules/claim/back/models/claim-beginning.json b/modules/claim/back/models/claim-beginning.json
index d355881e8..d224586da 100644
--- a/modules/claim/back/models/claim-beginning.json
+++ b/modules/claim/back/models/claim-beginning.json
@@ -1,6 +1,9 @@
{
"name": "ClaimBeginning",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimBeginning"
diff --git a/modules/claim/back/models/claim-development.json b/modules/claim/back/models/claim-development.json
index b0f352f50..732955660 100644
--- a/modules/claim/back/models/claim-development.json
+++ b/modules/claim/back/models/claim-development.json
@@ -1,6 +1,9 @@
{
"name": "ClaimDevelopment",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimDevelopment"
diff --git a/modules/claim/back/models/claim-dms.json b/modules/claim/back/models/claim-dms.json
index 26c90fd69..ed12c925b 100644
--- a/modules/claim/back/models/claim-dms.json
+++ b/modules/claim/back/models/claim-dms.json
@@ -1,6 +1,9 @@
{
"name": "ClaimDms",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimDms"
diff --git a/modules/claim/back/models/claim-end.json b/modules/claim/back/models/claim-end.json
index 9f12ff93a..ef5477f50 100644
--- a/modules/claim/back/models/claim-end.json
+++ b/modules/claim/back/models/claim-end.json
@@ -1,6 +1,9 @@
{
"name": "ClaimEnd",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimEnd"
diff --git a/modules/claim/back/models/claim-observation.json b/modules/claim/back/models/claim-observation.json
index 2d418b76e..1e4cb6a0f 100644
--- a/modules/claim/back/models/claim-observation.json
+++ b/modules/claim/back/models/claim-observation.json
@@ -1,6 +1,9 @@
{
"name": "ClaimObservation",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimObservation"
diff --git a/modules/claim/back/models/claim-state.json b/modules/claim/back/models/claim-state.json
index f5bde4168..c50fdebdf 100644
--- a/modules/claim/back/models/claim-state.json
+++ b/modules/claim/back/models/claim-state.json
@@ -1,6 +1,9 @@
{
"name": "ClaimState",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claimState"
@@ -32,7 +35,7 @@
"relations": {
"writeRole": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "roleFk"
}
},
diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json
index a7db1f3e1..b85b9e073 100644
--- a/modules/claim/back/models/claim.json
+++ b/modules/claim/back/models/claim.json
@@ -1,6 +1,9 @@
{
"name": "Claim",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "claim"
diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json
index 5f962677d..e8bf8d8a0 100644
--- a/modules/client/back/models/address.json
+++ b/modules/client/back/models/address.json
@@ -1,7 +1,10 @@
{
"name": "Address",
"description": "Client addresses",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "address"
diff --git a/modules/client/back/models/client-contact.json b/modules/client/back/models/client-contact.json
index 3f71ab79e..55cc9d436 100644
--- a/modules/client/back/models/client-contact.json
+++ b/modules/client/back/models/client-contact.json
@@ -1,7 +1,10 @@
{
"name": "ClientContact",
"description": "Client phone contacts",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "clientContact"
diff --git a/modules/client/back/models/client-dms.json b/modules/client/back/models/client-dms.json
index 14b19498e..6dbcd0140 100644
--- a/modules/client/back/models/client-dms.json
+++ b/modules/client/back/models/client-dms.json
@@ -1,6 +1,9 @@
{
"name": "ClientDms",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "clientDms"
diff --git a/modules/client/back/models/client-informa.json b/modules/client/back/models/client-informa.json
index 0c652484e..5e536faff 100644
--- a/modules/client/back/models/client-informa.json
+++ b/modules/client/back/models/client-informa.json
@@ -1,6 +1,9 @@
{
"name": "ClientInforma",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"log": {
"model":"ClientLog",
"relation": "client",
diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json
index 95d00d374..b204ebeb4 100644
--- a/modules/client/back/models/client-observation.json
+++ b/modules/client/back/models/client-observation.json
@@ -1,7 +1,10 @@
{
"name": "ClientObservation",
"description": "Client notes",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "clientObservation"
diff --git a/modules/client/back/models/client-sample.json b/modules/client/back/models/client-sample.json
index a32f308ab..4cd55d9df 100644
--- a/modules/client/back/models/client-sample.json
+++ b/modules/client/back/models/client-sample.json
@@ -1,6 +1,9 @@
{
"name": "ClientSample",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "clientSample"
diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json
index f32915bb5..bfde05162 100644
--- a/modules/client/back/models/client.json
+++ b/modules/client/back/models/client.json
@@ -1,6 +1,9 @@
{
"name": "Client",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "client"
diff --git a/modules/client/back/models/greuge.json b/modules/client/back/models/greuge.json
index 884cbd34e..f57744f8a 100644
--- a/modules/client/back/models/greuge.json
+++ b/modules/client/back/models/greuge.json
@@ -1,6 +1,9 @@
{
"name": "Greuge",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "greuge"
diff --git a/modules/client/back/models/recovery.json b/modules/client/back/models/recovery.json
index 5ea89197d..89ec54494 100644
--- a/modules/client/back/models/recovery.json
+++ b/modules/client/back/models/recovery.json
@@ -1,6 +1,9 @@
{
"name": "Recovery",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "recovery"
diff --git a/modules/client/back/models/role-credit-limit.json b/modules/client/back/models/role-credit-limit.json
index 4ea28b1a4..e36180dfc 100644
--- a/modules/client/back/models/role-credit-limit.json
+++ b/modules/client/back/models/role-credit-limit.json
@@ -19,8 +19,8 @@
"relations": {
"role": {
"type": "belongsTo",
- "model": "Role",
+ "model": "VnRole",
"foreignKey": "roleFk"
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json
index 30379eaf6..fa804f4d8 100644
--- a/modules/entry/back/models/buy.json
+++ b/modules/entry/back/models/buy.json
@@ -1,6 +1,9 @@
{
"name": "Buy",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "buy"
diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json
index cdf0c5e6e..6a1592037 100644
--- a/modules/entry/back/models/entry-observation.json
+++ b/modules/entry/back/models/entry-observation.json
@@ -1,6 +1,9 @@
{
"name": "EntryObservation",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "entryObservation"
diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json
index a7508b4e8..0f3e389b6 100644
--- a/modules/entry/back/models/entry.json
+++ b/modules/entry/back/models/entry.json
@@ -1,6 +1,9 @@
{
"name": "Entry",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "entry"
diff --git a/modules/invoiceIn/back/models/invoice-in-tax.json b/modules/invoiceIn/back/models/invoice-in-tax.json
index 5bfbbe2a8..53b5548b6 100644
--- a/modules/invoiceIn/back/models/invoice-in-tax.json
+++ b/modules/invoiceIn/back/models/invoice-in-tax.json
@@ -1,6 +1,9 @@
{
"name": "InvoiceInTax",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "invoiceInTax"
diff --git a/modules/invoiceIn/back/models/invoice-in.json b/modules/invoiceIn/back/models/invoice-in.json
index 5be55c851..59c179e76 100644
--- a/modules/invoiceIn/back/models/invoice-in.json
+++ b/modules/invoiceIn/back/models/invoice-in.json
@@ -1,6 +1,9 @@
{
"name": "InvoiceIn",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "invoiceIn"
diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
index 18e6903d6..043dfbead 100644
--- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
+++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js
@@ -85,7 +85,7 @@ module.exports = Self => {
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
// Validates ticket nagative base
- const hasNegativeBase = await getNegativeBase(ticketId, myOptions);
+ const hasNegativeBase = await getNegativeBase(maxShipped, clientId, companyId, myOptions);
if (hasNegativeBase && company.code == 'VNL')
throw new UserError(`A ticket with a negative base can't be invoiced`);
} else {
@@ -162,10 +162,13 @@ module.exports = Self => {
return result.invoiceable;
}
- async function getNegativeBase(ticketId, options) {
+ async function getNegativeBase(maxShipped, clientId, companyId, options) {
const models = Self.app.models;
- const query = 'SELECT vn.hasSomeNegativeBase(?) AS base';
- const [result] = await models.InvoiceOut.rawSql(query, [ticketId], options);
+ await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
+ [maxShipped, clientId, companyId], options
+ );
+ const query = 'SELECT vn.hasAnyNegativeBase() AS base';
+ const [result] = await models.InvoiceOut.rawSql(query, [], options);
return result.base;
}
diff --git a/modules/item/back/models/item-barcode.json b/modules/item/back/models/item-barcode.json
index 12068a65f..6726900ea 100644
--- a/modules/item/back/models/item-barcode.json
+++ b/modules/item/back/models/item-barcode.json
@@ -1,6 +1,9 @@
{
"name": "ItemBarcode",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "itemBarcode"
diff --git a/modules/item/back/models/item-botanical.json b/modules/item/back/models/item-botanical.json
index 8a8bba870..ff1410615 100644
--- a/modules/item/back/models/item-botanical.json
+++ b/modules/item/back/models/item-botanical.json
@@ -1,6 +1,9 @@
{
"name": "ItemBotanical",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "itemBotanical"
diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json
index bf9e5e4b1..893a1f81d 100644
--- a/modules/item/back/models/item-shelving.json
+++ b/modules/item/back/models/item-shelving.json
@@ -1,6 +1,9 @@
{
"name": "ItemShelving",
"base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "itemShelving"
diff --git a/modules/item/back/models/item-tag.json b/modules/item/back/models/item-tag.json
index 0742f8d3f..5702cf6cf 100644
--- a/modules/item/back/models/item-tag.json
+++ b/modules/item/back/models/item-tag.json
@@ -1,6 +1,9 @@
{
"name": "ItemTag",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "itemTag"
diff --git a/modules/item/back/models/item-tax-country.json b/modules/item/back/models/item-tax-country.json
index 002be97d8..795a1b950 100644
--- a/modules/item/back/models/item-tax-country.json
+++ b/modules/item/back/models/item-tax-country.json
@@ -1,6 +1,9 @@
{
"name": "ItemTaxCountry",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "itemTaxCountry"
diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json
index 097fe7708..595fb537d 100644
--- a/modules/item/back/models/item.json
+++ b/modules/item/back/models/item.json
@@ -1,6 +1,9 @@
{
"name": "Item",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "item"
diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json
index cdb64dd71..f8be9023c 100644
--- a/modules/route/back/models/route.json
+++ b/modules/route/back/models/route.json
@@ -1,6 +1,9 @@
{
"name": "Route",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "route"
diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json
index 3103b5a4a..46fce31e8 100644
--- a/modules/shelving/back/models/shelving.json
+++ b/modules/shelving/back/models/shelving.json
@@ -1,6 +1,9 @@
{
"name": "Shelving",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "shelving"
diff --git a/modules/supplier/back/models/supplier-account.json b/modules/supplier/back/models/supplier-account.json
index bc9cf0e24..460c435e2 100644
--- a/modules/supplier/back/models/supplier-account.json
+++ b/modules/supplier/back/models/supplier-account.json
@@ -1,6 +1,9 @@
{
"name": "SupplierAccount",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "supplierAccount"
diff --git a/modules/supplier/back/models/supplier-address.json b/modules/supplier/back/models/supplier-address.json
index 001b3a31f..fcd599287 100644
--- a/modules/supplier/back/models/supplier-address.json
+++ b/modules/supplier/back/models/supplier-address.json
@@ -1,7 +1,10 @@
{
"name": "SupplierAddress",
"description": "Supplier addresses",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "supplierAddress"
diff --git a/modules/supplier/back/models/supplier-contact.json b/modules/supplier/back/models/supplier-contact.json
index f928cd204..4ea1b8c2a 100644
--- a/modules/supplier/back/models/supplier-contact.json
+++ b/modules/supplier/back/models/supplier-contact.json
@@ -1,6 +1,9 @@
{
"name": "SupplierContact",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "supplierContact"
diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json
index b6245ef32..59d23f106 100644
--- a/modules/supplier/back/models/supplier.json
+++ b/modules/supplier/back/models/supplier.json
@@ -1,6 +1,9 @@
{
"name": "Supplier",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "supplier"
diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
index eef9136a8..200ea24cc 100644
--- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js
+++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js
@@ -102,7 +102,7 @@ describe('sale canEdit()', () => {
try {
const options = {transaction: tx};
- const role = await models.Role.findOne({
+ const role = await models.VnRole.findOne({
where: {
name: roleEnabled.principalId
}
@@ -159,7 +159,7 @@ describe('sale canEdit()', () => {
try {
const options = {transaction: tx};
- const role = await models.Role.findOne({
+ const role = await models.VnRole.findOne({
where: {
name: roleEnabled.principalId
}
diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json
index 069c6e281..2dcca1e87 100644
--- a/modules/ticket/back/models/expedition.json
+++ b/modules/ticket/back/models/expedition.json
@@ -1,6 +1,9 @@
{
"name": "Expedition",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "expedition"
diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json
index 72ca1f5e0..96a36bbc9 100644
--- a/modules/ticket/back/models/sale.json
+++ b/modules/ticket/back/models/sale.json
@@ -1,6 +1,9 @@
{
"name": "Sale",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "sale"
diff --git a/modules/ticket/back/models/ticket-dms.json b/modules/ticket/back/models/ticket-dms.json
index 071999be7..a3e697506 100644
--- a/modules/ticket/back/models/ticket-dms.json
+++ b/modules/ticket/back/models/ticket-dms.json
@@ -1,6 +1,9 @@
{
"name": "TicketDms",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketDms"
diff --git a/modules/ticket/back/models/ticket-observation.json b/modules/ticket/back/models/ticket-observation.json
index 64e49b217..26d6f7586 100644
--- a/modules/ticket/back/models/ticket-observation.json
+++ b/modules/ticket/back/models/ticket-observation.json
@@ -1,6 +1,9 @@
{
"name": "TicketObservation",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketObservation"
diff --git a/modules/ticket/back/models/ticket-packaging.json b/modules/ticket/back/models/ticket-packaging.json
index 6c94c810e..0cf494809 100644
--- a/modules/ticket/back/models/ticket-packaging.json
+++ b/modules/ticket/back/models/ticket-packaging.json
@@ -1,6 +1,9 @@
{
"name": "TicketPackaging",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketPackaging"
diff --git a/modules/ticket/back/models/ticket-refund.json b/modules/ticket/back/models/ticket-refund.json
index d344a3f1c..249270c8b 100644
--- a/modules/ticket/back/models/ticket-refund.json
+++ b/modules/ticket/back/models/ticket-refund.json
@@ -1,6 +1,9 @@
{
"name": "TicketRefund",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketRefund"
diff --git a/modules/ticket/back/models/ticket-request.json b/modules/ticket/back/models/ticket-request.json
index f8407792e..2cfcd30a1 100644
--- a/modules/ticket/back/models/ticket-request.json
+++ b/modules/ticket/back/models/ticket-request.json
@@ -1,6 +1,9 @@
{
"name": "TicketRequest",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketRequest"
diff --git a/modules/ticket/back/models/ticket-service.json b/modules/ticket/back/models/ticket-service.json
index f1dbede13..4dfbd2fbd 100644
--- a/modules/ticket/back/models/ticket-service.json
+++ b/modules/ticket/back/models/ticket-service.json
@@ -1,6 +1,9 @@
{
"name": "TicketService",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketService"
diff --git a/modules/ticket/back/models/ticket-tracking.json b/modules/ticket/back/models/ticket-tracking.json
index ac0eb9a69..025a07bc0 100644
--- a/modules/ticket/back/models/ticket-tracking.json
+++ b/modules/ticket/back/models/ticket-tracking.json
@@ -1,6 +1,9 @@
{
"name": "TicketTracking",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketTracking"
diff --git a/modules/ticket/back/models/ticket-weekly.json b/modules/ticket/back/models/ticket-weekly.json
index c5e485aa2..7494cac79 100644
--- a/modules/ticket/back/models/ticket-weekly.json
+++ b/modules/ticket/back/models/ticket-weekly.json
@@ -1,6 +1,9 @@
{
"name": "TicketWeekly",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticketWeekly"
diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json
index ec4193bed..c55cd82bb 100644
--- a/modules/ticket/back/models/ticket.json
+++ b/modules/ticket/back/models/ticket.json
@@ -1,6 +1,9 @@
{
"name": "Ticket",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "ticket"
diff --git a/modules/travel/back/models/travel-thermograph.json b/modules/travel/back/models/travel-thermograph.json
index 08eec2847..cc8e60aaf 100644
--- a/modules/travel/back/models/travel-thermograph.json
+++ b/modules/travel/back/models/travel-thermograph.json
@@ -1,6 +1,9 @@
{
"name": "TravelThermograph",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "travelThermograph"
diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json
index 95d458121..701894a76 100644
--- a/modules/travel/back/models/travel.json
+++ b/modules/travel/back/models/travel.json
@@ -1,6 +1,9 @@
{
"name": "Travel",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "travel"
diff --git a/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js b/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js
index da54f6adb..580e07351 100644
--- a/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js
+++ b/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js
@@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
describe('Worker activeWithInheritedRole', () => {
let allRolesCount;
beforeAll(async() => {
- allRolesCount = await app.models.Role.count();
+ allRolesCount = await app.models.VnRole.count();
});
it('should return the workers with an inherited role of salesPerson', async() => {
diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json
index 3eeaae137..35a90fb50 100644
--- a/modules/worker/back/models/device-production-user.json
+++ b/modules/worker/back/models/device-production-user.json
@@ -1,6 +1,9 @@
{
"name": "DeviceProductionUser",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"log": {
"model": "DeviceProductionLog",
"relation": "deviceProduction"
diff --git a/modules/worker/back/models/device-production.json b/modules/worker/back/models/device-production.json
index 35787cccc..f6e5105ad 100644
--- a/modules/worker/back/models/device-production.json
+++ b/modules/worker/back/models/device-production.json
@@ -1,6 +1,9 @@
{
"name": "DeviceProduction",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"log": {
"model": "DeviceProductionLog"
},
diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json
index e9a9f1773..a5c0f30b2 100644
--- a/modules/worker/back/models/worker-dms.json
+++ b/modules/worker/back/models/worker-dms.json
@@ -1,6 +1,9 @@
{
"name": "WorkerDms",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "workerDocument"
diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json
index 1a777fffe..ed430f133 100644
--- a/modules/worker/back/models/worker.json
+++ b/modules/worker/back/models/worker.json
@@ -1,7 +1,10 @@
{
"name": "Worker",
"description": "Company employees",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "worker"
diff --git a/modules/zone/back/models/zone-event.json b/modules/zone/back/models/zone-event.json
index e477dad6a..366bdec9d 100644
--- a/modules/zone/back/models/zone-event.json
+++ b/modules/zone/back/models/zone-event.json
@@ -1,6 +1,9 @@
{
"name": "ZoneEvent",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "zoneEvent"
diff --git a/modules/zone/back/models/zone-exclusion.json b/modules/zone/back/models/zone-exclusion.json
index 00c9145cd..6e91a0a01 100644
--- a/modules/zone/back/models/zone-exclusion.json
+++ b/modules/zone/back/models/zone-exclusion.json
@@ -1,6 +1,9 @@
{
"name": "ZoneExclusion",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "zoneExclusion"
diff --git a/modules/zone/back/models/zone-included.json b/modules/zone/back/models/zone-included.json
index deba73f34..a34e51091 100644
--- a/modules/zone/back/models/zone-included.json
+++ b/modules/zone/back/models/zone-included.json
@@ -1,6 +1,9 @@
{
"name": "ZoneIncluded",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "zoneIncluded"
diff --git a/modules/zone/back/models/zone-warehouse.json b/modules/zone/back/models/zone-warehouse.json
index b222e95e7..c2cc989f0 100644
--- a/modules/zone/back/models/zone-warehouse.json
+++ b/modules/zone/back/models/zone-warehouse.json
@@ -1,6 +1,9 @@
{
"name": "ZoneWarehouse",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "zoneWarehouse"
diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json
index c86da3d3e..cf7371053 100644
--- a/modules/zone/back/models/zone.json
+++ b/modules/zone/back/models/zone.json
@@ -1,6 +1,9 @@
{
"name": "Zone",
- "base": "Loggable",
+ "base": "VnModel",
+ "mixins": {
+ "Loggable": true
+ },
"options": {
"mysql": {
"table": "zone"