8179-testToMaster #3176

Merged
alexm merged 407 commits from 8179-testToMaster into master 2024-11-12 06:41:52 +00:00
1 changed files with 16 additions and 7 deletions
Showing only changes of commit 459f6601b7 - Show all commits

View File

@ -26,12 +26,20 @@ module.exports = Self => {
Self.getStockBoughtDetail = async(workerFk, dated) => {
const models = Self.app.models;
await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated]);
const tx = await models.Collection.beginTransaction({});
const options = {transaction: tx};
const myOptions = {};
let tx;
let result;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], options);
await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions);
result = await Self.rawSql(
`SELECT b.entryFk entryFk,
i.id itemFk,
@ -53,13 +61,14 @@ module.exports = Self => {
JOIN volumeConfig vc
WHERE ic.display
AND w.id = ?`,
[workerFk], options
[workerFk], myOptions
);
await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], options);
await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions);
if (tx) await tx.commit();
return result;
} catch (e) {
await tx.rollback();
throw e;
}
return result;
};
};