8355-testToMaster #3336

Merged
alexm merged 241 commits from 8355-testToMaster into master 2025-01-07 06:44:57 +00:00
13 changed files with 74 additions and 58 deletions
Showing only changes of commit 34f9f9b29f - Show all commits

View File

@ -1,15 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bi`.`rotacion`
AS SELECT `ic`.`itemFk` AS `Id_Article`,
`ic`.`warehouseFk` AS `warehouse_id`,
`ic`.`quantity` AS `total`,
`ic`.`rotation` AS `rotacion`,
`ic`.`cm3` AS `cm3`,
`ic`.`storage` AS `almacenaje`,
`ic`.`handling` AS `manipulacion`,
`ic`.`extraCharge` AS `auxiliar`,
`ic`.`wasted` AS `mermas`,
`ic`.`cm3delivery` AS `cm3reparto`,
`ic`.`grams` AS `grams`
FROM `vn`.`itemCost` `ic`

View File

@ -54,7 +54,9 @@ proc:BEGIN
WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated)
AND clientFk = vClientFk AND clientFk = vClientFk
AND addressFk = vAddressFk AND addressFk = vAddressFk
AND warehouseFk = vWarehouseFk; AND warehouseFk = vWarehouseFk
AND nickname = 'CAJAS AUTOCONSUMO'
LIMIT 1;
IF vTicketFk IS NULL AND vAction = 'add' THEN IF vTicketFk IS NULL AND vAction = 'add' THEN
INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk)

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.ticket DROP FOREIGN KEY tickets_zone_fk;
ALTER TABLE vn.ticket ADD CONSTRAINT tickets_zone_fk FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -9,6 +9,10 @@ module.exports = Self => {
required: true, required: true,
description: 'The entry id', description: 'The entry id',
http: {source: 'path'} http: {source: 'path'}
}, {
arg: 'showEntryLines',
type: 'boolean',
required: false
} }
], ],
returns: [ returns: [

View File

@ -47,8 +47,7 @@ module.exports = Self => {
for (const buy of buys) { for (const buy of buys) {
if (buy.stickers < 1) continue; if (buy.stickers < 1) continue;
ctx.args.id = buy.id; ctx.args = {...ctx.args, id: buy.id, showEntryLines: true};
ctx.args.copies = buy.stickers;
const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions);
await merger.add(new Uint8Array(pdfBuffer[0])); await merger.add(new Uint8Array(pdfBuffer[0]));
} }

View File

@ -14,6 +14,12 @@ module.exports = Self => {
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'} http: {source: 'query'}
}, },
{
arg: 'id',
type: 'number',
description: 'The invoiceOut id',
http: {source: 'query'}
},
{ {
arg: 'search', arg: 'search',
type: 'string', type: 'string',
@ -106,6 +112,8 @@ module.exports = Self => {
return {'i.created': value}; return {'i.created': value};
case 'clientFk': case 'clientFk':
return {'i.clientFk': value}; return {'i.clientFk': value};
case 'id':
return {'i.id': value};
case 'fi': case 'fi':
return {'c.fi': value}; return {'c.fi': value};
case 'amount': case 'amount':

View File

@ -178,17 +178,18 @@ module.exports = Self => {
i.isFloramondo, i.isFloramondo,
i.recycledPlastic, i.recycledPlastic,
i.nonRecycledPlastic, i.nonRecycledPlastic,
pr.name AS producer, pr.name producer,
it.name AS typeName, it.name typeName,
it.workerFk AS buyerFk, it.workerFk buyerFk,
u.name AS userName, u.name userName,
ori.code AS origin, ori.code origin,
ic.name AS category, ic.name category,
i.intrastatFk, i.intrastatFk,
intr.description AS intrastat, intr.description intrastat,
b.grouping, b.grouping,
b.packing, b.packing,
lb.landing AS landed lb.landing landed,
it.name typeName
FROM item i FROM item i
LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk

View File

@ -93,6 +93,11 @@ module.exports = Self => {
arg: 'packing', arg: 'packing',
type: 'string', type: 'string',
description: `The packing of the items` description: `The packing of the items`
},
{
arg: 'countryFk',
type: 'number',
description: 'The country id filter'
} }
], ],
returns: { returns: {
@ -189,6 +194,7 @@ module.exports = Self => {
t.totalWithVat, t.totalWithVat,
io.id invoiceOutId, io.id invoiceOutId,
a.provinceFk, a.provinceFk,
p.countryFk,
p.name province, p.name province,
w.name warehouse, w.name warehouse,
am.name agencyMode, am.name agencyMode,
@ -374,6 +380,7 @@ module.exports = Self => {
} }
case 'agencyModeFk': case 'agencyModeFk':
case 'warehouseFk': case 'warehouseFk':
case 'countryFk':
param = `f.${param}`; param = `f.${param}`;
return {[param]: value}; return {[param]: value};
} }

View File

@ -1,4 +1,3 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter; const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters; const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
@ -115,42 +114,39 @@ module.exports = Self => {
`CREATE TEMPORARY TABLE tmp.travel `CREATE TEMPORARY TABLE tmp.travel
(INDEX (id)) (INDEX (id))
ENGINE = MEMORY ENGINE = MEMORY
SELECT SELECT t.id,
t.id,
t.ref, t.ref,
t.shipped, t.shipped,
t.landed, t.landed,
t.kg, t.kg,
am.id AS agencyModeFk, am.id agencyModeFk,
am.name AS agencyModeName, am.name agencyModeName,
wo.id AS warehouseOutFk, wo.id warehouseOutFk,
wo.name AS warehouseOutName, wo.name warehouseOutName,
w.name AS warehouseInFk, w.name warehouseInFk,
w.name AS warehouseInName, w.name warehouseInName,
SUM(b.stickers) AS stickers, SUM(b.stickers) stickers,
s.id AS cargoSupplierFk, s.id cargoSupplierFk,
s.nickname AS cargoSupplierNickname, s.nickname cargoSupplierNickname,
s.name AS supplierName, s.name supplierName,
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg,
CAST( CAST(
SUM( SUM(
vc.aerealVolumetricDensity * vc.aerealVolumetricDensity *
b.stickers * b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
) as DECIMAL(10,0) ) AS DECIMAL(10,0)
) as volumeKg, ) volumeKg,
GREATEST(
CAST(SUM(b.weight * b.stickers) AS INT),
CAST( CAST(
GREATEST(
SUM(b.weight * b.stickers) ,
SUM(vc.aerealVolumetricDensity * SUM(vc.aerealVolumetricDensity *
b.stickers * b.stickers *
IF(pkg.volume, IF(pkg.volume,
pkg.volume, pkg.volume,
pkg.width * pkg.depth * pkg.height pkg.width * pkg.depth * pkg.height) / 1000000)
) / 1000000 ) / t.kg * 100 AS INT
) AS INT ) percentageKg
)
/ t.kg * 100, 0) percentageKg
FROM travel t FROM travel t
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id LEFT JOIN entry e ON e.travelFk = t.id

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "24.50.0", "version": "24.52.0",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@ -86,7 +86,7 @@
<td> <td>
<div class="cell"> <div class="cell">
<span class="lbl">{{$t('boxNum')}}</span> <span class="lbl">{{$t('boxNum')}}</span>
{{`${buy.labelNum} / ${buy.maxLabelNum}`}} {{getTotal(buy)}}
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -9,7 +9,7 @@ module.exports = {
mixins: [vnReport], mixins: [vnReport],
async serverPrefetch() { async serverPrefetch() {
const buy = await models.Buy.findById(this.id, null); const buy = await models.Buy.findById(this.id, null);
this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]);
const date = new Date(); const date = new Date();
this.weekNum = moment(date).isoWeek(); this.weekNum = moment(date).isoWeek();
this.dayNum = moment(date).day(); this.dayNum = moment(date).day();
@ -27,6 +27,11 @@ module.exports = {
height: 115, height: 115,
}); });
return new XMLSerializer().serializeToString(svgNode); return new XMLSerializer().serializeToString(svgNode);
},
getTotal(buy) {
return (this.showEntryLines) ?
`${buy.entryLabelNum} / ${buy.entryLabels}` :
`${buy.buyLabelNum} / ${buy.buyLabels}`;
} }
}, },
props: { props: {
@ -34,6 +39,10 @@ module.exports = {
type: Number, type: Number,
required: true, required: true,
description: 'The entry id' description: 'The entry id'
},
showEntryLines: {
type: Boolean,
required: false
} }
} }
}; };

View File

@ -10,7 +10,7 @@ WITH RECURSIVE numbers AS (
) )
), ),
labels AS ( labels AS (
SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) entryLabelNum,
i.name, i.name,
i.`size`, i.`size`,
i.category, i.category,
@ -33,6 +33,9 @@ labels AS (
WHERE b.entryFk = ? WHERE b.entryFk = ?
AND num.n <= b.stickers AND num.n <= b.stickers
) )
SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum SELECT *,
ROW_NUMBER() OVER(ORDER BY entryLabelNum) buyLabelNum,
(SELECT SUM(stickers) FROM buy WHERE entryFk = ?) entryLabels,
(SELECT stickers FROM buy WHERE id = ?) buyLabels
FROM labels FROM labels
WHERE id = ? WHERE id = ?