mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
Merge branch 'feature/Cash-flow' of https://github.com/bigcapitalhq/client into feature/Cash-flow
This commit is contained in:
@@ -30,3 +30,12 @@ export const addMoneyOut = [
|
|||||||
value: 'transfer_to_account',
|
value: 'transfer_to_account',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const TRANSACRIONS_TYPE = [
|
||||||
|
'OwnerContribution',
|
||||||
|
'OtherIncome',
|
||||||
|
'TransferFromAccount',
|
||||||
|
'OnwersDrawing',
|
||||||
|
'OtherExpense',
|
||||||
|
'TransferToAccount',
|
||||||
|
];
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ export default [
|
|||||||
shortcut_key: 'Shift + W',
|
shortcut_key: 'Shift + W',
|
||||||
description: intl.get('jump_to_the_items'),
|
description: intl.get('jump_to_the_items'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
shortcut_key: 'Shift + D',
|
||||||
|
description: intl.get('jump_to_the_add_money_in'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shortcut_key: 'Shift + Q',
|
||||||
|
description: intl.get('jump_to_the_add_money_out'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
shortcut_key: 'Shift + 1',
|
shortcut_key: 'Shift + 1',
|
||||||
description: intl.get('jump_to_the_balance_sheet'),
|
description: intl.get('jump_to_the_balance_sheet'),
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ function GlobalHotkeys({
|
|||||||
[history],
|
[history],
|
||||||
);
|
);
|
||||||
useHotkeys('ctrl+/', (event, handle) => handleSidebarToggleBtn());
|
useHotkeys('ctrl+/', (event, handle) => handleSidebarToggleBtn());
|
||||||
useHotkeys('shift+q', (event, handle) => openDialog('money-in', {}));
|
useHotkeys('shift+d', (event, handle) => openDialog('money-in', {}));
|
||||||
useHotkeys('shift+d', (event, handle) => openDialog('money-out', {}));
|
useHotkeys('shift+q', (event, handle) => openDialog('money-out', {}));
|
||||||
return <div></div>;
|
return <div></div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
||||||
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
import { useDeleteCashflowTransaction } from 'hooks/query';
|
||||||
|
|
||||||
|
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||||
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account delete transaction alert.
|
||||||
|
*/
|
||||||
|
function AccountDeleteTransactionAlert({
|
||||||
|
name,
|
||||||
|
|
||||||
|
// #withAlertStoreConnect
|
||||||
|
isOpen,
|
||||||
|
payload: { referenceId },
|
||||||
|
|
||||||
|
// #withAlertActions
|
||||||
|
closeAlert,
|
||||||
|
}) {
|
||||||
|
const { mutateAsync: deleteTransactionMutate, isLoading } =
|
||||||
|
useDeleteCashflowTransaction();
|
||||||
|
|
||||||
|
// handle cancel delete alert
|
||||||
|
const handleCancelDeleteAlert = () => {
|
||||||
|
closeAlert(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
// handleConfirm delete transaction.
|
||||||
|
const handleConfirmTransactioneDelete = () => {
|
||||||
|
deleteTransactionMutate(referenceId)
|
||||||
|
.then(() => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get('cash_flow_transaction.delete.alert_message'),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(
|
||||||
|
({
|
||||||
|
response: {
|
||||||
|
data: { errors },
|
||||||
|
},
|
||||||
|
}) => {},
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
closeAlert(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Alert
|
||||||
|
cancelButtonText={<T id={'cancel'} />}
|
||||||
|
confirmButtonText={<T id={'delete'} />}
|
||||||
|
icon="trash"
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
isOpen={isOpen}
|
||||||
|
onCancel={handleCancelDeleteAlert}
|
||||||
|
onConfirm={handleConfirmTransactioneDelete}
|
||||||
|
loading={isLoading}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
<FormattedHTMLMessage
|
||||||
|
id={
|
||||||
|
'cash_flow_transaction_once_delete_this_transaction_you_will_able_to_restore_it'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withAlertStoreConnect(),
|
||||||
|
withAlertActions,
|
||||||
|
)(AccountDeleteTransactionAlert);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import AccountDeleteTransactionAlert from '../../Alerts/CashFlow/AccountDeleteTransactionAlert';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account transaction alert.
|
||||||
|
*/
|
||||||
|
export default function AccountTransactionsAlerts() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<AccountDeleteTransactionAlert name={'account-transaction-delete'} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -9,9 +9,10 @@ import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
|
|||||||
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
|
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
|
||||||
|
|
||||||
import withSettings from '../../Settings/withSettings';
|
import withSettings from '../../Settings/withSettings';
|
||||||
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
import { useMemorizedColumnsWidths } from '../../../hooks';
|
import { useMemorizedColumnsWidths } from '../../../hooks';
|
||||||
import { useAccountTransactionsColumns } from './components';
|
import { useAccountTransactionsColumns, ActionsMenu } from './components';
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
@@ -21,6 +22,9 @@ import { compose } from 'utils';
|
|||||||
function AccountTransactionsDataTable({
|
function AccountTransactionsDataTable({
|
||||||
// #withSettings
|
// #withSettings
|
||||||
cashflowTansactionsTableSize,
|
cashflowTansactionsTableSize,
|
||||||
|
|
||||||
|
// #withAlertsActions
|
||||||
|
openAlert,
|
||||||
}) {
|
}) {
|
||||||
// Retrieve table columns.
|
// Retrieve table columns.
|
||||||
const columns = useAccountTransactionsColumns();
|
const columns = useAccountTransactionsColumns();
|
||||||
@@ -36,6 +40,11 @@ function AccountTransactionsDataTable({
|
|||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.CASHFLOW_Transactions);
|
useMemorizedColumnsWidths(TABLES.CASHFLOW_Transactions);
|
||||||
|
|
||||||
|
// handle delete transaction
|
||||||
|
const handleDeleteTransaction = ({ reference_id }) => {
|
||||||
|
openAlert('account-transaction-delete', { referenceId: reference_id });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CashflowTransactionsTable
|
<CashflowTransactionsTable
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
@@ -51,6 +60,7 @@ function AccountTransactionsDataTable({
|
|||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
TableRowsRenderer={TableVirtualizedListRows}
|
TableRowsRenderer={TableVirtualizedListRows}
|
||||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||||
|
ContextMenu={ActionsMenu}
|
||||||
// #TableVirtualizedListRows props.
|
// #TableVirtualizedListRows props.
|
||||||
vListrowHeight={cashflowTansactionsTableSize == 'small' ? 32 : 40}
|
vListrowHeight={cashflowTansactionsTableSize == 'small' ? 32 : 40}
|
||||||
vListOverscanRowCount={0}
|
vListOverscanRowCount={0}
|
||||||
@@ -60,6 +70,9 @@ function AccountTransactionsDataTable({
|
|||||||
'There is deposit/withdrawal transactions on the current account.'
|
'There is deposit/withdrawal transactions on the current account.'
|
||||||
}
|
}
|
||||||
className="table-constrant"
|
className="table-constrant"
|
||||||
|
payload={{
|
||||||
|
onDelete: handleDeleteTransaction,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -68,6 +81,7 @@ export default compose(
|
|||||||
withSettings(({ cashflowTransactionsSettings }) => ({
|
withSettings(({ cashflowTransactionsSettings }) => ({
|
||||||
cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize,
|
cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
|
withAlertsActions,
|
||||||
)(AccountTransactionsDataTable);
|
)(AccountTransactionsDataTable);
|
||||||
|
|
||||||
const DashboardConstrantTable = styled(DataTable)`
|
const DashboardConstrantTable = styled(DataTable)`
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { AccountTransactionsProvider } from './AccountTransactionsProvider';
|
|||||||
import AccountTransactionsActionsBar from './AccountTransactionsActionsBar';
|
import AccountTransactionsActionsBar from './AccountTransactionsActionsBar';
|
||||||
import AccountTransactionsDataTable from './AccountTransactionsDataTable';
|
import AccountTransactionsDataTable from './AccountTransactionsDataTable';
|
||||||
import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar';
|
import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar';
|
||||||
|
import AccountTransactionsAlerts from './AccountTransactionsAlerts';
|
||||||
import { AccountTransactionsProgressBar } from './components';
|
import { AccountTransactionsProgressBar } from './components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +26,7 @@ function AccountTransactionsList() {
|
|||||||
<AccountTransactionsDataTable />
|
<AccountTransactionsDataTable />
|
||||||
</DashboardContentTable>
|
</DashboardContentTable>
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
|
<AccountTransactionsAlerts />
|
||||||
</AccountTransactionsProvider>
|
</AccountTransactionsProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,28 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { MaterialProgressBar } from 'components';
|
|
||||||
import { FormatDateCell } from 'components';
|
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
|
||||||
|
|
||||||
|
import { Intent, Menu, MenuItem } from '@blueprintjs/core';
|
||||||
|
|
||||||
|
import { MaterialProgressBar } from 'components';
|
||||||
|
import { FormatDateCell, If, Icon } from 'components';
|
||||||
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
|
import { TRANSACRIONS_TYPE } from 'common/cashflowOptions';
|
||||||
|
import { safeCallback } from 'utils';
|
||||||
|
|
||||||
|
export function ActionsMenu({ payload: { onDelete }, row: { original } }) {
|
||||||
|
return (
|
||||||
|
<If condition={TRANSACRIONS_TYPE.includes(original.reference_type)}>
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
text={intl.get('delete_transaction')}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
onClick={safeCallback(onDelete, original)}
|
||||||
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
</If>
|
||||||
|
);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve account transctions table columns.
|
* Retrieve account transctions table columns.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1003,6 +1003,8 @@
|
|||||||
"jump_to_the_bills": "Jump to the bills.",
|
"jump_to_the_bills": "Jump to the bills.",
|
||||||
"jump_to_the_manual_journals": "Jump to the Manual Journals.",
|
"jump_to_the_manual_journals": "Jump to the Manual Journals.",
|
||||||
"jump_to_the_items": "Jump to the items.",
|
"jump_to_the_items": "Jump to the items.",
|
||||||
|
"jump_to_the_add_money_in": "Jump to the cash flow add money in.",
|
||||||
|
"jump_to_the_add_money_out": "Jump to the cash flow add money out.",
|
||||||
"jump_to_the_balance_sheet": "Jump to the Balance Sheet.",
|
"jump_to_the_balance_sheet": "Jump to the Balance Sheet.",
|
||||||
"jump_to_the_profit_loss_sheet": "Jump to the Profit Loss Sheet.",
|
"jump_to_the_profit_loss_sheet": "Jump to the Profit Loss Sheet.",
|
||||||
"jump_to_the_journal_sheet": "Jump to the Journal Sheet.",
|
"jump_to_the_journal_sheet": "Jump to the Journal Sheet.",
|
||||||
@@ -1012,7 +1014,7 @@
|
|||||||
"create_a_new_estimate": "Create a new estimate.",
|
"create_a_new_estimate": "Create a new estimate.",
|
||||||
"create_a_new_receipt": "Create a new receipt.",
|
"create_a_new_receipt": "Create a new receipt.",
|
||||||
"create_a_new_expense": "Create a new expense.",
|
"create_a_new_expense": "Create a new expense.",
|
||||||
"create_a_new_customer": "create_a_new_customer",
|
"create_a_new_customer": "Create a new customer",
|
||||||
"create_a_new_vendor": "Create a new vendor.",
|
"create_a_new_vendor": "Create a new vendor.",
|
||||||
"create_a_new_bill": "Create a new bill.",
|
"create_a_new_bill": "Create a new bill.",
|
||||||
"create_a_new_journal": "Create a new journal.",
|
"create_a_new_journal": "Create a new journal.",
|
||||||
@@ -1389,8 +1391,9 @@
|
|||||||
"save_and_publish": "Save & Publish",
|
"save_and_publish": "Save & Publish",
|
||||||
"cash_flow_transaction.label_transfer_from_account":"Transfer from account",
|
"cash_flow_transaction.label_transfer_from_account":"Transfer from account",
|
||||||
"cash_flow_transaction.label_transfer_to_account":"Transfer to account",
|
"cash_flow_transaction.label_transfer_to_account":"Transfer to account",
|
||||||
"cash_flow_transaction.label_current_account":"Current account"
|
"cash_flow_transaction.label_current_account":"Current account",
|
||||||
|
"cash_flow_transaction.delete.alert_message":"The cashflow transaction has been deleted successfully",
|
||||||
|
"cash_flow_transaction_once_delete_this_transaction_you_will_able_to_restore_it": "Once you delete this transaction, you won't be able to restore it later. Are you sure you want to delete this transaction?"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user