7152-devToTest_2414 #2228
|
@ -0,0 +1,28 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('assignCollection', {
|
||||
description: 'Assign a collection',
|
||||
accessType: 'WRITE',
|
||||
http: {
|
||||
path: `/assignCollection`,
|
||||
verb: 'POST'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
},
|
||||
});
|
||||
|
||||
Self.assignCollection = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk)', [userId]);
|
||||
|
||||
const [assignedCollection] = await Self.rawSql('SELECT @vCollectionFk');
|
||||
const {'@vCollectionFk': collectionFk} = assignedCollection;
|
||||
|
||||
if (!collectionFk) throw new UserError('No hay tickets para sacar');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk]);
|
||||
|
||||
return collectionFk;
|
||||
};
|
||||
};
|
|
@ -5,4 +5,5 @@ module.exports = Self => {
|
|||
require('../methods/collection/setSaleQuantity')(Self);
|
||||
require('../methods/collection/previousLabel')(Self);
|
||||
require('../methods/collection/getTickets')(Self);
|
||||
require('../methods/collection/assignCollection')(Self);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1218,6 +1218,7 @@ INSERT INTO `vn`.`train`(`id`, `name`)
|
|||
INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPackingTypeFk`, `warehouseFk`, `sectorFk`, `labelerFk`)
|
||||
VALUES
|
||||
('1106', '1', '1', 'H', '1', '1', '1'),
|
||||
('9', '2', '1', 'H', '1', '1', '1'),
|
||||
('1107', '1', '1', 'V', '1', '1', '1');
|
||||
|
||||
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
|
||||
|
@ -2996,3 +2997,671 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
|
|||
(1, 'Error in VAT calculation'),
|
||||
(2, 'Error in sales details'),
|
||||
(3, 'Error in customer data');
|
||||
|
||||
|
||||
/*
|
||||
Se necesitan, para hacer un simulacro de pedido, lo siguiente:
|
||||
|
||||
- Warehouse 999
|
||||
- Sectores
|
||||
- Normal 9991
|
||||
- Previa 9992
|
||||
- Altillo 9993
|
||||
- Parkings
|
||||
- Normal A-01-1, A-02-2, B-03-3, B-04-4, C-05-5
|
||||
- Previa P-01-1, P-02-2, P-03-3
|
||||
- Altillo M-01-1, M-02-2, M-03-3
|
||||
- Shelvings
|
||||
- Normal NAA, NBB, NCC, NDD, NEE
|
||||
- Previa PAA, PBB, PCC
|
||||
- Altillo MAA, MBB, MCC
|
||||
- Items
|
||||
* Normal
|
||||
* Previa:
|
||||
- Ticket
|
||||
- Sales
|
||||
|
||||
*/
|
||||
|
||||
INSERT IGNORE INTO intrastat
|
||||
SET id = 44219999,
|
||||
description = 'Manufacturas de madera',
|
||||
taxClassFk = 1,
|
||||
taxCodeFk = 1;
|
||||
|
||||
INSERT IGNORE INTO warehouse
|
||||
SET id = 999,
|
||||
name = 'TestingWarehouse',
|
||||
hasAvailable = TRUE,
|
||||
isForTicket = TRUE,
|
||||
isInventory = TRUE,
|
||||
hasUbications = TRUE,
|
||||
hasProduction = TRUE;
|
||||
|
||||
INSERT IGNORE INTO sector
|
||||
SET id = 9991,
|
||||
description = 'NormalSector',
|
||||
warehouseFk = 999,
|
||||
isPreviousPreparedByPacking = FALSE,
|
||||
code = 'NS',
|
||||
isPreviousPrepared = FALSE,
|
||||
isPackagingArea = FALSE,
|
||||
sonFk = NULL,
|
||||
isMain = TRUE,
|
||||
itemPackingTypeFk = NULL;
|
||||
|
||||
INSERT IGNORE INTO sector
|
||||
SET id = 9992,
|
||||
description = 'PreviousSector',
|
||||
warehouseFk = 999,
|
||||
isPreviousPreparedByPacking = FALSE,
|
||||
code = 'PS',
|
||||
isPreviousPrepared = TRUE,
|
||||
isPackagingArea = FALSE,
|
||||
sonFk = NULL,
|
||||
isMain = TRUE,
|
||||
itemPackingTypeFk = NULL;
|
||||
|
||||
INSERT IGNORE INTO sector
|
||||
SET id = 9993,
|
||||
description = 'MezaninneSector',
|
||||
warehouseFk = 999,
|
||||
isPreviousPreparedByPacking = TRUE,
|
||||
code = 'MS',
|
||||
isPreviousPrepared = FALSE,
|
||||
isPackagingArea = FALSE,
|
||||
sonFk = 9991,
|
||||
isMain = TRUE,
|
||||
itemPackingTypeFk = NULL;
|
||||
|
||||
REPLACE parking SET id = 9991011, sectorFk = 9991, code = 'A-01-1', pickingOrder = 1;
|
||||
REPLACE parking SET id = 9991012, sectorFk = 9991, code = 'A-02-2', pickingOrder = 2;
|
||||
REPLACE parking SET id = 9991013, sectorFk = 9991, code = 'A-03-3', pickingOrder = 3;
|
||||
REPLACE parking SET id = 9991014, sectorFk = 9991, code = 'A-04-4', pickingOrder = 4;
|
||||
REPLACE parking SET id = 9991015, sectorFk = 9991, code = 'A-05-5', pickingOrder = 5;
|
||||
|
||||
REPLACE parking SET id = 9992011, sectorFk = 9992, code = 'P-01-1', pickingOrder = 6;
|
||||
REPLACE parking SET id = 9992012, sectorFk = 9992, code = 'P-02-2', pickingOrder = 7;
|
||||
REPLACE parking SET id = 9992013, sectorFk = 9992, code = 'P-03-3', pickingOrder = 8;
|
||||
|
||||
REPLACE parking SET id = 9993011, sectorFk = 9993, code = 'M-01-1', pickingOrder = 9;
|
||||
REPLACE parking SET id = 9993012, sectorFk = 9993, code = 'M-02-2', pickingOrder = 10;
|
||||
REPLACE parking SET id = 9993013, sectorFk = 9993, code = 'M-03-3', pickingOrder = 11;
|
||||
|
||||
REPLACE shelving SET code = 'NAA', parkingFk = 9991011, priority = 1;
|
||||
REPLACE shelving SET code = 'NBB', parkingFk = 9991012, priority = 1;
|
||||
REPLACE shelving SET code = 'NCC', parkingFk = 9991013, priority = 1;
|
||||
REPLACE shelving SET code = 'NDD', parkingFk = 9991014, priority = 1;
|
||||
REPLACE shelving SET code = 'NEE', parkingFk = 9991015, priority = 1;
|
||||
|
||||
REPLACE shelving SET code = 'PAA', parkingFk = 9992011, priority = 1;
|
||||
REPLACE shelving SET code = 'PBB', parkingFk = 9992012, priority = 1;
|
||||
REPLACE shelving SET code = 'PCC', parkingFk = 9992013, priority = 1;
|
||||
|
||||
REPLACE shelving SET code = 'MAA', parkingFk = 9993011, priority = 1;
|
||||
REPLACE shelving SET code = 'MBB', parkingFk = 9993012, priority = 1;
|
||||
REPLACE shelving SET code = 'MCC', parkingFk = 9993013, priority = 1;
|
||||
|
||||
INSERT IGNORE INTO itemType
|
||||
SET id = 999,
|
||||
code = 'WOO',
|
||||
name = 'Wood Objects',
|
||||
categoryFk = 3,
|
||||
workerFk = 103,
|
||||
isInventory = TRUE,
|
||||
life = 10,
|
||||
density = 250,
|
||||
itemPackingTypeFk = NULL,
|
||||
temperatureFk = 'warm';
|
||||
|
||||
INSERT IGNORE INTO travel
|
||||
SET id = 99,
|
||||
shipped = CURDATE(),
|
||||
landed = CURDATE(),
|
||||
warehouseInFk = 999,
|
||||
warehouseOutFk = 1,
|
||||
isReceived = TRUE,
|
||||
agencyFk = 1;
|
||||
|
||||
REPLACE entry
|
||||
SET id = 999,
|
||||
supplierFk = 791,
|
||||
isConfirmed = TRUE,
|
||||
dated = CURDATE(),
|
||||
travelFk = 99,
|
||||
companyFk = 442;
|
||||
|
||||
REPLACE ticket
|
||||
SET id = 999999,
|
||||
clientFk = 2,
|
||||
warehouseFk = 999,
|
||||
shipped = CURDATE(),
|
||||
nickname = 'Cliente',
|
||||
addressFk = 1,
|
||||
companyFk = 442,
|
||||
agencyModeFk = 10,
|
||||
landed = CURDATE();
|
||||
|
||||
REPLACE collection
|
||||
SET id = 10101010,
|
||||
workerFk = 103;
|
||||
|
||||
INSERT IGNORE INTO ticketCollection
|
||||
SET id = 10101010,
|
||||
ticketFk = 999999,
|
||||
collectionFk = 10101010;
|
||||
|
||||
REPLACE item
|
||||
SET id = 999991,
|
||||
name = 'Palito para pinchos',
|
||||
`size` = 25,
|
||||
stems = NULL,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palito para pinchos',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 6,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999991,
|
||||
entryFk = 999,
|
||||
itemFk = 999991,
|
||||
quantity = 8,
|
||||
buyingValue = 0.61,
|
||||
stickers = 1,
|
||||
packing = 20,
|
||||
`grouping` = 1,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 50;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99991,
|
||||
itemFk = 999991,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palito para pinchos',
|
||||
quantity = 3,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
REPLACE item
|
||||
SET id = 999992,
|
||||
name = 'Madera verde',
|
||||
`size` = 10,
|
||||
stems = NULL,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Madera verde',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 50,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999992,
|
||||
entryFk = 999,
|
||||
itemFk = 999992,
|
||||
quantity = 40,
|
||||
buyingValue = 0.62,
|
||||
stickers = 1,
|
||||
packing = 40,
|
||||
`grouping` = 5,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 25;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99992,
|
||||
itemFk = 999992,
|
||||
ticketFk = 999999,
|
||||
concept = 'Madera Verde',
|
||||
quantity = 10,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
REPLACE item
|
||||
SET id = 999993,
|
||||
name = 'Madera Roja/Morada',
|
||||
`size` = 12,
|
||||
stems = 2,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Madera Roja/Morada',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 35,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999993,
|
||||
entryFk = 999,
|
||||
itemFk = 999993,
|
||||
quantity = 20,
|
||||
buyingValue = 0.63,
|
||||
stickers = 2,
|
||||
packing = 10,
|
||||
`grouping` = 5,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 25;
|
||||
|
||||
REPLACE itemShelving
|
||||
SET id = 9931,
|
||||
itemFk = 999993,
|
||||
shelvingFk = 'NCC',
|
||||
visible = 10,
|
||||
`grouping` = 5,
|
||||
packing = 10;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99993,
|
||||
itemFk = 999993,
|
||||
ticketFk = 999999,
|
||||
concept = 'Madera Roja/Morada',
|
||||
quantity = 15,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
REPLACE item
|
||||
SET id = 999994,
|
||||
name = 'Madera Naranja',
|
||||
`size` = 18,
|
||||
stems = 1,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Madera Naranja',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 160,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999994,
|
||||
entryFk = 999,
|
||||
itemFk = 999994,
|
||||
quantity = 20,
|
||||
buyingValue = 0.64,
|
||||
stickers = 1,
|
||||
packing = 20,
|
||||
`grouping` = 4,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 25;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99994,
|
||||
itemFk = 999994,
|
||||
ticketFk = 999999,
|
||||
concept = 'Madera Naranja',
|
||||
quantity = 4,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
REPLACE item
|
||||
SET id = 999995,
|
||||
name = 'Madera Amarilla',
|
||||
`size` = 11,
|
||||
stems = 5,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Madera Amarilla',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 78,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999995,
|
||||
entryFk = 999,
|
||||
itemFk = 999995,
|
||||
quantity = 4,
|
||||
buyingValue = 0.65,
|
||||
stickers = 1,
|
||||
packing = 20,
|
||||
`grouping` = 1,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 35;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99995,
|
||||
itemFk = 999995,
|
||||
ticketFk = 999999,
|
||||
concept = 'Madera Amarilla',
|
||||
quantity = 5,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
-- Palito naranja
|
||||
REPLACE item
|
||||
SET id = 999998,
|
||||
name = 'Palito naranja',
|
||||
`size` = 11,
|
||||
stems = 1,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palito naranja',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 78,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999998,
|
||||
entryFk = 999,
|
||||
itemFk = 999998,
|
||||
quantity = 80,
|
||||
buyingValue = 0.65,
|
||||
stickers = 1,
|
||||
packing = 200,
|
||||
`grouping` = 30,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 35;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99998,
|
||||
itemFk = 999998,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palito naranja',
|
||||
quantity = 60,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
-- Palito amarillo
|
||||
REPLACE item
|
||||
SET id = 999999,
|
||||
name = 'Palito amarillo',
|
||||
`size` = 11,
|
||||
stems = 1,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palito amarillo',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 78,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999999,
|
||||
entryFk = 999,
|
||||
itemFk = 999999,
|
||||
quantity = 70,
|
||||
buyingValue = 0.65,
|
||||
stickers = 1,
|
||||
packing = 500,
|
||||
`grouping` = 10,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 35;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99999,
|
||||
itemFk = 999999,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palito amarillo',
|
||||
quantity = 50,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
-- Palito azul
|
||||
REPLACE item
|
||||
SET id = 1000000,
|
||||
name = 'Palito azul',
|
||||
`size` = 10,
|
||||
stems = 1,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palito azul',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 78,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 10000000,
|
||||
entryFk = 999,
|
||||
itemFk = 1000000,
|
||||
quantity = 75,
|
||||
buyingValue = 0.65,
|
||||
stickers = 2,
|
||||
packing = 300,
|
||||
`grouping` = 50,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 35;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 100000,
|
||||
itemFk = 1000000,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palito azul',
|
||||
quantity = 50,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
-- Palito rojo
|
||||
REPLACE item
|
||||
SET id = 1000001,
|
||||
name = 'Palito rojo',
|
||||
`size` = 10,
|
||||
stems = NULL,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palito rojo',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 78,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 10000001,
|
||||
entryFk = 999,
|
||||
itemFk = 1000001,
|
||||
quantity = 12,
|
||||
buyingValue = 0.65,
|
||||
stickers = 2,
|
||||
packing = 50,
|
||||
`grouping` = 5,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 1,
|
||||
price2 = 1,
|
||||
price3 = 1,
|
||||
minPrice = 1,
|
||||
weight = 35;
|
||||
|
||||
|
||||
REPLACE sale
|
||||
SET id = 100001,
|
||||
itemFk = 1000001,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palito rojo',
|
||||
quantity = 10,
|
||||
price = 1,
|
||||
discount = 0;
|
||||
|
||||
-- Previa
|
||||
INSERT IGNORE INTO item
|
||||
SET id = 999996,
|
||||
name = 'Bolas de madera',
|
||||
`size` = 2,
|
||||
stems = 4,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Bolas de madera',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 20,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999996,
|
||||
entryFk = 999,
|
||||
itemFk = 999996,
|
||||
quantity = 5,
|
||||
buyingValue = 3,
|
||||
stickers = 1,
|
||||
packing = 5,
|
||||
`grouping` = 2,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 7,
|
||||
price2 = 7,
|
||||
price3 = 7,
|
||||
minPrice = 7,
|
||||
weight = 80;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99996,
|
||||
itemFk = 999996,
|
||||
ticketFk = 999999,
|
||||
concept = 'Bolas de madera',
|
||||
quantity = 4,
|
||||
price = 7,
|
||||
discount = 0,
|
||||
isPicked = TRUE;
|
||||
|
||||
INSERT IGNORE INTO item
|
||||
SET id = 999997,
|
||||
name = 'Palitos de polo MIX',
|
||||
`size` = 14,
|
||||
stems = NULL,
|
||||
category = 'EXT',
|
||||
typeFk = 999,
|
||||
longName = 'Palitos de polo MIX',
|
||||
itemPackingTypeFk = NULL,
|
||||
originFk = 1,
|
||||
weightByPiece = 20,
|
||||
intrastatFk = 44219999;
|
||||
|
||||
REPLACE buy
|
||||
SET id = 9999997,
|
||||
entryFk = 999,
|
||||
itemFk = 999997,
|
||||
quantity = 100,
|
||||
buyingValue = 3.2,
|
||||
stickers = 1,
|
||||
packing = 100,
|
||||
`grouping` = 5,
|
||||
groupingMode = 1,
|
||||
packageFk = 94,
|
||||
price1 = 7,
|
||||
price2 = 7,
|
||||
price3 = 7,
|
||||
minPrice = 7,
|
||||
weight = 80;
|
||||
|
||||
REPLACE sale
|
||||
SET id = 99997,
|
||||
itemFk = 999997,
|
||||
ticketFk = 999999,
|
||||
concept = 'Palitos de polo MIX',
|
||||
quantity = 5,
|
||||
price = 7,
|
||||
discount = 0;
|
||||
|
||||
-- Ubicación
|
||||
DELETE ish.*
|
||||
FROM itemShelving ish
|
||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||
JOIN parking p ON p.id = sh.parkingFk
|
||||
JOIN sector s ON s.id = p.sectorFk
|
||||
JOIN warehouse w ON w.id = s.warehouseFk
|
||||
WHERE w.name = 'TestingWarehouse';
|
||||
|
||||
REPLACE vn.itemShelving
|
||||
(id, itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
|
||||
VALUES
|
||||
(9911, 999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL),
|
||||
(9912, 999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL),
|
||||
(9913, 1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL),
|
||||
(9914, 1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL),
|
||||
(9915, 999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
|
||||
(9916, 999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL),
|
||||
(9917, 999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL),
|
||||
(9918, 999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
|
||||
(9919, 999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL),
|
||||
(9920, 999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
|
||||
(9921, 999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL),
|
||||
(9922, 1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL),
|
||||
(9923, 999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
|
||||
(9924, 1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL),
|
||||
(9925, 999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL),
|
||||
(9926, 999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL);
|
||||
|
||||
-- Previous for Bolas de madera
|
||||
INSERT IGNORE INTO sectorCollection
|
||||
SET id = 99,
|
||||
userFk = 1,
|
||||
sectorFk = 9992;
|
||||
|
||||
INSERT IGNORE INTO saleGroup
|
||||
SET id = 999,
|
||||
userFk = 1,
|
||||
parkingFk = 9992011,
|
||||
sectorFk = 9992;
|
||||
|
||||
INSERT IGNORE INTO sectorCollectionSaleGroup
|
||||
SET id = 9999,
|
||||
sectorCollectionFk = 99,
|
||||
saleGroupFk = 999;
|
||||
|
||||
REPLACE saleGroupDetail
|
||||
SET id = 99991,
|
||||
saleFk = 99996,
|
||||
saleGroupFk = 999;
|
||||
|
||||
REPLACE saleTracking
|
||||
SET saleFk = 99996,
|
||||
isChecked = TRUE,
|
||||
workerFk = 103,
|
||||
stateFk = 28;
|
||||
|
||||
INSERT IGNORE INTO itemShelvingSale
|
||||
SET id = 991,
|
||||
itemShelvingFk = 9962,
|
||||
saleFk = 99996,
|
||||
quantity = 5,
|
||||
userFk = 1;
|
||||
|
||||
|
||||
CALL itemShelvingSale_reserveByCollection(10101010);
|
||||
|
||||
UPDATE vn.collection
|
||||
SET workerFk=9
|
||||
WHERE id=10101010;
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('card', {
|
||||
description: 'Idk',
|
||||
accessType: 'READ',
|
||||
http: {
|
||||
path: `/card`,
|
||||
verb: 'GET'
|
||||
},
|
||||
accepts: [
|
||||
{
|
||||
arg: 'itemFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
arg: 'warehouseFk',
|
||||
type: 'number',
|
||||
required: true,
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
});
|
||||
|
||||
Self.card = async(itemFk, warehouseFk) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const [result] = await Self.rawSql('CALL vn.item_getInfo(?, ?)', [itemFk, warehouseFk]);
|
||||
|
||||
const barcodeItems = await Self.rawSql('SELECT vn.barcodeToItem(?) as realIdItem', [itemFk]);
|
||||
const realIdItems = barcodeItems.map(barcodeItem => barcodeItem.realIdItem);
|
||||
|
||||
const barcodes = await models.ItemBarcode.find({
|
||||
fields: ['code'],
|
||||
where: {
|
||||
realIdItem: {
|
||||
inq: realIdItems
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let itemInfo;
|
||||
if (result.length) {
|
||||
itemInfo = {...result[0]};
|
||||
itemInfo.barcodes = barcodes.map(barcode => barcode.code);
|
||||
}
|
||||
|
||||
return itemInfo;
|
||||
};
|
||||
};
|
|
@ -17,6 +17,7 @@ module.exports = Self => {
|
|||
require('../methods/item/buyerWasteEmail')(Self);
|
||||
require('../methods/item/labelPdf')(Self);
|
||||
require('../methods/item/setVisibleDiscard')(Self);
|
||||
require('../methods/item/card')(Self);
|
||||
|
||||
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getPallet', {
|
||||
description: 'Get pallet',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'expeditionFk',
|
||||
type: 'integer',
|
||||
},
|
||||
],
|
||||
http: {
|
||||
path: `/getPallet`,
|
||||
verb: 'GET'
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
},
|
||||
});
|
||||
|
||||
Self.getPallet = async expeditionFk => {
|
||||
try {
|
||||
const pallet = await Self.findOne({
|
||||
fields: ['truckFk'],
|
||||
where: {
|
||||
id: expeditionFk
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'expeditionTruck',
|
||||
scope: {
|
||||
fields: ['eta', 'description']
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
if (pallet) {
|
||||
const truck = pallet.expeditionTruck();
|
||||
return {
|
||||
truckFk: pallet.truckFk,
|
||||
eta: truck.eta,
|
||||
description: truck.description
|
||||
};
|
||||
}
|
||||
|
||||
throw new UserError('palletDoesNotExist');
|
||||
} catch (e) {
|
||||
return {message: e.message};
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/expedition-pallet/getPallet')(Self);
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"name": "ExpeditionPallet",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "expeditionPallet"
|
||||
|
@ -10,13 +11,27 @@
|
|||
"type": "number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
}
|
||||
},
|
||||
"truckFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"built": {
|
||||
"type": "date"
|
||||
},
|
||||
"position": {
|
||||
"type": "number"
|
||||
},
|
||||
"isPrint": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"acls": [{
|
||||
"accessType": "WRITE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "production",
|
||||
"permission": "ALLOW"
|
||||
}]
|
||||
"relations": {
|
||||
"expeditionTruck": {
|
||||
"type": "belongsTo",
|
||||
"model": "ExpeditionTruck",
|
||||
"foreignKey": "truckFk"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module.exports = Self => {
|
|||
|
||||
Self.add = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
// He visto findOrCreate pero no funciona
|
||||
const user = await Self.findById(userId);
|
||||
if (!user) {
|
||||
await Self.create({
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getAvailablePrinters', {
|
||||
description: 'Retrieve available printers for an user',
|
||||
accessType: 'READ',
|
||||
http: {
|
||||
path: `/getAvailabePrinters`,
|
||||
verb: 'GET'
|
||||
},
|
||||
returns: {
|
||||
type: ['object'],
|
||||
},
|
||||
});
|
||||
|
||||
Self.getAvailablePrinters = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const operators = await Self.find({
|
||||
fields: [],
|
||||
where: {
|
||||
workerFk: userId,
|
||||
},
|
||||
|
||||
include: {
|
||||
relation: 'printer',
|
||||
scope: {
|
||||
fields: ['id', 'name']
|
||||
},
|
||||
where: {
|
||||
isLabeler: {neq: 0}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (operators.length) {
|
||||
return operators.map(operator => {
|
||||
return operator.printer();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,39 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getPrinter', {
|
||||
description: 'Gets user\'s printer',
|
||||
accessType: 'READ',
|
||||
http: {
|
||||
path: `/getPrinter`,
|
||||
verb: 'GET'
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
},
|
||||
});
|
||||
|
||||
Self.getPrinter = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const operator = await Self.findOne({
|
||||
include: [
|
||||
{
|
||||
relation: 'printer',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
}
|
||||
}
|
||||
],
|
||||
where: {
|
||||
workerFk: userId
|
||||
}
|
||||
});
|
||||
|
||||
if (operator) {
|
||||
const printer = operator.printer();
|
||||
return {
|
||||
id: printer.id,
|
||||
name: printer.name
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
|
@ -1,5 +1,7 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/operator/add')(Self);
|
||||
require('../methods/operator/getPrinter')(Self);
|
||||
require('../methods/operator/getAvailablePrinters')(Self);
|
||||
|
||||
Self.observe('after save', async function(ctx) {
|
||||
const instance = ctx.data || ctx.instance;
|
||||
|
|
Loading…
Reference in New Issue