fix: formatted transaction type

This commit is contained in:
Ahmed Bouhuolia
2025-06-15 15:22:19 +02:00
parent bcae2dae03
commit bbf9ef9bc2
29 changed files with 248 additions and 67 deletions

View File

@@ -1,5 +1,4 @@
import { ACCOUNT_TYPE } from "@/constants/accounts";
import { ACCOUNT_TYPE } from '@/constants/accounts';
export const ERRORS = {
CASHFLOW_TRANSACTION_TYPE_INVALID: 'CASHFLOW_TRANSACTION_TYPE_INVALID',
@@ -111,35 +110,34 @@ export const BankTransactionsSampleData = [
},
];
export const CashflowTransactionTypes = {
OtherIncome: 'Other income',
OtherExpense: 'Other expense',
OwnerDrawing: 'Owner drawing',
OwnerContribution: 'Owner contribution',
TransferToAccount: 'Transfer to account',
TransferFromAccount: 'Transfer from account',
OtherIncome: 'transaction_type.other_income',
OtherExpense: 'transaction_type.other_expense',
OwnerDrawing: 'transaction_type.owner_drawing',
OwnerContribution: 'transaction_type.owner_contribution',
TransferToAccount: 'transaction_type.transfer_to_account',
TransferFromAccount: 'transaction_type.transfer_from_account',
};
export const TransactionTypes = {
SaleInvoice: 'Sale invoice',
SaleReceipt: 'Sale receipt',
PaymentReceive: 'Payment received',
Bill: 'Bill',
BillPayment: 'Payment made',
VendorOpeningBalance: 'Vendor opening balance',
CustomerOpeningBalance: 'Customer opening balance',
InventoryAdjustment: 'Inventory adjustment',
ManualJournal: 'Manual journal',
Journal: 'Manual journal',
Expense: 'Expense',
OwnerContribution: 'Owner contribution',
TransferToAccount: 'Transfer to account',
TransferFromAccount: 'Transfer from account',
OtherIncome: 'Other income',
OtherExpense: 'Other expense',
OwnerDrawing: 'Owner drawing',
InvoiceWriteOff: 'Invoice write-off',
SaleInvoice: 'transaction_type.sale_invoice',
SaleReceipt: 'transaction_type.sale_receipt',
PaymentReceive: 'transaction_type.payment_received',
Bill: 'transaction_type.bill',
BillPayment: 'transaction_type.payment_made',
VendorOpeningBalance: 'transaction_type.vendor_opening_balance',
CustomerOpeningBalance: 'transaction_type.customer_opening_balance',
InventoryAdjustment: 'transaction_type.inventory_adjustment',
ManualJournal: 'transaction_type.manual_journal',
Journal: 'transaction_type.manual_journal',
Expense: 'transaction_type.expense',
OwnerContribution: 'transaction_type.owner_contribution',
TransferToAccount: 'transaction_type.transfer_to_account',
TransferFromAccount: 'transaction_type.transfer_from_account',
OtherIncome: 'transaction_type.other_income',
OtherExpense: 'transaction_type.other_expense',
OwnerDrawing: 'transaction_type.owner_drawing',
InvoiceWriteOff: 'transaction_type.invoice_write_off',
CreditNote: 'transaction_type.credit_note',
VendorCredit: 'transaction_type.vendor_credit',
RefundCreditNote: 'transaction_type.refund_credit_note',

View File

@@ -3,11 +3,13 @@ import { getBankAccountTransactionsDefaultQuery } from './_utils';
import { GetBankAccountTransactionsRepository } from './GetBankAccountTransactionsRepo.service';
import { GetBankAccountTransactions } from './GetBankAccountTransactions';
import { GetBankTransactionsQueryDto } from '../../dtos/GetBankTranasctionsQuery.dto';
import { I18nService } from 'nestjs-i18n';
@Injectable()
export class GetBankAccountTransactionsService {
constructor(
private readonly getBankAccountTransactionsRepository: GetBankAccountTransactionsRepository,
private readonly i18nService: I18nService
) {}
/**
@@ -30,6 +32,7 @@ export class GetBankAccountTransactionsService {
const report = new GetBankAccountTransactions(
this.getBankAccountTransactionsRepository,
parsedQuery,
this.i18nService
);
const transactions = report.reportData();
const pagination = this.getBankAccountTransactionsRepository.pagination;

View File

@@ -11,11 +11,13 @@ import { FinancialSheet } from '@/modules/FinancialStatements/common/FinancialSh
import { formatBankTransactionsStatus } from './_utils';
import { GetBankAccountTransactionsRepository } from './GetBankAccountTransactionsRepo.service';
import { runningBalance } from '@/utils/running-balance';
import { I18nService } from 'nestjs-i18n';
export class GetBankAccountTransactions extends FinancialSheet {
private runningBalance: any;
private query: ICashflowAccountTransactionsQuery;
private repo: GetBankAccountTransactionsRepository;
private i18n: I18nService;
/**
* Constructor method.
@@ -26,11 +28,14 @@ export class GetBankAccountTransactions extends FinancialSheet {
constructor(
repo: GetBankAccountTransactionsRepository,
query: ICashflowAccountTransactionsQuery,
i18n: I18nService,
) {
super();
this.repo = repo;
this.query = query;
this.i18n = i18n;
this.runningBalance = runningBalance(this.repo.openingBalance);
}
@@ -104,7 +109,7 @@ export class GetBankAccountTransactions extends FinancialSheet {
referenceId: transaction.referenceId,
referenceType: transaction.referenceType,
formattedTransactionType: transaction.referenceTypeFormatted,
formattedTransactionType: this.i18n.t(transaction.referenceTypeFormatted),
transactionNumber: transaction.transactionNumber,
referenceNumber: transaction.referenceNumber,