fix(SPG-735) Ketika recap di click berkali kali, transaksi menggunakan tipe cash jadi duplicate
parent
11171b2859
commit
d413bd771b
|
@ -48,6 +48,7 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
|
|||
`${this.tableName}.customer_name`,
|
||||
`${this.tableName}.creator_counter_no`,
|
||||
|
||||
`${this.tableName}.invoice_code`,
|
||||
`${this.tableName}.booking_date`,
|
||||
`${this.tableName}.payment_type`,
|
||||
`${this.tableName}.payment_type_method_id`,
|
||||
|
|
|
@ -72,16 +72,22 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
|||
const { creator_counter_no, payment_type, payment_type_method_id } =
|
||||
first_transaction;
|
||||
|
||||
let query = {
|
||||
is_recap_transaction: true,
|
||||
created_at: Between(this.startOfDay, this.endOfDay),
|
||||
creator_counter_no: creator_counter_no,
|
||||
payment_type: payment_type,
|
||||
};
|
||||
|
||||
if (payment_type != 'cash')
|
||||
query['payment_type_method_id'] = payment_type_method_id ?? EMPTY_UUID;
|
||||
|
||||
const exist = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
is_recap_transaction: true,
|
||||
created_at: Between(this.startOfDay, this.endOfDay),
|
||||
creator_counter_no: creator_counter_no,
|
||||
payment_type: payment_type,
|
||||
payment_type_method_id: payment_type_method_id ?? EMPTY_UUID,
|
||||
},
|
||||
where: query,
|
||||
});
|
||||
|
||||
if (payment_type == 'cash') console.log(exist, 'das', query);
|
||||
|
||||
const new_recap = new TransactionModel();
|
||||
const total = _.sumBy(this.recapTransactions[recap], (recap) =>
|
||||
parseFloat(recap.payment_total),
|
||||
|
@ -89,9 +95,8 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
|||
|
||||
if (exist) {
|
||||
Object.assign(exist, {
|
||||
payment_total: Number(exist.payment_total) + total,
|
||||
payment_total_net_profit:
|
||||
Number(exist.payment_total_net_profit) + total,
|
||||
payment_total: total,
|
||||
payment_total_net_profit: total,
|
||||
editor_id: this.user.id,
|
||||
editor_name: this.user.name,
|
||||
updated_at: new Date().getTime(),
|
||||
|
|
Loading…
Reference in New Issue