refs #6276 fixtures & itemBarcode_delete
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2023-12-13 11:43:19 +01:00
parent a4c3d78e31
commit 8d61473d4f
4 changed files with 691 additions and 2 deletions

View File

@ -7,4 +7,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'),
('SaleTracking','deleteTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','updateTracking','WRITE','ALLOW','ROLE','employee'),
('SaleTracking','mark','WRITE','ALLOW','ROLE','employee');
('SaleTracking','mark','WRITE','ALLOW','ROLE','employee'),
('ItemBarcode','deleteByItemAndCode','WRITE','ALLOW','ROLE','employee');

View File

@ -3009,3 +3009,656 @@ INSERT INTO `vn`.`invoiceCorrectionType` (`id`, `description`)
(1, 'Error in VAT calculation'),
(2, 'Error in sales details'),
(3, 'Error in customer data');
-- NEW WAREHOUSE
UPDATE vn.packaging
SET id='--'
WHERE id='pallet 100';
INSERT IGNORE INTO vn.intrastat
SET id = 44219999,
description = 'Manufacturas de madera',
taxClassFk = 1,
taxCodeFk = 1;
INSERT IGNORE INTO vn.warehouse
SET id = 999,
name = 'TestingWarehouse',
hasAvailable = TRUE,
isForTicket = TRUE,
isInventory = TRUE,
hasUbications = TRUE,
hasProduction = TRUE;
INSERT IGNORE INTO vn.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 vn.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 vn.sector
SET id = 9993,
description = 'MezaninneSector',
warehouseFk = 999,
isPreviousPreparedByPacking = TRUE,
code = 'MS',
isPreviousPrepared = FALSE,
isPackagingArea = FALSE,
sonFk = 9991,
isMain = TRUE,
itemPackingTypeFk = NULL;
REPLACE vn.parking SET id = 9991011, sectorFk = 9991, code = 'A-01-1', pickingOrder = 1;
REPLACE vn.parking SET id = 9991012, sectorFk = 9991, code = 'A-02-2', pickingOrder = 2;
REPLACE vn.parking SET id = 9991013, sectorFk = 9991, code = 'A-03-3', pickingOrder = 3;
REPLACE vn.parking SET id = 9991014, sectorFk = 9991, code = 'A-04-4', pickingOrder = 4;
REPLACE vn.parking SET id = 9991015, sectorFk = 9991, code = 'A-05-5', pickingOrder = 5;
REPLACE vn.parking SET id = 9992011, sectorFk = 9992, code = 'P-01-1', pickingOrder = 6;
REPLACE vn.parking SET id = 9992012, sectorFk = 9992, code = 'P-02-2', pickingOrder = 7;
REPLACE vn.parking SET id = 9992013, sectorFk = 9992, code = 'P-03-3', pickingOrder = 8;
REPLACE vn.parking SET id = 9993011, sectorFk = 9993, code = 'M-01-1', pickingOrder = 9;
REPLACE vn.parking SET id = 9993012, sectorFk = 9993, code = 'M-02-2', pickingOrder = 10;
REPLACE vn.parking SET id = 9993013, sectorFk = 9993, code = 'M-03-3', pickingOrder = 11;
REPLACE vn.shelving SET code = 'NAA', parkingFk = 9991011, priority = 1;
REPLACE vn.shelving SET code = 'NBB', parkingFk = 9991012, priority = 1;
REPLACE vn.shelving SET code = 'NCC', parkingFk = 9991013, priority = 1;
REPLACE vn.shelving SET code = 'NDD', parkingFk = 9991014, priority = 1;
REPLACE vn.shelving SET code = 'NEE', parkingFk = 9991015, priority = 1;
REPLACE vn.shelving SET code = 'PAA', parkingFk = 9992011, priority = 1;
REPLACE vn.shelving SET code = 'PBB', parkingFk = 9992012, priority = 1;
REPLACE vn.shelving SET code = 'PCC', parkingFk = 9992013, priority = 1;
REPLACE vn.shelving SET code = 'MAA', parkingFk = 9993011, priority = 1;
REPLACE vn.shelving SET code = 'MBB', parkingFk = 9993012, priority = 1;
REPLACE vn.shelving SET code = 'MCC', parkingFk = 9993013, priority = 1;
INSERT IGNORE INTO vn.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 vn.travel
SET id = 99,
shipped = CURDATE(),
landed = CURDATE(),
warehouseInFk = 999,
warehouseOutFk = 1,
isReceived = TRUE,
agencyFk = 1;
REPLACE vn.entry
SET id = 999,
supplierFk = 791,
isConfirmed = TRUE,
dated = CURDATE(),
travelFk = 99,
companyFk = 442;
REPLACE vn.ticket
SET id = 999999,
clientFk = 2,
warehouseFk = 999,
shipped = CURDATE(),
nickname = 'Cliente',
addressFk = 1,
companyFk = 442,
agencyModeFk = 10,
landed = CURDATE();
REPLACE vn.collection
SET id = 10101010,
workerFk = 9;
INSERT IGNORE INTO vn.ticketCollection
SET id = 10101010,
ticketFk = 999999,
collectionFk = 10101010;
REPLACE vn.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 vn.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 vn.sale
SET id = 99991,
itemFk = 999991,
ticketFk = 999999,
concept = 'Palito para pinchos',
quantity = 3,
price = 1,
discount = 0;
REPLACE vn.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 vn.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 vn.sale
SET id = 99992,
itemFk = 999992,
ticketFk = 999999,
concept = 'Madera Verde',
quantity = 10,
price = 1,
discount = 0;
REPLACE vn.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 vn.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 vn.itemShelving
SET id = 9931,
itemFk = 999993,
shelvingFk = 'NCC',
visible = 10,
`grouping` = 5,
packing = 10;
REPLACE vn.sale
SET id = 99993,
itemFk = 999993,
ticketFk = 999999,
concept = 'Madera Roja/Morada',
quantity = 15,
price = 1,
discount = 0;
REPLACE vn.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 vn.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 vn.sale
SET id = 99994,
itemFk = 999994,
ticketFk = 999999,
concept = 'Madera Naranja',
quantity = 4,
price = 1,
discount = 0;
REPLACE vn.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 vn.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 vn.sale
SET id = 99995,
itemFk = 999995,
ticketFk = 999999,
concept = 'Madera Amarilla',
quantity = 5,
price = 1,
discount = 0;
-- Palito naranja
REPLACE vn.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 vn.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 vn.sale
SET id = 99998,
itemFk = 999998,
ticketFk = 999999,
concept = 'Palito naranja',
quantity = 60,
price = 1,
discount = 0;
-- Palito amarillo
REPLACE vn.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 vn.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 vn.sale
SET id = 99999,
itemFk = 999999,
ticketFk = 999999,
concept = 'Palito amarillo',
quantity = 50,
price = 1,
discount = 0;
-- Palito azul
REPLACE vn.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 vn.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 vn.sale
SET id = 100000,
itemFk = 1000000,
ticketFk = 999999,
concept = 'Palito azul',
quantity = 50,
price = 1,
discount = 0;
-- Palito rojo
REPLACE vn.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 vn.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 vn.sale
SET id = 100001,
itemFk = 1000001,
ticketFk = 999999,
concept = 'Palito rojo',
quantity = 10,
price = 1,
discount = 0;
-- Previa
INSERT IGNORE INTO vn.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 vn.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 vn.sale
SET id = 99996,
itemFk = 999996,
ticketFk = 999999,
concept = 'Bolas de madera',
quantity = 4,
price = 7,
discount = 0,
isPicked = TRUE;
INSERT IGNORE INTO vn.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 vn.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 vn.sale
SET id = 99997,
itemFk = 999997,
ticketFk = 999999,
concept = 'Palitos de polo MIX',
quantity = 5,
price = 7,
discount = 0;
USE vn;
DELETE ish.* FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.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 vn.sectorCollection
SET id = 99,
userFk = 1,
sectorFk = 9992;
INSERT IGNORE INTO vn.saleGroup
SET id = 999,
userFk = 1,
parkingFk = 9992011,
sectorFk = 9992;
INSERT IGNORE INTO vn.sectorCollectionSaleGroup
SET id = 9999,
sectorCollectionFk = 99,
saleGroupFk = 999;
REPLACE vn.saleGroupDetail
SET id = 99991,
saleFk = 99996,
saleGroupFk = 999;
REPLACE vn.saleTracking
SET saleFk = 99996,
isChecked = TRUE,
workerFk = 103,
stateFk = 28;
INSERT IGNORE INTO vn.itemShelvingSale
SET id = 991,
itemShelvingFk = 9962,
saleFk = 99996,
quantity = 5,
userFk = 1;
UPDATE vn.ticket
SET zoneFk=1
WHERE id=999999;
UPDATE vn.collection
SET workerFk=9
WHERE id=10101010;
UPDATE vn.sale
SET isPicked =FALSE;

View File

@ -0,0 +1,34 @@
module.exports = Self => {
Self.remoteMethod('delete', {
description: 'Delete an ItemBarcode by itemFk and code',
accessType: 'READ',
accepts: [
{
arg: 'barcode',
type: 'string',
required: true,
},
{
arg: 'itemFk',
type: 'number',
required: true,
}
],
http: {
path: `/delete`,
verb: 'DELETE'
}
});
Self.delete = async(barcode, itemFk, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
await Self.destroyAll({
code: barcode,
itemFk
}, myOptions);
};
};

View File

@ -1,5 +1,6 @@
module.exports = Self => {
require('../methods/item-barcode/toItem')(Self);
require('../methods/item-barcode/delete')(Self);
Self.validatesUniquenessOf('code', {
message: `Barcode must be unique`