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/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/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/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" } } 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..8a2b05c49 100644 --- a/services/ticket/server/model-config.json +++ b/services/ticket/server/model-config.json @@ -16,5 +16,17 @@ }, "Packaging": { "dataSource": "vn" + }, + "SaleChecked": { + "dataSource": "vn" + }, + "ComponentRate": { + "dataSource": "vn" + }, + "SaleComponent": { + "dataSource": "vn" } -} +} + + +