fix: reject payback

This commit is contained in:
ilham 2022-01-06 09:41:12 +07:00
parent 36d53b2f5f
commit b7b96d0f5c

View File

@ -528,7 +528,7 @@ export class TransactionService {
await this.productHistoryPriceService.updateEndDate(product.id); await this.productHistoryPriceService.updateEndDate(product.id);
listActivePrice.map(async (x) => { listActivePrice.map(async (x) => {
let newProductPrice = new ProductHistoryPrice(); const newProductPrice = new ProductHistoryPrice();
newProductPrice.id = uuid.v4(); newProductPrice.id = uuid.v4();
newProductPrice.type = x.type; newProductPrice.type = x.type;
@ -613,30 +613,32 @@ export class TransactionService {
await manager.save(transactionData); await manager.save(transactionData);
await this.accountingTransaction({ if (statusApproval != 'accept') {
createTransaction: false, await this.accountingTransaction({
transactionalEntityManager: manager, createTransaction: false,
transaction: transactionData, transactionalEntityManager: manager,
amount: transactionData.amount, transaction: transactionData,
journals: [ amount: transactionData.amount,
{ journals: [
coa_id: coaSenderWallet.id, {
credit: transactionData.amount, coa_id: coaSenderWallet.id,
}, credit: transactionData.amount,
{ },
coa_id: coaReceiverWallet.id, {
debit: transactionData.amount, coa_id: coaReceiverWallet.id,
}, debit: transactionData.amount,
{ },
coa_id: coaAR.id, {
credit: transactionData.amount, coa_id: coaAR.id,
}, credit: transactionData.amount,
{ },
coa_id: coaAP.id, {
debit: transactionData.amount, coa_id: coaAP.id,
}, debit: transactionData.amount,
], },
}); ],
});
}
}); });
return transactionData; return transactionData;
@ -1020,6 +1022,7 @@ export class TransactionService {
if (startDate && endDate) { if (startDate && endDate) {
filter['start'] = Between(new Date(startDate), new Date(endDate)); filter['start'] = Between(new Date(startDate), new Date(endDate));
} }
const baseQuery = this.transactionRepository.findAndCount({ const baseQuery = this.transactionRepository.findAndCount({
skip: page * (pageSize || 10), skip: page * (pageSize || 10),
take: pageSize || 10, take: pageSize || 10,
@ -1028,6 +1031,7 @@ export class TransactionService {
createdAt: 'DESC', createdAt: 'DESC',
}, },
}); });
return baseQuery; return baseQuery;
} }