Merge branch 'dev' into 7258-lastChangesMigrationVn2008
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
60a3ec99d0
|
@ -155,27 +155,28 @@ BEGIN
|
|||
SET @currentLineFk := 0;
|
||||
SET @shipped := '';
|
||||
|
||||
SELECT DATE(@shipped:= shipped) shipped,
|
||||
alertLevel,
|
||||
stateName,
|
||||
origin,
|
||||
reference,
|
||||
clientFk,
|
||||
name,
|
||||
`in` invalue,
|
||||
`out`,
|
||||
@a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0) balance,
|
||||
SELECT DATE(@shipped:= t.shipped) shipped,
|
||||
t.alertLevel,
|
||||
t.stateName,
|
||||
t.origin,
|
||||
t.reference,
|
||||
t.clientFk,
|
||||
t.name,
|
||||
t.`in` invalue,
|
||||
t.`out`,
|
||||
@a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance,
|
||||
@currentLineFk := IF (@shipped < util.VN_CURDATE()
|
||||
OR (@shipped = util.VN_CURDATE() AND (isPicked OR a.`code` >= 'ON_PREPARATION')),
|
||||
lineFk,
|
||||
OR (@shipped = util.VN_CURDATE() AND (t.isPicked OR a.`code` >= 'ON_PREPARATION')),
|
||||
t.lineFk,
|
||||
@currentLineFk) lastPreparedLineFk,
|
||||
isTicket,
|
||||
lineFk,
|
||||
isPicked,
|
||||
clientType,
|
||||
claimFk
|
||||
FROM tItemDiary
|
||||
LEFT JOIN alertLevel a ON a.id = tItemDiary.alertLevel;
|
||||
t.isTicket,
|
||||
t.lineFk,
|
||||
t.isPicked,
|
||||
t.clientType,
|
||||
t.claimFk,
|
||||
t.`order`
|
||||
FROM tItemDiary t
|
||||
LEFT JOIN alertLevel a ON a.id = t.alertLevel;
|
||||
|
||||
ELSE
|
||||
SELECT SUM(`in`) - SUM(`out`) INTO @a
|
||||
|
@ -197,7 +198,8 @@ BEGIN
|
|||
0 lineFk,
|
||||
0 isPicked,
|
||||
0 clientType,
|
||||
0 claimFk
|
||||
0 claimFk,
|
||||
NULL `order`
|
||||
UNION ALL
|
||||
SELECT shipped,
|
||||
alertlevel,
|
||||
|
@ -213,7 +215,8 @@ BEGIN
|
|||
lineFk,
|
||||
isPicked,
|
||||
clientType,
|
||||
claimFk
|
||||
claimFk,
|
||||
`order`
|
||||
FROM tItemDiary
|
||||
WHERE shipped >= vDate;
|
||||
END IF;
|
||||
|
|
|
@ -8,38 +8,14 @@ BEGIN
|
|||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed <= vDateToAdvance
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL);
|
||||
CALL item_getMinacum(
|
||||
vWarehouseFk,
|
||||
vDateToAdvance,
|
||||
DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance),
|
||||
NULL
|
||||
);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
|
@ -87,7 +63,7 @@ BEGIN
|
|||
count(s.id) futureLines,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock,
|
||||
SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock,
|
||||
z.id futureZoneFk,
|
||||
z.name futureZoneName,
|
||||
st.classColor,
|
||||
|
@ -107,7 +83,9 @@ BEGIN
|
|||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
JOIN zone z ON t.zoneFk = z.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = i.id
|
||||
LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id
|
||||
AND im.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN tmp.itemList il ON il.itemFk = i.id
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
|
@ -146,6 +124,8 @@ BEGIN
|
|||
) dest ON dest.addressFk = origin.addressFk
|
||||
WHERE origin.hasStock;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.itemList,
|
||||
tmp.itemMinacum;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -21,7 +21,7 @@ BEGIN
|
|||
WHERE t.id = vTicketFk;
|
||||
|
||||
-- Añadimos un dia más para calcular el stock hasta vNewShipped inclusive
|
||||
CALL item_getStock(vWarehouseFk, DATE_ADD(vNewShipped, INTERVAL 1 DAY), NULL);
|
||||
CALL item_getStock(vWarehouseFk, vNewShipped, NULL);
|
||||
CALL item_getMinacum(
|
||||
vWarehouseFk,
|
||||
vNewShipped,
|
||||
|
@ -38,7 +38,7 @@ BEGIN
|
|||
s.discount,
|
||||
i.image,
|
||||
i.subName,
|
||||
il.stock + IFNULL(im.amount, 0) AS movable
|
||||
IFNULL(il.stock,0) + IFNULL(im.amount, 0) AS movable
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
|
|
|
@ -150,7 +150,7 @@ module.exports = Self => {
|
|||
const salesNewTicket = salesMovable.filter(sale => (sale.movable ? sale.movable : 0) >= sale.quantity);
|
||||
|
||||
const salesNewTicketLength = salesNewTicket.length;
|
||||
if (salesNewTicketLength && sales.length != salesNewTicketLength) {
|
||||
if (salesNewTicketLength && (args.newTicket || sales.length != salesNewTicketLength)) {
|
||||
const newTicket = await models.Ticket.transferSales(
|
||||
ctx,
|
||||
args.id,
|
||||
|
|
|
@ -118,7 +118,7 @@ module.exports = Self => {
|
|||
const [salesMovable] = await Self.rawSql(query, params, myOptions);
|
||||
|
||||
const itemMovable = new Map();
|
||||
for (sale of salesMovable) {
|
||||
for (let sale of salesMovable) {
|
||||
const saleMovable = sale.movable ? sale.movable : 0;
|
||||
itemMovable.set(sale.id, saleMovable);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ module.exports = Self => {
|
|||
const [difComponents] = await Self.rawSql(query, params, myOptions);
|
||||
|
||||
const map = new Map();
|
||||
for (difComponent of difComponents)
|
||||
for (let difComponent of difComponents)
|
||||
map.set(difComponent.saleFk, difComponent);
|
||||
|
||||
for (sale of salesObj.items) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||
|
||||
describe('sale priceDifference()', () => {
|
||||
|
@ -83,12 +82,10 @@ describe('sale priceDifference()', () => {
|
|||
warehouseId: 1
|
||||
};
|
||||
|
||||
const result = await models.Ticket.priceDifference(ctx, options);
|
||||
const firstItem = result.items[0];
|
||||
const secondtItem = result.items[1];
|
||||
const {items} = await models.Ticket.priceDifference(ctx, options);
|
||||
|
||||
expect(firstItem.movable).toEqual(380);
|
||||
expect(secondtItem.movable).toEqual(1790);
|
||||
expect(items[0].movable).toEqual(410);
|
||||
expect(items[1].movable).toEqual(1810);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue