add log updateReservationAndLoadingBalance

This commit is contained in:
WildanFahri
2025-01-13 19:23:33 +07:00
parent aec06cb481
commit ba20dce4d1
@@ -623,6 +623,9 @@ const updateReservationAndLoadingBalance = async (
.where('c_load_balance_no', data.c_load_balance_no)
.then(() => {
// insert load balance history
winston.logger.debug(
`${uniqueCode} result insert t_d_load_balance_history updateReservationAndLoadingBalance success`
);
return knex('trx.t_d_load_balance_history')
.transacting(trx)
.returning('i_load_balance')
@@ -648,6 +651,9 @@ const updateReservationAndLoadingBalance = async (
});
});
winston.logger.debug(
`${uniqueCode} result insert t_d_load_balance_history_detail updateReservationAndLoadingBalance success`
);
// insert detail load balance
return knex('trx.t_d_load_balance_history_detail')
.transacting(trx)
@@ -655,6 +661,9 @@ const updateReservationAndLoadingBalance = async (
})
.then(() => {
// update reservation
winston.logger.debug(
`${uniqueCode} result insert t_d_reservation_balance updateReservationAndLoadingBalance success`
);
return knex('trx.t_d_reservation_balance')
.transacting(trx)
.update({
@@ -671,8 +680,19 @@ const updateReservationAndLoadingBalance = async (
})
.whereIn('c_reservation_no', reservationNumber);
})
.then(trx.commit)
.catch(trx.rollback);
.then(() => {
winston.logger.debug(
`${uniqueCode} commit update t_d_reservation_balance updateReservationAndLoadingBalance`
);
trx.commit();
})
.catch((error) => {
winston.logger.debug(
`${uniqueCode} rollback update t_d_reservation_balance updateReservationAndLoadingBalance: ${error.message}`
);
trx.rollback(); // Rollback transaction
throw error; // Rethrow error to outer catch
});
})
.then((result) => {
winston.logger.debug(