BC-4: feat: base currency withCurrentOrganization

This commit is contained in:
elforjani3
2021-09-07 00:16:46 +02:00
parent 6401692903
commit 39ba31a842
31 changed files with 152 additions and 213 deletions

View File

@@ -20,6 +20,7 @@ import EstimateFormFooter from './EstimateFormFooter';
import EstimateFormDialogs from './EstimateFormDialogs';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { AppToaster } from 'components';
import { ERROR } from 'common/errors';
@@ -35,7 +36,9 @@ function EstimateForm({
estimateNextNumber,
estimateNumberPrefix,
estimateIncrementMode,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const history = useHistory();
const {
@@ -55,14 +58,14 @@ function EstimateForm({
const initialValues = useMemo(
() => ({
...(!isEmpty(estimate)
? { ...transformToEditForm(estimate), currency_code: baseCurrency }
? { ...transformToEditForm(estimate), currency_code: base_currency }
: {
...defaultEstimate,
...(estimateIncrementMode && {
estimate_number: estimateNumber,
}),
entries: orderingLinesIndexes(defaultEstimate.entries),
currency_code: baseCurrency,
currency_code: base_currency,
}),
}),
[estimate, estimateNumber, estimateIncrementMode],
@@ -172,10 +175,10 @@ function EstimateForm({
}
export default compose(
withSettings(({ estimatesSettings, organizationSettings }) => ({
withSettings(({ estimatesSettings }) => ({
estimateNextNumber: estimatesSettings?.nextNumber,
estimateNumberPrefix: estimatesSettings?.numberPrefix,
estimateIncrementMode: estimatesSettings?.autoIncrement,
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(EstimateForm);

View File

@@ -6,7 +6,7 @@ import intl from 'react-intl-universal';
import { CLASSES } from 'common/classes';
import EstimateFormHeaderFields from './EstimateFormHeaderFields';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { getEntriesTotal } from 'containers/Entries/utils';
import { PageFormBigNumber } from 'components';
@@ -14,8 +14,8 @@ import { compose } from 'utils';
// Estimate form top header.
function EstimateFormHeader({
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
@@ -32,14 +32,10 @@ function EstimateFormHeader({
<PageFormBigNumber
label={intl.get('amount')}
amount={totalDueAmount}
currencyCode={baseCurrency}
currencyCode={base_currency}
/>
</div>
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(EstimateFormHeader);
export default compose(withCurrentOrganization())(EstimateFormHeader);

View File

@@ -9,7 +9,6 @@ import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withEstimatesActions from './withEstimatesActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions';
@@ -146,7 +145,4 @@ export default compose(
withAlertsActions,
withDrawerActions,
withDialogActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(EstimatesDataTable);