hotFix(ticket): refs #7225 fix advanced and movable #2356

Merged
alexm merged 6 commits from 7225-hotFix_ticket_advanced_movable into master 2024-04-25 05:52:40 +00:00
2 changed files with 5 additions and 8 deletions
Showing only changes of commit 0cd740ce0c - Show all commits

View File

@ -118,7 +118,7 @@ module.exports = Self => {
const [salesMovable] = await Self.rawSql(query, params, myOptions); const [salesMovable] = await Self.rawSql(query, params, myOptions);
const itemMovable = new Map(); const itemMovable = new Map();
for (sale of salesMovable) { for (let sale of salesMovable) {
const saleMovable = sale.movable ? sale.movable : 0; const saleMovable = sale.movable ? sale.movable : 0;
itemMovable.set(sale.id, saleMovable); itemMovable.set(sale.id, saleMovable);
} }
@ -129,7 +129,7 @@ module.exports = Self => {
const [difComponents] = await Self.rawSql(query, params, myOptions); const [difComponents] = await Self.rawSql(query, params, myOptions);
const map = new Map(); const map = new Map();
for (difComponent of difComponents) for (let difComponent of difComponents)
map.set(difComponent.saleFk, difComponent); map.set(difComponent.saleFk, difComponent);
for (sale of salesObj.items) { for (sale of salesObj.items) {

View File

@ -1,5 +1,4 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const UserError = require('vn-loopback/util/user-error');
const ForbiddenError = require('vn-loopback/util/forbiddenError'); const ForbiddenError = require('vn-loopback/util/forbiddenError');
describe('sale priceDifference()', () => { describe('sale priceDifference()', () => {
@ -83,12 +82,10 @@ describe('sale priceDifference()', () => {
warehouseId: 1 warehouseId: 1
}; };
const result = await models.Ticket.priceDifference(ctx, options); const {items} = await models.Ticket.priceDifference(ctx, options);
const firstItem = result.items[0];
const secondtItem = result.items[1];
expect(firstItem.movable).toEqual(380); expect(items[0].movable).toEqual(410);
expect(secondtItem.movable).toEqual(1790); expect(items[1].movable).toEqual(1810);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {