feat: refs #7644 Added with recursive buy-label
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-09 08:37:36 +02:00
parent cb5c660e13
commit 3f0335cf37
2 changed files with 16 additions and 3 deletions

View File

@ -7,7 +7,7 @@ module.exports = {
name: 'buy-label',
mixins: [vnReport],
async serverPrefetch() {
this.buys = await this.rawSqlFromDef('buys', [this.id]);
this.buys = await this.rawSqlFromDef('buys', [this.id, this.id]);
this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum));
const date = new Date();
this.weekNum = moment(date).isoWeek();

View File

@ -1,4 +1,15 @@
SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
WITH RECURSIVE numbers AS (
SELECT 1 n
UNION ALL
SELECT n + 1
FROM numbers
WHERE n < (
SELECT MAX(stickers)
FROM buy
WHERE entryFk = ?
)
)
SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum,
i.name,
i.`size`,
i.category,
@ -15,4 +26,6 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
LEFT JOIN producer p ON p.id = i.producerFk
LEFT JOIN ink ON ink.id = i.inkFk
LEFT JOIN origin o ON o.id = i.originFk
WHERE b.entryFk = ?
JOIN numbers num
WHERE b.entryFk = ?
AND num.n <= b.stickers