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

@@ -19,6 +19,7 @@ import MakeJournalFormFooter from './MakeJournalFormFooter';
import MakeJournalFormDialogs from './MakeJournalFormDialogs';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import AppToaster from 'components/AppToaster';
import withMediaActions from 'containers/Media/withMediaActions';
@@ -38,7 +39,8 @@ function MakeJournalEntriesForm({
journalNextNumber,
journalNumberPrefix,
journalAutoIncrement,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
// Journal form context.
const {
@@ -68,10 +70,10 @@ function MakeJournalEntriesForm({
...(journalAutoIncrement && {
journal_number: defaultTo(journalNumber, ''),
}),
currency_code: baseCurrency,
currency_code: base_currency,
}),
}),
[manualJournal, baseCurrency, journalNumber],
[manualJournal, base_currency, journalNumber],
);
// Handle the form submiting.
@@ -182,10 +184,10 @@ function MakeJournalEntriesForm({
export default compose(
withMediaActions,
withSettings(({ manualJournalsSettings, organizationSettings }) => ({
withSettings(({ manualJournalsSettings }) => ({
journalNextNumber: parseInt(manualJournalsSettings?.nextNumber, 10),
journalNumberPrefix: manualJournalsSettings?.numberPrefix,
journalAutoIncrement: manualJournalsSettings?.autoIncrement,
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(MakeJournalEntriesForm);

View File

@@ -6,13 +6,12 @@ import {
MenuItem,
Menu,
MenuDivider,
Intent
Intent,
} from '@blueprintjs/core';
import { Icon, Money, If } from 'components';
import intl from 'react-intl-universal';
import { safeCallback } from 'utils';
/**
* Accounts table actions menu.
*/
@@ -101,7 +100,8 @@ export function BalanceCell({ cell }) {
return account.amount !== null ? (
<span>
<Money amount={account.amount} currency={account.currency_code} />
{account.formatted_amount}
{/* <Money amount={account.amount} currency={account.currency_code} /> */}
</span>
) : (
<span class="placeholder"></span>

View File

@@ -14,7 +14,7 @@ import CustomerFormAfterPrimarySection from './CustomerFormAfterPrimarySection';
import CustomersTabs from './CustomersTabs';
import CustomerFloatingActions from './CustomerFloatingActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose, transformToForm } from 'utils';
import { useCustomerFormContext } from './CustomerFormProvider';
@@ -59,10 +59,7 @@ const defaultInitialValues = {
/**
* Customer form.
*/
function CustomerForm({
// #withSettings
baseCurrency,
}) {
function CustomerForm({ organization: { base_currency } }) {
const {
customer,
customerId,
@@ -75,7 +72,6 @@ function CustomerForm({
// const isNewMode = !customerId;
const history = useHistory();
/**
* Initial values in create and edit mode.
@@ -83,10 +79,10 @@ function CustomerForm({
const initialValues = useMemo(
() => ({
...defaultInitialValues,
currency_code: baseCurrency,
currency_code: base_currency,
...transformToForm(contactDuplicate || customer, defaultInitialValues),
}),
[customer, contactDuplicate, baseCurrency],
[customer, contactDuplicate, base_currency],
);
//Handles the form submit.
@@ -153,8 +149,4 @@ function CustomerForm({
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(CustomerForm);
export default compose(withCurrentOrganization())(CustomerForm);

View File

@@ -10,7 +10,6 @@ import { useAccountDrawerContext } from './AccountDrawerProvider';
*/
export default function AccountDrawerHeader() {
const { account } = useAccountDrawerContext();
return (
<div className={'account-drawer__content-header'}>
<DetailsMenu>
@@ -18,9 +17,7 @@ export default function AccountDrawerHeader() {
name={'closing-balance'}
label={<T id={'closing_balance'} />}
>
<h3 class={'big-number'}>
<Money amount={account.amount} currency={account.currency_code} />
</h3>
<h3 class={'big-number'}>{account.formatted_amount}</h3>
</DetailItem>
<DetailItem name={'account-type'} label={<T id={'account_type'} />}>
@@ -50,7 +47,7 @@ export default function AccountDrawerHeader() {
<DetailItem name={'description'} label={<T id={'description'} />}>
{defaultTo(account.description, '--')}
</DetailItem>
</DetailsMenu>
</DetailsMenu>
</div>
);
}

View File

@@ -9,9 +9,10 @@ import { isBlank } from 'utils';
* Debit/credit table cell.
*/
function DebitCreditTableCell({ value, payload: { account } }) {
return !isBlank(value) && value !== 0 ? (
<Money amount={value} currency={account.currency_code} />
) : null;
return !isBlank(value) && value !== 0
? // <Money amount={value} currency={account.currency_code} />
account.formatted_amount
: null;
}
/**
@@ -19,7 +20,8 @@ function DebitCreditTableCell({ value, payload: { account } }) {
*/
function RunningBalanceTableCell({ value, payload: { account } }) {
return (
<Money amount={value} currency={account.currency_code} />
// <Money amount={value} currency={account.currency_code} />
account.formatted_amount
);
}

View File

@@ -18,6 +18,7 @@ import { useExpenseFormContext } from './ExpenseFormPageProvider';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withMediaActions from 'containers/Media/withMediaActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import AppToaster from 'components/AppToaster';
import {
@@ -32,8 +33,9 @@ import { compose, orderingLinesIndexes } from 'utils';
*/
function ExpenseForm({
// #withSettings
baseCurrency,
preferredPaymentAccount,
// #withCurrentOrganization
organization: { base_currency },
}) {
// Expense form context.
const {
@@ -58,11 +60,11 @@ function ExpenseForm({
}
: {
...defaultExpense,
currency_code: baseCurrency,
currency_code: base_currency,
payment_account_id: defaultTo(preferredPaymentAccount, ''),
}),
}),
[expense, baseCurrency, preferredPaymentAccount],
[expense, base_currency, preferredPaymentAccount],
);
// Handle form submit.
@@ -79,16 +81,13 @@ function ExpenseForm({
}
// Filter expense entries that has no amount or expense account.
const categories = values.categories.filter(
(category) =>
category.amount && category.expense_account_id,
(category) => category.amount && category.expense_account_id,
);
const form = {
...values,
publish: submitPayload.publish,
categories: R.compose(
orderingLinesIndexes,
)(categories),
categories: R.compose(orderingLinesIndexes)(categories),
};
// Handle request success.
const handleSuccess = (response) => {
@@ -158,11 +157,11 @@ function ExpenseForm({
export default compose(
withDashboardActions,
withMediaActions,
withSettings(({ organizationSettings, expenseSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
withSettings(({ expenseSettings }) => ({
preferredPaymentAccount: parseInt(
expenseSettings?.preferredPaymentAccount,
10,
),
})),
withCurrentOrganization(),
)(ExpenseForm);

View File

@@ -19,7 +19,7 @@ import { FormattedMessage as T } from 'components';
import classNames from 'classnames';
import { useItemFormContext } from './ItemFormProvider';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { ACCOUNT_PARENT_TYPE } from 'common/accountTypes';
import { compose, inputIntent } from 'utils';
@@ -35,7 +35,7 @@ import {
/**
* Item form body.
*/
function ItemFormBody({ baseCurrency }) {
function ItemFormBody({ organization: { base_currency } }) {
const { accounts } = useItemFormContext();
const { values } = useFormikContext();
@@ -76,7 +76,7 @@ function ItemFormBody({ baseCurrency }) {
inline={true}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
inputGroupProps={{ fill: true }}
@@ -182,7 +182,7 @@ function ItemFormBody({ baseCurrency }) {
inline={true}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
inputGroupProps={{ medium: true }}
@@ -259,8 +259,4 @@ function ItemFormBody({ baseCurrency }) {
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ItemFormBody);
export default compose(withCurrentOrganization())(ItemFormBody);

View File

@@ -6,7 +6,7 @@ import { CLASSES } from 'common/classes';
import { FormattedMessage as T } from 'components';
import classNames from 'classnames';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { accountsFieldShouldUpdate } from './utils';
import { compose, inputIntent } from 'utils';
@@ -16,7 +16,7 @@ import { useItemFormContext } from './ItemFormProvider';
/**
* Item form inventory sections.
*/
function ItemFormInventorySection({ baseCurrency }) {
function ItemFormInventorySection({ organization: { base_currency } }) {
const { accounts } = useItemFormContext();
return (
@@ -63,8 +63,4 @@ function ItemFormInventorySection({ baseCurrency }) {
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ItemFormInventorySection);
export default compose(withCurrentOrganization())(ItemFormInventorySection);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -15,6 +15,8 @@ import PaymentMadeFormBody from './PaymentMadeFormBody';
import { PaymentMadeInnerProvider } from './PaymentMadeInnerProvider';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import {
EditPaymentMadeFormSchema,
CreatePaymentMadeFormSchema,
@@ -29,7 +31,9 @@ import { defaultPaymentMade, transformToEditForm, ERRORS } from './utils';
function PaymentMadeForm({
// #withSettings
preferredPaymentAccount,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const history = useHistory();
@@ -54,7 +58,7 @@ function PaymentMadeForm({
: {
...defaultPaymentMade,
payment_account_id: defaultTo(preferredPaymentAccount),
currency_code: baseCurrency,
currency_code: base_currency,
entries: orderingLinesIndexes(defaultPaymentMade.entries),
}),
}),
@@ -156,10 +160,10 @@ function PaymentMadeForm({
}
export default compose(
withSettings(({ billPaymentSettings, organizationSettings }) => ({
withSettings(({ billPaymentSettings }) => ({
paymentNextNumber: billPaymentSettings?.next_number,
paymentNumberPrefix: billPaymentSettings?.number_prefix,
preferredPaymentAccount: parseInt(billPaymentSettings?.withdrawalAccount),
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(PaymentMadeForm);

View File

@@ -8,14 +8,14 @@ import { Money } from 'components';
import { FormattedMessage as T } from 'components';
import PaymentMadeFormHeaderFields from './PaymentMadeFormHeaderFields';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
/**
* Payment made header form.
*/
function PaymentMadeFormHeader({
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
// Formik form context.
const {
@@ -36,7 +36,7 @@ function PaymentMadeFormHeader({
<T id={'amount_received'} />
</span>
<h1 class="big-amount__number">
<Money amount={amountPaid} currency={baseCurrency} />
<Money amount={amountPaid} currency={base_currency} />
</h1>
</div>
</div>
@@ -45,8 +45,4 @@ function PaymentMadeFormHeader({
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentMadeFormHeader);
export default compose(withCurrentOrganization())(PaymentMadeFormHeader);

View File

@@ -23,7 +23,7 @@ import {
Icon,
MoneyInputGroup,
} from 'components';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { usePaymentMadeFormContext } from './PaymentMadeFormProvider';
import { ACCOUNT_TYPE } from 'common/accountTypes';
import {
@@ -41,7 +41,7 @@ import { accountsFieldShouldUpdate, vendorsFieldShouldUpdate } from './utils';
/**
* Payment made form header fields.
*/
function PaymentMadeFormHeaderFields({ baseCurrency }) {
function PaymentMadeFormHeaderFields({ organization: { base_currency } }) {
// Formik form context.
const {
values: { entries },
@@ -143,7 +143,7 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
helperText={<ErrorMessage name="full_amount" />}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
onChange={(value) => {
@@ -160,7 +160,7 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
minimal={true}
>
<T id={'receive_full_amount'} /> (
<Money amount={payableFullAmount} currency={baseCurrency} />)
<Money amount={payableFullAmount} currency={base_currency} />)
</Button>
</FormGroup>
)}
@@ -244,8 +244,4 @@ function PaymentMadeFormHeaderFields({ baseCurrency }) {
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentMadeFormHeaderFields);
export default compose(withCurrentOrganization())(PaymentMadeFormHeaderFields);

View File

@@ -10,7 +10,8 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withPaymentMadeActions from './withPaymentMadeActions';
import withPaymentMade from './withPaymentMade';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { usePaymentMadesTableColumns, ActionsMenu } from './components';
@@ -109,7 +110,5 @@ export default compose(
withPaymentMade(({ paymentMadesTableState }) => ({ paymentMadesTableState })),
withAlertsActions,
withDrawerActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(PaymentMadesTable);

View File

@@ -24,7 +24,7 @@ import EstimatesEmptyStatus from './EstimatesEmptyStatus';
import { statusAccessor } from './components';
import withEstimates from './withEstimates';
import withEstimateActions from './withEstimateActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
// Estimates transactions datatable.
function EstimatesDataTable({
@@ -38,8 +38,8 @@ function EstimatesDataTable({
// #withEstimatesActions
addEstimatesTableQueries,
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
// #ownProps
onEditEstimate,
@@ -50,7 +50,6 @@ function EstimatesDataTable({
onDrawerEstimate,
onSelectedRowsChange,
}) {
const isLoaded = useIsValuePassed(estimatesLoading, false);
const handleEditEstimate = useCallback(
@@ -171,7 +170,7 @@ function EstimatesDataTable({
{
id: 'amount',
Header: intl.get('amount'),
accessor: (r) => <Money amount={r.amount} currency={baseCurrency} />,
accessor: (r) => <Money amount={r.amount} currency={base_currency} />,
width: 140,
className: 'amount',
@@ -293,7 +292,5 @@ export default compose(
estimatesCurrentViewId,
}),
),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(EstimatesDataTable);

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);

View File

@@ -20,6 +20,7 @@ import InvoiceFormDialogs from './InvoiceFormDialogs';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withMediaActions from 'containers/Media/withMediaActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { AppToaster } from 'components';
import { compose, orderingLinesIndexes, transactionNumber } from 'utils';
@@ -34,7 +35,9 @@ function InvoiceForm({
invoiceNextNumber,
invoiceNumberPrefix,
invoiceIncrementMode,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const history = useHistory();
@@ -58,7 +61,7 @@ function InvoiceForm({
const initialValues = useMemo(
() => ({
...(!isEmpty(invoice)
? { ...transformToEditForm(invoice), currency_code: baseCurrency }
? { ...transformToEditForm(invoice), currency_code: base_currency }
: {
...defaultInvoice,
...(invoiceIncrementMode && {
@@ -66,7 +69,7 @@ function InvoiceForm({
}),
entries: orderingLinesIndexes(defaultInvoice.entries),
...newInvoice,
currency_code: baseCurrency,
currency_code: base_currency,
}),
}),
[invoice, newInvoice, invoiceNumber, invoiceIncrementMode],
@@ -171,10 +174,10 @@ function InvoiceForm({
export default compose(
withDashboardActions,
withMediaActions,
withSettings(({ invoiceSettings, organizationSettings }) => ({
withSettings(({ invoiceSettings }) => ({
invoiceNextNumber: invoiceSettings?.nextNumber,
invoiceNumberPrefix: invoiceSettings?.numberPrefix,
invoiceIncrementMode: invoiceSettings?.incrementMode,
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(InvoiceForm);

View File

@@ -9,7 +9,7 @@ import InvoiceFormHeaderFields from './InvoiceFormHeaderFields';
import { getEntriesTotal } from 'containers/Entries/utils';
import { PageFormBigNumber } from 'components';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'redux';
@@ -17,8 +17,8 @@ import { compose } from 'redux';
* Invoice form header section.
*/
function InvoiceFormHeader({
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
@@ -34,13 +34,9 @@ function InvoiceFormHeader({
<PageFormBigNumber
label={intl.get('due_amount')}
amount={totalDueAmount}
currencyCode={baseCurrency}
currencyCode={base_currency}
/>
</div>
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(InvoiceFormHeader);
export default compose(withCurrentOrganization())(InvoiceFormHeader);

View File

@@ -11,7 +11,6 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withInvoices from './withInvoices';
import withInvoiceActions from './withInvoiceActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions';
@@ -29,9 +28,6 @@ function InvoicesDataTable({
// #withInvoices
invoicesTableState,
// #withSettings
baseCurrency,
// #withAlertsActions
openAlert,
@@ -136,7 +132,6 @@ function InvoicesDataTable({
onQuick: handleQuickPaymentReceive,
onViewDetails: handleViewDetailInvoice,
onPrint: handlePrintInvoice,
baseCurrency,
}}
/>
);
@@ -149,7 +144,4 @@ export default compose(
withDrawerActions,
withDialogActions,
withInvoices(({ invoicesTableState }) => ({ invoicesTableState })),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(InvoicesDataTable);

View File

@@ -18,6 +18,8 @@ import PaymentReceiveFormDialogs from './PaymentReceiveFormDialogs';
import { PaymentReceiveInnerProvider } from './PaymentReceiveInnerProvider';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import {
EditPaymentReceiveFormSchema,
CreatePaymentReceiveFormSchema,
@@ -37,7 +39,9 @@ function PaymentReceiveForm({
paymentReceiveNextNumber,
paymentReceiveNumberPrefix,
paymentReceiveAutoIncrement,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const history = useHistory();
@@ -68,7 +72,7 @@ function PaymentReceiveForm({
payment_receive_no: nextPaymentNumber,
deposit_account_id: defaultTo(preferredDepositAccount, ''),
}),
currency_code: baseCurrency,
currency_code: base_currency,
}),
}),
[
@@ -198,12 +202,12 @@ function PaymentReceiveForm({
}
export default compose(
withSettings(({ paymentReceiveSettings, organizationSettings }) => ({
withSettings(({ paymentReceiveSettings }) => ({
paymentReceiveSettings,
paymentReceiveNextNumber: paymentReceiveSettings?.nextNumber,
paymentReceiveNumberPrefix: paymentReceiveSettings?.numberPrefix,
paymentReceiveAutoIncrement: paymentReceiveSettings?.autoIncrement,
preferredDepositAccount: paymentReceiveSettings?.depositAccount,
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(PaymentReceiveForm);

View File

@@ -7,7 +7,7 @@ import { FormattedMessage as T } from 'components';
import { CLASSES } from 'common/classes';
import PaymentReceiveHeaderFields from './PaymentReceiveHeaderFields';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'utils';
@@ -15,8 +15,8 @@ import { compose } from 'utils';
* Payment receive form header.
*/
function PaymentReceiveFormHeader({
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
// Formik form context.
const { values } = useFormikContext();
@@ -38,7 +38,7 @@ function PaymentReceiveFormHeader({
<T id={'amount_received'} />
</span>
<h1 class="big-amount__number">
<Money amount={paymentFullAmount} currency={baseCurrency} />
<Money amount={paymentFullAmount} currency={base_currency} />
</h1>
</div>
</div>
@@ -47,8 +47,4 @@ function PaymentReceiveFormHeader({
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentReceiveFormHeader);
export default compose(withCurrentOrganization())(PaymentReceiveFormHeader);

View File

@@ -37,6 +37,7 @@ import { ACCOUNT_TYPE } from 'common/accountTypes';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import {
useObservePaymentNoSettings,
@@ -51,7 +52,8 @@ import { toSafeInteger } from 'lodash';
* Payment receive header fields.
*/
function PaymentReceiveHeaderFields({
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
// #withDialogActions
openDialog,
@@ -192,7 +194,7 @@ function PaymentReceiveHeaderFields({
helperText={<ErrorMessage name="full_amount" />}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
onChange={(value) => {
@@ -209,7 +211,7 @@ function PaymentReceiveHeaderFields({
minimal={true}
>
<T id={'receive_full_amount'} /> (
<Money amount={totalDueAmount} currency={baseCurrency} />)
<Money amount={totalDueAmount} currency={base_currency} />)
</Button>
</FormGroup>
)}
@@ -313,11 +315,11 @@ function PaymentReceiveHeaderFields({
}
export default compose(
withSettings(({ organizationSettings, paymentReceiveSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
withSettings(({ paymentReceiveSettings }) => ({
paymentReceiveNextNumber: paymentReceiveSettings?.nextNumber,
paymentReceiveNumberPrefix: paymentReceiveSettings?.numberPrefix,
paymentReceiveAutoIncrement: paymentReceiveSettings?.autoIncrement,
})),
withDialogActions,
withCurrentOrganization(),
)(PaymentReceiveHeaderFields);

View File

@@ -12,7 +12,6 @@ import withPaymentReceives from './withPaymentReceives';
import withPaymentReceivesActions from './withPaymentReceivesActions';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withSettings from 'containers/Settings/withSettings';
import { usePaymentReceivesColumns, ActionsMenu } from './components';
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
@@ -121,7 +120,4 @@ export default compose(
withPaymentReceives(({ paymentReceivesTableState }) => ({
paymentReceivesTableState,
})),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentReceivesDataTable);

View File

@@ -23,6 +23,7 @@ import ReceiptFormDialogs from './ReceiptFormDialogs';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { AppToaster } from 'components';
import { compose, orderingLinesIndexes, transactionNumber } from 'utils';
@@ -37,7 +38,9 @@ function ReceiptForm({
receiptNumberPrefix,
receiptAutoIncrement,
preferredDepositAccount,
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const history = useHistory();
@@ -59,7 +62,7 @@ function ReceiptForm({
const initialValues = useMemo(
() => ({
...(!isEmpty(receipt)
? { ...transformToEditForm(receipt), currency_code: baseCurrency }
? { ...transformToEditForm(receipt), currency_code: base_currency }
: {
...defaultReceipt,
...(receiptAutoIncrement && {
@@ -67,7 +70,7 @@ function ReceiptForm({
}),
deposit_account_id: parseInt(preferredDepositAccount),
entries: orderingLinesIndexes(defaultReceipt.entries),
currency_code: baseCurrency,
currency_code: base_currency,
}),
}),
[receipt, preferredDepositAccount, nextReceiptNumber, receiptAutoIncrement],
@@ -104,7 +107,7 @@ function ReceiptForm({
...omit(values, ['receipt_number_manually', 'receipt_number']),
...(values.receipt_number_manually && {
receipt_number: values.receipt_number,
currency_code: baseCurrency,
currency_code: base_currency,
}),
closed: submitPayload.status,
entries: entries.map((entry) => ({ ...omit(entry, ['total']) })),
@@ -178,11 +181,11 @@ function ReceiptForm({
export default compose(
withDashboardActions,
withSettings(({ receiptSettings, organizationSettings }) => ({
withSettings(({ receiptSettings }) => ({
receiptNextNumber: receiptSettings?.nextNumber,
receiptNumberPrefix: receiptSettings?.numberPrefix,
receiptAutoIncrement: receiptSettings?.autoIncrement,
preferredDepositAccount: receiptSettings?.preferredDepositAccount,
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(ReceiptForm);

View File

@@ -7,7 +7,7 @@ import { CLASSES } from 'common/classes';
import { PageFormBigNumber } from 'components';
import ReceiptFormHeaderFields from './ReceiptFormHeaderFields';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { getEntriesTotal } from 'containers/Entries/utils';
import { compose } from 'redux';
@@ -18,8 +18,8 @@ import { compose } from 'redux';
function ReceiptFormHeader({
// #ownProps
onReceiptNumberChanged,
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
const { values } = useFormikContext();
@@ -37,14 +37,10 @@ function ReceiptFormHeader({
<PageFormBigNumber
label={intl.get('due_amount')}
amount={totalDueAmount}
currencyCode={baseCurrency}
currencyCode={base_currency}
/>
</div>
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ReceiptFormHeader);
export default compose(withCurrentOrganization())(ReceiptFormHeader);

View File

@@ -13,7 +13,6 @@ import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withReceipts from './withReceipts';
import withReceiptsActions from './withReceiptsActions';
import withSettings from 'containers/Settings/withSettings';
import { useReceiptsListContext } from './ReceiptsListProvider';
import { useReceiptsTableColumns, ActionsMenu } from './components';
@@ -28,9 +27,6 @@ function ReceiptsDataTable({
// #withReceipts
receiptTableState,
// #withSettings
baseCurrency,
// #withAlertsActions
openAlert,
@@ -128,7 +124,6 @@ function ReceiptsDataTable({
onDrawer: handleDrawerReceipt,
onViewDetails: handleViewDetailReceipt,
onPrint: handlePrintInvoice,
baseCurrency,
}}
/>
);
@@ -142,7 +137,4 @@ export default compose(
withReceipts(({ receiptTableState }) => ({
receiptTableState,
})),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ReceiptsDataTable);

View File

@@ -4,7 +4,7 @@ import 'style/pages/Subscription/BillingPlans.scss';
import BillingPlansInput from './BillingPlansInput';
import BillingPeriodsInput from './BillingPeriodsInput';
import BillingPaymentMethod from './BillingPaymentMethod';
// import BillingPaymentMethod from './BillingPaymentMethod';
/**
* Billing plans form.
@@ -14,7 +14,7 @@ export default function BillingPlansForm() {
<div class="billing-plans">
<BillingPlansInput />
<BillingPeriodsInput />
<BillingPaymentMethod />
{/* <BillingPaymentMethod /> */}
</div>
);
}

View File

@@ -20,7 +20,7 @@ import VendorTabs from './VendorsTabs';
import VendorFloatingActions from './VendorFloatingActions';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { useVendorFormContext } from './VendorFormProvider';
import { compose, transformToForm } from 'utils';
@@ -67,8 +67,8 @@ function VendorForm({
// #withDashboardActions
changePageTitle,
// #withSettings
baseCurrency,
// #withCurrentOrganization
organization: { base_currency },
}) {
// Vendor form context.
const {
@@ -93,11 +93,11 @@ function VendorForm({
const initialValues = useMemo(
() => ({
...defaultInitialValues,
currency_code: baseCurrency,
currency_code: base_currency,
...transformToForm(vendor, defaultInitialValues),
...transformToForm(contactDuplicate, defaultInitialValues),
}),
[vendor, contactDuplicate, baseCurrency],
[vendor, contactDuplicate, base_currency],
);
// Handles the form submit.
@@ -169,7 +169,5 @@ function VendorForm({
export default compose(
withDashboardActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
withCurrentOrganization(),
)(VendorForm);