fix: Cashflow transactions types

This commit is contained in:
Ahmed Bouhuolia
2024-07-09 14:47:30 +02:00
parent aa89653967
commit 533006b90e
7 changed files with 113 additions and 25 deletions

View File

@@ -1,5 +1,36 @@
import { TransactionTypes } from '@/data/TransactionTypes';
import { isObject, upperFirst, camelCase } from 'lodash';
import {
TransactionTypes,
CashflowTransactionTypes,
} from '@/data/TransactionTypes';
export const getTransactionTypeLabel = (transactionType: string) => {
return TransactionTypes[transactionType];
/**
* Retrieves the formatted type of account transaction.
* @param {string} referenceType
* @param {string} transactionType
* @returns {string}
*/
export const getTransactionTypeLabel = (
referenceType: string,
transactionType?: string
) => {
const _referenceType = upperFirst(camelCase(referenceType));
const _transactionType = upperFirst(camelCase(transactionType));
return isObject(TransactionTypes[_referenceType])
? TransactionTypes[_referenceType][_transactionType]
: TransactionTypes[_referenceType] || null;
};
/**
* Retrieves the formatted type of cashflow transaction.
* @param {string} transactionType
* @returns {string¿}
*/
export const getCashflowTransactionFormattedType = (
transactionType: string
) => {
const _transactionType = upperFirst(camelCase(transactionType));
return CashflowTransactionTypes[_transactionType] || null;
};