Merge pull request 'hotfix length sales' (!1785) from 4764-hotfixServices into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1785
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Carlos Satorres 2023-10-10 10:33:00 +00:00
commit 93db2663a8
1 changed files with 2 additions and 4 deletions

View File

@ -55,7 +55,7 @@ module.exports = Self => {
const refoundZoneId = refundAgencyMode.zones()[0].id;
if (salesIds) {
if (salesIds.length) {
const salesFilter = {
where: {id: {inq: salesIds}},
include: {
@ -91,16 +91,14 @@ module.exports = Self => {
await models.SaleComponent.create(components, myOptions);
}
}
if (!refundTicket) {
const servicesFilter = {
where: {id: {inq: servicesIds}}
};
const services = await models.TicketService.find(servicesFilter, myOptions);
const ticketsIds = [...new Set(services.map(service => service.ticketFk))];
const firstTicketId = services[0].ticketFk;
const now = Date.vnNew();
const [firstTicketId] = ticketsIds;
// eslint-disable-next-line max-len
refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);