mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
BC-4: feat: base currency withCurrentOrganization
This commit is contained in:
@@ -20,14 +20,14 @@ import { ERROR } from 'common/errors';
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
import { compose, orderingLinesIndexes, safeSumBy } from 'utils';
|
||||
import { defaultBill, transformToEditForm } from './utils';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
|
||||
/**
|
||||
* Bill form.
|
||||
*/
|
||||
function BillForm({
|
||||
// #withSettings
|
||||
baseCurrency,
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
@@ -41,14 +41,14 @@ function BillForm({
|
||||
...(!isEmpty(bill)
|
||||
? {
|
||||
...transformToEditForm(bill),
|
||||
currency_code: baseCurrency,
|
||||
currency_code: base_currency,
|
||||
}
|
||||
: {
|
||||
...defaultBill,
|
||||
currency_code: baseCurrency,
|
||||
currency_code: base_currency,
|
||||
}),
|
||||
}),
|
||||
[bill, baseCurrency],
|
||||
[bill, base_currency],
|
||||
);
|
||||
|
||||
// Transform response error to fields.
|
||||
@@ -142,8 +142,4 @@ function BillForm({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillForm);
|
||||
export default compose(withCurrentOrganization())(BillForm);
|
||||
|
||||
@@ -8,22 +8,24 @@ import { CLASSES } from 'common/classes';
|
||||
|
||||
import BillFormHeaderFields from './BillFormHeaderFields';
|
||||
import { PageFormBigNumber } from 'components';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
|
||||
import { compose } from 'redux';
|
||||
|
||||
/**
|
||||
* Fill form header.
|
||||
*/
|
||||
function BillFormHeader({
|
||||
// #withSettings
|
||||
baseCurrency,
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
}) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate the total due amount of bill entries.
|
||||
const totalDueAmount = useMemo(() => sumBy(values.entries, 'amount'), [
|
||||
values.entries,
|
||||
]);
|
||||
const totalDueAmount = useMemo(
|
||||
() => sumBy(values.entries, 'amount'),
|
||||
[values.entries],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||
@@ -31,13 +33,9 @@ function BillFormHeader({
|
||||
<PageFormBigNumber
|
||||
label={intl.get('due_amount')}
|
||||
amount={totalDueAmount}
|
||||
currencyCode={baseCurrency}
|
||||
currencyCode={base_currency}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillFormHeader);
|
||||
export default compose(withCurrentOrganization())(BillFormHeader);
|
||||
|
||||
@@ -11,7 +11,6 @@ import BillsEmptyStatus from './BillsEmptyStatus';
|
||||
|
||||
import withBills from './withBills';
|
||||
import withBillActions from './withBillsActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
@@ -33,7 +32,7 @@ function BillsDataTable({
|
||||
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
@@ -127,7 +126,4 @@ export default compose(
|
||||
withAlertsActions,
|
||||
withDrawerActions,
|
||||
withDialogActions,
|
||||
withSettings(({ organizationSettings }) => ({
|
||||
baseCurrency: organizationSettings?.baseCurrency,
|
||||
})),
|
||||
)(BillsDataTable);
|
||||
|
||||
Reference in New Issue
Block a user