From a5eb42edafd0a1d2990211f8c00940f32e3566c4 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 3 Jul 2024 18:49:21 +0200 Subject: [PATCH] feat: wip bank transaction matching --- .../Banking/ReconcileBankController.ts | 30 --------------- .../BankAccounts/GetBankAccountSummary.ts | 2 + .../Matching/GetMatchedTransactions.ts | 1 - .../Matching/GetMatchedTransactionsByType.ts | 3 +- .../AppContentShell.module.scss} | 0 .../AppContentShell.tsx} | 28 +++++++------- .../AppContentShellProvider.tsx} | 0 .../AppShell/AppContentShell/index.ts | 1 + .../webapp/src/components/AppShell/index.ts | 1 + .../Rules/RulesList/RulesListActionsBar.tsx | 8 ++-- .../Banking/Rules/RulesList/RulesTable.tsx | 7 ---- .../AccountTransactionsList.tsx | 14 +++---- .../AccountTransactionsUncategorizedTable.tsx | 12 ++---- ...ncategorizedTransactionsFilterProvider.tsx | 37 ------------------- .../AllTransactionsUncategorized.tsx | 12 +++--- .../RecognizedTransactionsTable.tsx | 1 - 16 files changed, 39 insertions(+), 118 deletions(-) delete mode 100644 packages/server/src/api/controllers/Banking/ReconcileBankController.ts rename packages/webapp/src/components/AppShell/{AppShell.module.scss => AppContentShell/AppContentShell.module.scss} (100%) rename packages/webapp/src/components/AppShell/{AppShell.tsx => AppContentShell/AppContentShell.tsx} (58%) rename packages/webapp/src/components/AppShell/{AppShellProvider.tsx => AppContentShell/AppContentShellProvider.tsx} (100%) create mode 100644 packages/webapp/src/components/AppShell/AppContentShell/index.ts create mode 100644 packages/webapp/src/components/AppShell/index.ts delete mode 100644 packages/webapp/src/containers/CashFlow/AccountTransactions/AccountUncategorizedTransactionsFilterProvider.tsx diff --git a/packages/server/src/api/controllers/Banking/ReconcileBankController.ts b/packages/server/src/api/controllers/Banking/ReconcileBankController.ts deleted file mode 100644 index 4aa08a295..000000000 --- a/packages/server/src/api/controllers/Banking/ReconcileBankController.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { body } from 'express-validator'; -import BaseController from '../BaseController'; -import { Router } from 'express'; -import { Service } from 'typedi'; - -@Service() -export class BankReconcileController extends BaseController { - /** - * Router constructor. - */ - public router() { - const router = Router(); - - router.post( - '/', - [ - body('amount').exists(), - body('date').exists(), - body('fromAccountId').exists(), - body('toAccountId').exists(), - body('reference').optional({ nullable: true }), - ], - this.validationResult, - this.createBankReconcileTransaction.bind(this) - ); - return router; - } - - createBankReconcileTransaction() {} -} diff --git a/packages/server/src/services/Banking/BankAccounts/GetBankAccountSummary.ts b/packages/server/src/services/Banking/BankAccounts/GetBankAccountSummary.ts index a3cb35b98..6a07e614a 100644 --- a/packages/server/src/services/Banking/BankAccounts/GetBankAccountSummary.ts +++ b/packages/server/src/services/Banking/BankAccounts/GetBankAccountSummary.ts @@ -24,12 +24,14 @@ export class GetBankAccountSummary { .findById(bankAccountId) .throwIfNotFound(); + // Retrieves the uncategorized transactions count of the given bank account. const uncategorizedTranasctionsCount = await UncategorizedCashflowTransaction.query() .where('accountId', bankAccountId) .count('id as total') .first(); + // Retrieves the recognized transactions count of the given bank account. const recognizedTransactionsCount = await RecognizedBankTransaction.query() .whereExists( UncategorizedCashflowTransaction.query().where( diff --git a/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts b/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts index bbe41a5aa..43f5ba532 100644 --- a/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts +++ b/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts @@ -100,7 +100,6 @@ export class GetMatchedTransactions { moment(match.date).isSame(uncategorizedTransaction.date, 'day'), closestResullts ); - const possibleMatches = R.difference(closestResullts, perfectMatches); return { perfectMatches, possibleMatches }; diff --git a/packages/server/src/services/Banking/Matching/GetMatchedTransactionsByType.ts b/packages/server/src/services/Banking/Matching/GetMatchedTransactionsByType.ts index 2d3ed07f8..ad036fa98 100644 --- a/packages/server/src/services/Banking/Matching/GetMatchedTransactionsByType.ts +++ b/packages/server/src/services/Banking/Matching/GetMatchedTransactionsByType.ts @@ -8,7 +8,6 @@ import { } from './types'; import { Inject, Service } from 'typedi'; -// @Service() export abstract class GetMatchedTransactionsByType { @Inject() protected tenancy: HasTenancyService; @@ -17,6 +16,7 @@ export abstract class GetMatchedTransactionsByType { * Retrieves the matched transactions. * @param {number} tenantId - * @param {GetMatchedTransactionsFilter} filter - + * @returns {Promise} */ public async getMatchedTransactions( tenantId: number, @@ -31,6 +31,7 @@ export abstract class GetMatchedTransactionsByType { * Retrieves the matched transaction details. * @param {number} tenantId - * @param {number} transactionId - + * @returns {Promise} */ public async getMatchedTransaction( tenantId: number, diff --git a/packages/webapp/src/components/AppShell/AppShell.module.scss b/packages/webapp/src/components/AppShell/AppContentShell/AppContentShell.module.scss similarity index 100% rename from packages/webapp/src/components/AppShell/AppShell.module.scss rename to packages/webapp/src/components/AppShell/AppContentShell/AppContentShell.module.scss diff --git a/packages/webapp/src/components/AppShell/AppShell.tsx b/packages/webapp/src/components/AppShell/AppContentShell/AppContentShell.tsx similarity index 58% rename from packages/webapp/src/components/AppShell/AppShell.tsx rename to packages/webapp/src/components/AppShell/AppContentShell/AppContentShell.tsx index 57a84133a..6ebbfb8b1 100644 --- a/packages/webapp/src/components/AppShell/AppShell.tsx +++ b/packages/webapp/src/components/AppShell/AppContentShell/AppContentShell.tsx @@ -1,25 +1,25 @@ import React from 'react'; -import { AppShellProvider, useAppShellContext } from './AppShellProvider'; -import { Box } from '../Layout'; +import { AppShellProvider, useAppShellContext } from './AppContentShellProvider'; +import { Box, BoxProps } from '../../Layout'; import styles from './AppShell.module.scss'; -interface AppShellProps { +interface AppContentShellProps { topbarOffset?: number; - mainProps: any; - asideProps: any; + mainProps?: BoxProps; + asideProps?: BoxProps; children: React.ReactNode; hideAside?: boolean; hideMain?: boolean; } -export function AppShell({ +export function AppContentShell({ asideProps, mainProps, topbarOffset = 0, hideAside = false, hideMain = false, ...restProps -}: AppShellProps) { +}: AppContentShellProps) { return ( ; } -interface AppShellAsideProps { +interface AppContentShellAsideProps extends BoxProps { children: React.ReactNode; } -function AppShellAside({ ...props }: AppShellAsideProps) { +function AppContentShellAside({ ...props }: AppContentShellAsideProps) { const { hideAside } = useAppShellContext(); - console.log(hideAside, 'hideAsidehideAsidehideAsidehideAside'); if (hideAside === true) { return null; } return ; } + +AppContentShell.Main = AppContentShellMain; +AppContentShell.Aside = AppContentShellAside; diff --git a/packages/webapp/src/components/AppShell/AppShellProvider.tsx b/packages/webapp/src/components/AppShell/AppContentShell/AppContentShellProvider.tsx similarity index 100% rename from packages/webapp/src/components/AppShell/AppShellProvider.tsx rename to packages/webapp/src/components/AppShell/AppContentShell/AppContentShellProvider.tsx diff --git a/packages/webapp/src/components/AppShell/AppContentShell/index.ts b/packages/webapp/src/components/AppShell/AppContentShell/index.ts new file mode 100644 index 000000000..1979e45a6 --- /dev/null +++ b/packages/webapp/src/components/AppShell/AppContentShell/index.ts @@ -0,0 +1 @@ +export * from './AppContentShell'; diff --git a/packages/webapp/src/components/AppShell/index.ts b/packages/webapp/src/components/AppShell/index.ts new file mode 100644 index 000000000..1979e45a6 --- /dev/null +++ b/packages/webapp/src/components/AppShell/index.ts @@ -0,0 +1 @@ +export * from './AppContentShell'; diff --git a/packages/webapp/src/containers/Banking/Rules/RulesList/RulesListActionsBar.tsx b/packages/webapp/src/containers/Banking/Rules/RulesList/RulesListActionsBar.tsx index 1a020dfcf..2516c1563 100644 --- a/packages/webapp/src/containers/Banking/Rules/RulesList/RulesListActionsBar.tsx +++ b/packages/webapp/src/containers/Banking/Rules/RulesList/RulesListActionsBar.tsx @@ -3,7 +3,6 @@ import { Button, Classes, NavbarGroup } from '@blueprintjs/core'; import * as R from 'ramda'; import { Can, DashboardActionsBar, Icon } from '@/components'; import { AbilitySubject, BankRuleAction } from '@/constants/abilityOption'; -import withAlertActions from '@/containers/Alert/withAlertActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { DialogsName } from '@/constants/dialogs'; @@ -31,7 +30,6 @@ function RulesListActionsBarRoot({ ); } -export const RulesListActionsBar = R.compose( - withDialogActions, - withAlertActions, -)(RulesListActionsBarRoot); +export const RulesListActionsBar = R.compose(withDialogActions)( + RulesListActionsBarRoot, +); diff --git a/packages/webapp/src/containers/Banking/Rules/RulesList/RulesTable.tsx b/packages/webapp/src/containers/Banking/Rules/RulesList/RulesTable.tsx index 9ad4fcd6b..771c5ae16 100644 --- a/packages/webapp/src/containers/Banking/Rules/RulesList/RulesTable.tsx +++ b/packages/webapp/src/containers/Banking/Rules/RulesList/RulesTable.tsx @@ -8,9 +8,7 @@ import { } from '@/components'; import withAlertsActions from '@/containers/Alert/withAlertActions'; -import withDrawerActions from '@/containers/Drawer/withDrawerActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; -import withDashboardActions from '@/containers/Dashboard/withDashboardActions'; import { useBankRulesTableColumns } from './hooks'; import { BankRulesTableActionsMenu } from './_components'; @@ -25,9 +23,6 @@ function RulesTable({ // #withAlertsActions openAlert, - // #withDrawerActions - openDrawer, - // #withDialogAction openDialog, }) { @@ -81,8 +76,6 @@ function RulesTable({ } export const BankRulesTable = R.compose( - withDashboardActions, withAlertsActions, - withDrawerActions, withDialogActions, )(RulesTable); diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsList.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsList.tsx index 5f0d743ab..671747706 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsList.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsList.tsx @@ -15,7 +15,7 @@ import { import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar'; import { AccountTransactionsProgressBar } from './components'; import { AccountTransactionsFilterTabs } from './AccountTransactionsFilterTabs'; -import { AppShell } from '@/components/AppShell/AppShell'; +import { AppContentShell } from '@/components/AppShell'; import { CategorizeTransactionAside } from '../CategorizeTransactionAside/CategorizeTransactionAside'; import { withBanking } from '../withBanking'; @@ -28,8 +28,8 @@ function AccountTransactionsListRoot({ }) { return ( - - + + @@ -41,12 +41,12 @@ function AccountTransactionsListRoot({ - + - + - - + + ); } diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsUncategorizedTable.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsUncategorizedTable.tsx index 326a71358..5fbe79118 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsUncategorizedTable.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountTransactionsUncategorizedTable.tsx @@ -1,7 +1,7 @@ // @ts-nocheck import React from 'react'; import styled from 'styled-components'; - +import { Intent } from '@blueprintjs/core'; import { DataTable, TableFastCell, @@ -14,7 +14,6 @@ import { import { TABLES } from '@/constants/tables'; import withSettings from '@/containers/Settings/withSettings'; -import withDrawerActions from '@/containers/Drawer/withDrawerActions'; import { withBankingActions } from '../withBankingActions'; import { useMemorizedColumnsWidths } from '@/hooks'; @@ -26,7 +25,6 @@ import { useAccountUncategorizedTransactionsContext } from './AllTransactionsUnc import { compose } from '@/utils'; import { useExcludeUncategorizedTransaction } from '@/hooks/query/bank-rules'; -import { Intent } from '@blueprintjs/core'; /** * Account transactions data table. @@ -37,9 +35,6 @@ function AccountTransactionsDataTable({ // #withBankingActions setUncategorizedTransactionIdForMatching, - - // #withDrawerActions - openDrawer, }) { // Retrieve table columns. const columns = useAccountUncategorizedTransactionsColumns(); @@ -102,7 +97,9 @@ function AccountTransactionsDataTable({ vListOverscanRowCount={0} initialColumnsWidths={initialColumnsWidths} onColumnResizing={handleColumnResizing} - noResults={'There is no uncategorized transactions in the current account.'} + noResults={ + 'There is no uncategorized transactions in the current account.' + } className="table-constrant" payload={{ onExclude: handleExcludeTransaction, @@ -116,7 +113,6 @@ export default compose( withSettings(({ cashflowTransactionsSettings }) => ({ cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize, })), - withDrawerActions, withBankingActions, )(AccountTransactionsDataTable); diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountUncategorizedTransactionsFilterProvider.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountUncategorizedTransactionsFilterProvider.tsx deleted file mode 100644 index 2909f3b75..000000000 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/AccountUncategorizedTransactionsFilterProvider.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; - -interface UncategorizedTransactionsFilterValue {} - -const UncategorizedTransactionsFilterContext = - React.createContext( - {} as UncategorizedTransactionsFilterValue, - ); - -interface UncategorizedTransactionsFilterProviderProps { - children: React.ReactNode; -} - -/** - * - */ -function UncategorizedTransactionsFilterProvider({ - ...props -}: UncategorizedTransactionsFilterProviderProps) { - // Provider payload. - const provider = {}; - - return ( - - ); -} - -const useUncategorizedTransactionsFilter = () => - React.useContext(UncategorizedTransactionsFilterContext); - -export { - UncategorizedTransactionsFilterProvider, - useUncategorizedTransactionsFilter, -}; diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/AllTransactionsUncategorized.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/AllTransactionsUncategorized.tsx index a9aa38e47..ad903b06d 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/AllTransactionsUncategorized.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/AllTransactionsUncategorized.tsx @@ -6,7 +6,6 @@ import * as R from 'ramda'; import '@/style/pages/CashFlow/AccountTransactions/List.scss'; import { AccountTransactionsUncategorizeFilter } from './AccountTransactionsUncategorizeFilter'; -import { UncategorizedTransactionsFilterProvider } from './AccountUncategorizedTransactionsFilterProvider'; import { WithBankingActionsProps, withBankingActions, @@ -23,6 +22,7 @@ function AllTransactionsUncategorizedRoot({ // #withBankingActions closeMatchingTransactionAside, }: AllTransactionsUncategorizedProps) { + // Close the match aside once leaving the page. useEffect( () => () => { closeMatchingTransactionAside(); @@ -31,12 +31,10 @@ function AllTransactionsUncategorizedRoot({ ); return ( - - - - - - + + + + ); } diff --git a/packages/webapp/src/containers/CashFlow/AccountTransactions/RecognizedTransactions/RecognizedTransactionsTable.tsx b/packages/webapp/src/containers/CashFlow/AccountTransactions/RecognizedTransactions/RecognizedTransactionsTable.tsx index 3739aad31..162da1b69 100644 --- a/packages/webapp/src/containers/CashFlow/AccountTransactions/RecognizedTransactions/RecognizedTransactionsTable.tsx +++ b/packages/webapp/src/containers/CashFlow/AccountTransactions/RecognizedTransactions/RecognizedTransactionsTable.tsx @@ -14,7 +14,6 @@ import { } from '@/components'; import { TABLES } from '@/constants/tables'; -import withSettings from '@/containers/Settings/withSettings'; import withAlertsActions from '@/containers/Alert/withAlertActions'; import withDrawerActions from '@/containers/Drawer/withDrawerActions';