feat: refs #6897 add EntryConfig model and enhance entry filtering with new parameters
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2025-01-17 08:11:18 +01:00
parent 2572182a89
commit f8a156b7ab
9 changed files with 531 additions and 72 deletions

View File

@ -917,17 +917,18 @@ INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerF
(5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0), (5, 'CON', 'Container', 3, NULL, 35, 1, 'warm', 0),
(6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1); (6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm', 1);
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`, `hexJson`)
VALUES VALUES
('YEL', 'Yellow', 1, 1, 'F4D03F'), ('YEL', 'Yellow', 1, 1, 'F4D03F', '{"value": ["F4D03F"]}'),
('BLU', 'Blue', 1, 2, '5DADE2'), ('BLU', 'Blue', 1, 2, '5DADE2', '{"value": ["5DADE2"]}'),
('RED', 'Red', 1, 3, 'EC7063'), ('RED', 'Red', 1, 3, 'EC7063', '{"value": ["EC7063"]}'),
('SLV', 'Silver', 1, 4, 'CACFD2'), ('SLV', 'Silver', 1, 4, 'CACFD2', '{"value": ["CACFD2"]}'),
('BRW', 'Brown', 1, 5, 'DC7633'), ('BRW', 'Brown', 1, 5, 'DC7633', '{"value": ["DC7633"]}'),
('BLK', 'Black', 1, 6, '000000'), ('BLK', 'Black', 1, 6, '000000', '{"value": ["000000"]}'),
('BAS', 'Blue/Silver', 1, 7, '5DADE2'), ('BAS', 'Blue/Silver', 1, 7, '5DADE2', '{"value": ["5DADE2"]}'),
('GRN', 'Green', 1, 8, '28A745'), ('GRN', 'Green', 1, 8, '28A745', '{"value": ["28A745"]}'),
('WHT', 'White', 1, 9, 'FFFFFF'); ('WHT', 'White', 1, 9, 'FFFFFF', '{"value": ["FFFFFF"]}'),
('RGB', 'Red/Green/Blue', 1, 9, 'FFFFFF', '{"value": ["EC7063","5DADE2","28A745"]}');
INSERT INTO `vn`.`origin`(`id`,`code`, `name`) INSERT INTO `vn`.`origin`(`id`,`code`, `name`)
VALUES VALUES
@ -977,28 +978,31 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`)
INSERT INTO `vn`.`item`( INSERT INTO `vn`.`item`(
`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, `id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`,
`comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`,
`itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `isCustomInspectionRequired` `itemPackingTypeFk`, `hasMinPrice`, `packingOut`, `weightByPiece`, `isCustomInspectionRequired`
) )
VALUES VALUES
(1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 1), (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, NULL, 3, 1),
(2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 1), (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, NULL, 2, 1),
(3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 0), (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 5, 0),
(4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, NULL, 0),
(10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 0), (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, NULL, 0),
(14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, NULL, 0),
(15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, NULL, 0),
(16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, NULL, 0),
(71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, NULL, 0),
(72, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', 'marvel', 1, 'VT', 0, NULL, NULL, 1, 1, NULL, 0);
--
-- Update the taxClass after insert of the items -- Update the taxClass after insert of the items
UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2
WHERE `itemFk` IN(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 71); WHERE `itemFk` IN(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 71);
@ -1451,7 +1455,14 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
(98, 14, 23, '1', 7), (98, 14, 23, '1', 7),
(99, 15, 92, 'Trolley', 2), (99, 15, 92, 'Trolley', 2),
(100, 16, 92, 'Pallet', 2), (100, 16, 92, 'Pallet', 2),
(101, 71, 92, 'Shipping cost', 2); (101, 71, 92, 'Shipping cost', 2),
(102, 72, 56, 'Mistic weapon', 1),
(103, 72, 58, 'Stormbreaker', 2),
(104, 72, 27, '200cm', 3),
(105, 72, 36, 'Stark Industries', 4),
(106, 72, 1, 'Red/Green/Blue', 5),
(107, 72, 67, '-1 precission', 6),
(108, 72, 23, '1', 7);
INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`)
VALUES VALUES
@ -1521,7 +1532,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2),
(11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
(12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
(13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL),
(14, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL);
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`)
VALUES VALUES
@ -1537,7 +1549,8 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'),
(11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'), (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'),
(12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'), (12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'),
(99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'); (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'),
(100, 1, util.VN_CURDATE() , 14, 0, 442, 'IN2009','Movement 100',0, '', 'product');
INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`)
VALUES (2, 4, 1); VALUES (2, 4, 1);
@ -1560,26 +1573,34 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'), ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20'); ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created) INSERT INTO edi.supplier (supplier_id,company_name,entry_date,expiry_date,change_date_time,isAllowedDirectSales,isBanned)
VALUES (1,'MV', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 0);
INSERT INTO edi.ekt (id,`ref`,qty,pro,pri,ok,scanned)
VALUES (1, 1234, 1, 1, 1.1, 1, 1);
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,ektFk,weight,created)
VALUES VALUES
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), ( 1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), ( 2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
(3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), ( 3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE()),
(4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), ( 4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), ( 5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), ( 6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), ( 7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), ( 8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), ( 9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, NULL, 4, util.VN_CURDATE()),
(16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), (16, 99, 1, 50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, NULL, 1.00, '2024-07-30 08:13:51.000'),
(17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), (17, 11, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
(18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
(19, 100, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, NULL, 1, util.VN_CURDATE()),
(20, 100, 2, 5, 450, 3, 2, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, NULL, 2.5, util.VN_CURDATE()),
(21, 100,72, 55, 500, 5, 3, 1.000, 1.000, 0.000, 1, 1, 'packing', NULL, 0.00, 78.3, 75.6, 0, 1, 0, 1, 3, util.VN_CURDATE());
INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`)
VALUES VALUES
@ -4056,3 +4077,7 @@ INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance)
INSERT IGNORE INTO vn.inventoryConfig INSERT IGNORE INTO vn.inventoryConfig
SET id = 1, SET id = 1,
supplierFk = 4; supplierFk = 4;

View File

@ -0,0 +1,10 @@
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Entry','getBuyList','READ','ALLOW','ROLE','buyer'),
('Entry','create','WRITE','ALLOW','ROLE','buyer'),
('EntryType','find','READ','ALLOW','ROLE','buyer'),
('EntryConfig','findOne','READ','ALLOW','ROLE','buyer');
ALTER TABLE vn.ink ADD IF NOT EXISTS hexJson TEXT NOT NULL;
UPDATE vn.ink
SET hexJson = CONCAT('{"value": ["',hex,'"]}')

View File

@ -0,0 +1,271 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => {
Self.remoteMethodCtx('getBuyList', {
description: 'Returns buys for editing of one entry',
accessType: 'READ',
accepts: [{
arg: 'entryFk',
type: 'number',
required: true,
description: 'The entry id',
http: {source: 'path'}
},
{
arg: 'filter',
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
},
{
arg: 'isIgnored',
type: 'boolean',
description: 'check if the buy is ignored',
http: {source: 'query'}
},
{
arg: 'itemFk',
type: 'number',
description: 'item id',
http: {source: 'query'}
},
{
arg: 'name',
type: 'string',
description: 'item name',
http: {source: 'query'}
},
{
arg: 'size',
type: 'number',
description: 'item size',
http: {source: 'query'}
},
{
arg: 'stickers',
type: 'number',
description: 'sticker quantity',
http: {source: 'query'}
},
{
arg: 'packagingFk',
type: 'number',
description: 'packaging id',
http: {source: 'query'}
},
{
arg: 'weight',
type: 'number',
description: 'weight',
http: {source: 'query'}
},
{
arg: 'packing',
type: 'number',
description: 'packing quantity',
http: {source: 'query'}
},
{
arg: 'grouping',
type: 'number',
description: 'grouping quantity',
http: {source: 'query'}
},
{
arg: 'quantity',
type: 'number',
http: {source: 'query'}
},
{
arg: 'buyingValue',
type: 'number',
http: {source: 'query'}
},
{
arg: 'amount',
type: 'number',
description: 'buying value * quantity',
http: {source: 'query'}
},
{
arg: 'price2',
type: 'number',
description: 'price for the package',
http: {source: 'query'}
},
{
arg: 'price3',
type: 'number',
description: 'price for the box',
http: {source: 'query'}
},
{
arg: 'minPrice',
type: 'number',
description: 'item minimum price',
http: {source: 'query'}
},
{
arg: 'packingOut',
type: 'number',
description: 'quantity of package on a vn box',
http: {source: 'query'}
},
{
arg: 'comment',
type: 'string',
description: 'item comment',
http: {source: 'query'}
},
{
arg: 'subName',
type: 'string',
description: 'supplier name',
http: {source: 'query'}
},
{
arg: 'subName',
type: 'string',
description: 'supplier name',
http: {source: 'query'}
},
{
arg: 'company_name',
type: 'string',
description: 'company name',
http: {source: 'query'}
},
{
arg: 'groupBy',
type: 'string',
description: 'group by',
http: {source: 'query'}
},
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/:entryFk/getBuyList`,
verb: 'GET'
}
});
Self.getBuyList = async(ctx, entryFk, filter, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
let conn = Self.dataSource.connector;
let where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'name':
case 'subName':
case 'company_name':
case 'comment':
return {[param]: {like: `%${value}%`}};
case 'size':
case 'isIgnored':
case 'itemFk':
case 'stickers':
case 'packagingFk':
case 'weight':
case 'packing':
case 'grouping':
case 'quantity':
case 'buyingValue':
case 'amount':
case 'price2':
case 'price3':
case 'packingOut':
case 'minPrice':
return {[param]: value};
}
});
filter = mergeFilters(filter, {where});
let stmts = [];
let stmt;
const selectFields = `b.id,
b.isIgnored,
b.itemFk,
b.printedStickers,
b.stickers,
b.packagingFk,
b.weight,
b.packing,
b.groupingMode,
b.grouping,
b.quantity,
b.buyingValue,
ROUND(b.buyingValue * b.quantity, 2) amount,
b.isChecked,
b.price2,
b.price3,
i.name,
i.size,
i.minPrice,
i.hasMinPrice,
i.packingOut,
i.comment,
i.subName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7,
i.tag8,
i.value8,
i.tag9,
i.value9,
i.tag10,
i.value10,
s.company_name,
ik.hexJson`;
const groupByFields = `SUM(b.printedStickers) printedStickers,
SUM(b.stickers) stickers,
SUM(b.weight) weight,
SUM(b.quantity) quantity,
SUM(ROUND(b.buyingValue * b.quantity, 2)) amount
`;
const groupBy = ctx.args.groupBy;
stmt = new ParameterizedSQL(
`SELECT *
FROM(
SELECT
${ groupBy ? groupByFields : selectFields}
FROM item i
LEFT JOIN ink ik ON ik.id = i.inkFk
LEFT JOIN buy b ON b.itemFk = i.id
LEFT JOIN edi.ekt e ON e.id = b.ektFk
LEFT JOIN edi.supplier s ON e.pro = s.supplier_id
WHERE b.entryFk = ?
${groupBy ?? ''}
) sub`,
[entryFk]
);
stmt.merge(conn.makeSuffix(filter));
let itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql, myOptions);
if (groupBy) {
const buys = await Self.app.models.Buy.find({where: {entryFk}}, myOptions);
const buysChecked = buys.filter(buy => buy?.isChecked);
result[0].isAllChecked = buysChecked.length === buys.length;
}
return itemsIndex === 0 ? result : result[itemsIndex];
};
};

View File

@ -0,0 +1,37 @@
module.exports = Self => {
Self.remoteMethodCtx('getBuyUltimate', {
description: 'Returns the last buy of the item',
accessType: 'READ',
accepts: [
{
arg: 'itemFk',
type: 'number',
required: true
}, {
arg: 'warehouseFk',
type: 'number',
required: true
}, {
arg: 'date',
type: 'date',
required: true
}
],
returns: {
type: 'object',
root: true
},
http: {
path: `/getBuyUltimate`,
verb: 'GET'
}
});
Self.getBuyUltimate = async(ctx, itemFk, warehouseFk, date, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
return Self.rawSql('CALL vn.buy_getUltimate(?, ?, ?)', [itemFk, warehouseFk, date], myOptions);
};
};

View File

@ -119,7 +119,68 @@ module.exports = Self => {
arg: 'invoiceAmount', arg: 'invoiceAmount',
type: 'number', type: 'number',
description: `The invoice amount` description: `The invoice amount`
} },
{
arg: 'isExcludedFromAvailable',
type: 'boolean',
description: `landing date`
},
{
arg: 'isReceived',
type: 'boolean',
description: `travel received`
},
{
arg: 'isRaid',
type: 'boolean',
description: `travel isRaid`
},
{
arg: 'landed',
type: 'date',
description: `landing date`
},
{
arg: 'invoiceNumber',
type: 'string',
description: `entry invoice`
},
{
arg: 'reference',
type: 'string',
description: `entry reference`
},
{
arg: 'awbCode',
type: 'string',
description: `awb code`
},
{
arg: 'agencyModeId',
type: 'number',
description: `agency mode id`
},
{
arg: 'evaNotes',
type: 'string',
description: `observation`
},
{
arg: 'warehouseInFk',
type: 'number',
description: `warehouse in id`
},
{
arg: 'warehouseOutFk',
type: 'number',
description: `warehouse out id`
},
{
arg: 'entryTypeCode',
type: 'string',
description: 'entry type code'
},
], ],
returns: { returns: {
type: ['object'], type: ['object'],
@ -146,19 +207,12 @@ module.exports = Self => {
{'s.name': {like: `%${value}%`}}, {'s.name': {like: `%${value}%`}},
{'s.nickname': {like: `%${value}%`}} {'s.nickname': {like: `%${value}%`}}
]}; ]};
case 'invoiceNumber':
case 'reference':
case 'ref': case 'ref':
case 'evaNotes':
param = `e.${param}`; param = `e.${param}`;
return {[param]: {like: `%${value}%`}}; return {[param]: {like: `%${value}%`}};
case 'created':
return {'e.created': {gte: value}};
case 'from':
return {'t.landed': {gte: value}};
case 'fromShipped':
return {'t.shipped': {gte: value}};
case 'to':
return {'t.landed': {lte: value}};
case 'toShipped':
return {'t.shipped': {lte: value}};
case 'id': case 'id':
case 'isBooked': case 'isBooked':
case 'isConfirmed': case 'isConfirmed':
@ -168,10 +222,23 @@ module.exports = Self => {
case 'currencyFk': case 'currencyFk':
case 'supplierFk': case 'supplierFk':
case 'invoiceInFk': case 'invoiceInFk':
param = `e.${param}`; case 'isExcludedFromAvailable':
return {[param]: value}; return {[`e.${param}`]: value};
case 'isReceived':
case 'landed':
case 'isRaid':
case 'warehouseInFk':
case 'warehouseOutFk':
return {[`t.${param}`]: value};
case 'awbCode':
return {'a.code': {like: `%${value}%`}};
case 'agencyModeId':
return {[`am.id`]: value};
case 'entryTypeCode':
return {[`et.code`]: value};
} }
}); });
console.log('where: ', where);
filter = mergeFilters(ctx.args.filter, {where}); filter = mergeFilters(ctx.args.filter, {where});
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const client = await Self.app.models.Client.findById(userId, myOptions); const client = await Self.app.models.Client.findById(userId, myOptions);
@ -183,15 +250,14 @@ module.exports = Self => {
const stmts = []; const stmts = [];
let stmt; let stmt;
stmt = new ParameterizedSQL( stmt = new ParameterizedSQL(
`SELECT `SELECT e.id,
e.id,
e.supplierFk, e.supplierFk,
e.dated, e.dated,
e.reference, e.reference,
e.invoiceNumber, e.invoiceNumber,
e.isBooked, e.isBooked,
e.isExcludedFromAvailable, e.isExcludedFromAvailable,
e.evaNotes observation, e.evaNotes,
e.isConfirmed, e.isConfirmed,
e.isOrdered, e.isOrdered,
t.isRaid, t.isRaid,
@ -211,15 +277,27 @@ module.exports = Self => {
cu.code currencyCode, cu.code currencyCode,
t.shipped, t.shipped,
t.landed, t.landed,
t.ref AS travelRef, t.ref travelRef,
t.warehouseInFk, t.warehouseInFk,
w.name warehouseInName w.name warehouseInName,
t.warehouseOutFk,
w2.name warehouseOutName,
a.code awbCode,
am.id agencyModeId,
am.name agencyModeName,
et.code entryTypeCode,
et.description entryTypeDescription,
t.isReceived
FROM vn.entry e FROM vn.entry e
JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.supplier s ON s.id = e.supplierFk
JOIN vn.travel t ON t.id = e.travelFk JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.warehouse w ON w.id = t.warehouseInFk
JOIN vn.warehouse w2 ON w2.id = t.warehouseOutFk
JOIN vn.company co ON co.id = e.companyFk JOIN vn.company co ON co.id = e.companyFk
JOIN vn.currency cu ON cu.id = e.currencyFk` JOIN vn.currency cu ON cu.id = e.currencyFk
LEFT JOIN vn.awb a ON a.id = t.awbFk
LEFT JOIN vn.agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN vn.entryType et ON et.code = e.typeFk`
); );
stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeWhere(filter.where));

View File

@ -31,5 +31,8 @@
}, },
"InventoryConfig": { "InventoryConfig": {
"dataSource": "vn" "dataSource": "vn"
},
"EntryConfig": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,30 @@
{
"name": "EntryConfig",
"base": "VnModel",
"mixins": {
"Loggable": true
},
"options": {
"mysql": {
"table": "entryConfig"
}
},
"properties": {
"defaultEntry": {
"type": "number",
"id": true
},
"mailToNotify": {
"type": "string"
},
"inventorySupplierFk": {
"type": "number"
},
"maxLockTime": {
"type": "number"
},
"defaultSupplierFk": {
"type": "number"
}
}
}

View File

@ -14,8 +14,10 @@ module.exports = Self => {
require('../methods/entry/buyLabel')(Self); require('../methods/entry/buyLabel')(Self);
require('../methods/entry/labelSupplier')(Self); require('../methods/entry/labelSupplier')(Self);
require('../methods/entry/buyLabelSupplier')(Self); require('../methods/entry/buyLabelSupplier')(Self);
require('../methods/entry-buys/getBuyList')(Self);
require('../methods/entry-buys/getBuyUltimate')(Self);
Self.observe('before save', async function(ctx, options) { Self.observe('before save', async(ctx, options) => {
if (ctx.isNewInstance) return; if (ctx.isNewInstance) return;
const changes = ctx.data || ctx.instance; const changes = ctx.data || ctx.instance;

View File

@ -17,6 +17,9 @@
}, },
"showOrder": { "showOrder": {
"type": "number" "type": "number"
},
"hexJson": {
"type": "string"
} }
}, },
"acls": [ "acls": [