create new modul 'pedidos' update structure DB, fixtures, add hedera to the package and create model Order and orderRow

This commit is contained in:
Bernat 2018-06-20 08:30:16 +02:00
parent 0ab7d09a41
commit 2eeaf9e66b
11 changed files with 391 additions and 182 deletions

View File

@ -3,7 +3,7 @@ CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `buy` AS
VIEW `vn`.`buy` AS
SELECT
`c`.`Id_Compra` AS `id`,
`c`.`Id_Entrada` AS `entryFk`,
@ -27,6 +27,7 @@ VIEW `buy` AS
`c`.`Vida` AS `printedStickers`,
`c`.`punteo` AS `isChecked`,
`c`.`buy_edi_id` AS `ektFk`,
`c`.`odbc_date` AS `created`,
`c`.`Novincular` AS `isIgnored`
FROM
`vn2008`.`Compres` `c`;

View File

@ -7,6 +7,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `itemLastEntries`(vItem INT, vDays DATE)
BEGIN
SELECT
w.id AS warehouseFk,
w.name AS warehouse,
tr.landed,
b.entryFk,
b.isIgnored,
@ -19,9 +20,10 @@ BEGIN
b.quantity,
b.buyingValue,
b.packageFk ,
s.id AS supplierFk
FROM itemType it
RIGHT JOIN (entry e
s.id AS supplierFk,
s.name AS supplier
FROM itemType it
RIGHT JOIN (entry e
LEFT JOIN supplier s ON s.id = e.supplierFk
RIGHT JOIN buy b ON b.entryFk = e.id
LEFT JOIN item i ON i.id = b.itemFk
@ -29,11 +31,10 @@ FROM itemType it
LEFT JOIN travel tr ON tr.id = e.travelFk
LEFT JOIN warehouse w ON w.id = tr.warehouseInFk
LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE()
ORDER BY tr.landed DESC , b.id DESC;
) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE()
ORDER BY tr.landed DESC , b.id DESC;
END$$
DELIMITER ;

View File

@ -328,7 +328,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`)
VALUES
(1, 1, 13, 5, CURDATE()),
(1, 1, 3, 5, CURDATE()),
(2, 2, 15, 5, CURDATE()),
(3, 3, 16, 5, CURDATE()),
(4, 4, 13, 5, CURDATE()),
@ -684,4 +684,23 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`package
INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`)
VALUES
(1,CURDATE());
(1,CURDATE());
INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
VALUES
( 1, 'AGENCY', 'Agencia'),
( 2, 'DELIVERY', 'Reparto'),
( 3, 'PICKUP', 'Recogida'),
( 4, 'OTHER', 'Otros');
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES
( 1, date_add(CURDATE(),INTERVAL +1 DAY), 101, 1, 1, 121, 442, NULL, 'TPV' , 1, CURDATE(), CURDATE() , CURDATE()),
( 2, date_add(CURDATE(),INTERVAL +1 DAY), 102, 2, 2, 122, 442, NULL, 'WEB' , 1, CURDATE(), CURDATE() , CURDATE()),
( 3, date_add(CURDATE(),INTERVAL +2 DAY), 103, 3, 3, 123, 442, NULL, 'ANDROID', 0, CURDATE(), date_add(CURDATE(), INTERVAL +5 DAY), date_add(CURDATE(),INTERVAL +5 DAY));
INSERT INTO `hedera`.`orderRow`(`id`, `orderFk`, `itemFk`, `warehouseFk`, `shipment`, `amount`, `price`, `rate`, `created`, `saleFk`)
VALUES
( 1, 1, 1, NULL , NULL , 9, 1.5 , 1, CURDATE(), 1),
( 2, 2, 2, 1 , NULL , 5, 1.23, 2, CURDATE(), 2),
( 3, 3, 3, 2 , CURDATE(), 3, 0.50, 3, CURDATE(), 3);

View File

@ -1,60 +1,71 @@
{
"db": {
"connector": "memory"
},
"vn": {
"connector": "mysql",
"database": "vn",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"salix": {
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"account": {
"connector": "mysql",
"database": "account",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"edi": {
"connector": "mysql",
"database": "edi",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"bs": {
"connector": "mysql",
"database": "bs",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}
{
"db": {
"connector": "memory"
},
"vn": {
"connector": "mysql",
"database": "vn",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"salix": {
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"account": {
"connector": "mysql",
"database": "account",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"edi": {
"connector": "mysql",
"database": "edi",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"bs": {
"connector": "mysql",
"database": "bs",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"hedera": {
"connector": "mysql",
"database": "hedera",
"debug": false,
"host": "${salixHost}",
"port": "${salixPort}",
"username": "${salixUser}",
"password": "${salixPassword}",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,114 +1,114 @@
{
"user": {
"dataSource": "salix"
},
"AccessToken": {
"dataSource": "salix",
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "userId"
}
"user": {
"dataSource": "salix"
},
"AccessToken": {
"dataSource": "salix",
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "userId"
}
}
},
"ACL": {
"dataSource": "salix"
},
"RoleMapping": {
"dataSource": "salix"
},
"Role": {
"dataSource": "salix"
},
"Account": {
"dataSource": "account"
},
"Address": {
"dataSource": "vn"
},
"Agency": {
"dataSource": "vn"
},
"AgencyMode": {
"dataSource": "vn"
},
"Client": {
"dataSource": "vn"
},
"ClientCreditLimit": {
"dataSource": "vn"
},
"Company": {
"dataSource": "vn"
},
"ContactChannel": {
"dataSource": "vn"
},
"Country": {
"dataSource": "vn"
},
"PayMethod": {
"dataSource": "vn"
},
"Province": {
"dataSource": "vn"
},
"Warehouse":{
"dataSource": "vn"
},
"Worker": {
"dataSource": "vn"
},
"Ticket": {
"dataSource": "vn"
},
"Route": {
"dataSource": "vn"
},
"State":{
"dataSource": "vn"
},
"Sale": {
"dataSource": "vn"
},
"TicketState":{
"dataSource": "vn"
},
"Item": {
"dataSource": "vn"
},
"ItemTag": {
"dataSource": "vn"
},
"Tag": {
"dataSource": "vn"
},
"Origin": {
"dataSource": "vn"
},
"ItemType": {
"dataSource": "vn"
},
"Expence": {
"dataSource": "vn"
},
"Ink": {
"dataSource": "vn"
},
"Intrastat": {
"dataSource": "vn"
},
"Producer": {
"dataSource": "vn"
},
"Message": {
"dataSource": "vn"
},
"WorkerMana": {
"dataSource": "bs"
},
"DeliveryMethod": {
"dataSource": "vn"
}
},
"ACL": {
"dataSource": "salix"
},
"RoleMapping": {
"dataSource": "salix"
},
"Role": {
"dataSource": "salix"
},
"Account": {
"dataSource": "account"
},
"Address": {
"dataSource": "vn"
},
"Agency": {
"dataSource": "vn"
},
"AgencyMode": {
"dataSource": "vn"
},
"Client": {
"dataSource": "vn"
},
"ClientCreditLimit": {
"dataSource": "vn"
},
"Company": {
"dataSource": "vn"
},
"ContactChannel": {
"dataSource": "vn"
},
"Country": {
"dataSource": "vn"
},
"PayMethod": {
"dataSource": "vn"
},
"Province": {
"dataSource": "vn"
},
"Warehouse":{
"dataSource": "vn"
},
"Worker": {
"dataSource": "vn"
},
"Ticket": {
"dataSource": "vn"
},
"Route": {
"dataSource": "vn"
},
"State":{
"dataSource": "vn"
},
"Sale": {
"dataSource": "vn"
},
"TicketState":{
"dataSource": "vn"
},
"Item": {
"dataSource": "vn"
},
"ItemTag": {
"dataSource": "vn"
},
"Tag": {
"dataSource": "vn"
},
"Origin": {
"dataSource": "vn"
},
"ItemType": {
"dataSource": "vn"
},
"Expence": {
"dataSource": "vn"
},
"Ink": {
"dataSource": "vn"
},
"Intrastat": {
"dataSource": "vn"
},
"Producer": {
"dataSource": "vn"
},
"Message": {
"dataSource": "vn"
},
"WorkerMana": {
"dataSource": "bs"
},
"DeliveryMethod": {
"dataSource": "vn"
}
}

View File

@ -0,0 +1,6 @@
FROM vn-loopback:latest
COPY pedidos /app
WORKDIR /app
CMD ["pm2-docker", "./server/server.js"]

View File

@ -0,0 +1,85 @@
{
"name": "Order",
"base": "VnModel",
"options": {
"mysql": {
"table": "order"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"landed": {
"type": "date",
"mysql": {
"columnName": "date_send"
}
},
"clientFk": {
"type": "Number",
"required": true,
"mysql": {
"columnName": "customer_id"
}
},
"companyFk": {
"type": "Number",
"mysql": {
"columnName": "company_id"
}
},
"note": {
"type": "String"
},
"sourceApp": {
"type": "String",
"mysql": {
"columnName": "source_app"
}
},
"isConfirmed": {
"type": "Number",
"mysql": {
"columnName": "confirmed"
}
},
"created": {
"type": "date",
"mysql": {
"columnName": "date_make"
}
},
"firstRowStamp": {
"type": "date",
"mysql": {
"columnName": "first_row_stamp"
}
},
"confirmed": {
"type": "date",
"mysql": {
"columnName": "confirm_date"
}
}
},
"relations": {
"agencyModeFk": {
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agency_id"
},
"addressFk": {
"type": "belongsTo",
"model": "Address",
"foreignKey": "address_id"
},
"deliveryMethodFk": {
"type": "belongsTo",
"model": "DeliveryMethod",
"foreignKey": "delivery_method_id"
}
}
}

View File

@ -0,0 +1,55 @@
{
"name": "OrderRow",
"base": "VnModel",
"options": {
"mysql": {
"table": "orderRow"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"warehouseFk": {
"type": "Number"
},
"shipped": {
"type": "date",
"mysql": {
"columnName": "shipment"
}
},
"quantity": {
"type": "Number",
"mysql": {
"columnName": "amount"
}
},
"price": {
"type": "Number"
},
"rate": {
"type": "Number"
},
"created": {
"type": "date"
},
"saleFk": {
"type": "Number"
}
},
"relations": {
"itemFk": {
"type": "belongsTo",
"model": "Item",
"foreignKey": "itemFk"
},
"orderFk": {
"type": "belongsTo",
"model": "Order",
"foreignKey": "orderFk"
}
}
}

View File

@ -0,0 +1,19 @@
{
"name": "vn-pedidos",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
"lint": "eslint .",
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"repository": {
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "GPL-3.0",
"description": "vn-pedidos",
"dependencies": {
"uuid": "^3.1.0"
}
}

View File

@ -0,0 +1,8 @@
{
"Order": {
"dataSource": "hedera"
},
"OrderRow": {
"dataSource": "hedera"
}
}

View File

@ -0,0 +1,4 @@
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = vnLoopback.loopback();
vnLoopback.boot(app, __dirname, module);