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}.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`,
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
Loading…
Reference in New Issue