fix(transaction): priceDifference now commits its created transaction
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8fabd378e7
commit
ace1c9c84b
|
@ -66,6 +66,7 @@ module.exports = Self => {
|
|||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const isEditable = await Self.isEditable(ctx, args.id, myOptions);
|
||||
|
||||
if (!isEditable)
|
||||
|
@ -109,10 +110,6 @@ module.exports = Self => {
|
|||
for (difComponent of difComponents)
|
||||
map.set(difComponent.saleFk, difComponent);
|
||||
|
||||
function round(value) {
|
||||
return Math.round(value * 100) / 100;
|
||||
}
|
||||
|
||||
for (sale of salesObj.items) {
|
||||
const difComponent = map.get(sale.id);
|
||||
|
||||
|
@ -130,6 +127,16 @@ module.exports = Self => {
|
|||
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return salesObj;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
function round(value) {
|
||||
return Math.round(value * 100) / 100;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue