Merge pull request '#6243 generalize cmr section' (!2406) from 6243-generalizeCmrSection into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2406
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jorge Penadés 2024-06-11 07:41:19 +00:00
commit 8117b748b3
4 changed files with 19 additions and 28 deletions

View File

@ -0,0 +1,4 @@
UPDATE salix.ACL
SET property = 'cmrs'
WHERE property = 'getExternalCmrs'
AND model = 'Route';

View File

@ -3,8 +3,8 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters; const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('getExternalCmrs', { Self.remoteMethod('cmrs', {
description: 'Returns an array of external cmrs', description: 'Returns an array of cmrs',
accessType: 'READ', accessType: 'READ',
accepts: [ accepts: [
{ {
@ -47,37 +47,25 @@ module.exports = Self => {
type: 'date', type: 'date',
description: 'The to date filter', description: 'The to date filter',
}, },
{
arg: 'warehouseFk',
type: 'integer',
}
], ],
returns: { returns: {
type: ['object'], type: ['object'],
root: true root: true
}, },
http: { http: {
path: `/getExternalCmrs`, path: `/cmrs`,
verb: 'GET' verb: 'GET'
} }
}); });
Self.getExternalCmrs = async( Self.cmrs = async(
filter, filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options
cmrFk,
ticketFk,
routeFk,
country,
clientFk,
hasCmrDms,
shipped,
options
) => { ) => {
const params = { const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped};
cmrFk,
ticketFk,
routeFk,
country,
clientFk,
hasCmrDms,
shipped,
};
const conn = Self.dataSource.connector; const conn = Self.dataSource.connector;
let where = buildFilter(params, (param, value) => { let where = buildFilter(params, (param, value) => {
@ -106,7 +94,8 @@ module.exports = Self => {
co.name country, co.name country,
t.clientFk, t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms, IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped DATE(t.shipped) shipped,
t.warehouseFk
FROM ticket t FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.id = ts.stateFk JOIN state s ON s.id = ts.stateFk
@ -124,8 +113,7 @@ module.exports = Self => {
JOIN dmsType dt ON dt.id = d.dmsTypeFk JOIN dmsType dt ON dt.id = d.dmsTypeFk
WHERE dt.name = 'cmr' WHERE dt.name = 'cmr'
) sub ON sub.ticketFk = t.id ) sub ON sub.ticketFk = t.id
WHERE co.code <> 'ES' WHERE am.name <> 'ABONO'
AND am.name <> 'ABONO'
AND w.code = 'ALG' AND w.code = 'ALG'
AND t.cmrFk AND t.cmrFk
) sub ) sub

View File

@ -15,7 +15,7 @@ module.exports = Self => {
require('../methods/route/sendSms')(Self); require('../methods/route/sendSms')(Self);
require('../methods/route/downloadZip')(Self); require('../methods/route/downloadZip')(Self);
require('../methods/route/cmr')(Self); require('../methods/route/cmr')(Self);
require('../methods/route/getExternalCmrs')(Self); require('../methods/route/cmrs')(Self);
require('../methods/route/downloadCmrsZip')(Self); require('../methods/route/downloadCmrsZip')(Self);
require('../methods/route/cmrEmail')(Self); require('../methods/route/cmrEmail')(Self);
require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getExpeditionSummary')(Self);

View File

@ -39,8 +39,7 @@ SELECT c.id cmrFk,
LEFT JOIN supplier s ON s.id = c.supplierFk LEFT JOIN supplier s ON s.id = c.supplierFk
LEFT JOIN country cou ON cou.id = s.countryFk LEFT JOIN country cou ON cou.id = s.countryFk
LEFT JOIN company co ON co.id = c.companyFk LEFT JOIN company co ON co.id = c.companyFk
LEFT JOIN supplierAccount sa ON sa.id = co.supplierAccountFk LEFT JOIN supplier s2 ON s2.id = c.companyFk
LEFT JOIN supplier s2 ON s2.id = sa.supplierFk
LEFT JOIN country cou2 ON cou2.id = s2.countryFk LEFT JOIN country cou2 ON cou2.id = s2.countryFk
LEFT JOIN `address` a ON a.id = c.addressToFk LEFT JOIN `address` a ON a.id = c.addressToFk
LEFT JOIN province p ON p.id = a.provinceFk LEFT JOIN province p ON p.id = a.provinceFk