#6276 createNewWarehouse methods migrated from silex to salix #1850

Merged
jorgep merged 158 commits from 6276-createNewWarehouse into dev 2024-03-06 11:32:11 +00:00
2 changed files with 43 additions and 4 deletions
Showing only changes of commit e849f0b6e2 - Show all commits

View File

@ -92,9 +92,29 @@ module.exports = Self => {
for (let sale of sales) {
if (sale.ticketFk == ticketFk) {
sale.placements = placements.filter(placement =>
placement.saleFk == sale.saleFk && placement.order
);
sale.placements = [];
jorgep marked this conversation as resolved Outdated

si solo se usa en el if, porque no la defines dentro?

si solo se usa en el if, porque no la defines dentro?

@jgallego que quieres decir?

@jgallego que quieres decir?

la variable let placement moverla 2 linea abajo, incluso valorar si es const

la variable let placement moverla 2 linea abajo, incluso valorar si es const

debería ser const e ir dentro. Lo cambio

debería ser const e ir dentro. Lo cambio
for (const salePlacement of placements) {
let placement;
if (salePlacement.saleFk == sale.saleFk && salePlacement.order) {
placement = {
saleFk: salePlacement.saleFk,
itemFk: salePlacement.itemFk,
placement: salePlacement.placement,
shelving: salePlacement.shelving,
created: salePlacement.created,
visible: salePlacement.visible,
order: salePlacement.order,
grouping: salePlacement.grouping,
priority: salePlacement.priority,
saleOrder: salePlacement.saleOrder,
isPreviousPrepared: salePlacement.isPreviousPrepared,
itemShelvingSaleFk: salePlacement.itemShelvingSaleFk,
ticketFk: salePlacement.ticketFk,
id: salePlacement.id
};
sale.placements.push(placement);
}
}
sale.barcodes = [];
for (const barcode of barcodes) {
@ -143,7 +163,7 @@ module.exports = Self => {
if (state) {
await Self.rawSql(
'CALL vn.ticketStateToday_setState(?,?)',
[id, source],
[id, state],
options
);
}

View File

@ -56,4 +56,23 @@ describe('collection getSalesFromTicketOrCollection()', () => {
throw e;
}
});
it('should add a ticketTracking', async() => {
const collectionOrTicketFk = 23;
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
try {
const ticketTrackingBefore = await models.TicketTracking.find(null, options);
await models.Collection.getSalesFromTicketOrCollection(ctx,
collectionOrTicketFk, print, source, options);
const ticketTrackingAfter = await models.TicketTracking.find(null, options);
expect(ticketTrackingAfter.length).toEqual(ticketTrackingBefore.length + 1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});