feat: enhance transaction filtering by adding status criteria
parent
f76bbcf19d
commit
7967df9f1f
|
@ -111,6 +111,7 @@ export class CouchService {
|
|||
const selector = {
|
||||
created_at: {
|
||||
$gte: todayTimestamp,
|
||||
status: 'settled',
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ import {
|
|||
SalesPriceFormulaModel,
|
||||
TransactionSettingModel,
|
||||
} from '../models/sales-price-formula.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import {
|
||||
CONNECTION_NAME,
|
||||
STATUS,
|
||||
} from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
import { FormulaType } from '../../constants';
|
||||
import { TaxModel } from 'src/modules/transaction/tax/data/models/tax.model';
|
||||
|
@ -75,6 +78,7 @@ export class SalesPriceFormulaDataService extends BaseDataService<SalesPriceForm
|
|||
.where('transaction.created_at > :timestamp', {
|
||||
timestamp: todayTimestamp,
|
||||
})
|
||||
.andWhere('transaction.status = :status', { status: STATUS.SETTLED })
|
||||
.andWhere('transaction.type = :type', { type: TransactionType.COUNTER })
|
||||
.getRawOne()
|
||||
.then((result) => result.sum || 0),
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
TransactionCreateQueueEvent,
|
||||
} from '../../entities/event/transaction-change-status.event';
|
||||
import { PriceCalculator } from '../calculator/price.calculator';
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
@EventsHandler(ChangeDocEvent)
|
||||
export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
||||
|
@ -41,6 +42,7 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
|||
try {
|
||||
const database = event.data.database;
|
||||
const data = { ...event.data.data };
|
||||
Logger.log(`receipt data with code ${data?.code}`);
|
||||
|
||||
// jika bukan database transaksi, return langsung
|
||||
if (database != 'transaction') return;
|
||||
|
|
Loading…
Reference in New Issue