test #3056

Merged
robert merged 18 commits from test into dev 2024-10-02 09:22:28 +00:00
8 changed files with 104 additions and 57 deletions

View File

@ -3184,7 +3184,7 @@ UPDATE vn.department
SET workerFk = null; SET workerFk = null;
INSERT INTO vn.packaging INSERT INTO vn.packaging
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0); VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1);
INSERT IGNORE INTO vn.intrastat INSERT IGNORE INTO vn.intrastat

View File

@ -29,21 +29,24 @@ BEGIN
(INDEX (itemFk)) (INDEX (itemFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT i.id itemFk, SELECT i.id itemFk,
SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, SUM(IFNULL(pd.absIncreasing,0)) absIncreasing,
SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing,
pd.warehouseFk pd.warehouseFk
FROM item i FROM item i
JOIN priceDelta pd JOIN priceDelta pd
ON pd.itemTypeFk = i.typeFk ON pd.itemTypeFk = i.typeFk
AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) AND (pd.minSize IS NULL OR pd.minSize <= i.`size`)
AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`) AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`)
AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk) AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk)
AND (pd.originFk IS NULL OR pd.originFk = i.originFk) AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk) AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk) AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped) LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk
AND (pd.toDated IS NULL OR pd.toDated >= vShipped) LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk)
GROUP BY i.id; WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt)
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
(INDEX (itemFk)) (INDEX (itemFk))
@ -130,15 +133,15 @@ BEGIN
-- Bonus del comprador a un rango de productos -- Bonus del comprador a un rango de productos
INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
SELECT SELECT
tcb.warehouseFk, tcb.warehouseFk,
tcb.itemFk, tcb.itemFk,
c.id, c.id,
IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0) IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0)
FROM tmp.ticketComponentBase tcb FROM tmp.ticketComponentBase tcb
JOIN component c ON c.code = 'bonus' JOIN component c ON c.code = 'bonus'
JOIN tPriceDelta tpd JOIN tPriceDelta tpd
ON tpd.itemFk = tcb.itemFk ON tpd.itemFk = tcb.itemFk
AND tpd.warehouseFk = tcb.warehouseFk; AND tpd.warehouseFk = tcb.warehouseFk;
-- RECOBRO -- RECOBRO

View File

@ -1,10 +1,10 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getSimilar`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getSimilar`(
vSelf INT, vSelf INT,
vWarehouseFk INT, vWarehouseFk INT,
vDated DATE, vDated DATE,
vShowType BOOL, vShowType BOOL,
vDaysInForward INT vDaysInForward INT
) )
BEGIN BEGIN
/** /**
@ -17,48 +17,48 @@ BEGIN
* @param vShowType Mostrar tipos * @param vShowType Mostrar tipos
* @param vDaysInForward Días de alcance para las ventas * @param vDaysInForward Días de alcance para las ventas
*/ */
DECLARE vAvailableCalcFk INT; DECLARE vAvailableCalcFk INT;
DECLARE vPriority INT DEFAULT 1; DECLARE vPriority INT DEFAULT 1;
CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated);
WITH itemTags AS ( WITH itemTags AS (
SELECT i.id, SELECT i.id,
typeFk, typeFk,
tag5, tag5,
value5, value5,
tag6, tag6,
value6, value6,
tag7, tag7,
value7, value7,
tag8, tag8,
value8, value8,
t.name, t.name,
it.value it.value
FROM vn.item i FROM vn.item i
LEFT JOIN vn.itemTag it ON it.itemFk = i.id LEFT JOIN vn.itemTag it ON it.itemFk = i.id
AND it.priority = vPriority AND it.priority = vPriority
LEFT JOIN vn.tag t ON t.id = it.tagFk LEFT JOIN vn.tag t ON t.id = it.tagFk
WHERE i.id = vSelf WHERE i.id = vSelf
), ),
stock AS ( stock AS (
SELECT itemFk, SUM(visible) stock SELECT itemFk, SUM(visible) stock
FROM vn.itemShelvingStock FROM vn.itemShelvingStock
WHERE warehouseFk = vWarehouseFk WHERE warehouseFk = vWarehouseFk
GROUP BY itemFk GROUP BY itemFk
), ),
sold AS ( sold AS (
SELECT SUM(s.quantity) quantity, s.itemFk SELECT SUM(s.quantity) quantity, s.itemFk
FROM vn.sale s FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
WHERE t.shipped BETWEEN CURDATE() AND CURDATE() + INTERVAL vDaysInForward DAY WHERE t.shipped >= CURDATE() + INTERVAL vDaysInForward DAY
AND iss.saleFk IS NULL AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk GROUP BY s.itemFk
) )
SELECT i.id itemFk, SELECT i.id itemFk,
CAST(sd.quantity AS INT) advanceable, LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable,
i.longName, i.longName,
i.subName, i.subName,
i.tag5, i.tag5,

View File

@ -17,5 +17,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`,
`p`.`upload` AS `Suben`, `p`.`upload` AS `Suben`,
`p`.`base` AS `Base`, `p`.`base` AS `Base`,
`p`.`isBox` AS `box`, `p`.`isBox` AS `box`,
`p`.`returnCost` AS `costeRetorno` `p`.`returnCost` AS `costeRetorno`,
`p`.`isActive` AS `isActive`
FROM `vn`.`packaging` `p` FROM `vn`.`packaging` `p`

View File

@ -0,0 +1,6 @@
-- Place your SQL code here
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL;
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk)
REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,6 @@
-- Place your SQL code here
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL;
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk)
REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,24 @@
ALTER TABLE `vn`.`packaging`
ADD COLUMN IF NOT EXISTS `isActive` TINYINT(1) DEFAULT 1;
UPDATE vn.packaging
SET isActive = FALSE
WHERE id IN('06x04x06','07x04x03','1000','100SM','1031','104','105','1060','10x04x06','10x04x07','1100','118','119','1200','129','1300',
'134','146','147','148','158','159','17x01x02','17X01X03','17x01x04','17x01x05','18X01X04','198','199',
'20P','20x01x03','246','273','278','279','280','290','359','37247','382','40P','453','463','464','465','466',
'467','469','471','473','494','508','509','511','512','514','515','516','518','519-50B','575','598-3x6','604','605','606',
'607','609','647','67515','676','680','682','685','687','688','691','692','693','694','695','730','751','7808','790','7910',
'7920','79450','7950','7952','7960','7976','7982','7986','7988',
'7993','8000','8046','8049','8053','8057','8058','8065','8076','8085','8086','8088',
'8091','8095','8096','8097','8101','8106','8108','8110','8112','8124','8134','8140','8141','8143','8145','8149','8150',
'8170','8174','8192','8200','8210','8249','8270','8275','8288','8300','8350','8375','8399','8400','8420','845','847','8480','8500',
'855','858','8600','862','869','871','872','8720','878','879','880','8800','882','885','910','911','912','914','916','917','918','919',
'920','921','922','923','924','925','926','927','930','9300','932','934','935','936','938','942','948','9600','980','984','9920',
'B20x16','B43x13','Bande Rota','bb3','Bcesta','BcestaOVAL','BcestaRED','Bcirios','BciriosG','BjarronBLN','BjarronNGR',
'Btazon','Bvelas','cactus200','Caja040','CajaTGLF','CC Alza Pl','CC_falso',
'EB-RSMINA','EMB 1_4','EMB 2_5','espuma','FB-BENCH','granel','Grenex','guzma1200','guzma1400','guzma330','guzma400','guzma650','guzma900','HB-ALEX',
'HB-APOSENT','HB-MAGIC','HB-NATUF','HB-RSMINA','HB-TES-RSR','HB068','HB117','HB2-CIRCA','JB-AROMA','jumboX3','kalan330','kalan400',
'kalan577','kalan900','L12','L120','L14','L2-120','L200','L3-120','L4-120','L44','L6','L6-180','L8','L8-200','MB-BENCH','MBOLA','mc_11',
'mc_13','Msp','NO VALIDO','NO-002','PANIC','PBLG','PISOCC/3','PISOCC/4','PISOCC/5','PISOCC/6',
'procona','QB-CARDENA','QB-PANDERO','QB-TES-RSR','QB7-TOSCA','QB9-TOSCA','RB-BENCH','SemiEuroPa','spolette','t_flori11','T26x23',
'T26x25','T27x24','T27x30','T28x26','T30x24','T33x30','THA50','ti_13','Tumbado','UB-BENCH')

View File

@ -142,12 +142,19 @@ module.exports = Self => {
ctx.args.addressId = ticket.addressFk; ctx.args.addressId = ticket.addressFk;
const newTicket = await models.Ticket.new(ctx, myOptions); const newTicket = await models.Ticket.new(ctx, myOptions);
const existingRefund = await models.TicketRefund.findOne({
await models.TicketRefund.create({ where: {
originalTicketFk: ticketId, originalTicketFk: ticketId,
refundTicketFk: newTicket.id refundTicketFk: newTicket.id
}, myOptions); },
myOptions
});
if (!existingRefund) {
await models.TicketRefund.create({
originalTicketFk: ticketId,
refundTicketFk: newTicket.id
}, myOptions);
}
return newTicket; return newTicket;
} }
}; };