mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
Merge pull request #877 from bigcapitalhq/fix-import-bank-transactions
fix: import bank transactions
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
import uniqid from 'uniqid';
|
import * as uniqid from 'uniqid';
|
||||||
import { Importable } from '../../Import/Importable';
|
import { Importable } from '../../Import/Importable';
|
||||||
import { CreateUncategorizedTransactionService } from './CreateUncategorizedTransaction.service';
|
import { CreateUncategorizedTransactionService } from './CreateUncategorizedTransaction.service';
|
||||||
import { ImportableContext } from '../../Import/interfaces';
|
import { ImportableContext } from '../../Import/interfaces';
|
||||||
@@ -9,8 +9,10 @@ import { BankTransactionsSampleData } from '../../BankingTransactions/constants'
|
|||||||
import { Account } from '@/modules/Accounts/models/Account.model';
|
import { Account } from '@/modules/Accounts/models/Account.model';
|
||||||
import { CreateUncategorizedTransactionDTO } from '../types/BankingCategorize.types';
|
import { CreateUncategorizedTransactionDTO } from '../types/BankingCategorize.types';
|
||||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { ImportableService } from '../../Import/decorators/Import.decorator';
|
||||||
|
import { UncategorizedBankTransaction } from '../../BankingTransactions/models/UncategorizedBankTransaction';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ImportableService({ name: UncategorizedBankTransaction.name })
|
||||||
export class UncategorizedTransactionsImportable extends Importable {
|
export class UncategorizedTransactionsImportable extends Importable {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly createUncategorizedTransaction: CreateUncategorizedTransactionService,
|
private readonly createUncategorizedTransaction: CreateUncategorizedTransactionService,
|
||||||
|
|||||||
@@ -83,4 +83,4 @@ const models = [
|
|||||||
CreateBankTransactionService
|
CreateBankTransactionService
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class BankingTransactionsModule {}
|
export class BankingTransactionsModule { }
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
export const UncategorizedBankTransactionMeta = {
|
||||||
|
defaultFilterField: 'createdAt',
|
||||||
|
defaultSort: {
|
||||||
|
sortOrder: 'DESC',
|
||||||
|
sortField: 'created_at',
|
||||||
|
},
|
||||||
|
importable: true,
|
||||||
|
fields: {
|
||||||
|
date: {
|
||||||
|
name: 'Date',
|
||||||
|
column: 'date',
|
||||||
|
fieldType: 'date',
|
||||||
|
},
|
||||||
|
payee: {
|
||||||
|
name: 'Payee',
|
||||||
|
column: 'payee',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: 'Description',
|
||||||
|
column: 'description',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
referenceNo: {
|
||||||
|
name: 'Reference No.',
|
||||||
|
column: 'reference_no',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
amount: {
|
||||||
|
name: 'Amount',
|
||||||
|
column: 'Amount',
|
||||||
|
fieldType: 'numeric',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
name: 'Account',
|
||||||
|
column: 'account_id',
|
||||||
|
fieldType: 'relation',
|
||||||
|
to: { model: 'Account', to: 'id' },
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
name: 'Created At',
|
||||||
|
column: 'createdAt',
|
||||||
|
fieldType: 'date',
|
||||||
|
importable: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fields2: {
|
||||||
|
date: {
|
||||||
|
name: 'Date',
|
||||||
|
fieldType: 'date',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
payee: {
|
||||||
|
name: 'Payee',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
name: 'Description',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
referenceNo: {
|
||||||
|
name: 'Reference No.',
|
||||||
|
fieldType: 'text',
|
||||||
|
},
|
||||||
|
amount: {
|
||||||
|
name: 'Amount',
|
||||||
|
fieldType: 'number',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -2,7 +2,10 @@
|
|||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { Model } from 'objection';
|
import { Model } from 'objection';
|
||||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||||
|
import { UncategorizedBankTransactionMeta } from './UncategorizedBankTransaction.meta';
|
||||||
|
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||||
|
|
||||||
|
@InjectModelMeta(UncategorizedBankTransactionMeta)
|
||||||
export class UncategorizedBankTransaction extends TenantBaseModel {
|
export class UncategorizedBankTransaction extends TenantBaseModel {
|
||||||
readonly amount!: number;
|
readonly amount!: number;
|
||||||
readonly date!: Date | string;
|
readonly date!: Date | string;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class ImportFileCommon {
|
|||||||
private readonly importFileValidator: ImportFileDataValidator,
|
private readonly importFileValidator: ImportFileDataValidator,
|
||||||
private readonly resource: ResourceService,
|
private readonly resource: ResourceService,
|
||||||
private readonly importableRegistry: ImportableRegistry,
|
private readonly importableRegistry: ImportableRegistry,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports the given parsed data to the resource storage through registered importable service.
|
* Imports the given parsed data to the resource storage through registered importable service.
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export class ImportFileUploadService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
const _params = this.importFileCommon.transformParams(resource, params);
|
const _params = await this.importFileCommon.transformParams(resource, params);
|
||||||
const paramsStringified = JSON.stringify(_params);
|
const paramsStringified = JSON.stringify(_params);
|
||||||
|
|
||||||
const tenant = await this.tenancyContext.getTenant();
|
const tenant = await this.tenancyContext.getTenant();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const TABLES = {
|
|||||||
EXPENSES: 'expenses',
|
EXPENSES: 'expenses',
|
||||||
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
||||||
CASHFLOW_Transactions: 'cashflow_transactions',
|
CASHFLOW_Transactions: 'cashflow_transactions',
|
||||||
UNCATEGORIZED_CASHFLOW_TRANSACTION: 'UNCATEGORIZED_CASHFLOW_TRANSACTION',
|
UNCATEGORIZED_BANK_TRANSACTION: 'UNCATEGORIZED_BANK_TRANSACTION',
|
||||||
CREDIT_NOTES: 'credit_notes',
|
CREDIT_NOTES: 'credit_notes',
|
||||||
VENDOR_CREDITS: 'vendor_credits',
|
VENDOR_CREDITS: 'vendor_credits',
|
||||||
WAREHOUSE_TRANSFERS: 'warehouse_transfers',
|
WAREHOUSE_TRANSFERS: 'warehouse_transfers',
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function AccountTransactionsDataTable({
|
|||||||
|
|
||||||
// Local storage memorizing columns widths.
|
// Local storage memorizing columns widths.
|
||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.UNCATEGORIZED_CASHFLOW_TRANSACTION);
|
useMemorizedColumnsWidths(TABLES.UNCATEGORIZED_BANK_TRANSACTION);
|
||||||
|
|
||||||
// Handle cell click.
|
// Handle cell click.
|
||||||
const handleCellClick = (cell) => {
|
const handleCellClick = (cell) => {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default function ImportUncategorizedTransactions() {
|
|||||||
return (
|
return (
|
||||||
<DashboardInsider name={'import-uncategorized-bank-transactions'}>
|
<DashboardInsider name={'import-uncategorized-bank-transactions'}>
|
||||||
<ImportView
|
<ImportView
|
||||||
resource={'uncategorized_cashflow_transaction'}
|
resource={'uncategorized_bank_transaction'}
|
||||||
params={{ accountId: params.id }}
|
params={{ accountId: params.id }}
|
||||||
onImportSuccess={handleImportSuccess}
|
onImportSuccess={handleImportSuccess}
|
||||||
onCancelClick={handleCnacelBtnClick}
|
onCancelClick={handleCnacelBtnClick}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ const invalidateResourcesOnImport = (
|
|||||||
queryClient.invalidateQueries(T.MANUAL_JOURNALS);
|
queryClient.invalidateQueries(T.MANUAL_JOURNALS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'UncategorizedCashflowTransaction':
|
case 'UncategorizedBankTransaction':
|
||||||
queryClient.invalidateQueries(T.CASH_FLOW_TRANSACTIONS);
|
queryClient.invalidateQueries(T.CASH_FLOW_TRANSACTIONS);
|
||||||
queryClient.invalidateQueries(T.CASH_FLOW_TRANSACTIONS);
|
queryClient.invalidateQueries(T.CASH_FLOW_TRANSACTIONS);
|
||||||
queryClient.invalidateQueries(T.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
queryClient.invalidateQueries(T.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||||
|
|||||||
Reference in New Issue
Block a user