#6276 createNewWarehouse methods migrated from silex to salix #1850
|
@ -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 = [];
|
||||
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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue