Merge branch 'master' into hotfix-6899invoiceOut
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-12-04 08:18:27 +00:00
commit 7d1e3b6751
3 changed files with 33 additions and 28 deletions

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

@ -88,6 +88,11 @@ module.exports = Self => {
arg: 'alertLevel', arg: 'alertLevel',
type: 'number', type: 'number',
description: `The alert level of the tickets` description: `The alert level of the tickets`
},
{
arg: 'countryFk',
type: 'number',
description: 'The country id filter'
} }
], ],
returns: { returns: {
@ -182,6 +187,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,
@ -360,6 +366,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;
@ -112,45 +111,42 @@ module.exports = Self => {
let stmt; let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel');
stmt = new ParameterizedSQL( stmt = new ParameterizedSQL(
`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(
CAST(SUM(b.weight * b.stickers) AS INT), GREATEST(
CAST( 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