mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
fix: bank rules
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
exports.up = function (knex) {
|
exports.up = function (knex) {
|
||||||
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
|
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
|
||||||
table.boolean('excluded');
|
table.datetime('excluded_at');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.down = function (knex) {
|
exports.down = function (knex) {
|
||||||
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
|
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
|
||||||
table.dropColumn('excluded');
|
table.dropColumn('excluded_at');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
|||||||
* Filters the not excluded transactions.
|
* Filters the not excluded transactions.
|
||||||
*/
|
*/
|
||||||
notExcluded(query) {
|
notExcluded(query) {
|
||||||
query.whereNull('excluded');
|
query.whereNull('excluded_at');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the excluded transactions.
|
* Filters the excluded transactions.
|
||||||
*/
|
*/
|
||||||
excluded(query) {
|
excluded(query) {
|
||||||
query.where('excluded', true)
|
query.whereNotNull('excluded_at')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class ExcludeBankTransaction {
|
|||||||
await UncategorizedCashflowTransaction.query(trx)
|
await UncategorizedCashflowTransaction.query(trx)
|
||||||
.findById(uncategorizedTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.patch({
|
.patch({
|
||||||
excluded: true,
|
excludedAt: new Date(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class GetExcludedBankTransactionsService {
|
|||||||
const { results, pagination } =
|
const { results, pagination } =
|
||||||
await UncategorizedCashflowTransaction.query()
|
await UncategorizedCashflowTransaction.query()
|
||||||
.onBuild((q) => {
|
.onBuild((q) => {
|
||||||
q.where('excluded', true);
|
q.modify('excluded');
|
||||||
q.orderBy('date', 'DESC');
|
q.orderBy('date', 'DESC');
|
||||||
|
|
||||||
if (_query.accountId) {
|
if (_query.accountId) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class UnexcludeBankTransaction {
|
|||||||
await UncategorizedCashflowTransaction.query(trx)
|
await UncategorizedCashflowTransaction.query(trx)
|
||||||
.findById(uncategorizedTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.patch({
|
.patch({
|
||||||
excluded: null,
|
excludedAt: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { Form, Formik, FormikHelpers, useFormikContext } from 'formik';
|
import { Form, Formik, FormikHelpers, useFormikContext } from 'formik';
|
||||||
import { Button, Classes, Intent, Radio } from '@blueprintjs/core';
|
import { Button, Classes, Intent, Radio, Tag } from '@blueprintjs/core';
|
||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import { CreateRuleFormSchema } from './RuleFormContentForm.schema';
|
import { CreateRuleFormSchema } from './RuleFormContentForm.schema';
|
||||||
import {
|
import {
|
||||||
@@ -73,7 +73,7 @@ function RuleFormContentFormRoot({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
editBankRule([bankRuleId, _values])
|
editBankRule({ id: bankRuleId, value: _values })
|
||||||
.then(handleSuccess)
|
.then(handleSuccess)
|
||||||
.catch(handleError);
|
.catch(handleError);
|
||||||
} else {
|
} else {
|
||||||
@@ -88,16 +88,26 @@ function RuleFormContentFormRoot({
|
|||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
<Form>
|
||||||
<FFormGroup name={'name'} label={'Rule Name'} style={{ maxWidth: 300 }}>
|
<FFormGroup
|
||||||
|
name={'name'}
|
||||||
|
label={'Rule Name'}
|
||||||
|
labelInfo={<Tag minimal>Required</Tag>}
|
||||||
|
style={{ maxWidth: 300 }}
|
||||||
|
>
|
||||||
<FInputGroup name={'name'} />
|
<FInputGroup name={'name'} />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'applyIfAccountId'}
|
name={'applyIfAccountId'}
|
||||||
label={'Apply the rule to account'}
|
label={'Apply the rule to account'}
|
||||||
|
labelInfo={<Tag minimal>Required</Tag>}
|
||||||
style={{ maxWidth: 350 }}
|
style={{ maxWidth: 350 }}
|
||||||
>
|
>
|
||||||
<AccountsSelect name={'applyIfAccountId'} items={accounts} />
|
<AccountsSelect
|
||||||
|
name={'applyIfAccountId'}
|
||||||
|
items={accounts}
|
||||||
|
filterByTypes={['cash', 'bank']}
|
||||||
|
/>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
@@ -133,6 +143,7 @@ function RuleFormContentFormRoot({
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'assignCategory'}
|
name={'assignCategory'}
|
||||||
label={'Transaction type'}
|
label={'Transaction type'}
|
||||||
|
labelInfo={<Tag minimal>Required</Tag>}
|
||||||
style={{ maxWidth: 300 }}
|
style={{ maxWidth: 300 }}
|
||||||
>
|
>
|
||||||
<FSelect
|
<FSelect
|
||||||
@@ -145,6 +156,7 @@ function RuleFormContentFormRoot({
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'assignAccountId'}
|
name={'assignAccountId'}
|
||||||
label={'Account category'}
|
label={'Account category'}
|
||||||
|
labelInfo={<Tag minimal>Required</Tag>}
|
||||||
style={{ maxWidth: 300 }}
|
style={{ maxWidth: 300 }}
|
||||||
>
|
>
|
||||||
<AccountsSelect name={'assignAccountId'} items={accounts} />
|
<AccountsSelect name={'assignAccountId'} items={accounts} />
|
||||||
@@ -251,6 +263,7 @@ function RuleFormActionsRoot({
|
|||||||
<Box className={Classes.DIALOG_FOOTER_ACTIONS}>
|
<Box className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||||
<Button onClick={handleCancelBtnClick}>Cancel</Button>
|
<Button onClick={handleCancelBtnClick}>Cancel</Button>
|
||||||
<Button
|
<Button
|
||||||
|
type="submit"
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
onClick={handleSaveBtnClick}
|
onClick={handleSaveBtnClick}
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ import {
|
|||||||
Classes,
|
Classes,
|
||||||
NavbarDivider,
|
NavbarDivider,
|
||||||
Alignment,
|
Alignment,
|
||||||
|
Popover,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
Position,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
@@ -39,18 +44,20 @@ function AccountTransactionsActionsBar({
|
|||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
}) {
|
}) {
|
||||||
// Handle table row size change.
|
const history = useHistory();
|
||||||
const handleTableRowSizeChange = (size) => {
|
|
||||||
addSetting('cashflowTransactions', 'tableSize', size);
|
|
||||||
};
|
|
||||||
const { accountId } = useAccountTransactionsContext();
|
const { accountId } = useAccountTransactionsContext();
|
||||||
|
|
||||||
|
// Refresh cashflow infinity transactions hook.
|
||||||
|
const { refresh } = useRefreshCashflowTransactionsInfinity();
|
||||||
|
|
||||||
// Retrieves the money in/out buttons options.
|
// Retrieves the money in/out buttons options.
|
||||||
const addMoneyInOptions = useMemo(() => getAddMoneyInOptions(), []);
|
const addMoneyInOptions = useMemo(() => getAddMoneyInOptions(), []);
|
||||||
const addMoneyOutOptions = useMemo(() => getAddMoneyOutOptions(), []);
|
const addMoneyOutOptions = useMemo(() => getAddMoneyOutOptions(), []);
|
||||||
|
|
||||||
const history = useHistory();
|
// Handle table row size change.
|
||||||
|
const handleTableRowSizeChange = (size) => {
|
||||||
|
addSetting('cashflowTransactions', 'tableSize', size);
|
||||||
|
};
|
||||||
// Handle money in form
|
// Handle money in form
|
||||||
const handleMoneyInFormTransaction = (account) => {
|
const handleMoneyInFormTransaction = (account) => {
|
||||||
openDialog('money-in', {
|
openDialog('money-in', {
|
||||||
@@ -71,10 +78,10 @@ function AccountTransactionsActionsBar({
|
|||||||
const handleImportBtnClick = () => {
|
const handleImportBtnClick = () => {
|
||||||
history.push(`/cashflow-accounts/${accountId}/import`);
|
history.push(`/cashflow-accounts/${accountId}/import`);
|
||||||
};
|
};
|
||||||
|
// Handle bank rules click.
|
||||||
// Refresh cashflow infinity transactions hook.
|
const handleBankRulesClick = () => {
|
||||||
const { refresh } = useRefreshCashflowTransactionsInfinity();
|
history.push(`/bank-rules?accountId=${accountId}`);
|
||||||
|
};
|
||||||
// Handle the refresh button click.
|
// Handle the refresh button click.
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
@@ -125,6 +132,22 @@ function AccountTransactionsActionsBar({
|
|||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|
||||||
<NavbarGroup align={Alignment.RIGHT}>
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Popover
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
|
modifiers={{
|
||||||
|
offset: { offset: '0, 4' },
|
||||||
|
}}
|
||||||
|
content={
|
||||||
|
<Menu>
|
||||||
|
<MenuItem onClick={handleBankRulesClick} text={'Bank rules'} />
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button icon={<Icon icon="cog-16" iconSize={16} />} minimal={true} />
|
||||||
|
</Popover>
|
||||||
|
<NavbarDivider />
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon="refresh-16" iconSize={14} />}
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
|||||||
|
|
||||||
import { useMemorizedColumnsWidths } from '@/hooks';
|
import { useMemorizedColumnsWidths } from '@/hooks';
|
||||||
import { useAccountTransactionsColumns, ActionsMenu } from './components';
|
import { useAccountTransactionsColumns, ActionsMenu } from './components';
|
||||||
|
import { useAccountTransactionsAllContext } from './AccountTransactionsAllBoot';
|
||||||
import { handleCashFlowTransactionType } from './utils';
|
import { handleCashFlowTransactionType } from './utils';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import { useAccountTransactionsAllContext } from './AccountTransactionsAllBoot';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account transactions data table.
|
* Account transactions data table.
|
||||||
@@ -108,7 +108,6 @@ const DashboardConstrantTable = styled(DataTable)`
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: 500;
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Root = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-bottom: 18px;
|
margin-bottom: 14px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FilterTag = styled(Tag)`
|
const FilterTag = styled(Tag)`
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ function AccountTransactionsDataTable({
|
|||||||
const handleCellClick = (cell) => {
|
const handleCellClick = (cell) => {
|
||||||
setUncategorizedTransactionIdForMatching(cell.row.original.id);
|
setUncategorizedTransactionIdForMatching(cell.row.original.id);
|
||||||
};
|
};
|
||||||
|
// Handles categorize button click.
|
||||||
|
const handleCategorizeBtnClick = (transaction) => {
|
||||||
|
setUncategorizedTransactionIdForMatching(transaction.id);
|
||||||
|
};
|
||||||
// Handle exclude transaction.
|
// Handle exclude transaction.
|
||||||
const handleExcludeTransaction = (transaction) => {
|
const handleExcludeTransaction = (transaction) => {
|
||||||
excludeTransaction(transaction.id)
|
excludeTransaction(transaction.id)
|
||||||
@@ -102,6 +106,7 @@ function AccountTransactionsDataTable({
|
|||||||
className="table-constrant"
|
className="table-constrant"
|
||||||
payload={{
|
payload={{
|
||||||
onExclude: handleExcludeTransaction,
|
onExclude: handleExcludeTransaction,
|
||||||
|
onCategorize: handleCategorizeBtnClick,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ import { ActionsMenu } from './_components';
|
|||||||
import { useUnexcludeUncategorizedTransaction } from '@/hooks/query/bank-rules';
|
import { useUnexcludeUncategorizedTransaction } from '@/hooks/query/bank-rules';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
interface ExcludedTransactionsTableProps {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the recognized account transactions datatable.
|
* Renders the recognized account transactions datatable.
|
||||||
*/
|
*/
|
||||||
function ExcludedTransactionsTableRoot({}: ExcludedTransactionsTableProps) {
|
function ExcludedTransactionsTableRoot() {
|
||||||
const { excludedBankTransactions } = useExcludedTransactionsBoot();
|
const { excludedBankTransactions } = useExcludedTransactionsBoot();
|
||||||
const { mutateAsync: unexcludeBankTransaction } =
|
const { mutateAsync: unexcludeBankTransaction } =
|
||||||
useUnexcludeUncategorizedTransaction();
|
useUnexcludeUncategorizedTransaction();
|
||||||
@@ -103,7 +101,6 @@ const DashboardConstrantTable = styled(DataTable)`
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: 500;
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ function RecognizedTransactionsTableRoot({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
// Handles categorize button click.
|
||||||
const handleCategorizeClick = (transaction) => {
|
const handleCategorizeClick = (transaction) => {
|
||||||
setUncategorizedTransactionIdForMatching(
|
setUncategorizedTransactionIdForMatching(
|
||||||
transaction.uncategorized_transaction_id,
|
transaction.uncategorized_transaction_id,
|
||||||
@@ -137,7 +137,6 @@ const DashboardConstrantTable = styled(DataTable)`
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: 500;
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export function ActionsMenu({
|
|||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={'Categorize'}
|
text={'Categorize'}
|
||||||
|
icon={<Icon icon="reader-18" />}
|
||||||
onClick={safeCallback(onCategorize, original)}
|
onClick={safeCallback(onCategorize, original)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
|
|||||||
@@ -1,41 +1,22 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { Intent, Menu, MenuItem, MenuDivider } from '@blueprintjs/core';
|
import { Intent, Menu, MenuItem, MenuDivider, Tag } from '@blueprintjs/core';
|
||||||
import {
|
import { Can, FormatDateCell, Icon, MaterialProgressBar } from '@/components';
|
||||||
Can,
|
|
||||||
FormatDateCell,
|
|
||||||
If,
|
|
||||||
Icon,
|
|
||||||
MaterialProgressBar,
|
|
||||||
} from '@/components';
|
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
import { TRANSACRIONS_TYPE } from '@/constants/cashflowOptions';
|
|
||||||
import { AbilitySubject, CashflowAction } from '@/constants/abilityOption';
|
|
||||||
import { safeCallback } from '@/utils';
|
import { safeCallback } from '@/utils';
|
||||||
|
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
payload: { onDelete, onViewDetails, onExclude },
|
payload: { onCategorize, onExclude },
|
||||||
row: { original },
|
row: { original },
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="reader-18" />}
|
icon={<Icon icon="reader-18" />}
|
||||||
text={intl.get('view_details')}
|
text={'Categorize'}
|
||||||
onClick={safeCallback(onViewDetails, original)}
|
onClick={safeCallback(onCategorize, original)}
|
||||||
/>
|
/>
|
||||||
<Can I={CashflowAction.Delete} a={AbilitySubject.Cashflow}>
|
|
||||||
<If condition={TRANSACRIONS_TYPE.includes(original.reference_type)}>
|
|
||||||
<MenuDivider />
|
|
||||||
<MenuItem
|
|
||||||
text={intl.get('delete_transaction')}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
onClick={safeCallback(onDelete, original)}
|
|
||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
|
||||||
/>
|
|
||||||
</If>
|
|
||||||
</Can>
|
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={'Exclude'}
|
text={'Exclude'}
|
||||||
@@ -186,6 +167,20 @@ export function useAccountUncategorizedTransactionsColumns() {
|
|||||||
clickable: true,
|
clickable: true,
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'status',
|
||||||
|
Header: 'Status',
|
||||||
|
accessor: () =>
|
||||||
|
false ? (
|
||||||
|
<Tag intent={Intent.SUCCESS} interactive>
|
||||||
|
1 Matches
|
||||||
|
</Tag>
|
||||||
|
) : (
|
||||||
|
<Tag intent={Intent.SUCCESS} interactive>
|
||||||
|
Recognized
|
||||||
|
</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'deposit',
|
id: 'deposit',
|
||||||
Header: intl.get('cash_flow.label.deposit'),
|
Header: intl.get('cash_flow.label.deposit'),
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export function useEditBankRule(
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation<EditBankRuleResponse, Error, EditBankRuleValues>(
|
return useMutation<EditBankRuleResponse, Error, EditBankRuleValues>(
|
||||||
({ id, value }) => apiRequest.post(`/banking/rules/${id}`, values),
|
({ id, value }) => apiRequest.post(`/banking/rules/${id}`, value),
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user