#6942 toUnbook #2135

Merged
jorgep merged 46 commits from 6942-improveInvoiceIn into dev 2024-05-29 07:03:35 +00:00
2 changed files with 7 additions and 7 deletions
Showing only changes of commit c136f2783a - Show all commits

View File

@ -18,5 +18,4 @@ VALUES
('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), ('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), ('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), ('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'buyer'),
('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), ('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'buyer');
('InvoiceIn', 'toUnbook', 'WRITE', 'ALLOW', 'ROLE', 'buyer');

View File

@ -47,10 +47,11 @@ module.exports = Self => {
} }
}, myOptions); }, myOptions);
jorgep marked this conversation as resolved
Review

El numero de ocurrencias de bookEntry.ASIEN es medio-alto.
Propongo crear una variable representativa de este valor y reemplazar donde toque.
Otro enfoque puede ser que en el if, reemplazar bookEntry.ASIEN porque ya es true

El numero de ocurrencias de bookEntry.ASIEN es medio-alto. Propongo crear una variable representativa de este valor y reemplazar donde toque. Otro enfoque puede ser que en el if, reemplazar bookEntry.ASIEN porque ya es true
Review

Me parece bien.

Me parece bien.
if (bookEntry?.ASIEN) { let asien = bookEntry?.ASIEN;
accountingEntries = await models.Xdiario.count({ASIEN: bookEntry.ASIEN}, myOptions); if (asien) {
accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions);
await models.Xdiario.destroyAll({ASIEN: bookEntry.ASIEN}, myOptions); await models.Xdiario.destroyAll({ASIEN: asien}, myOptions);
await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions); await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions);
} else { } else {
const linkedBookEntry = await models.Xdiario.findOne({ const linkedBookEntry = await models.Xdiario.findOne({
@ -61,14 +62,14 @@ module.exports = Self => {
} }
}, myOptions); }, myOptions);
bookEntry = linkedBookEntry?.ASIEN; asien = linkedBookEntry?.ASIEN;
isLinked = true; isLinked = true;
} }
if (tx) await tx.commit(); if (tx) await tx.commit();
return { return {
isLinked, isLinked,
bookEntry: bookEntry?.ASIEN, bookEntry: asien,
accountingEntries accountingEntries
}; };
} catch (e) { } catch (e) {