mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: wip categorized transactions
This commit is contained in:
@@ -90,7 +90,7 @@ export class PlaidSyncDb {
|
||||
tenantId,
|
||||
uncategoriedDTO
|
||||
),
|
||||
{ concurrency: CONCURRENCY_ASYNC }
|
||||
{ concurrency: 1 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,9 @@ export const transformPlaidTrxsToCashflowCreate = R.curry(
|
||||
): CreateUncategorizedTransactionDTO => {
|
||||
return {
|
||||
date: plaidTranasction.date,
|
||||
description: plaidTranasction.name,
|
||||
amount: plaidTranasction.amount,
|
||||
description: plaidTranasction.name,
|
||||
payee: plaidTranasction.payment_meta?.payee,
|
||||
currencyCode: plaidTranasction.iso_currency_code,
|
||||
accountId: cashflowAccountId,
|
||||
referenceNo: plaidTranasction.payment_meta?.reference_number,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
import UnitOfWork from '../UnitOfWork';
|
||||
import UnitOfWork, { IsolationLevel } from '../UnitOfWork';
|
||||
import { Knex } from 'knex';
|
||||
import { CreateUncategorizedTransactionDTO } from '@/interfaces';
|
||||
|
||||
@@ -21,15 +21,20 @@ export class CreateUncategorizedTransaction {
|
||||
tenantId: number,
|
||||
createDTO: CreateUncategorizedTransactionDTO
|
||||
) {
|
||||
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
|
||||
const { UncategorizedCashflowTransaction, Account } =
|
||||
this.tenancy.models(tenantId);
|
||||
|
||||
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
||||
const transaction = await UncategorizedCashflowTransaction.query(
|
||||
trx
|
||||
).insertAndFetch({
|
||||
...createDTO,
|
||||
});
|
||||
return transaction;
|
||||
});
|
||||
return this.uow.withTransaction(
|
||||
tenantId,
|
||||
async (trx: Knex.Transaction) => {
|
||||
const transaction = await UncategorizedCashflowTransaction.query(
|
||||
trx
|
||||
).insertAndFetch({
|
||||
...createDTO,
|
||||
});
|
||||
|
||||
return transaction;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,12 @@ export class UncategorizedTransactionTransformer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattetDepositAmount(transaction) {
|
||||
return formatNumber(transaction.deposit, {
|
||||
currencyCode: transaction.currencyCode,
|
||||
});
|
||||
if (transaction.isDepositTransaction) {
|
||||
return formatNumber(transaction.deposit, {
|
||||
currencyCode: transaction.currencyCode,
|
||||
});
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,8 +43,11 @@ export class UncategorizedTransactionTransformer extends Transformer {
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedWithdrawalAmount(transaction) {
|
||||
return formatNumber(transaction.withdrawal, {
|
||||
currencyCode: transaction.currencyCode,
|
||||
});
|
||||
if (transaction.isWithdrawalTransaction) {
|
||||
return formatNumber(transaction.withdrawal, {
|
||||
currencyCode: transaction.currencyCode,
|
||||
});
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user