From ddcd7baaf652224b39723957c83d04354e6d532b Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 30 Oct 2018 12:17:22 +0100 Subject: [PATCH] create new model ticketRequest --- .../db/install/changes/1.2-CHECK/10-ACL.sql | 1 + .../changes/1.2-CHECK/11.ticketRequest.sql | 18 ++++++++ services/db/install/dump/fixtures.sql | 9 +++- .../common/models/ticket-request.json | 46 +++++++++++++++++++ services/loopback/server/model-config.json | 3 ++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 services/db/install/changes/1.2-CHECK/11.ticketRequest.sql create mode 100644 services/loopback/common/models/ticket-request.json diff --git a/services/db/install/changes/1.2-CHECK/10-ACL.sql b/services/db/install/changes/1.2-CHECK/10-ACL.sql index 04548b327..2750d43a5 100644 --- a/services/db/install/changes/1.2-CHECK/10-ACL.sql +++ b/services/db/install/changes/1.2-CHECK/10-ACL.sql @@ -1 +1,2 @@ INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (118, 'WorkerTeam', '*', '*', 'ALLOW', 'role', 'salesPerson'); +INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (119, 'TicketRequest', '*', '*', 'ALLOW', 'role', 'salesPerson'); diff --git a/services/db/install/changes/1.2-CHECK/11.ticketRequest.sql b/services/db/install/changes/1.2-CHECK/11.ticketRequest.sql new file mode 100644 index 000000000..5fd0276f1 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/11.ticketRequest.sql @@ -0,0 +1,18 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `ticketRequest` AS + SELECT + `t`.`Id_ORDEN` AS `id`, + `t`.`ORDEN` AS `description`, + `t`.`CodVENDEDOR` AS `requestFk`, + `t`.`CodCOMPRADOR` AS `atenderFk`, + `t`.`CANTIDAD` AS `quantity`, + `t`.`PRECIOMAX` AS `price`, + `t`.`KO` AS `isOk`, + `t`.`Id_Movimiento` AS `saleFk`, + `t`.`odbc_date` AS `created` + FROM + `vn2008`.`Ordenes` `t`; diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index e33fae53f..75be58e18 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -1017,4 +1017,11 @@ INSERT INTO `vn2008`.`workerTeam`(`id`, `team`, `user`) (3, 2, 101), (4, 2, 102), (5, 3, 103), - (6, 3, 104); \ No newline at end of file + (6, 3, 104); + +INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requestFk`, `atenderFk`, `quantity`, `price`, `isOk`, `saleFk`, `created`) + VALUES + (1, 'Gem of Time', '018', '035', 5, 9.10, 0, 1, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (2, 'Gem of Mind', '018', '035', 10, 1.07, 0, 2, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (3, 'Mark I', '018', '035', 20, 3.06, 0, 4, DATE_ADD(CURDATE(), INTERVAL -15 DAY)), + (4, 'Gem of Mind', '018', '035', 15, 1.30, 0, 7, CURDATE()); \ No newline at end of file diff --git a/services/loopback/common/models/ticket-request.json b/services/loopback/common/models/ticket-request.json new file mode 100644 index 000000000..504b67d81 --- /dev/null +++ b/services/loopback/common/models/ticket-request.json @@ -0,0 +1,46 @@ +{ + "name": "TicketRequest", + "base": "VnModel", + "options": { + "mysql": { + "table": "ticketRequest" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "String" + }, + "created": { + "type": "Date" + }, + "quantity": { + "type": "Number" + }, + "price": { + "type": "Number" + }, + "isOk": { + "type": "Boolean" + }, + "atender": { + "type": "String", + "columnName": "atenderFk" + }, + "requester": { + "type": "String", + "columnName": "requesterFk" + } + }, + "relations": { + "sale": { + "type": "belongsTo", + "model": "Sale", + "foreignKey": "saleFk" + } + } +} \ No newline at end of file diff --git a/services/loopback/server/model-config.json b/services/loopback/server/model-config.json index 47a46c412..7c0141494 100644 --- a/services/loopback/server/model-config.json +++ b/services/loopback/server/model-config.json @@ -143,5 +143,8 @@ }, "WorkerTeam": { "dataSource": "vn" + }, + "TicketRequest": { + "dataSource": "vn" } } \ No newline at end of file