refs #6184 saveCmr #1788

Merged
guillermo merged 58 commits from 6184-saveCmr into dev 2024-02-13 06:47:06 +00:00
1 changed files with 16 additions and 15 deletions
Showing only changes of commit 2792efa9cd - Show all commits

View File

@ -31,38 +31,39 @@ module.exports = Self => {
}
try {
const dmsTypeCmr = await models.DmsType.findOne({
where: {code: 'cmr'},
fields: ['id']
}, myOptions);
guillermo marked this conversation as resolved Outdated

Este el cree cada vegada pero es el mateix id per a tots. Pujal fora del for
El nom jo posaría dmsTypeCmr

Este el cree cada vegada pero es el mateix id per a tots. Pujal fora del for El nom jo posaría dmsTypeCmr
for (const ticketId of tickets) {
const ticket = await models.Ticket.findById(ticketId, myOptions);
if (ticket.cmrFk) {
const dmsType = await models.DmsType.findOne({
where: {code: 'cmr'},
fields: ['id']
}, myOptions);
const hasDmsCmr = await models.TicketDms.findOne({
where: { ticketFk: ticketId },
include: {
relation: 'dms',
fields: ['dmsFk'],
scope: {
where: { dmsTypeFk: dmsType.id }
where: { dmsTypeFk: dmsTypeCmr.id }
}
}
}, myOptions);
if (!hasDmsCmr.dms()) {
const zip = await models.Route.downloadCmrsZip(ctx, ticket.cmrFk.toString(), myOptions);
let ctxUploadFile;
ctx.req.file = Object.assign({}, zip);
guillermo marked this conversation as resolved Outdated

const

const

En eixe cas te que ser let, fijat baix.
Per a que siga const he tingut que juntar-ho.

En eixe cas te que ser let, fijat baix. Per a que siga const he tingut que juntar-ho.
ctxUploadFile = Object.assign({}, ctx);
ctxUploadFile.args = {
warehouseId: ticket.warehouseFk,
companyId: ticket.companyFk,
dmsTypeId: dmsType.id,
reference: '',
description: `${ticket.cmrFk} - ${ticket.id}`,
hasFile: false
const ctxUploadFile = {
...ctx,
args: {
warehouseId: ticket.warehouseFk,
companyId: ticket.companyFk,
dmsTypeId: dmsTypeCmr.id,
reference: ticket.id,
guillermo marked this conversation as resolved Outdated

si es dms, en reference posa ticket.cmrFk

si es dms, en reference posa ticket.cmrFk
description: `${ticket.cmrFk} - ${ticket.id}`,
guillermo marked this conversation as resolved Outdated

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

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
}
};
const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
await models.TicketDms.create({