From c1659d191f98aeb6695ebbc949ecf2c67f811ca7 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 27 May 2020 20:21:05 +0200 Subject: [PATCH] feat: Ability to hide/show financial statement header. --- client/src/components/AccountsMultiSelect.js | 99 ++++---- client/src/components/App.js | 2 + client/src/components/DialogsContainer.js | 4 +- client/src/components/FinancialStatement.js | 5 + client/src/components/index.js | 2 + .../BalanceSheet/BalanceSheet.js | 13 +- .../BalanceSheet/BalanceSheetActionsBar.js | 77 ++++-- .../BalanceSheet/BalanceSheetHeader.js | 3 +- .../BalanceSheet/withBalanceSheetActions.js | 1 + .../BalanceSheet/withBalanceSheetDetail.js | 1 + .../FinancialStatementHeader.js | 13 +- .../GeneralLedger/GeneralLedger.js | 2 +- .../GeneralLedger/GeneralLedgerActionsBar.js | 46 +++- .../GeneralLedger/GeneralLedgerHeader.js | 15 +- .../GeneralLedger/withGeneralLedger.js | 1 + .../GeneralLedger/withGeneralLedgerActions.js | 1 + .../FinancialStatements/Journal/Journal.js | 2 +- .../Journal/JournalActionsBar.js | 74 ++++-- .../Journal/JournalHeader.js | 19 +- .../Journal/withJournal.js | 1 + .../Journal/withJournalActions.js | 1 + .../ProfitLossSheet/ProfitLossActionsBar.js | 76 ++++-- .../ProfitLossSheet/ProfitLossSheetHeader.js | 58 +++-- .../ProfitLossSheet/withProfitLoss.js | 1 + .../ProfitLossSheet/withProfitLossActions.js | 1 + .../TrialBalanceActionsBar.js | 75 ++++-- .../TrialBalanceSheet/TrialBalanceSheet.js | 1 + .../TrialBalanceSheetHeader.js | 16 +- .../TrialBalanceSheet/withTrialBalance.js | 1 + .../withTrialBalanceActions.js | 1 + client/src/lang/en/index.js | 2 + client/src/static/json/icons.js | 219 ++++++++++++------ .../financialStatements.reducer.js | 18 ++ .../src/style/pages/financial-statements.scss | 12 + server/bin/bigcapital.js | 65 +----- server/bin/license.js | 57 +++++ server/bin/utils.js | 67 ++++++ .../seeds/seed_subscriptions_plans.js | 22 ++ .../http/middleware/SubscriptionObserver.js | 8 + .../services/Subscription/UserSubscription.js | 22 ++ ...091642_create_subscriptions_plans_table.js | 28 +++ ...091649_create_subscriptions_usage_table.js | 18 ++ ...812_create_subscriptions_licenses_table.js | 14 ++ .../src/system/models/SubscriptionLicense.js | 18 ++ server/src/system/models/SubscriptionPlan.js | 10 + server/src/system/models/SubscriptionUsage.js | 10 + server/src/system/models/SystemUser.js | 13 +- 47 files changed, 914 insertions(+), 301 deletions(-) create mode 100644 client/src/components/FinancialStatement.js create mode 100644 server/bin/license.js create mode 100644 server/bin/utils.js create mode 100644 server/src/database/seeds/seed_subscriptions_plans.js create mode 100644 server/src/http/middleware/SubscriptionObserver.js create mode 100644 server/src/services/Subscription/UserSubscription.js create mode 100644 server/src/system/migrations/20200527091642_create_subscriptions_plans_table.js create mode 100644 server/src/system/migrations/20200527091649_create_subscriptions_usage_table.js create mode 100644 server/src/system/migrations/20200527101812_create_subscriptions_licenses_table.js create mode 100644 server/src/system/models/SubscriptionLicense.js create mode 100644 server/src/system/models/SubscriptionPlan.js create mode 100644 server/src/system/models/SubscriptionUsage.js diff --git a/client/src/components/AccountsMultiSelect.js b/client/src/components/AccountsMultiSelect.js index b32833f56..d9e24c7e5 100644 --- a/client/src/components/AccountsMultiSelect.js +++ b/client/src/components/AccountsMultiSelect.js @@ -1,67 +1,76 @@ -import React, {useMemo, useCallback, useState} from 'react'; -import {omit} from 'lodash'; -import { - MenuItem, - Button -} from '@blueprintjs/core'; +import React, { useMemo, useCallback, useState } from 'react'; +import { omit } from 'lodash'; +import { MenuItem, Button } from '@blueprintjs/core'; import MultiSelect from 'components/MultiSelect'; import { FormattedMessage as T } from 'react-intl'; -export default function AccountsMultiSelect({ - accounts, - onAccountSelected, -}) { - const [selectedAccounts, setSelectedAccounts] = useState({}); +export default function AccountsMultiSelect({ accounts, onAccountSelected }) { + const [selectedAccounts, setSelectedAccounts] = useState({}); - const isAccountSelect = useCallback((accountId) => { - return 'undefined' !== typeof selectedAccounts[accountId]; - }, [selectedAccounts]); + const isAccountSelect = useCallback( + (accountId) => { + return 'undefined' !== typeof selectedAccounts[accountId]; + }, + [selectedAccounts], + ); // Account item of select accounts field. - const accountItem = useCallback((item, { handleClick, modifiers, query }) => { - return ( - - ); - }, [isAccountSelect]); + const accountItem = useCallback( + (item, { handleClick, modifiers, query }) => { + return ( + + ); + }, + [isAccountSelect], + ); - const countSelectedAccounts = useMemo(() => - Object.values(selectedAccounts).length, - [selectedAccounts]); + const countSelectedAccounts = useMemo( + () => Object.values(selectedAccounts).length, + [selectedAccounts], + ); - const onAccountSelect = useCallback((account) => { - const selected = { - ...(!isAccountSelect(account.id)) ? { - ...selectedAccounts, - [account.id]: true, - } : { - ...omit(selectedAccounts, [account.id]) - } - }; - setSelectedAccounts({ ...selected }); - onAccountSelected && onAccountSelected(selected); - }, [setSelectedAccounts, selectedAccounts, isAccountSelect, onAccountSelected]); + const onAccountSelect = useCallback( + (account) => { + const selected = { + ...(!isAccountSelect(account.id) + ? { + ...selectedAccounts, + [account.id]: true, + } + : { + ...omit(selectedAccounts, [account.id]), + }), + }; + setSelectedAccounts({ ...selected }); + onAccountSelected && onAccountSelected(selected); + }, + [setSelectedAccounts, selectedAccounts, isAccountSelect, onAccountSelected], + ); return ( } + noResults={} itemRenderer={accountItem} popoverProps={{ minimal: true }} filterable={true} onItemSelect={onAccountSelect} > ); -} \ No newline at end of file +} + +export default compose( + withProfitLoss(({ profitLossSheetFilter }) => ({ profitLossSheetFilter })), +)(ProfitLossHeader); diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js index 8fe8aff53..9aee1d7f6 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLoss.js @@ -19,6 +19,7 @@ export default (mapState) => { profitLossTableRows: getFinancialSheetTableRows(state.financialStatements.profitLoss.sheets, profitLossIndex), profitLossSheetLoading: state.financialStatements.profitLoss.loading, + profitLossSheetFilter: state.financialStatements.profitLoss.filter, }; return mapState ? mapState(mapped, state, props) : mapped; }; diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js index 962eb971d..ec08bf6c0 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/withProfitLossActions.js @@ -5,6 +5,7 @@ import { export const mapDispatchToProps = (dispatch) => ({ fetchProfitLossSheet: (query = {}) => dispatch(fetchProfitLossSheet({ query })), + toggleProfitLossSheetFilter: () => dispatch({ type: 'PROFIT_LOSS_FILTER_TOGGLE' }), }); export default connect(null, mapDispatchToProps); \ No newline at end of file diff --git a/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js b/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js index 6e88ac1ed..7e546fa0d 100644 --- a/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js +++ b/client/src/containers/FinancialStatements/TrialBalanceSheet/TrialBalanceActionsBar.js @@ -1,46 +1,77 @@ import React from 'react'; -import { - NavbarGroup, - Button, - Classes, - NavbarDivider, -} from '@blueprintjs/core'; +import { NavbarGroup, Button, Classes, NavbarDivider } from '@blueprintjs/core'; import Icon from 'components/Icon'; import { FormattedMessage as T } from 'react-intl'; -import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar' +import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import classNames from 'classnames'; // import FilterDropdown from 'components/FilterDropdown'; -export default function GeneralLedgerActionsBar() { - - // const filterDropdown = FilterDropdown({ - // fields: [], - // onFilterChange: (filterConditions) => { - - // }, - // }); +import { If } from 'components'; + +import withTrialBalance from './withTrialBalance'; +import withTrialBalanceActions from './withTrialBalanceActions'; +import { compose } from 'utils'; + + +function TrialBalanceActionsBar({ + + // #withTrialBalance + trialBalanceSheetFilter, + + // #withTrialBalanceActions + toggleTrialBalanceFilter, +}) { + + const handleFilterToggleClick = () => { + toggleTrialBalanceFilter(); + }; return (