feat: refs #7266 Requested changes and improvements

This commit is contained in:
Guillermo Bonet 2024-10-28 14:51:19 +01:00
parent c43bdb5021
commit a37b7b71a8
33 changed files with 81 additions and 256 deletions

View File

@ -1,14 +1,28 @@
module.exports = Self => {
Self.remoteMethodCtx('buyLabel', {
description: 'Returns the entry buy labels',
description: 'Returns the buy label',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The entry id',
description: 'The buy id',
http: {source: 'path'}
}, {
arg: 'labelType',
type: 'string',
required: true,
description: 'The label type',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
@ -27,11 +41,16 @@ module.exports = Self => {
}
],
http: {
path: '/:id/buy-label',
path: '/:id/:labelType/buy-label',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label');
Self.buyLabel = (ctx, id, labelType) => {
if (labelType == 'qr')
return Self.printReport(ctx, id, 'buy-label-qr');
else
return Self.printReport(ctx, id, 'buy-label-barcode');
};
};

View File

@ -1,22 +1,14 @@
module.exports = Self => {
Self.remoteMethodCtx('labelBarcodePdf', {
description: 'Returns the item label pdf with barcode',
Self.remoteMethodCtx('buyLabelSupplier', {
description: 'Returns the entry buy labels',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
description: 'The entry id',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
@ -35,14 +27,11 @@ module.exports = Self => {
}
],
http: {
path: '/:id/label-barcode-pdf',
path: '/:id/buy-label-supplier',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelBarcodePdf = (ctx, id) => {
ctx.args.typeId = 'buy';
return Self.printReport(ctx, id, 'item-label-barcode');
};
Self.buyLabelSupplier = (ctx, id) => Self.printReport(ctx, id, 'buy-label-supplier');
};

View File

@ -1,49 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('labelQrPdf', {
description: 'Returns the item label pdf with qr',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
}, {
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
}, {
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: '/:id/label-qr-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelQrPdf = (ctx, id) => {
ctx.args.userId = ctx.req.accessToken.userId;
ctx.args.typeId = 'buy';
return Self.printReport(ctx, id, 'item-label-qr');
};
};

View File

@ -2,6 +2,5 @@ module.exports = Self => {
require('../methods/entry/editLatestBuys')(Self);
require('../methods/entry/latestBuysFilter')(Self);
require('../methods/entry/deleteBuys')(Self);
require('../methods/entry/labelBarcodePdf')(Self);
require('../methods/entry/labelQrPdf')(Self);
require('../methods/entry/buyLabel')(Self);
};

View File

@ -1,52 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('labelBarcodePdf', {
description: 'Returns the item label pdf with barcode',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'warehouseId',
type: 'number',
required: true
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
}, {
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
}, {
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: '/:id/label-barcode-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelBarcodePdf = (ctx, id) => {
ctx.args.typeId = 'item';
return Self.printReport(ctx, id, 'item-label-barcode');
};
};

View File

@ -1,53 +0,0 @@
module.exports = Self => {
Self.remoteMethodCtx('labelQrPdf', {
description: 'Returns the item label pdf with qr',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'number',
required: true,
description: 'The item id',
http: {source: 'path'}
}, {
arg: 'warehouseId',
type: 'number',
required: true
}, {
arg: 'packing',
type: 'number',
required: false
}, {
arg: 'copies',
type: 'number',
required: false
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
}, {
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
}, {
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: '/:id/label-qr-pdf',
verb: 'GET'
},
accessScopes: ['DEFAULT', 'read:multimedia']
});
Self.labelQrPdf = (ctx, id) => {
ctx.args.userId = ctx.req.accessToken.userId;
ctx.args.typeId = 'item';
return Self.printReport(ctx, id, 'item-label-qr');
};
};

View File

@ -15,8 +15,6 @@ module.exports = Self => {
require('../methods/item/getWasteByItem')(Self);
require('../methods/item/createIntrastat')(Self);
require('../methods/item/buyerWasteEmail')(Self);
require('../methods/item/labelBarcodePdf')(Self);
require('../methods/item/labelQrPdf')(Self);
require('../methods/item/setVisibleDiscard')(Self);
require('../methods/item/get')(Self);

View File

@ -1,16 +1,16 @@
<!DOCTYPE html>
<html>
<body table v-for="item in items" style="break-before: page">
<body table v-for="buy in buys" style="break-before: page">
<table>
<tr>
<td class="md-txt bold center black-bg lg-width md-height">
<div class="overflow-multiline">
{{item.item}}
{{buy.item}}
</div>
</td>
<td colspan="2" class="xl-txt bold center black-bg md-height md-width">
<div class="overflow-line">
{{item.size}}
{{buy.size}}
</div>
</td>
</tr>
@ -18,64 +18,64 @@
<td class="right lg-width">
<div class="overflow-line">
{{
(item.longName && item.size && item.subName)
? `${item.longName} ${item.size} ${item.subName}`
: item.comment
(buy.longName && buy.size && buy.subName)
? `${buy.longName} ${buy.size} ${buy.subName}`
: buy.comment
}}
</div>
</td>
<td class="center sm-width">
<div class="overflow-line">
{{item.producerName || item.producerFk}}
{{buy.producerName || buy.producerFk}}
</div>
</td>
<td class="center sm-width">
<div class="overflow-line">
{{item.inkFk}}
{{buy.inkFk}}
</div>
</td>
</tr>
<tr>
<td class="md-txt xl-width bold center">
<div class="overflow-line">
{{item.itemFk}}
{{buy.itemFk}}
</div>
</td>
<td colspan="2" class="md-txt md-width center">
<div class="overflow-line">
{{`${(packing || item.packing)} x ${item.stems || ''}`}}
{{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
</div>
</td>
</tr>
<tr>
<td rowspan="2" class="center">
<div v-html="getBarcode(item.buyFk)"></div>
<div v-html="getBarcode(buy.buyFk)"></div>
</td>
<td colspan="2" class="center md-width xs-height xs-txt">
<div v-if="item.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
<div v-if="buy.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
{{'LAID'}}
</div>
<div v-else class="overflow-line">
{{item.entryFk}}
{{buy.entryFk}}
</div>
</td>
</tr>
<tr>
<td class="center xs-txt sm-width">
<div class="overflow-line">
{{item.buyerName}}
{{buy.buyerName}}
</div>
</td>
<td class="center xs-txt sm-width">
<div class="overflow-line">
{{item.origin}}
{{buy.origin}}
</div>
</td>
</tr>
<tr>
<td class="center xl-width">
<div class="overflow-line">
{{item.buyFk}}
{{buy.buyFk}}
</div>
</td>
<td class="xs-txt sm-width center">
@ -85,7 +85,7 @@
</td>
<td class="xs-txt sm-width cursive center bold">
<div class="overflow-line">
{{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
{{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
</div>
</td>
</tr>

View File

@ -4,21 +4,11 @@ const moment = require('moment');
const jsbarcode = require('jsbarcode');
module.exports = {
name: 'item-label-barcode',
name: 'buy-label-barcode',
async serverPrefetch() {
this.date = Date.vnNew();
if (this.typeId === 'item') {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
}
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]);
if (!this.items.length) throw new UserError(`Empty data source`);
this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]);
if (!this.buys.length) throw new UserError(`Empty data source`);
this.date = moment(this.date).format('WW/E');
},
methods: {

View File

@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum,
ig.subName,
i.comment,
w.code buyerName,
i.isLaid
i.isLaid,
c.code company
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum,
LEFT JOIN vn.producer p ON p.id = i.producerFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.worker w ON w.id = it.workerFk
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.company c ON c.id = e.companyFk
JOIN numbers num
WHERE b.id = ?

View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<body v-for="item in items" style="break-before: page">
<body v-for="buy in buys" style="break-before: page">
<table class="leftTable">
<tr>
<td>
@ -12,7 +12,7 @@
</tr>
<tr>
<td colspan="2">
{{item.buyFk}}
{{buy.buyFk}}
</td>
</tr>
<tr>
@ -28,65 +28,65 @@
<tr>
<td colspan="3" class="lg-width black-bg center bold xl-txt padding">
<div class="overflow-line">
{{item.itemFk}}
{{buy.itemFk}}
</div>
</td>
</tr>
<tr>
<td colspan="2" class="black-bg center bold md-txt md-width md-height">
<div class="overflow-multiline">
{{item.item}}
{{buy.item}}
</div>
</td>
<td class="xs-width black-bg center bold xl-txt">
<div class="overflow-line">
{{item.size}}
{{buy.size}}
</div>
</td>
</tr>
<tr>
<td class="sm-width">
<div class="overflow-line">
<i>Color:</i> <b>{{item.inkFk}}</b>
<i>Color:</i> <b>{{buy.inkFk}}</b>
</div>
</td>
<td rowspan="2" class="xs-width center md-txt">
<div class="overflow-line cell">
{{packing || item.packing}}
{{packing || buy.packing}}
</div>
</td>
<td rowspan="2" class="xs-width center md-txt">
<div class="overflow-line cell">
{{item.stems}}
{{buy.stems}}
</div>
</td>
</tr>
<tr>
<td class="sm-width">
<div class="overflow-line">
<i>Origen:</i> {{item.origin}}
<i>Origen:</i> {{buy.origin}}
</div>
</td>
</tr>
<tr>
<td colspan="2" class="md-width">
<div class="overflow-line">
<i>Productor:</i> {{item.producerName || item.producerFk}}
<i>Productor:</i> {{buy.producerName || buy.producerFk}}
</div>
</td>
<td class="center xs-width xs-txt">
<div v-if="item.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
<div v-if="buy.isLaid && typeId === 'buy'" class="overflow-line black-bg bold">
{{'LAID'}}
</div>
<div v-else class="overflow-line">
{{item.entryFk}}
{{buy.entryFk}}
</div>
</td>
</tr>
<tr>
<td class="sm-width">
<div class="overflow-line">
<i>Comprador:</i> {{item.buyerName}}
<i>Comprador:</i> {{buy.buyerName}}
</div>
</td>
<td rowspan="2" class="xs-width">
@ -96,14 +96,14 @@
</td>
<td rowspan="2" class="xs-width center cursive bold md-txt">
<div class="overflow-line">
{{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
{{`${buy.labelNum}/${buy.quantity / (packing || buy.packing)}`}}
</div>
</td>
</tr>
<tr>
<td class="sm-width">
<div class="overflow-line">
<i>Entrada:</i> {{item.entryFk}}
<i>Entrada:</i> {{buy.entryFk}}
</div>
</td>
</tr>
@ -111,9 +111,9 @@
<td colspan="3" class="lg-width center cursive bold">
<div class="overflow-line">
{{
(item.longName && item.size && item.subName)
? `${item.longName} ${item.size} ${item.subName}`
: item.comment
(buy.longName && buy.size && buy.subName)
? `${buy.longName} ${buy.size} ${buy.subName}`
: buy.comment
}}
</div>
</td>

View File

@ -3,28 +3,18 @@ const moment = require('moment');
const qrcode = require('qrcode');
module.exports = {
name: 'item-label-qr',
name: 'buy-label-qr',
async serverPrefetch() {
this.date = Date.vnNew();
if (this.typeId === 'item') {
this.company = await this.findOneFromDef('company', [this.warehouseId]);
if (!this.company)
throw new UserError(`There is no company associated with that warehouse`);
this.lastBuy = await this.findOneFromDef('lastBuy', [
this.id,
this.warehouseId,
this.date
]);
}
this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy?.id || this.id]);
if (!this.items.length) throw new UserError(`Empty data source`);
this.qr = await this.getQr(this.items[0].buyFk);
this.buys = await this.rawSqlFromDef('buy', [this.copies || 1, this.id]);
if (!this.buys.length) throw new UserError(`Empty data source`);
this.qr = await this.getQr(this.buys[0].buyFk);
this.date = moment(this.date).format('WW/E');
},
methods: {
getQr(data) {
data = {
company: this.company,
company: this.buys.company,
user: this.userId,
created: this.date,
table: 'buy',

View File

@ -23,7 +23,8 @@ SELECT ROW_NUMBER() OVER() labelNum,
ig.subName,
i.comment,
w.code buyerName,
i.isLaid
i.isLaid,
c.code company
FROM vn.buy b
JOIN vn.item i ON i.id = b.itemFk
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
@ -31,5 +32,7 @@ SELECT ROW_NUMBER() OVER() labelNum,
LEFT JOIN vn.producer p ON p.id = i.producerFk
JOIN vn.itemType it ON it.id = i.typeFk
JOIN vn.worker w ON w.id = it.workerFk
JOIN vn.entry e ON e.id = b.entryFk
JOIN vn.company c ON c.id = e.companyFk
JOIN numbers num
WHERE b.id = ?

View File

@ -5,7 +5,7 @@ const jsBarcode = require('jsbarcode');
const moment = require('moment');
module.exports = {
name: 'buy-label',
name: 'buy-label-supplier',
mixins: [vnReport],
async serverPrefetch() {
const buy = await models.Buy.findById(this.id, null);

View File

@ -1,5 +0,0 @@
SELECT co.code
FROM warehouse w
JOIN address a ON a.id = w.addressFk
JOIN company co ON co.clientFk = a.clientFk
WHERE w.id = ?

View File

@ -1 +0,0 @@
SELECT buy_getUltimate(?, ?, ?) id

View File

@ -1,5 +0,0 @@
SELECT co.code
FROM warehouse w
JOIN address a ON a.id = w.addressFk
JOIN company co ON co.clientFk = a.clientFk
WHERE w.id = ?

View File

@ -1 +0,0 @@
SELECT buy_getUltimate(?, ?, ?) id