fix(SPG-735) Ketika recap di click berkali kali, transaksi menggunakan tipe cash jadi duplicate

pull/47/head
Aswin Ashar Abdullah 2024-08-01 17:25:12 +07:00
parent 11171b2859
commit d413bd771b
2 changed files with 16 additions and 10 deletions

View File

@ -48,6 +48,7 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
`${this.tableName}.customer_name`, `${this.tableName}.customer_name`,
`${this.tableName}.creator_counter_no`, `${this.tableName}.creator_counter_no`,
`${this.tableName}.invoice_code`,
`${this.tableName}.booking_date`, `${this.tableName}.booking_date`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,

View File

@ -72,16 +72,22 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
const { creator_counter_no, payment_type, payment_type_method_id } = const { creator_counter_no, payment_type, payment_type_method_id } =
first_transaction; first_transaction;
const exist = await this.dataService.getOneByOptions({ let query = {
where: {
is_recap_transaction: true, is_recap_transaction: true,
created_at: Between(this.startOfDay, this.endOfDay), created_at: Between(this.startOfDay, this.endOfDay),
creator_counter_no: creator_counter_no, creator_counter_no: creator_counter_no,
payment_type: payment_type, payment_type: payment_type,
payment_type_method_id: payment_type_method_id ?? EMPTY_UUID, };
},
if (payment_type != 'cash')
query['payment_type_method_id'] = payment_type_method_id ?? EMPTY_UUID;
const exist = await this.dataService.getOneByOptions({
where: query,
}); });
if (payment_type == 'cash') console.log(exist, 'das', query);
const new_recap = new TransactionModel(); const new_recap = new TransactionModel();
const total = _.sumBy(this.recapTransactions[recap], (recap) => const total = _.sumBy(this.recapTransactions[recap], (recap) =>
parseFloat(recap.payment_total), parseFloat(recap.payment_total),
@ -89,9 +95,8 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
if (exist) { if (exist) {
Object.assign(exist, { Object.assign(exist, {
payment_total: Number(exist.payment_total) + total, payment_total: total,
payment_total_net_profit: payment_total_net_profit: total,
Number(exist.payment_total_net_profit) + total,
editor_id: this.user.id, editor_id: this.user.id,
editor_name: this.user.name, editor_name: this.user.name,
updated_at: new Date().getTime(), updated_at: new Date().getTime(),