From 60f3bfc7b86b8a88f061ddc0f3e24616dcefd4ed Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Wed, 14 Mar 2018 12:06:21 +0100 Subject: [PATCH 1/3] create models saleChecked saleComponent, added fixtures and ACL --- services/db/04-fixtures.sql | 23 +++++++++++ services/db/changes/1.0.2/01-ACLinserts.sql | 2 + services/db/changes/1.0.2/03-saleChecked.sql | 11 ++++++ .../ticket/common/models/componentRate.json | 39 +++++++++++++++++++ .../ticket/common/models/saleChecked.json | 24 ++++++++++++ .../ticket/common/models/saleComponent.json | 29 ++++++++++++++ services/ticket/server/model-config.json | 8 +++- 7 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 services/db/changes/1.0.2/03-saleChecked.sql create mode 100644 services/ticket/common/models/componentRate.json create mode 100644 services/ticket/common/models/saleChecked.json create mode 100644 services/ticket/common/models/saleComponent.json diff --git a/services/db/04-fixtures.sql b/services/db/04-fixtures.sql index 9a8a36e6f..047720eeb 100644 --- a/services/db/04-fixtures.sql +++ b/services/db/04-fixtures.sql @@ -415,6 +415,29 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric ( 2, 1, 1, 'Gem of Time', 2 , 1.5, 0, 0, 0, CURDATE()), ( 3, 2, 2, 'Mjolnir' , 10, 4 , 0, 0, 0, CURDATE()); +INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`) + VALUES + ( 1, 0), + ( 2, 1); + +INSERT INTO `vn`.`componentTypeRate`(`id`, `type`) + VALUES + ( 1, 'agency'), + ( 2, 'client'), + ( 3, 'company'); + +INSERT INTO `vn`.`componentRate`(`id`, `name`, `componentTypeRate`, `classRate`, `tax`, `isRenewable`) + VALUES + ( 1, 'Special price', 1, NULL, NULL, 1), + ( 2, 'Delivery', 2, NULL, NULL, 1), + ( 3, 'Mana', 3, 1, NULL, 0 ); + +INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) + VALUES + ( 1, 1, 0.5), + ( 2, 2, 1.2 ); + + INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`) VALUES (1, 1 ,1 ), diff --git a/services/db/changes/1.0.2/01-ACLinserts.sql b/services/db/changes/1.0.2/01-ACLinserts.sql index ec1bc0282..635e6145d 100644 --- a/services/db/changes/1.0.2/01-ACLinserts.sql +++ b/services/db/changes/1.0.2/01-ACLinserts.sql @@ -7,3 +7,5 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('TicketPackaging', '*', '*', 'ALLOW', 'ROLE', 'employee'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Packaging', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Packaging', '*', 'WRITE', 'ALLOW', 'ROLE', 'logistic'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SaleChecked', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SaleComponent', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/services/db/changes/1.0.2/03-saleChecked.sql b/services/db/changes/1.0.2/03-saleChecked.sql new file mode 100644 index 000000000..ba79c0565 --- /dev/null +++ b/services/db/changes/1.0.2/03-saleChecked.sql @@ -0,0 +1,11 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`saleChecked` AS + SELECT + `m`.`Id_Movimiento` AS `saleFk`, + `m`.`checked` AS `isChecked` + FROM + `vn2008`.`Movimientos_checked` `m`; diff --git a/services/ticket/common/models/componentRate.json b/services/ticket/common/models/componentRate.json new file mode 100644 index 000000000..41e987880 --- /dev/null +++ b/services/ticket/common/models/componentRate.json @@ -0,0 +1,39 @@ +{ + "name": "ComponentRate", + "base": "VnModel", + "options": { + "mysql": { + "table": "componentRate" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "name": { + "type": "String" + }, + "classRate": { + "type": "Number" + }, + "tax": { + "type": "Number" + }, + "isRenewable": { + "type": "Number" + }, + "componentTypeRate": { + "type": "Number" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/services/ticket/common/models/saleChecked.json b/services/ticket/common/models/saleChecked.json new file mode 100644 index 000000000..8ac52d598 --- /dev/null +++ b/services/ticket/common/models/saleChecked.json @@ -0,0 +1,24 @@ +{ + "name": "SaleChecked", + "base": "VnModel", + "options": { + "mysql": { + "table": "saleChecked" + } + }, + "properties": { + "isChecked": { + "type": "Number" + }, + "saleFk": { + "id": true + } + }, + "relations": { + "sale": { + "type": "belongsTo", + "model": "Sale", + "foreignKey": "saleFk" + } + } +} \ No newline at end of file diff --git a/services/ticket/common/models/saleComponent.json b/services/ticket/common/models/saleComponent.json new file mode 100644 index 000000000..b990b1ed8 --- /dev/null +++ b/services/ticket/common/models/saleComponent.json @@ -0,0 +1,29 @@ +{ + "name": "SaleComponent", + "base": "VnModel", + "options": { + "mysql": { + "table": "saleComponent" + } + }, + "properties": { + "value": { + "type": "Number" + }, + "saleFk": { + "id": true + } + }, + "relations": { + "sale": { + "type": "belongsTo", + "model": "Sale", + "foreignKey": "saleFk" + }, + "componentRate": { + "type": "belongsTo", + "model": "componentRate", + "foreignKey": "componentFk" + } + } +} \ No newline at end of file diff --git a/services/ticket/server/model-config.json b/services/ticket/server/model-config.json index 55ec2a2a5..5b82e8f58 100644 --- a/services/ticket/server/model-config.json +++ b/services/ticket/server/model-config.json @@ -16,5 +16,11 @@ }, "Packaging": { "dataSource": "vn" + }, + "SaleChecked": { + "dataSource": "vn" } -} +} + + + From ab3ead6a28e01f6f1f91f13d2862fe65e39f35ab Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Wed, 14 Mar 2018 13:00:17 +0100 Subject: [PATCH 2/3] added modelconfig.json for models in the commit 60f3bfc and new procedure 04.ticketVolume --- services/db/changes/1.0.2/04.ticketVolume.sql | 30 +++++++++++++++++++ services/ticket/server/model-config.json | 6 ++++ 2 files changed, 36 insertions(+) create mode 100644 services/db/changes/1.0.2/04.ticketVolume.sql diff --git a/services/db/changes/1.0.2/04.ticketVolume.sql b/services/db/changes/1.0.2/04.ticketVolume.sql new file mode 100644 index 000000000..5b6860700 --- /dev/null +++ b/services/db/changes/1.0.2/04.ticketVolume.sql @@ -0,0 +1,30 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketVolume`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketVolume`(IN vTicketId INT) +BEGIN + DECLARE vWarehouseId INTEGER; + DECLARE vShippedDate DATE; + + DROP TEMPORARY TABLE IF EXISTS ticketVolume; + SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; + + CREATE TEMPORARY TABLE IF NOT EXISTS ticketVolume ENGINE MEMORY + + SELECT itemFk,quantity, concept, VolUd as m3_uni, volume as m3, @m3:= @m3 + ifnull(volume,0) as m3_total + FROM + ( + SELECT round(r.cm3 / 1000000,3) as VolUd ,s.quantity, round(r.cm3 * s.quantity / 1000000,3) as volume, + s.itemFk, s.concept, @m3:= 0, @vol:=0, t.agencyModeFk + FROM sale s + JOIN vn.ticket t on t.id = s.ticketFk + JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + WHERE s.ticketFk = vTicketId + ) sub; + +END$$ + +DELIMITER ; + diff --git a/services/ticket/server/model-config.json b/services/ticket/server/model-config.json index 5b82e8f58..8a2b05c49 100644 --- a/services/ticket/server/model-config.json +++ b/services/ticket/server/model-config.json @@ -19,6 +19,12 @@ }, "SaleChecked": { "dataSource": "vn" + }, + "ComponentRate": { + "dataSource": "vn" + }, + "SaleComponent": { + "dataSource": "vn" } } From a4166cc14d057d8b92a9f020cb8ede00b69692fb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Wed, 14 Mar 2018 13:51:07 +0100 Subject: [PATCH 3/3] update model packaging.json --- services/ticket/common/models/packaging.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ticket/common/models/packaging.json b/services/ticket/common/models/packaging.json index e05de2c93..119fbb154 100644 --- a/services/ticket/common/models/packaging.json +++ b/services/ticket/common/models/packaging.json @@ -37,7 +37,7 @@ "relations": { "item": { "type": "belongsTo", - "model": "Iicket", + "model": "Item", "foreignKey": "itemFk" } }