feat: refs #7905 getBuysCsv #2900

Merged
guillermo merged 10 commits from 7905-getBuysCsv into dev 2024-09-05 09:44:39 +00:00
8 changed files with 98 additions and 2 deletions
Showing only changes of commit 8aa4427693 - Show all commits

View File

@ -0,0 +1,24 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
vSelf INT
)
BEGIN
/**
* Update the volume ticket
*
* @param vSelf Ticket id
*/
DECLARE vVolume DECIMAL(10,6);
SELECT SUM(s.quantity * ic.cm3delivery / 1000000) INTO vVolume
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
WHERE t.id = vSelf;
UPDATE ticket
SET volume = vVolume
WHERE id = vSelf;
END$$
DELIMITER ;

View File

@ -0,0 +1,29 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`(
vItemFk INT
)
BEGIN
/**
* Update the volume tickets of item
*
* @param vSelf Ticket id
*/
CREATE OR REPLACE TEMPORARY TABLE tTicket
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
WHERE s.itemFk = vItemFk
AND t.shipped >= util.VN_CURDATE()
GROUP BY t.id;
UPDATE ticket t
JOIN tTicket tt ON tt.id = t.id
SET t.volume = tt.volume;
DROP TEMPORARY TABLE tTicket;
END$$
DELIMITER ;

View File

@ -0,0 +1 @@
ALTER TABLE vn.ticket ADD volume decimal(10,6) DEFAULT NULL NULL COMMENT 'Unidad en m3';

View File

@ -0,0 +1,16 @@
-- Calculamos todos los volumenes de todos los tickets una sola vez
CREATE OR REPLACE TEMPORARY TABLE tmp.tTicketVolume
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume
FROM vn.sale s
JOIN vn.ticket t ON t.id = s.ticketFk
JOIN vn.itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
GROUP BY t.id;
UPDATE vn.ticket t
JOIN tmp.tTicketVolume tv ON tv.id = t.id
SET t.volume = tv.volume;
DROP TEMPORARY TABLE tmp.tTicketVolume;

View File

@ -109,6 +109,11 @@ module.exports = Self => {
arg: 'days', arg: 'days',
type: 'number', type: 'number',
description: `N days interval` description: `N days interval`
},
{
arg: 'invoiceAmount',
type: 'number',
description: `The invoice amount`
} }
], ],
returns: { returns: {
@ -192,6 +197,7 @@ module.exports = Self => {
e.companyFk, e.companyFk,
e.gestDocFk, e.gestDocFk,
e.invoiceInFk, e.invoiceInFk,
e.invoiceAmount,
t.landed, t.landed,
s.name supplierName, s.name supplierName,
s.nickname supplierAlias, s.nickname supplierAlias,

View File

@ -74,6 +74,9 @@
}, },
"observationEditorFk": { "observationEditorFk": {
"type": "number" "type": "number"
},
"invoiceAmount": {
"type": "number"
} }
}, },
"relations": { "relations": {

View File

@ -71,7 +71,15 @@ module.exports = Self => {
arg: 'continent', arg: 'continent',
type: 'string', type: 'string',
description: 'The continent code' description: 'The continent code'
}, }, {
arg: 'shipmentHour',
type: 'string',
description: 'The shipment hour'
}, {
arg: 'landingHour',
type: 'string',
description: 'The landing hour'
}
], ],
returns: { returns: {
type: ['Object'], type: ['Object'],
@ -130,6 +138,8 @@ module.exports = Self => {
t.isReceived, t.isReceived,
t.m3, t.m3,
t.kg, t.kg,
t.shipmentHour,
t.landingHour,
t.cargoSupplierFk, t.cargoSupplierFk,
t.totalEntries, t.totalEntries,
am.name agencyModeName, am.name agencyModeName,

View File

@ -44,6 +44,12 @@
}, },
"agencyModeFk": { "agencyModeFk": {
"type": "number" "type": "number"
},
"shipmentHour": {
"type": "string"
},
"landingHour": {
"type": "string"
} }
}, },
"relations": { "relations": {
@ -64,3 +70,4 @@
} }
} }
} }