mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: Categorize the bank synced transactions
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
import { upperFirst, camelCase } from 'lodash';
|
||||
import { upperFirst, camelCase, omit } from 'lodash';
|
||||
import {
|
||||
CASHFLOW_TRANSACTION_TYPE,
|
||||
CASHFLOW_TRANSACTION_TYPE_META,
|
||||
ICashflowTransactionTypeMeta,
|
||||
} from './constants';
|
||||
import {
|
||||
ICashflowNewCommandDTO,
|
||||
ICashflowTransaction,
|
||||
ICategorizeCashflowTransactioDTO,
|
||||
IUncategorizedCashflowTransaction,
|
||||
} from '@/interfaces';
|
||||
|
||||
/**
|
||||
* Ensures the given transaction type to transformed to appropriate format.
|
||||
* @param {string} type
|
||||
* @param {string} type
|
||||
* @returns {string}
|
||||
*/
|
||||
export const transformCashflowTransactionType = (type) => {
|
||||
@@ -32,3 +38,29 @@ export function getCashflowTransactionType(
|
||||
export const getCashflowAccountTransactionsTypes = () => {
|
||||
return Object.values(CASHFLOW_TRANSACTION_TYPE_META).map((meta) => meta.type);
|
||||
};
|
||||
|
||||
/**
|
||||
* Tranasformes the given uncategorized transaction and categorized DTO
|
||||
* to cashflow create DTO.
|
||||
* @param {IUncategorizedCashflowTransaction} uncategorizeModel
|
||||
* @param {ICategorizeCashflowTransactioDTO} categorizeDTO
|
||||
* @returns {ICashflowNewCommandDTO}
|
||||
*/
|
||||
export const transformCategorizeTransToCashflow = (
|
||||
uncategorizeModel: IUncategorizedCashflowTransaction,
|
||||
categorizeDTO: ICategorizeCashflowTransactioDTO
|
||||
): ICashflowNewCommandDTO => {
|
||||
return {
|
||||
date: uncategorizeModel.date,
|
||||
referenceNo: categorizeDTO.referenceNo || uncategorizeModel.referenceNo,
|
||||
description: categorizeDTO.description || uncategorizeModel.description,
|
||||
cashflowAccountId: uncategorizeModel.accountId,
|
||||
creditAccountId: categorizeDTO.fromAccountId || categorizeDTO.toAccountId,
|
||||
exchangeRate: categorizeDTO.exchangeRate || 1,
|
||||
currencyCode: uncategorizeModel.currencyCode,
|
||||
amount: uncategorizeModel.amount,
|
||||
transactionNumber: categorizeDTO.transactionNumber,
|
||||
transactionType: categorizeDTO.transactionType,
|
||||
publish: true,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user