Refactor sellAllProducts method in FalukantService to ensure atomic transactions for selling products, updating inventory, and handling financial transactions. Implement batch processing for sell items and enhance error handling for inventory deletions. Update updateFalukantUserMoney function to support transactions, improving consistency and reliability in financial operations.
This commit is contained in:
@@ -401,7 +401,7 @@ const updateSchema = async (models) => {
|
||||
console.log('✅ Datenbankschema aktualisiert');
|
||||
};
|
||||
|
||||
async function updateFalukantUserMoney(falukantUserId, moneyChange, activity, changedBy = null) {
|
||||
async function updateFalukantUserMoney(falukantUserId, moneyChange, activity, changedBy = null, transaction = null) {
|
||||
try {
|
||||
const result = await sequelize.query(
|
||||
`SELECT falukant_data.update_money(
|
||||
@@ -418,6 +418,7 @@ async function updateFalukantUserMoney(falukantUserId, moneyChange, activity, ch
|
||||
changedBy,
|
||||
},
|
||||
type: sequelize.QueryTypes.SELECT,
|
||||
transaction: transaction || undefined,
|
||||
}
|
||||
);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user