Merge branch 'dev' into 6281_buyFk
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Robert Ferrús 2024-05-20 09:38:11 +00:00
commit 623aa8d537
3 changed files with 93 additions and 9 deletions

View File

@ -35,7 +35,7 @@ BEGIN
itemFk, itemFk,
longName, longName,
supplier, supplier,
entryFk, CONCAT('E',entryFk) entryFk,
landed, landed,
`in`, `in`,
`out`, `out`,
@ -49,16 +49,98 @@ BEGIN
itemFk, itemFk,
longName, longName,
supplier, supplier,
'previous', 'E previous',
vFromDated, vFromDated,
SUM(`in`), SUM(`in`),
SUM(`out`), SUM(`out`),
NULL, NULL,
buyingValue AVG(buyingValue)
FROM supplierPackaging FROM supplierPackaging
WHERE supplierFk = vSupplierFk WHERE supplierFk = vSupplierFk
AND landed < vFromDated AND landed < vFromDated
GROUP BY itemFk GROUP BY itemFk
UNION ALL
SELECT vSupplierFk,
s.itemFk,
i.longName,
c.name,
CONCAT('T',s.ticketFk),
DATE(t.shipped),
-LEAST(s.quantity,0) `in`,
GREATEST(s.quantity,0) `out`,
t.warehouseFk,
s.price * (100 - s.discount) / 100
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN packaging p ON p.itemFk = i.id
JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN supplier su ON su.nif = c.fi
WHERE su.id = vSupplierFk
AND t.shipped >= vFromDated
AND p.isPackageReturnable
UNION ALL
SELECT vSupplierFk,
s.itemFk,
i.longName,
c.name,
'T previous',
vFromDated,
SUM(-LEAST(s.quantity,0)) `in`,
SUM(GREATEST(s.quantity,0)) `out`,
NULL,
AVG(s.price * (100 - s.discount) / 100)
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN packaging p ON p.itemFk = i.id
JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN supplier su ON su.nif = c.fi
WHERE su.id = vSupplierFk
AND t.shipped < vFromDated
AND p.isPackageReturnable
GROUP BY s.itemFk
UNION ALL
SELECT vSupplierFk,
p.itemFk,
i.longName,
c.name,
CONCAT('TP',tp.ticketFk),
DATE(t.shipped),
-LEAST(tp.quantity,0) `in`,
GREATEST(tp.quantity,0) `out`,
t.warehouseFk,
0
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
JOIN ticket t ON t.id = tp.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN supplier su ON su.nif = c.fi
WHERE su.id = vSupplierFk
AND t.shipped >= vFromDated
AND p.isPackageReturnable
UNION ALL
SELECT vSupplierFk,
p.itemFk,
i.longName,
c.name,
'TP previous',
vFromDated,
SUM(-LEAST(tp.quantity,0)) `in`,
SUM(GREATEST(tp.quantity,0)) `out`,
NULL,
0
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
JOIN ticket t ON t.id = tp.ticketFk
JOIN client c ON c.id = t.clientFk
JOIN supplier su ON su.nif = c.fi
WHERE su.id = vSupplierFk
AND t.shipped >= vFromDated
AND p.isPackageReturnable
GROUP BY p.itemFk
ORDER BY itemFk, landed, entryFk ORDER BY itemFk, landed, entryFk
) sub ) sub
WHERE `out` OR `in`; WHERE `out` OR `in`;

View File

@ -8,7 +8,8 @@
}, },
"properties": { "properties": {
"id": { "id": {
"type": "string" "type": "number",
"id": true
}, },
"originFk": { "originFk": {
"type": "number" "type": "number"

View File

@ -37,18 +37,19 @@ class Controller extends Section {
}); });
const filter = { const filter = {
fields: ['originFk', 'creationDate', 'newInstance'], fields: ['id', 'originFk', 'creationDate', 'newInstance'],
where: { where: {
originFk: value, originFk: value,
newInstance: {like: '%"isDeleted":true%'} newInstance: {like: '%"isDeleted":true%'}
}, },
order: 'creationDate DESC' order: 'creationDate DESC',
limit: 1
}; };
this.$http.get(`TicketLogs/findOne`, {filter}) this.$http.get(`TicketLogs`, {filter})
.then(res => { .then(res => {
if (res && res.data) { if (res && res.data && res.data.length) {
const now = Date.vnNew(); const now = Date.vnNew();
const maxDate = new Date(res.data.creationDate); const maxDate = new Date(res.data[0].creationDate);
maxDate.setHours(maxDate.getHours() + 1); maxDate.setHours(maxDate.getHours() + 1);
if (now <= maxDate) if (now <= maxDate)
return this.canRestoreTicket = true; return this.canRestoreTicket = true;