Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6818-addDefaultChannel
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-14 16:32:40 +01:00
commit 86c95e185c
13 changed files with 82 additions and 40 deletions

View File

@ -39,6 +39,9 @@ module.exports = Self => {
const xmlString = response.data; const xmlString = response.data;
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', xmlDoc]);
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
return result.toLowerCase().includes('se ha cancelado correctamente'); return result.toLowerCase().includes('se ha cancelado correctamente');
}; };

View File

@ -59,7 +59,7 @@ proc: BEGIN
INSERT INTO stockBought(workerFk, bought, dated) INSERT INTO stockBought(workerFk, bought, dated)
SELECT tb.workerFk, SELECT tb.workerFk,
ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1), ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 2),
vDated vDated
FROM tStockBought tb FROM tStockBought tb
LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk; LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk;

View File

@ -1,3 +1,2 @@
UPDATE vn.sale -- Debido a que tardaba mucho en la subida a master, se ha creado una nueva versión para que el proceso no se vea afectado y se ejecute por la noche.
SET originalQuantity = quantity -- Se crea de nuevo en la versión 11344-grayBamboo
WHERE originalQuantity IS NULL

View File

@ -0,0 +1,3 @@
UPDATE vn.sale
SET originalQuantity = quantity
WHERE originalQuantity IS NULL

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.clientObservation MODIFY COLUMN observationTypeFk tinyint(3) unsigned DEFAULT 4 NOT NULL;
UPDATE vn.clientObservation SET observationTypeFk=4 WHERE observationTypeFk=0;

View File

@ -55,7 +55,7 @@
"relation": "user", "relation": "user",
"scope": { "scope": {
"fields": [ "fields": [
"nickname" "name"
] ]
} }
} }

View File

@ -6,6 +6,9 @@ module.exports = Self => {
arg: 'workerFk', arg: 'workerFk',
type: 'number', type: 'number',
description: 'The id for a buyer', description: 'The id for a buyer',
}, {
arg: 'filter',
type: 'object',
}, },
{ {
arg: 'dated', arg: 'dated',
@ -23,7 +26,7 @@ module.exports = Self => {
} }
}); });
Self.getStockBought = async(workerFk, dated = Date.vnNew()) => { Self.getStockBought = async(workerFk, filter, dated = Date.vnNew()) => {
const models = Self.app.models; const models = Self.app.models;
const today = Date.vnNew(); const today = Date.vnNew();
dated.setHours(0, 0, 0, 0); dated.setHours(0, 0, 0, 0);
@ -31,7 +34,7 @@ module.exports = Self => {
await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]);
const filter = { const defaultFilter = {
where: {dated}, where: {dated},
include: [ include: [
{ {
@ -53,6 +56,6 @@ module.exports = Self => {
if (workerFk) filter.where.workerFk = workerFk; if (workerFk) filter.where.workerFk = workerFk;
return models.StockBought.find(filter); return models.StockBought.find({...filter, ...defaultFilter});
}; };
}; };

View File

@ -1,3 +1,4 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('getStockBoughtDetail', { Self.remoteMethod('getStockBoughtDetail', {
description: 'Returns the detail of stock bought for a given date and a worker', description: 'Returns the detail of stock bought for a given date and a worker',
@ -12,6 +13,9 @@ module.exports = Self => {
type: 'string', type: 'string',
description: 'The date to filter', description: 'The date to filter',
required: true, required: true,
}, {
arg: 'filter',
type: 'object',
} }
], ],
returns: { returns: {
@ -24,11 +28,10 @@ module.exports = Self => {
} }
}); });
Self.getStockBoughtDetail = async(workerFk, dated) => { Self.getStockBoughtDetail = async(workerFk, dated, filter, options) => {
const models = Self.app.models; const conn = Self.dataSource.connector;
const myOptions = {}; const myOptions = {};
let tx; let tx;
let result;
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
@ -39,8 +42,10 @@ module.exports = Self => {
} }
try { try {
await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions); const stmts = [];
result = await Self.rawSql( stmts.push(new ParameterizedSQL(`CALL vn.item_calculateStock(?)`, [dated]));
const query = new ParameterizedSQL(
`SELECT b.entryFk entryFk, `SELECT b.entryFk entryFk,
i.id itemFk, i.id itemFk,
i.name itemName, i.name itemName,
@ -61,11 +66,17 @@ module.exports = Self => {
JOIN volumeConfig vc JOIN volumeConfig vc
WHERE ic.display WHERE ic.display
AND w.id = ?`, AND w.id = ?`,
[workerFk], myOptions [workerFk]
); );
await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions);
stmts.push(query.merge(conn.makeSuffix(filter)));
stmts.push(new ParameterizedSQL(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate`));
const sql = ParameterizedSQL.join(stmts, ';');
const result = await conn.executeStmt(sql, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();
return result; return result[1];
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();
throw e; throw e;

View File

@ -18,3 +18,13 @@ h3 {
font-size: 10px; font-size: 10px;
margin: 0; margin: 0;
} }
.column-oriented th,
.column-oriented td{
padding: 5px
}
[row] {
display: flex;
column-gap: 5px;
}

View File

@ -41,42 +41,50 @@
<table class="column-oriented vn-mt-ml border-collapse"> <table class="column-oriented vn-mt-ml border-collapse">
<thead> <thead>
<tr> <tr>
<th width="5%">{{$t('code')}}</th>
<th class="number">{{$t('boxes')}}</th> <th class="number">{{$t('boxes')}}</th>
<th width="5%" class="number"></th> <th width="1px" class="number"></th>
<th class="number">{{$t('packing')}}</th> <th class="number">{{$t('packing')}}</th>
<th width="40%">{{$t('concept')}}</th> <th width="5%">{{$t('concept')}}</th>
<th width="10%">{{$t('reference')}}</th> <th width="20%">{{$t('reference')}}</th>
<th width="10%">{{$t('tags')}}</th> <th width="20%">{{$t('tags')}}</th>
<th width="10%" class="number">{{$t('quantity')}}</th> <th width="5%" class="number">{{$t('quantity')}}</th>
<th width="5%" class="number"></th> <th width="1px" class="number"></th>
<th width="15%" class="number">{{$t('price')}}</th> <th width="5%" class="number">{{$t('price')}}</th>
<th width="5%" class="number"></th> <th width="1px" class="number"></th>
<th width="15%" class="number">{{$t('amount')}}</th> <th width="5%" class="number">{{$t('amount')}}</th>
</tr> </tr>
</thead> </thead>
<tbody v-for="buy in buys"> <tbody v-for="buy in buys">
<tr> <tr>
<td width="5%">{{buy.itemFk}}</td>
<td class="number">{{buy.stickers}}</td> <td class="number">{{buy.stickers}}</td>
<td width="5%" class="number">x</td> <td width="1px" class="number">x</td>
<td class="number">{{buy.packing}}</td> <td class="number align-left">{{buy.packing}}</td>
<td width="40%" class="nowrap">{{buy.name}}</td> <td width="5%" class="nowrap">{{buy.name}}</td>
<td width="10%">{{buy.comment}}</td> <td width="20%">referencia de prueba</td>
<td width="10%" class="font light-gray tags"> <td width="20%" class="font light-gray tags" row>
<span v-if="buy.value5" class="nowrap"><strong>{{buy.tag5}} → </strong>{{buy.value5}} </span> <div>
<span v-if="buy.value6" class="nowrap"><strong>{{buy.tag6}} → </strong>{{buy.value6}} </span> <div class="nowrap" v-if="buy.value5">{{buy.tag5}}<strong>→ {{buy.value5}}</strong></div>
<span v-if="buy.value7" class="nowrap"><strong>{{buy.tag7}} → </strong>{{buy.value7}} </span> <div class="nowrap" v-if="buy.value6">{{buy.tag6}}<strong>→ {{buy.value6}}</strong></div>
</div>
<div>
<div class="nowrap" v-if="buy.value7">{{buy.tag7}}<strong>→ {{buy.value7}}</strong></div>
<div class="nowrap" v-if="buy.value8">{{buy.tag8}}<strong>→ {{buy.value8}}</strong></div>
</div>
</td> </td>
<td width="10%" class="number">{{buy.quantity | number($i18n.locale)}}</td> <td width="5%" class="number">{{buy.quantity | number($i18n.locale)}}</td>
<td width="5%" class="number">x</td> <td width="1px" class="number">x</td>
<td width="15%" class="number">{{buy.buyingValue | currency('EUR', $i18n.locale)}}</td> <td width="5%" class="number">{{buy.buyingValue | currency('EUR', $i18n.locale)}}</td>
<td width="5%" class="number">=</td> <td width="1px" class="number">=</td>
<td width="15%" class="number"> <td width="5%" class="number align-left">
{{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}} {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tfoot> <tfoot>
<tr class="font bold"> <tr class="font bold">
<td></td>
<td class="number">{{getTotalBy('stickers')}}</td> <td class="number">{{getTotalBy('stickers')}}</td>
<td></td> <td></td>
<td></td> <td></td>

View File

@ -16,4 +16,5 @@ entry: Entrada {0}
supplierData: Datos del proveedor supplierData: Datos del proveedor
notes: Notas notes: Notas
reference: Referencia reference: Referencia
tags: Tags tags: Etiquetas
code: Código

View File

@ -10,7 +10,9 @@ SELECT b.itemFk,
i.tag6, i.tag6,
i.value6, i.value6,
i.tag7, i.tag7,
i.value7 i.value7,
i.tag8,
i.value8
FROM buy b FROM buy b
JOIN item i ON i.id = b.itemFk JOIN item i ON i.id = b.itemFk
LEFT JOIN item i2 ON i2.id = b.itemOriginalFk LEFT JOIN item i2 ON i2.id = b.itemOriginalFk