mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
// @ts-nocheck
|
||||
import React, { useEffect } from 'react';
|
||||
import moment from 'moment';
|
||||
|
||||
import { BalanceSheetAlerts, BalanceSheetLoadingBar } from './components';
|
||||
import { FinancialStatement, DashboardPageContent } from '@/components';
|
||||
|
||||
import BalanceSheetHeader from './BalanceSheetHeader';
|
||||
import BalanceSheetActionsBar from './BalanceSheetActionsBar';
|
||||
import { BalanceSheetProvider } from './BalanceSheetProvider';
|
||||
import { BalanceSheetBody } from './BalanceSheetBody';
|
||||
import { useBalanceSheetQuery } from './utils';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
import withBalanceSheetActions from './withBalanceSheetActions';
|
||||
|
||||
/**
|
||||
* Balance sheet.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function BalanceSheet({
|
||||
// #withBalanceSheetActions
|
||||
toggleBalanceSheetFilterDrawer,
|
||||
}) {
|
||||
// Balance sheet query.
|
||||
const { query, setLocationQuery } = useBalanceSheetQuery();
|
||||
|
||||
// Handle re-fetch balance sheet after filter change.
|
||||
const handleFilterSubmit = (filter) => {
|
||||
const newFilter = {
|
||||
...filter,
|
||||
fromDate: moment(filter.fromDate).format('YYYY-MM-DD'),
|
||||
toDate: moment(filter.toDate).format('YYYY-MM-DD'),
|
||||
};
|
||||
setLocationQuery({ ...newFilter });
|
||||
};
|
||||
// Handle number format submit.
|
||||
const handleNumberFormatSubmit = (values) => {
|
||||
setLocationQuery({
|
||||
...query,
|
||||
numberFormat: values,
|
||||
});
|
||||
};
|
||||
// Hides the balance sheet filter drawer once the page unmount.
|
||||
useEffect(
|
||||
() => () => {
|
||||
toggleBalanceSheetFilterDrawer(false);
|
||||
},
|
||||
[toggleBalanceSheetFilterDrawer],
|
||||
);
|
||||
|
||||
return (
|
||||
<BalanceSheetProvider filter={query}>
|
||||
<BalanceSheetActionsBar
|
||||
numberFormat={query.numberFormat}
|
||||
onNumberFormatSubmit={handleNumberFormatSubmit}
|
||||
/>
|
||||
<BalanceSheetLoadingBar />
|
||||
<BalanceSheetAlerts />
|
||||
|
||||
<DashboardPageContent>
|
||||
<FinancialStatement>
|
||||
<BalanceSheetHeader
|
||||
pageFilter={query}
|
||||
onSubmitFilter={handleFilterSubmit}
|
||||
/>
|
||||
<BalanceSheetBody />
|
||||
</FinancialStatement>
|
||||
</DashboardPageContent>
|
||||
</BalanceSheetProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withBalanceSheetActions)(BalanceSheet);
|
||||
@@ -0,0 +1,132 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import {
|
||||
NavbarGroup,
|
||||
Button,
|
||||
Classes,
|
||||
NavbarDivider,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
} from '@blueprintjs/core';
|
||||
import classNames from 'classnames';
|
||||
import { DashboardActionsBar, FormattedMessage as T, Icon } from '@/components';
|
||||
|
||||
import NumberFormatDropdown from '@/components/NumberFormatDropdown';
|
||||
|
||||
import { compose, saveInvoke } from '@/utils';
|
||||
import { useBalanceSheetContext } from './BalanceSheetProvider';
|
||||
import withBalanceSheet from './withBalanceSheet';
|
||||
import withBalanceSheetActions from './withBalanceSheetActions';
|
||||
|
||||
/**
|
||||
* Balance sheet - actions bar.
|
||||
*/
|
||||
function BalanceSheetActionsBar({
|
||||
// #withBalanceSheet
|
||||
balanceSheetDrawerFilter,
|
||||
|
||||
// #withBalanceSheetActions
|
||||
toggleBalanceSheetFilterDrawer: toggleFilterDrawer,
|
||||
|
||||
// #ownProps
|
||||
numberFormat,
|
||||
onNumberFormatSubmit,
|
||||
}) {
|
||||
const { isLoading, refetchBalanceSheet } = useBalanceSheetContext();
|
||||
|
||||
// Handle filter toggle click.
|
||||
const handleFilterToggleClick = () => {
|
||||
toggleFilterDrawer();
|
||||
};
|
||||
|
||||
// Handle recalculate the report button.
|
||||
const handleRecalcReport = () => {
|
||||
refetchBalanceSheet();
|
||||
};
|
||||
|
||||
// Handle number format form submit.
|
||||
const handleNumberFormatSubmit = (values) => {
|
||||
saveInvoke(onNumberFormatSubmit, values);
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Button
|
||||
className={classNames(Classes.MINIMAL, 'button--gray-highlight')}
|
||||
text={<T id={'recalc_report'} />}
|
||||
onClick={handleRecalcReport}
|
||||
icon={<Icon icon="refresh-16" iconSize={16} />}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
|
||||
<Button
|
||||
className={classNames(Classes.MINIMAL, 'button--table-views')}
|
||||
icon={<Icon icon="cog-16" iconSize={16} />}
|
||||
text={
|
||||
!balanceSheetDrawerFilter ? (
|
||||
<T id={'customize_report'} />
|
||||
) : (
|
||||
<T id={'hide_customizer'} />
|
||||
)
|
||||
}
|
||||
onClick={handleFilterToggleClick}
|
||||
active={balanceSheetDrawerFilter}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
|
||||
<Popover
|
||||
content={
|
||||
<NumberFormatDropdown
|
||||
numberFormat={numberFormat}
|
||||
onSubmit={handleNumberFormatSubmit}
|
||||
submitDisabled={isLoading}
|
||||
/>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
className={classNames(Classes.MINIMAL, 'button--filter')}
|
||||
text={<T id={'format'} />}
|
||||
icon={<Icon icon="numbers" width={23} height={16} />}
|
||||
/>
|
||||
</Popover>
|
||||
|
||||
<Popover
|
||||
// content={}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
className={classNames(Classes.MINIMAL, 'button--filter')}
|
||||
text={<T id={'filter'} />}
|
||||
icon={<Icon icon="filter-16" iconSize={16} />}
|
||||
/>
|
||||
</Popover>
|
||||
|
||||
<NavbarDivider />
|
||||
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="print-16" iconSize={16} />}
|
||||
text={<T id={'print'} />}
|
||||
/>
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon="file-export-16" iconSize={16} />}
|
||||
text={<T id={'export'} />}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
</DashboardActionsBar>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withBalanceSheet(({ balanceSheetDrawerFilter }) => ({
|
||||
balanceSheetDrawerFilter,
|
||||
})),
|
||||
withBalanceSheetActions,
|
||||
)(BalanceSheetActionsBar);
|
||||
@@ -0,0 +1,37 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
|
||||
import BalanceSheetTable from './BalanceSheetTable';
|
||||
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
|
||||
|
||||
import { FinancialReportBody } from '../FinancialReportPage';
|
||||
import { useBalanceSheetContext } from './BalanceSheetProvider';
|
||||
import { FinancialSheetSkeleton } from '@/components';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Balance sheet body JSX.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function BalanceSheetBodyJSX({
|
||||
// #withCurrentOrganization
|
||||
organizationName,
|
||||
}) {
|
||||
const { isLoading } = useBalanceSheetContext();
|
||||
|
||||
return (
|
||||
<FinancialReportBody>
|
||||
{isLoading ? (
|
||||
<FinancialSheetSkeleton />
|
||||
) : (
|
||||
<BalanceSheetTable companyName={organizationName} />
|
||||
)}
|
||||
</FinancialReportBody>
|
||||
);
|
||||
}
|
||||
|
||||
export const BalanceSheetBody = compose(
|
||||
withCurrentOrganization(({ organization }) => ({
|
||||
organizationName: organization.name,
|
||||
})),
|
||||
)(BalanceSheetBodyJSX);
|
||||
@@ -0,0 +1,132 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import moment from 'moment';
|
||||
import { Tabs, Tab, Button, Intent } from '@blueprintjs/core';
|
||||
import { Formik, Form } from 'formik';
|
||||
|
||||
import { FormattedMessage as T } from '@/components';
|
||||
import { useFeatureCan } from '@/hooks/state';
|
||||
import { Features } from '@/constants';
|
||||
|
||||
import withBalanceSheet from './withBalanceSheet';
|
||||
import withBalanceSheetActions from './withBalanceSheetActions';
|
||||
|
||||
import BalanceSheetHeaderGeneralPanal from './BalanceSheetHeaderGeneralPanal';
|
||||
import BalanceSheetHeaderComparisonPanal from './BalanceSheetHeaderComparisonPanal';
|
||||
import BalanceSheetHeaderDimensionsPanel from './BalanceSheetHeaderDimensionsPanel';
|
||||
import FinancialStatementHeader from '../../FinancialStatements/FinancialStatementHeader';
|
||||
|
||||
import { compose, transformToForm } from '@/utils';
|
||||
import {
|
||||
getBalanceSheetHeaderValidationSchema,
|
||||
getDefaultBalanceSheetQuery,
|
||||
} from './utils';
|
||||
|
||||
/**
|
||||
* Balance sheet header.
|
||||
*/
|
||||
function BalanceSheetHeader({
|
||||
// #ownProps
|
||||
onSubmitFilter,
|
||||
pageFilter,
|
||||
|
||||
// #withBalanceSheet
|
||||
balanceSheetDrawerFilter,
|
||||
|
||||
// #withBalanceSheetActions
|
||||
toggleBalanceSheetFilterDrawer: toggleFilterDrawer,
|
||||
}) {
|
||||
const defaultValues = getDefaultBalanceSheetQuery();
|
||||
|
||||
// Filter form initial values.
|
||||
const initialValues = transformToForm(
|
||||
{
|
||||
...defaultValues,
|
||||
...pageFilter,
|
||||
fromDate: moment(pageFilter.fromDate).toDate(),
|
||||
toDate: moment(pageFilter.toDate).toDate(),
|
||||
},
|
||||
defaultValues,
|
||||
);
|
||||
// Validation schema.
|
||||
const validationSchema = getBalanceSheetHeaderValidationSchema();
|
||||
|
||||
// Handle form submit.
|
||||
const handleSubmit = (values, actions) => {
|
||||
onSubmitFilter(values);
|
||||
toggleFilterDrawer(false);
|
||||
actions.setSubmitting(false);
|
||||
};
|
||||
// Handle cancel button click.
|
||||
const handleCancelClick = () => {
|
||||
toggleFilterDrawer(false);
|
||||
};
|
||||
// Handle drawer close action.
|
||||
const handleDrawerClose = () => {
|
||||
toggleFilterDrawer(false);
|
||||
};
|
||||
// Detarmines the given feature whether is enabled.
|
||||
const { featureCan } = useFeatureCan();
|
||||
|
||||
const isBranchesFeatureCan = featureCan(Features.Branches);
|
||||
|
||||
return (
|
||||
<BalanceSheetFinancialHeader
|
||||
isOpen={balanceSheetDrawerFilter}
|
||||
drawerProps={{
|
||||
onClose: handleDrawerClose,
|
||||
}}
|
||||
>
|
||||
<Formik
|
||||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
<Form>
|
||||
<Tabs animate={true} vertical={true} renderActiveTabPanelOnly={true}>
|
||||
<Tab
|
||||
id="general"
|
||||
title={<T id={'general'} />}
|
||||
panel={<BalanceSheetHeaderGeneralPanal />}
|
||||
/>
|
||||
<Tab
|
||||
id="comparison"
|
||||
title={<T id={'balance_sheet.comparisons'} />}
|
||||
panel={<BalanceSheetHeaderComparisonPanal />}
|
||||
/>
|
||||
{isBranchesFeatureCan && (
|
||||
<Tab
|
||||
id="dimensions"
|
||||
title={<T id={'balance_sheet.dimensions'} />}
|
||||
panel={<BalanceSheetHeaderDimensionsPanel />}
|
||||
/>
|
||||
)}
|
||||
</Tabs>
|
||||
|
||||
<div class="financial-header-drawer__footer">
|
||||
<Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}>
|
||||
<T id={'calculate_report'} />
|
||||
</Button>
|
||||
<Button onClick={handleCancelClick} minimal={true}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</Formik>
|
||||
</BalanceSheetFinancialHeader>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withBalanceSheet(({ balanceSheetDrawerFilter }) => ({
|
||||
balanceSheetDrawerFilter,
|
||||
})),
|
||||
withBalanceSheetActions,
|
||||
)(BalanceSheetHeader);
|
||||
|
||||
const BalanceSheetFinancialHeader = styled(FinancialStatementHeader)`
|
||||
.bp3-drawer {
|
||||
max-height: 520px;
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,173 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { FastField, Field } from 'formik';
|
||||
import { FormGroup, Checkbox } from '@blueprintjs/core';
|
||||
import { Flex, FlexItem, FieldHint, FormattedMessage as T } from '@/components';
|
||||
import {
|
||||
handlePreviousYearCheckBoxChange,
|
||||
handlePreviousYearChangeCheckboxChange,
|
||||
handlePreviousPeriodCheckBoxChange,
|
||||
handlePreivousPeriodPercentageCheckboxChange,
|
||||
handlePreviousYearPercentageCheckboxChange,
|
||||
handlePreviousPeriodChangeCheckboxChange,
|
||||
} from './utils';
|
||||
|
||||
/**
|
||||
* Balance sheet header - Comparison panal - Comparisons fields.
|
||||
*/
|
||||
function BalanceSheetHeaderComparisonPanalFields() {
|
||||
return (
|
||||
<>
|
||||
{/**----------- Previous Year -----------*/}
|
||||
<Field name={'previousYear'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
label={<T id={'balance_sheet.previous_year'} />}
|
||||
{...field}
|
||||
onChange={handlePreviousYearCheckBoxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
|
||||
<FlexSubFields align={'left'}>
|
||||
<FlexItem col={6}>
|
||||
<Field name={'previousYearAmountChange'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
small={true}
|
||||
label={<T id={'balance_sheet.total_change'} />}
|
||||
{...field}
|
||||
onChange={handlePreviousYearChangeCheckboxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</Field>
|
||||
</FlexItem>
|
||||
|
||||
<FlexItem col={6}>
|
||||
<FastField name={'previousYearPercentageChange'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
label={<T id={'balance_sheet.change'} />}
|
||||
{...field}
|
||||
onChange={handlePreviousYearPercentageCheckboxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</FlexItem>
|
||||
</FlexSubFields>
|
||||
|
||||
{/*------------ Previous Period -----------*/}
|
||||
<FastField name={'previousPeriod'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
small={true}
|
||||
label={<T id={'balance_sheet.previous_period'} />}
|
||||
{...field}
|
||||
onChange={handlePreviousPeriodCheckBoxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
<FlexSubFields>
|
||||
<FlexItem col={6}>
|
||||
<FastField name={'previousPeriodAmountChange'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
small={true}
|
||||
label={<T id={'balance_sheet.total_change'} />}
|
||||
{...field}
|
||||
onChange={handlePreviousPeriodChangeCheckboxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</FlexItem>
|
||||
|
||||
<FlexItem col={6}>
|
||||
<FastField name={'previousPeriodPercentageChange'} type={'checkbox'}>
|
||||
{({ form, field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
label={<T id={'balance_sheet.change'} />}
|
||||
{...field}
|
||||
onChange={handlePreivousPeriodPercentageCheckboxChange(form)}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</FlexItem>
|
||||
</FlexSubFields>
|
||||
|
||||
{/**----------- % of Column -----------*/}
|
||||
<FastField name={'percentageOfColumn'} type={'checkbox'}>
|
||||
{({ field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
small={true}
|
||||
label={<T id={'balance_sheet.percentage_of_column'} />}
|
||||
{...field}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
{/**----------- % of Row -----------*/}
|
||||
<FastField name={'percentageOfRow'} type={'checkbox'}>
|
||||
{({ field }) => (
|
||||
<FormGroup labelInfo={<FieldHint />}>
|
||||
<Checkbox
|
||||
inline={true}
|
||||
small={true}
|
||||
label={<T id={'balance_sheet.percentage_of_row'} />}
|
||||
{...field}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Balance sheet header - Comparison panal.
|
||||
*/
|
||||
export default function BalanceSheetHeaderComparisonPanal() {
|
||||
return (
|
||||
<BalanceSheetComparisonWrap>
|
||||
<BalanceSheetComparisonFieldsWrap>
|
||||
<BalanceSheetHeaderComparisonPanalFields />
|
||||
</BalanceSheetComparisonFieldsWrap>
|
||||
</BalanceSheetComparisonWrap>
|
||||
);
|
||||
}
|
||||
|
||||
const BalanceSheetComparisonWrap = styled.div`
|
||||
.bp3-form-group {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
`;
|
||||
|
||||
const FlexSubFields = styled(Flex)`
|
||||
padding-left: 20px;
|
||||
`;
|
||||
|
||||
const BalanceSheetComparisonFieldsWrap = styled.div`
|
||||
width: 400px;
|
||||
`;
|
||||
@@ -0,0 +1,49 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||
import { BranchMultiSelect, Row, Col } from '@/components';
|
||||
import {
|
||||
BalanceSheetHeaderDimensionsProvider,
|
||||
useBalanceSheetHeaderDimensionsPanelContext,
|
||||
} from './BalanceSheetHeaderDimensionsProvider';
|
||||
import { Features } from '@/constants';
|
||||
import { useFeatureCan } from '@/hooks/state';
|
||||
|
||||
/**
|
||||
* Balance sheet header dismension panel.
|
||||
* @returns
|
||||
*/
|
||||
export default function BalanceSheetHeaderDimensionsPanel() {
|
||||
return (
|
||||
<BalanceSheetHeaderDimensionsProvider>
|
||||
<BalanceSheetHeaderDimensionsPanelContent />
|
||||
</BalanceSheetHeaderDimensionsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Balance sheet header dismension panel content.
|
||||
* @returns
|
||||
*/
|
||||
function BalanceSheetHeaderDimensionsPanelContent() {
|
||||
const { branches } = useBalanceSheetHeaderDimensionsPanelContext();
|
||||
const { featureCan } = useFeatureCan();
|
||||
|
||||
const isBranchesFeatureCan = featureCan(Features.Branches);
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col xs={4}>
|
||||
{isBranchesFeatureCan && (
|
||||
<FormGroup
|
||||
label={intl.get('branches_multi_select.label')}
|
||||
className={Classes.FILL}
|
||||
>
|
||||
<BranchMultiSelect name={'branchesIds'} branches={branches} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
|
||||
import { Features } from '@/constants';
|
||||
import { useBranches } from '@/hooks/query';
|
||||
import { useFeatureCan } from '@/hooks/state';
|
||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||
|
||||
const BalanceSheetHeaderDimensionsPanelContext = React.createContext();
|
||||
|
||||
/**
|
||||
* BL sheet header provider.
|
||||
* @returns
|
||||
*/
|
||||
function BalanceSheetHeaderDimensionsProvider({ query, ...props }) {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
|
||||
// Fetches the branches list.
|
||||
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||
enabled: isBranchFeatureCan,
|
||||
keepPreviousData: true,
|
||||
});
|
||||
|
||||
// Provider
|
||||
const provider = {
|
||||
branches,
|
||||
isBranchesLoading,
|
||||
};
|
||||
|
||||
return isBranchesLoading ? (
|
||||
<FinancialHeaderLoadingSkeleton />
|
||||
) : (
|
||||
<BalanceSheetHeaderDimensionsPanelContext.Provider
|
||||
value={provider}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const useBalanceSheetHeaderDimensionsPanelContext = () =>
|
||||
React.useContext(BalanceSheetHeaderDimensionsPanelContext);
|
||||
|
||||
export {
|
||||
BalanceSheetHeaderDimensionsProvider,
|
||||
useBalanceSheetHeaderDimensionsPanelContext,
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
|
||||
import { Row, Col } from '@/components';
|
||||
|
||||
import RadiosAccountingBasis from '../RadiosAccountingBasis';
|
||||
import SelectDisplayColumnsBy from '../SelectDisplayColumnsBy';
|
||||
import FinancialStatementDateRange from '../FinancialStatementDateRange';
|
||||
import FinancialStatementsFilter from '../FinancialStatementsFilter';
|
||||
|
||||
/**
|
||||
* Balance sheet header - General panal.
|
||||
*/
|
||||
export default function BalanceSheetHeaderGeneralTab({}) {
|
||||
return (
|
||||
<div>
|
||||
<FinancialStatementDateRange />
|
||||
<SelectDisplayColumnsBy />
|
||||
|
||||
<Row>
|
||||
<Col xs={4}>
|
||||
<FinancialStatementsFilter initialSelectedItem={'all-accounts'} />
|
||||
</Col>
|
||||
</Row>
|
||||
<RadiosAccountingBasis key={'basis'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// @ts-nocheck
|
||||
import React, { createContext, useContext } from 'react';
|
||||
|
||||
import FinancialReportPage from '../FinancialReportPage';
|
||||
import { useBalanceSheet } from '@/hooks/query';
|
||||
import { transformFilterFormToQuery } from '../common';
|
||||
|
||||
const BalanceSheetContext = createContext();
|
||||
|
||||
function BalanceSheetProvider({ filter, ...props }) {
|
||||
// Transformes the given filter to query.
|
||||
const query = React.useMemo(() => transformFilterFormToQuery(filter), [
|
||||
filter,
|
||||
]);
|
||||
|
||||
// Fetches the balance sheet report.
|
||||
const {
|
||||
data: balanceSheet,
|
||||
isFetching,
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useBalanceSheet(query, { keepPreviousData: true });
|
||||
|
||||
const provider = {
|
||||
balanceSheet,
|
||||
isFetching,
|
||||
isLoading,
|
||||
refetchBalanceSheet: refetch,
|
||||
|
||||
query,
|
||||
filter,
|
||||
};
|
||||
return (
|
||||
<FinancialReportPage name={'balance-sheet'}>
|
||||
<BalanceSheetContext.Provider value={provider} {...props} />
|
||||
</FinancialReportPage>
|
||||
);
|
||||
}
|
||||
|
||||
const useBalanceSheetContext = () => useContext(BalanceSheetContext);
|
||||
|
||||
export { BalanceSheetProvider, useBalanceSheetContext };
|
||||
@@ -0,0 +1,89 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { TableStyle } from '@/constants';
|
||||
import { ReportDataTable, FinancialSheet } from '@/components';
|
||||
import { useBalanceSheetContext } from './BalanceSheetProvider';
|
||||
import { useBalanceSheetColumns } from './components';
|
||||
import { defaultExpanderReducer, tableRowTypesToClassnames } from '@/utils';
|
||||
|
||||
|
||||
/**
|
||||
* Balance sheet table.
|
||||
*/
|
||||
export default function BalanceSheetTable({
|
||||
// #ownProps
|
||||
companyName,
|
||||
}) {
|
||||
// Balance sheet context.
|
||||
const {
|
||||
balanceSheet: { table, query },
|
||||
} = useBalanceSheetContext();
|
||||
|
||||
// Retrieve the database columns.
|
||||
const tableColumns = useBalanceSheetColumns();
|
||||
|
||||
// Retrieve default expanded rows of balance sheet.
|
||||
const expandedRows = React.useMemo(
|
||||
() => defaultExpanderReducer(table.rows, 3),
|
||||
[table],
|
||||
);
|
||||
|
||||
return (
|
||||
<FinancialSheet
|
||||
companyName={companyName}
|
||||
sheetType={intl.get('balance_sheet')}
|
||||
asDate={query.to_date}
|
||||
basis={query.basis}
|
||||
>
|
||||
<BalanceSheetDataTable
|
||||
columns={tableColumns}
|
||||
data={table.rows}
|
||||
rowClassNames={tableRowTypesToClassnames}
|
||||
noInitialFetch={true}
|
||||
expandable={true}
|
||||
expanded={expandedRows}
|
||||
expandToggleColumn={1}
|
||||
expandColumnSpace={0.8}
|
||||
headerLoading={true}
|
||||
sticky={true}
|
||||
styleName={TableStyle.Constrant}
|
||||
/>
|
||||
</FinancialSheet>
|
||||
);
|
||||
}
|
||||
|
||||
const BalanceSheetDataTable = styled(ReportDataTable)`
|
||||
.table {
|
||||
.tbody .tr {
|
||||
.td {
|
||||
border-bottom: 0;
|
||||
padding-top: 0.32rem;
|
||||
padding-bottom: 0.32rem;
|
||||
}
|
||||
&.is-expanded {
|
||||
.td:not(.name) .cell-inner {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
&.row_type--TOTAL {
|
||||
.td {
|
||||
font-weight: 500;
|
||||
border-top: 1px solid #bbb;
|
||||
}
|
||||
}
|
||||
|
||||
&:last-of-type .td {
|
||||
border-bottom: 1px solid #bbb;
|
||||
}
|
||||
&.row_type--TOTAL.row-id--ASSETS,
|
||||
&.row_type--TOTAL.row-id--LIABILITY_EQUITY {
|
||||
.td {
|
||||
border-bottom: 3px double #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,66 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Button } from '@blueprintjs/core';
|
||||
|
||||
import { FormattedMessage as T, Icon, If } from '@/components';
|
||||
|
||||
import FinancialLoadingBar from '../FinancialLoadingBar';
|
||||
import { useBalanceSheetContext } from './BalanceSheetProvider';
|
||||
import { FinancialComputeAlert } from '../FinancialReportPage';
|
||||
import { dynamicColumns } from './dynamicColumns';
|
||||
|
||||
/**
|
||||
* Balance sheet alerts.
|
||||
*/
|
||||
export function BalanceSheetAlerts() {
|
||||
const { isLoading, refetchBalanceSheet, balanceSheet } =
|
||||
useBalanceSheetContext();
|
||||
|
||||
// Handle refetch the report sheet.
|
||||
const handleRecalcReport = () => {
|
||||
refetchBalanceSheet();
|
||||
};
|
||||
// Can't display any error if the report is loading.
|
||||
if (isLoading) return null;
|
||||
|
||||
return (
|
||||
<If condition={balanceSheet.meta.is_cost_compute_running}>
|
||||
<FinancialComputeAlert>
|
||||
<Icon icon="info-block" iconSize={12} />{' '}
|
||||
<T id={'just_a_moment_we_re_calculating_your_cost_transactions'} />
|
||||
|
||||
<Button onClick={handleRecalcReport} minimal={true} small={true}>
|
||||
<T id={'report.compute_running.refresh'} />
|
||||
</Button>
|
||||
</FinancialComputeAlert>
|
||||
</If>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Balance sheet loading bar.
|
||||
*/
|
||||
export function BalanceSheetLoadingBar() {
|
||||
const { isFetching } = useBalanceSheetContext();
|
||||
|
||||
return (
|
||||
<If condition={isFetching}>
|
||||
<FinancialLoadingBar />
|
||||
</If>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve balance sheet columns.
|
||||
*/
|
||||
export const useBalanceSheetColumns = () => {
|
||||
// Balance sheet context.
|
||||
const {
|
||||
balanceSheet: { table },
|
||||
} = useBalanceSheetContext();
|
||||
|
||||
return React.useMemo(
|
||||
() => dynamicColumns(table.columns, table.rows),
|
||||
[table],
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,334 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
import { Align } from '@/constants';
|
||||
import { CellTextSpan } from '@/components/Datatable/Cells';
|
||||
import { getColumnWidth } from '@/utils';
|
||||
|
||||
const getTableCellValueAccessor = (index) => `cells[${index}].value`;
|
||||
|
||||
const getReportColWidth = (data, accessor, headerText) => {
|
||||
return getColumnWidth(
|
||||
data,
|
||||
accessor,
|
||||
{ magicSpacing: 10, minWidth: 100 },
|
||||
headerText,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Account name column mapper.
|
||||
*/
|
||||
const accountNameMapper = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
key: column.key,
|
||||
Header: column.label,
|
||||
accessor,
|
||||
className: column.key,
|
||||
textOverview: true,
|
||||
width: Math.max(width, 300),
|
||||
sticky: Align.Left,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Assoc columns to total column.
|
||||
*/
|
||||
const assocColumnsToTotalColumn = R.curry((data, column, columnAccessor) => {
|
||||
const columns = totalColumnsComposer(data, column);
|
||||
|
||||
return R.assoc('columns', columns, columnAccessor);
|
||||
});
|
||||
|
||||
/**
|
||||
* Detarmines whether the given column has children columns.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isColumnHasColumns = (column) => !isEmpty(column.children);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} data
|
||||
* @param {*} column
|
||||
* @returns
|
||||
*/
|
||||
const dateRangeSoloColumnAttrs = (data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
|
||||
return {
|
||||
accessor,
|
||||
width: getReportColWidth(data, accessor),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Date range columns mapper.
|
||||
*/
|
||||
const dateRangeMapper = R.curry((data, column) => {
|
||||
const isDateColumnHasColumns = isColumnHasColumns(column);
|
||||
|
||||
const columnAccessor = {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
align: isDateColumnHasColumns ? Align.Center : Align.Right,
|
||||
};
|
||||
return R.compose(
|
||||
R.when(
|
||||
R.always(isDateColumnHasColumns),
|
||||
assocColumnsToTotalColumn(data, column),
|
||||
),
|
||||
R.when(
|
||||
R.always(!isDateColumnHasColumns),
|
||||
R.mergeLeft(dateRangeSoloColumnAttrs(data, column)),
|
||||
),
|
||||
)(columnAccessor);
|
||||
});
|
||||
|
||||
/**
|
||||
* Total column mapper.
|
||||
*/
|
||||
const totalMapper = R.curry((data, column) => {
|
||||
const hasChildren = !isEmpty(column.children);
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
const columnAccessor = {
|
||||
key: column.key,
|
||||
Header: column.label,
|
||||
accessor,
|
||||
textOverview: true,
|
||||
Cell: CellTextSpan,
|
||||
width,
|
||||
disableSortBy: true,
|
||||
align: hasChildren ? Align.Center : Align.Right,
|
||||
};
|
||||
return R.compose(
|
||||
R.when(R.always(hasChildren), assocColumnsToTotalColumn(data, column)),
|
||||
)(columnAccessor);
|
||||
});
|
||||
|
||||
/**
|
||||
* `Percentage of column` column accessor.
|
||||
*/
|
||||
const percentageOfColumnAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* `Percentage of row` column accessor.
|
||||
*/
|
||||
const percentageOfRowAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Previous year column accessor.
|
||||
*/
|
||||
const previousYearAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Pervious year change column accessor.
|
||||
*/
|
||||
const previousYearChangeAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Previous year percentage column accessor.
|
||||
*/
|
||||
const previousYearPercentageAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Previous period column accessor.
|
||||
*/
|
||||
const previousPeriodAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Previous period change column accessor.
|
||||
*/
|
||||
const previousPeriodChangeAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Previous period percentage column accessor.
|
||||
*/
|
||||
const previousPeriodPercentageAccessor = R.curry((data, column) => {
|
||||
const accessor = getTableCellValueAccessor(column.cell_index);
|
||||
const width = getReportColWidth(data, accessor, column.label);
|
||||
|
||||
return {
|
||||
Header: column.label,
|
||||
key: column.key,
|
||||
accessor,
|
||||
width,
|
||||
align: Align.Right,
|
||||
disableSortBy: true,
|
||||
textOverview: true,
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} column
|
||||
* @param {*} index
|
||||
* @returns
|
||||
*/
|
||||
const totalColumnsMapper = R.curry((data, column) => {
|
||||
return R.compose(
|
||||
R.when(R.pathEq(['key'], 'total'), totalMapper(data)),
|
||||
// Percetage of column/row.
|
||||
R.when(
|
||||
R.pathEq(['key'], 'percentage_of_column'),
|
||||
percentageOfColumnAccessor(data),
|
||||
),
|
||||
R.when(
|
||||
R.pathEq(['key'], 'percentage_of_row'),
|
||||
percentageOfRowAccessor(data),
|
||||
),
|
||||
// Previous year.
|
||||
R.when(R.pathEq(['key'], 'previous_year'), previousYearAccessor(data)),
|
||||
R.when(
|
||||
R.pathEq(['key'], 'previous_year_change'),
|
||||
previousYearChangeAccessor(data),
|
||||
),
|
||||
R.when(
|
||||
R.pathEq(['key'], 'previous_year_percentage'),
|
||||
previousYearPercentageAccessor(data),
|
||||
),
|
||||
// Pervious period.
|
||||
R.when(R.pathEq(['key'], 'previous_period'), previousPeriodAccessor(data)),
|
||||
R.when(
|
||||
R.pathEq(['key'], 'previous_period_change'),
|
||||
previousPeriodChangeAccessor(data),
|
||||
),
|
||||
R.when(
|
||||
R.pathEq(['key'], 'previous_period_percentage'),
|
||||
previousPeriodPercentageAccessor(data),
|
||||
),
|
||||
)(column);
|
||||
});
|
||||
|
||||
/**
|
||||
* Total sub-columns composer.
|
||||
*/
|
||||
const totalColumnsComposer = R.curry((data, column) => {
|
||||
return R.map(totalColumnsMapper(data), column.children);
|
||||
});
|
||||
|
||||
/**
|
||||
* Detarmines the given string starts with `date-range` string.
|
||||
*/
|
||||
const isMatchesDateRange = (r) => R.match(/^date-range/g, r).length > 0;
|
||||
|
||||
/**
|
||||
* Dynamic column mapper.
|
||||
*/
|
||||
const dynamicColumnMapper = R.curry((data, column) => {
|
||||
const indexTotalMapper = totalMapper(data);
|
||||
const indexAccountNameMapper = accountNameMapper(data);
|
||||
const indexDatePeriodMapper = dateRangeMapper(data);
|
||||
|
||||
return R.compose(
|
||||
R.when(R.pathSatisfies(isMatchesDateRange, ['key']), indexDatePeriodMapper),
|
||||
R.when(R.pathEq(['key'], 'name'), indexAccountNameMapper),
|
||||
R.when(R.pathEq(['key'], 'total'), indexTotalMapper),
|
||||
)(column);
|
||||
});
|
||||
|
||||
/**
|
||||
* Cash flow dynamic columns.
|
||||
*/
|
||||
export const dynamicColumns = (columns, data) => {
|
||||
return R.map(dynamicColumnMapper(data), columns);
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import moment from 'moment';
|
||||
import * as Yup from 'yup';
|
||||
import { castArray } from 'lodash';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { transformToForm } from '@/utils';
|
||||
import { useAppQueryString } from '@/hooks';
|
||||
|
||||
/**
|
||||
* Retrieves the default balance sheet query.
|
||||
* @returns {}
|
||||
*/
|
||||
export const getDefaultBalanceSheetQuery = () => ({
|
||||
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
|
||||
toDate: moment().endOf('year').format('YYYY-MM-DD'),
|
||||
basis: 'cash',
|
||||
displayColumnsType: 'total',
|
||||
filterByOption: 'without-zero-balance',
|
||||
|
||||
previousYear: false,
|
||||
previousYearAmountChange: false,
|
||||
previousYearPercentageChange: false,
|
||||
|
||||
previousPeriod: false,
|
||||
previousPeriodAmountChange: false,
|
||||
previousPeriodPercentageChange: false,
|
||||
|
||||
// Percentage columns.
|
||||
percentageOfColumn: false,
|
||||
percentageOfRow: false,
|
||||
|
||||
branchesIds: [],
|
||||
});
|
||||
|
||||
/**
|
||||
* Parses balance sheet query.
|
||||
*/
|
||||
const parseBalanceSheetQuery = (locationQuery) => {
|
||||
const defaultQuery = getDefaultBalanceSheetQuery();
|
||||
|
||||
const transformed = {
|
||||
...defaultQuery,
|
||||
...transformToForm(locationQuery, defaultQuery),
|
||||
};
|
||||
return {
|
||||
...transformed,
|
||||
|
||||
// Ensures the branches ids is always array.
|
||||
branchesIds: castArray(transformed.branchesIds),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet query.
|
||||
*/
|
||||
export const useBalanceSheetQuery = () => {
|
||||
// Retrieves location query.
|
||||
const [locationQuery, setLocationQuery] = useAppQueryString();
|
||||
|
||||
// Merges the default filter query with location URL query.
|
||||
const query = React.useMemo(
|
||||
() => parseBalanceSheetQuery(locationQuery),
|
||||
[locationQuery],
|
||||
);
|
||||
|
||||
return {
|
||||
query,
|
||||
locationQuery,
|
||||
setLocationQuery,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet header default values.
|
||||
*/
|
||||
export const getBalanceSheetHeaderDefaultValues = () => {
|
||||
return {
|
||||
basic: 'cash',
|
||||
filterByOption: 'without-zero-balance',
|
||||
displayColumnsType: 'total',
|
||||
fromDate: moment().toDate(),
|
||||
toDate: moment().toDate(),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet header validation schema.
|
||||
*/
|
||||
export const getBalanceSheetHeaderValidationSchema = () =>
|
||||
Yup.object().shape({
|
||||
dateRange: Yup.string().optional(),
|
||||
fromDate: Yup.date().required().label(intl.get('fromDate')),
|
||||
toDate: Yup.date()
|
||||
.min(Yup.ref('fromDate'))
|
||||
.required()
|
||||
.label(intl.get('toDate')),
|
||||
filterByOption: Yup.string(),
|
||||
displayColumnsType: Yup.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles previous year checkbox change.
|
||||
*/
|
||||
export const handlePreviousYearCheckBoxChange = R.curry((form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
form.setFieldValue('previousYear', isChecked);
|
||||
|
||||
if (!isChecked) {
|
||||
form.setFieldValue('previousYearAmountChange', isChecked);
|
||||
form.setFieldValue('previousYearPercentageChange', isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles previous period checkbox change.
|
||||
*/
|
||||
export const handlePreviousPeriodCheckBoxChange = R.curry((form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
form.setFieldValue('previousPeriod', isChecked);
|
||||
|
||||
if (!isChecked) {
|
||||
form.setFieldValue('previousPeriodAmountChange', isChecked);
|
||||
form.setFieldValue('previousPeriodPercentageChange', isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles previous year change checkbox change.
|
||||
*/
|
||||
export const handlePreviousYearChangeCheckboxChange = R.curry((form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
|
||||
if (isChecked) {
|
||||
form.setFieldValue('previousYear', event.currentTarget.checked);
|
||||
}
|
||||
form.setFieldValue('previousYearAmountChange', event.currentTarget.checked);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles preivous year percentage checkbox change.
|
||||
*/
|
||||
export const handlePreviousYearPercentageCheckboxChange = R.curry(
|
||||
(form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
|
||||
if (isChecked) {
|
||||
form.setFieldValue('previousYear', event.currentTarget.checked);
|
||||
}
|
||||
form.setFieldValue('previousYearPercentageChange', isChecked);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Handles previous period percentage checkbox change.
|
||||
*/
|
||||
export const handlePreivousPeriodPercentageCheckboxChange = R.curry(
|
||||
(form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
|
||||
if (isChecked) {
|
||||
form.setFieldValue('previousPeriod', isChecked);
|
||||
}
|
||||
form.setFieldValue('previousPeriodPercentageChange', isChecked);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Handle previous period change checkbox change.
|
||||
*/
|
||||
export const handlePreviousPeriodChangeCheckboxChange = R.curry(
|
||||
(form, event) => {
|
||||
const isChecked = event.currentTarget.checked;
|
||||
|
||||
if (isChecked) {
|
||||
form.setFieldValue('previousPeriod', isChecked);
|
||||
}
|
||||
form.setFieldValue('previousPeriodAmountChange', isChecked);
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { getBalanceSheetFilterDrawer } from '@/store/financialStatement/financialStatements.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
const mapStateToProps = (state, props) => {
|
||||
const mapped = {
|
||||
balanceSheetDrawerFilter: getBalanceSheetFilterDrawer(state),
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
};
|
||||
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
toggleBalanceSheetFilterDrawer,
|
||||
} from '@/store/financialStatement/financialStatements.actions';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
toggleBalanceSheetFilterDrawer: (toggle) =>
|
||||
dispatch(toggleBalanceSheetFilterDrawer(toggle)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps);
|
||||
Reference in New Issue
Block a user