fix: maneja si se elimina la sale
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6f35eb0ce3
commit
5af961ac69
|
@ -30,35 +30,47 @@ module.exports = Self => {
|
|||
const ticketLogs = await models.TicketLog.find(
|
||||
{
|
||||
where: {
|
||||
or: [
|
||||
{
|
||||
and: [
|
||||
{originFk: id},
|
||||
{action: 'update'},
|
||||
{changedModel: 'Sale'}
|
||||
]
|
||||
},
|
||||
{
|
||||
and: [
|
||||
{originFk: id},
|
||||
{action: 'delete'},
|
||||
{changedModel: 'Sale'}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
fields: [
|
||||
'oldInstance',
|
||||
'newInstance',
|
||||
'changedModelId'
|
||||
'changedModelId',
|
||||
'changedModelValue'
|
||||
],
|
||||
}, myOptions);
|
||||
|
||||
const changes = [];
|
||||
for (const ticketLog of ticketLogs) {
|
||||
const oldQuantity = ticketLog.oldInstance.quantity;
|
||||
const newQuantity = ticketLog.newInstance.quantity;
|
||||
|
||||
for (const log of ticketLogs) {
|
||||
const oldQuantity = log.oldInstance.quantity;
|
||||
const newQuantity = log.newInstance?.quantity || 0;
|
||||
|
||||
if (oldQuantity || newQuantity) {
|
||||
const sale = await models.Sale.findById(ticketLog.changedModelId, null, myOptions);
|
||||
const message = $t('Change quantity', {
|
||||
concept: sale.concept,
|
||||
const changeMessage = $t('Change quantity', {
|
||||
concept: log.changedModelValue,
|
||||
oldQuantity: oldQuantity || 0,
|
||||
newQuantity: newQuantity || 0,
|
||||
});
|
||||
changes.push(changeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
changes.push(message);
|
||||
}
|
||||
}
|
||||
return changes.join('\n');
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue