diff --git a/db/changes/10140-kings/01-customsAgent.sql b/db/changes/10140-kings/01-customsAgent.sql new file mode 100644 index 0000000000..2e8867166a --- /dev/null +++ b/db/changes/10140-kings/01-customsAgent.sql @@ -0,0 +1,13 @@ +CREATE TABLE `vn`.`customsAgent` ( + `id` int(11) NOT NULL, + `fiscalName` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `street` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `nif` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `phone` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, + `email` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +ALTER TABLE `vn`.`customsAgent` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `nif_UNIQUE` (`nif`); +COMMIT; \ No newline at end of file diff --git a/db/changes/10140-kings/02-incoterms.sql b/db/changes/10140-kings/02-incoterms.sql new file mode 100644 index 0000000000..3e31b0c898 --- /dev/null +++ b/db/changes/10140-kings/02-incoterms.sql @@ -0,0 +1,10 @@ +CREATE TABLE `vn`.`incoterms` ( + `code` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Internacional Commercial Terms'; + +ALTER TABLE `vn`.`incoterms` + ADD PRIMARY KEY (`code`); + +REPLACE INTO `vn`.`incoterms` (`code`, `name`) VALUES +('FAS', 'Free Alongside Ship'); diff --git a/db/changes/10140-kings/03-address.sql b/db/changes/10140-kings/03-address.sql new file mode 100644 index 0000000000..042c2e17e2 --- /dev/null +++ b/db/changes/10140-kings/03-address.sql @@ -0,0 +1,26 @@ +ALTER TABLE `vn`.`address` +ADD COLUMN `customsAgentFk` INT NULL DEFAULT NULL AFTER `isEqualizated`; + +ALTER TABLE `vn`.`address` +ADD COLUMN `incotermsFk` VARCHAR(3) NULL DEFAULT NULL AFTER `customsAgentFk`; + + +ALTER TABLE `vn`.`address` +ADD INDEX `address_customsAgentFk_idx` (`customsAgentFk` ASC); + +ALTER TABLE `vn`.`address` +ADD INDEX `address_incotermsFk_idx` (`incotermsFk` ASC); + +ALTER TABLE `vn`.`address` +ADD CONSTRAINT `address_customsAgentFk` + FOREIGN KEY (`customsAgentFk`) + REFERENCES `vn`.`customsAgent` (`id`) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE `vn`.`address` +ADD CONSTRAINT `address_incotermsFk` + FOREIGN KEY (`incotermsFk`) + REFERENCES `vn`.`incoterms` (`code`) + ON DELETE RESTRICT + ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index bfa56eb266..8d40e93f6e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1960,4 +1960,8 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('TL.BBA85422', CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL), ('TZ1905012010', CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5), ('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), - ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL); \ No newline at end of file + ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL); + +INSERT INTO `vn`.`incoterms` (`code`, `name`) + VALUES + ('FAS', 'Free Alongside Ship'); diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index 670b7d2cad..cdb54f6b69 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -97,5 +97,11 @@ }, "ClientDms": { "dataSource": "vn" + }, + "CustomsAgent": { + "dataSource": "vn" + }, + "Incoterms": { + "dataSource": "vn" } } diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json index ffc80c49bb..7032661415 100644 --- a/modules/client/back/models/address.json +++ b/modules/client/back/models/address.json @@ -1,78 +1,88 @@ { - "name": "Address", - "description": "Client addresses", - "base": "Loggable", - "log": { - "model": "ClientLog", - "relation": "client", - "showField": "nickname" - }, - "options": { - "mysql": { - "table": "address" + "name": "Address", + "description": "Client addresses", + "base": "Loggable", + "log": { + "model": "ClientLog", + "relation": "client", + "showField": "nickname" + }, + "options": { + "mysql": { + "table": "address" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "nickname": { + "type": "string", + "required": true + }, + "street": { + "type": "string", + "required": true + }, + "city": { + "type": "string", + "required": true + }, + "postalCode": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "mobile": { + "type": "string" + }, + "isActive": { + "type": "boolean" + }, + "longitude": { + "type": "Number" + }, + "latitude": { + "type": "Number" + }, + "isEqualizated": { + "type": "boolean" + } + }, + "validations": [], + "relations": { + "province": { + "type": "belongsTo", + "model": "Province", + "foreignKey": "provinceFk" + }, + "client": { + "type": "belongsTo", + "model": "Client", + "foreignKey": "clientFk" + }, + "agencyMode": { + "type": "belongsTo", + "model": "AgencyMode", + "foreignKey": "agencyModeFk" + }, + "observations": { + "type": "hasMany", + "model": "AddressObservation", + "foreignKey": "addressFk" + }, + "incoterms": { + "type": "belongsTo", + "model": "Incoterm", + "foreignKey": "incotermsFk" + }, + "customsAgent": { + "type": "belongsTo", + "model": "CustomsAgent", + "foreignKey": "customsAgentFk" + } } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" - }, - "nickname": { - "type": "string", - "required": true - }, - "street": { - "type": "string", - "required": true - }, - "city": { - "type": "string", - "required": true - }, - "postalCode": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "mobile": { - "type": "string" - }, - "isActive": { - "type": "boolean" - }, - "longitude": { - "type": "Number" - }, - "latitude": { - "type": "Number" - }, - "isEqualizated": { - "type": "boolean" - } - }, - "validations": [], - "relations": { - "province": { - "type": "belongsTo", - "model": "Province", - "foreignKey": "provinceFk" - }, - "client": { - "type": "belongsTo", - "model": "Client", - "foreignKey": "clientFk" - }, - "agencyMode": { - "type": "belongsTo", - "model": "AgencyMode", - "foreignKey": "agencyModeFk" - }, - "observations": { - "type": "hasMany", - "model": "AddressObservation", - "foreignKey": "addressFk" - } - } -} +} \ No newline at end of file diff --git a/modules/client/back/models/customs-agent.json b/modules/client/back/models/customs-agent.json new file mode 100644 index 0000000000..f72d7bf28b --- /dev/null +++ b/modules/client/back/models/customs-agent.json @@ -0,0 +1,33 @@ +{ + "name": "CustomsAgent", + "base": "VnModel", + "options": { + "mysql": { + "table": "customsAgent" + } + }, + "properties": { + "id": { + "type": "Number", + "description": "Identifier", + "id": true + }, + "fiscalName": { + "type": "String", + "required": true + }, + "street": { + "type": "String" + }, + "nif": { + "type": "String", + "required": true + }, + "phone": { + "type": "String" + }, + "email": { + "type": "String" + } + } +} \ No newline at end of file diff --git a/modules/client/back/models/incoterms.json b/modules/client/back/models/incoterms.json new file mode 100644 index 0000000000..647fea7f1a --- /dev/null +++ b/modules/client/back/models/incoterms.json @@ -0,0 +1,19 @@ +{ + "name": "Incoterms", + "base": "VnModel", + "options": { + "mysql": { + "table": "incoterms" + } + }, + "properties": { + "code": { + "type": "String", + "description": "Identifier", + "id": true + }, + "name": { + "type": "String" + } + } +} \ No newline at end of file