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

View File

@ -15,7 +15,7 @@ module.exports = Self => {
require('../methods/route/sendSms')(Self);
require('../methods/route/downloadZip')(Self);
require('../methods/route/cmr')(Self);
require('../methods/route/getExternalCmrs')(Self);
require('../methods/route/cmrs')(Self);
require('../methods/route/downloadCmrsZip')(Self);
require('../methods/route/cmrEmail')(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 country cou ON cou.id = s.countryFk
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 = sa.supplierFk
LEFT JOIN supplier s2 ON s2.id = c.companyFk
LEFT JOIN country cou2 ON cou2.id = s2.countryFk
LEFT JOIN `address` a ON a.id = c.addressToFk
LEFT JOIN province p ON p.id = a.provinceFk