feat: refs #4734 Added viaexpress interdia
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-01-16 13:05:16 +01:00
parent f5372cb801
commit 5bbeda4014
6 changed files with 14 additions and 8 deletions

View File

@ -20,7 +20,7 @@ module.exports = Self => {
} }
}); });
Self.internationalExpedition = async expeditionFk => { Self.internationalExpedition = async (expeditionFk) => {
const models = Self.app.models; const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({ const viaexpressConfig = await models.ViaexpressConfig.findOne({

View File

@ -20,11 +20,11 @@ module.exports = Self => {
} }
}); });
Self.renderer = async expeditionFk => { Self.renderer = async (expeditionFk) => {
const models = Self.app.models; const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({ const viaexpressConfig = await models.ViaexpressConfig.findOne({
fields: ['client', 'user', 'password', 'defaultWeight', 'deliveryType'] fields: ['client', 'user', 'password', 'defaultWeight', 'deliveryType', 'agencyModeFk']
}); });
const expedition = await models.Expedition.findOne({ const expedition = await models.Expedition.findOne({
@ -34,7 +34,7 @@ module.exports = Self => {
{ {
relation: 'ticket', relation: 'ticket',
scope: { scope: {
fields: ['shipped', 'addressFk', 'clientFk', 'companyFk'], fields: ['shipped', 'addressFk', 'clientFk', 'companyFk', 'agencyModeFk'],
include: [ include: [
{ {
relation: 'client', relation: 'client',
@ -102,7 +102,6 @@ module.exports = Self => {
} }
] ]
} }
} }
] ]
}); });
@ -110,13 +109,15 @@ module.exports = Self => {
const ticket = expedition.ticket(); const ticket = expedition.ticket();
const sender = ticket.company().client(); const sender = ticket.company().client();
const shipped = ticket.shipped.toISOString(); const shipped = ticket.shipped.toISOString();
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk)
const data = { const data = {
viaexpressConfig, viaexpressConfig,
sender, sender,
senderAddress: sender.defaultAddress(), senderAddress: sender.defaultAddress(),
client: ticket.client(), client: ticket.client(),
address: ticket.address(), address: ticket.address(),
shipped shipped,
isInterdia
}; };
const template = fs.readFileSync(__dirname + '/template.ejs', 'utf-8'); const template = fs.readFileSync(__dirname + '/template.ejs', 'utf-8');

View File

@ -13,7 +13,7 @@
<Asegurado>0</Asegurado> <Asegurado>0</Asegurado>
<Imprimir>0</Imprimir> <Imprimir>0</Imprimir>
<ConDevolucionAlbaran>0</ConDevolucionAlbaran> <ConDevolucionAlbaran>0</ConDevolucionAlbaran>
<Intradia>0</Intradia> <Intradia><%= isInterdia %></Intradia>
<Observaciones></Observaciones> <Observaciones></Observaciones>
<AlbaranRemitente></AlbaranRemitente> <AlbaranRemitente></AlbaranRemitente>
<Modo>0</Modo> <Modo>0</Modo>

View File

@ -29,6 +29,9 @@
}, },
"deliveryType": { "deliveryType": {
"type": "string" "type": "string"
},
"agencyModeFk": {
"type": "number"
} }
} }
} }

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.viaexpressConfig ADD agencyModeFk int DEFAULT NULL NULL COMMENT 'Indica el agencyMode que es interdia';
ALTER TABLE vn.viaexpressConfig ADD CONSTRAINT viaexpressConfig_agencyMode_Fk FOREIGN KEY (agencyModeFK) REFERENCES vn.agencyMode(id) ON DELETE RESTRICT ON UPDATE RESTRICT;

View File

@ -5,7 +5,7 @@ module.exports = Self => {
accepts: [ accepts: [
{ {
arg: 'workerFk', arg: 'workerFk',
type: 'int', type: 'number',
required: true, required: true,
}, },