Reviewed-on: #2303 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
17ed4b7f08
|
@ -180,5 +180,11 @@
|
|||
},
|
||||
"ProductionConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"AgencyLog": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"AgencyWorkCenter": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "AgencyLog",
|
||||
"base": "Log",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "agencyLog"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.rewriteDbError(function(err) {
|
||||
if (err.code === 'ER_DUP_ENTRY')
|
||||
return new UserError(`This workCenter is already assigned to this agency`);
|
||||
return err;
|
||||
});
|
||||
};
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "AgencyWorkCenter",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "agencyWorkCenter"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"forceId": false
|
||||
},
|
||||
"agencyFk": {
|
||||
"type": "number",
|
||||
"required": false
|
||||
},
|
||||
"workCenterFk": {
|
||||
"type": "number",
|
||||
"required": false
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"agency": {
|
||||
"type": "belongsTo",
|
||||
"model": "WorkCenter",
|
||||
"foreignKey": "agencyFk"
|
||||
},
|
||||
"workCenter": {
|
||||
"type": "belongsTo",
|
||||
"model": "WorkCenter",
|
||||
"foreignKey": "workCenterFk"
|
||||
}
|
||||
},
|
||||
"scope": {
|
||||
"include":{
|
||||
"relation": "workCenter"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3788,3 +3788,6 @@ INSERT INTO `vn`.`accountReconciliationConfig`(currencyFk, warehouseFk)
|
|||
INSERT INTO vn.workerTeam(id, team, workerFk)
|
||||
VALUES
|
||||
(8, 1, 19);
|
||||
|
||||
INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment)
|
||||
VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL);
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`agency_beforeInsert`
|
||||
BEFORE INSERT ON `agency`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,24 @@
|
|||
-- vn.agencyLog definition
|
||||
ALTER TABLE vn.agency ADD IF NOT EXISTS editorFk int(10) unsigned DEFAULT NULL NULL;
|
||||
|
||||
ALTER TABLE vn.agency ADD CONSTRAINT agency_user_FK FOREIGN KEY (editorFk) REFERENCES `account`.`user`(id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `vn`.`agencyLog` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`originFk` smallint(5) unsigned DEFAULT NULL,
|
||||
`userFk` int(10) unsigned DEFAULT NULL,
|
||||
`action` set('insert','update','delete','select') NOT NULL,
|
||||
`creationDate` timestamp NULL DEFAULT current_timestamp(),
|
||||
`description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
|
||||
`changedModel` enum('agency','agencyMode') NOT NULL DEFAULT 'agency',
|
||||
`oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)),
|
||||
`newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)),
|
||||
`changedModelId` int(11) NOT NULL,
|
||||
`changedModelValue` varchar(45) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `logAgencyUserFk` (`userFk`),
|
||||
KEY `agencyLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`),
|
||||
KEY `agencyLog_originFk` (`originFk`,`creationDate`),
|
||||
CONSTRAINT `agencyOriginFk` FOREIGN KEY (`originFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `agencyUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
|
@ -0,0 +1,18 @@
|
|||
CREATE TABLE IF NOT EXISTS `vn`.`agencyWorkCenter` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`agencyFk` smallint(5) unsigned NOT NULL,
|
||||
`workCenterFk` int(11) NOT NULL,
|
||||
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `agencyWorkCenter_unique` (`agencyFk`,`workCenterFk`),
|
||||
KEY `agencyWorkCenter_workCenter_FK` (`workCenterFk`),
|
||||
KEY `agencyWorkCenter_user_FK` (`editorFk`),
|
||||
CONSTRAINT `agencyWorkCenter_agency_FK` FOREIGN KEY (`agencyFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `agencyWorkCenter_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `agencyWorkCenter_workCenter_FK` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #4988';
|
||||
|
||||
INSERT INTO vn.agencyWorkCenter (agencyFk, workCenterFk)
|
||||
SELECT id, workCenterFk
|
||||
FROM vn.agency
|
||||
WHERE workCenterFk IS NOT NULL;
|
|
@ -0,0 +1,19 @@
|
|||
-- Place your SQL code here
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('AgencyLog','*','READ','ALLOW','ROLE','employee');
|
||||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('AgencyWorkCenter','*','READ','ALLOW','ROLE','employee');
|
||||
|
||||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('AgencyMode', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('Agency', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant');
|
||||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant');
|
||||
|
|
@ -354,6 +354,7 @@
|
|||
"They're not your subordinate": "No es tu subordinado/a.",
|
||||
"No results found": "No se han encontrado resultados",
|
||||
"InvoiceIn is already booked": "La factura recibida está contabilizada",
|
||||
"This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia",
|
||||
"Select ticket or client": "Elija un ticket o un client",
|
||||
"It was not able to create the invoice": "No se pudo crear la factura"
|
||||
}
|
||||
|
|
|
@ -15,6 +15,22 @@
|
|||
"name": {
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
"warehouseFk": {
|
||||
"type": "number",
|
||||
"required": false
|
||||
},
|
||||
"isOwn": {
|
||||
"type": "boolean",
|
||||
"required": false
|
||||
},
|
||||
"workCenterFk": {
|
||||
"type": "number",
|
||||
"required": false
|
||||
},
|
||||
"isAnyVolumeAllowed": {
|
||||
"type": "boolean",
|
||||
"required": false
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -22,6 +38,16 @@
|
|||
"type": "hasOne",
|
||||
"model": "SupplierAgencyTerm",
|
||||
"foreignKey": "agencyFk"
|
||||
}
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
},
|
||||
"workCenter": {
|
||||
"type": "belongsTo",
|
||||
"model": "WorkCenter",
|
||||
"foreignKey": "workCenterFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue