This commit is contained in:
parent
a2055d35fb
commit
9760e50212
|
@ -1,6 +1,6 @@
|
|||
CREATE TABLE `vn`.`buyConfig` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`showLastBuy` int(11) NOT NULL DEFAULT 6 COMMENT 'Meses desde la última compra',
|
||||
`monthsAgo` int(11) NOT NULL DEFAULT 6 COMMENT 'Meses desde la última compra',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
|
|
|
@ -2863,10 +2863,10 @@ INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`)
|
|||
(2, 1, 50, 2),
|
||||
(3, 1, 0, 3);
|
||||
|
||||
INSERT INTO `vn`.`travelConfig` (id, warehouseInFk, warehouseOutFk, agencyFk, companyFk)
|
||||
INSERT INTO `vn`.`travelConfig` (`id`, `warehouseInFk`, `warehouseOutFk`, `agencyFk`, `companyFk`)
|
||||
VALUES
|
||||
(1, 1, 1, 1, 442);
|
||||
|
||||
INSERT INTO `vn`.`buyConfig` (id, showLastBuy)
|
||||
INSERT INTO `vn`.`buyConfig` (`id`, `monthsAgo`)
|
||||
VALUES
|
||||
(1, 6);
|
||||
|
|
|
@ -38,12 +38,12 @@ module.exports = Self => {
|
|||
JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN vn.entry e ON e.id = b.entryFk
|
||||
JOIN vn.supplier s ON s.id = e.supplierFk
|
||||
JOIN vn.buyConfig bc ON bc.showLastBuy
|
||||
JOIN vn.buyConfig bc ON bc.monthsAgo
|
||||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
LEFT JOIN entryTmp et ON et.id = i.id
|
||||
WHERE e.supplierFk = ?
|
||||
AND (i.family ='EMB' OR i.family = 'CONT')
|
||||
AND b.created > (util.VN_CURDATE() - INTERVAL bc.showLastBuy MONTH)
|
||||
AND i.family IN ('EMB', 'CONT')
|
||||
AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH)
|
||||
GROUP BY b.itemFk
|
||||
ORDER BY et.quantity DESC, quantityTotal DESC`, [entry, id, id]);
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue