refs #6184 saveCmr #1788
|
@ -31,38 +31,39 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const ticketId of tickets) {
|
const dmsTypeCmr = await models.DmsType.findOne({
|
||||||
const ticket = await models.Ticket.findById(ticketId, myOptions);
|
|
||||||
|
|
||||||
if (ticket.cmrFk) {
|
|
||||||
const dmsType = await models.DmsType.findOne({
|
|
||||||
where: {code: 'cmr'},
|
where: {code: 'cmr'},
|
||||||
fields: ['id']
|
fields: ['id']
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
guillermo marked this conversation as resolved
Outdated
|
|||||||
|
for (const ticketId of tickets) {
|
||||||
|
const ticket = await models.Ticket.findById(ticketId, myOptions);
|
||||||
|
|
||||||
|
if (ticket.cmrFk) {
|
||||||
const hasDmsCmr = await models.TicketDms.findOne({
|
const hasDmsCmr = await models.TicketDms.findOne({
|
||||||
where: { ticketFk: ticketId },
|
where: { ticketFk: ticketId },
|
||||||
include: {
|
include: {
|
||||||
relation: 'dms',
|
relation: 'dms',
|
||||||
fields: ['dmsFk'],
|
fields: ['dmsFk'],
|
||||||
scope: {
|
scope: {
|
||||||
where: { dmsTypeFk: dmsType.id }
|
where: { dmsTypeFk: dmsTypeCmr.id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (!hasDmsCmr.dms()) {
|
if (!hasDmsCmr.dms()) {
|
||||||
const zip = await models.Route.downloadCmrsZip(ctx, ticket.cmrFk.toString(), myOptions);
|
const zip = await models.Route.downloadCmrsZip(ctx, ticket.cmrFk.toString(), myOptions);
|
||||||
let ctxUploadFile;
|
|
||||||
ctx.req.file = Object.assign({}, zip);
|
ctx.req.file = Object.assign({}, zip);
|
||||||
guillermo marked this conversation as resolved
Outdated
jgallego
commented
const const
guillermo
commented
En eixe cas te que ser let, fijat baix. En eixe cas te que ser let, fijat baix.
Per a que siga const he tingut que juntar-ho.
|
|||||||
ctxUploadFile = Object.assign({}, ctx);
|
const ctxUploadFile = {
|
||||||
ctxUploadFile.args = {
|
...ctx,
|
||||||
|
args: {
|
||||||
warehouseId: ticket.warehouseFk,
|
warehouseId: ticket.warehouseFk,
|
||||||
companyId: ticket.companyFk,
|
companyId: ticket.companyFk,
|
||||||
dmsTypeId: dmsType.id,
|
dmsTypeId: dmsTypeCmr.id,
|
||||||
reference: '',
|
reference: ticket.id,
|
||||||
guillermo marked this conversation as resolved
Outdated
jgallego
commented
si es dms, en reference posa ticket.cmrFk si es dms, en reference posa ticket.cmrFk
|
|||||||
description: `${ticket.cmrFk} - ${ticket.id}`,
|
description: `${ticket.cmrFk} - ${ticket.id}`,
|
||||||
guillermo marked this conversation as resolved
Outdated
jgallego
commented
al ser el tipo cmr, no es neceario poner cmr, pueden buscar por tipo al ser el tipo cmr, no es neceario poner cmr, pueden buscar por tipo
quitar texto en español.
Propuesta: poner cmr: cmrFk, ticket: ticketFk
|
|||||||
hasFile: false
|
hasFile: false
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
||||||
await models.TicketDms.create({
|
await models.TicketDms.create({
|
||||||
|
|
Loading…
Reference in New Issue
Este el cree cada vegada pero es el mateix id per a tots. Pujal fora del for
El nom jo posaría dmsTypeCmr