diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index c3b5a0dc6..c248d0deb 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -80,7 +80,7 @@ proc: BEGIN UPDATE stockBought s JOIN tStockSold ts ON ts.workerFk = s.workerFk - SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0) + SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1)) WHERE s.dated = vDated; DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold; diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 60b099682..723e04cb9 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -50,8 +50,11 @@ module.exports = Self => { i.id itemFk, i.name itemName, ti.quantity, - ROUND((ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) - / (vc.trolleyM3 * 1000000),1) volume, + ROUND((ac.conversionCoefficient * + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / (vc.trolleyM3 * 1000000), + 2) volume, b.packagingFk packagingFk, b.packing FROM tmp.item ti