This commit is contained in:
a.bouhuolia
2021-09-08 16:32:59 +02:00
49 changed files with 305 additions and 216 deletions

View File

@@ -73,6 +73,11 @@ function ManualJournalsDataTable({
}); });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('journal-drawer', { manualJournalId: cell.row.original.id });
};
// Handle fetch data once the page index, size or sort by of the table change. // Handle fetch data once the page index, size or sort by of the table change.
const handleFetchData = React.useCallback( const handleFetchData = React.useCallback(
({ pageSize, pageIndex, sortBy }) => { ({ pageSize, pageIndex, sortBy }) => {
@@ -112,6 +117,7 @@ function ManualJournalsDataTable({
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onFetchData={handleFetchData} onFetchData={handleFetchData}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleDeleteJournal, onDelete: handleDeleteJournal,
onPublish: handlePublishJournal, onPublish: handlePublishJournal,

View File

@@ -20,6 +20,7 @@ export const useManualJournalsColumns = () => {
accessor: DateAccessor, accessor: DateAccessor,
width: 115, width: 115,
className: 'date', className: 'date',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -27,6 +28,7 @@ export const useManualJournalsColumns = () => {
accessor: 'formatted_amount', accessor: 'formatted_amount',
className: 'amount', className: 'amount',
width: 115, width: 115,
clickable: true,
}, },
{ {
id: 'journal_number', id: 'journal_number',
@@ -34,6 +36,7 @@ export const useManualJournalsColumns = () => {
accessor: (row) => `#${row.journal_number}`, accessor: (row) => `#${row.journal_number}`,
className: 'journal_number', className: 'journal_number',
width: 100, width: 100,
clickable: true,
}, },
{ {
id: 'journal_type', id: 'journal_type',
@@ -41,6 +44,7 @@ export const useManualJournalsColumns = () => {
accessor: 'journal_type', accessor: 'journal_type',
width: 110, width: 110,
className: 'journal_type', className: 'journal_type',
clickable: true,
}, },
{ {
id: 'status', id: 'status',
@@ -48,6 +52,7 @@ export const useManualJournalsColumns = () => {
accessor: (row) => StatusAccessor(row), accessor: (row) => StatusAccessor(row),
width: 95, width: 95,
className: 'status', className: 'status',
clickable: true,
}, },
{ {
id: 'note', id: 'note',
@@ -56,6 +61,7 @@ export const useManualJournalsColumns = () => {
disableSortBy: true, disableSortBy: true,
width: 85, width: 85,
className: 'note', className: 'note',
clickable: true,
}, },
{ {
id: 'created_at', id: 'created_at',
@@ -63,6 +69,7 @@ export const useManualJournalsColumns = () => {
accessor: (r) => moment(r.created_at).format('YYYY MMM DD'), accessor: (r) => moment(r.created_at).format('YYYY MMM DD'),
width: 125, width: 125,
className: 'created_at', className: 'created_at',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

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

View File

@@ -95,6 +95,11 @@ function CustomersTable({
openDrawer('contact-detail-drawer', { contactId: id }); openDrawer('contact-detail-drawer', { contactId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('contact-detail-drawer', { contactId: cell.row.original.id });
};
if (isEmptyStatus) { if (isEmptyStatus) {
return <CustomersEmptyStatus />; return <CustomersEmptyStatus />;
} }
@@ -122,6 +127,7 @@ function CustomersTable({
autoResetPage={false} autoResetPage={false}
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleCustomerDelete, onDelete: handleCustomerDelete,
onEdit: handleCustomerEdit, onEdit: handleCustomerEdit,

View File

@@ -104,6 +104,7 @@ export function useCustomersTableColumns() {
width: 45, width: 45,
disableResizing: true, disableResizing: true,
disableSortBy: true, disableSortBy: true,
clickable: true,
}, },
{ {
id: 'display_name', id: 'display_name',
@@ -111,6 +112,7 @@ export function useCustomersTableColumns() {
accessor: 'display_name', accessor: 'display_name',
className: 'display_name', className: 'display_name',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'company_name', id: 'company_name',
@@ -118,6 +120,7 @@ export function useCustomersTableColumns() {
accessor: 'company_name', accessor: 'company_name',
className: 'company_name', className: 'company_name',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'work_phone', id: 'work_phone',
@@ -125,6 +128,7 @@ export function useCustomersTableColumns() {
accessor: PhoneNumberAccessor, accessor: PhoneNumberAccessor,
className: 'phone_number', className: 'phone_number',
width: 100, width: 100,
clickable: true,
}, },
{ {
id: 'balance', id: 'balance',
@@ -132,6 +136,7 @@ export function useCustomersTableColumns() {
accessor: BalanceAccessor, accessor: BalanceAccessor,
className: 'receivable_balance', className: 'receivable_balance',
width: 100, width: 100,
clickable: true,
}, },
], ],
[], [],

View File

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

View File

@@ -9,9 +9,10 @@ import { isBlank } from 'utils';
* Debit/credit table cell. * Debit/credit table cell.
*/ */
function DebitCreditTableCell({ value, payload: { account } }) { function DebitCreditTableCell({ value, payload: { account } }) {
return !isBlank(value) && value !== 0 ? ( return !isBlank(value) && value !== 0
<Money amount={value} currency={account.currency_code} /> ? // <Money amount={value} currency={account.currency_code} />
) : null; account.formatted_amount
: null;
} }
/** /**
@@ -19,7 +20,8 @@ function DebitCreditTableCell({ value, payload: { account } }) {
*/ */
function RunningBalanceTableCell({ value, payload: { account } }) { function RunningBalanceTableCell({ value, payload: { account } }) {
return ( 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 withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withMediaActions from 'containers/Media/withMediaActions'; import withMediaActions from 'containers/Media/withMediaActions';
import withSettings from 'containers/Settings/withSettings'; import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import AppToaster from 'components/AppToaster'; import AppToaster from 'components/AppToaster';
import { import {
@@ -32,8 +33,9 @@ import { compose, orderingLinesIndexes } from 'utils';
*/ */
function ExpenseForm({ function ExpenseForm({
// #withSettings // #withSettings
baseCurrency,
preferredPaymentAccount, preferredPaymentAccount,
// #withCurrentOrganization
organization: { base_currency },
}) { }) {
// Expense form context. // Expense form context.
const { const {
@@ -58,11 +60,11 @@ function ExpenseForm({
} }
: { : {
...defaultExpense, ...defaultExpense,
currency_code: baseCurrency, currency_code: base_currency,
payment_account_id: defaultTo(preferredPaymentAccount, ''), payment_account_id: defaultTo(preferredPaymentAccount, ''),
}), }),
}), }),
[expense, baseCurrency, preferredPaymentAccount], [expense, base_currency, preferredPaymentAccount],
); );
// Handle form submit. // Handle form submit.
@@ -79,16 +81,13 @@ function ExpenseForm({
} }
// Filter expense entries that has no amount or expense account. // Filter expense entries that has no amount or expense account.
const categories = values.categories.filter( const categories = values.categories.filter(
(category) => (category) => category.amount && category.expense_account_id,
category.amount && category.expense_account_id,
); );
const form = { const form = {
...values, ...values,
publish: submitPayload.publish, publish: submitPayload.publish,
categories: R.compose( categories: R.compose(orderingLinesIndexes)(categories),
orderingLinesIndexes,
)(categories),
}; };
// Handle request success. // Handle request success.
const handleSuccess = (response) => { const handleSuccess = (response) => {
@@ -158,11 +157,11 @@ function ExpenseForm({
export default compose( export default compose(
withDashboardActions, withDashboardActions,
withMediaActions, withMediaActions,
withSettings(({ organizationSettings, expenseSettings }) => ({ withSettings(({ expenseSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
preferredPaymentAccount: parseInt( preferredPaymentAccount: parseInt(
expenseSettings?.preferredPaymentAccount, expenseSettings?.preferredPaymentAccount,
10, 10,
), ),
})), })),
withCurrentOrganization(),
)(ExpenseForm); )(ExpenseForm);

View File

@@ -79,6 +79,11 @@ function ExpensesDataTable({
}); });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('expense-drawer', { expenseId: cell.row.original.id });
};
// Display empty status instead of the table. // Display empty status instead of the table.
if (isEmptyStatus) { if (isEmptyStatus) {
return <ExpensesEmptyStatus />; return <ExpensesEmptyStatus />;
@@ -105,6 +110,7 @@ function ExpensesDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onPublish: handlePublishExpense, onPublish: handlePublishExpense,
onDelete: handleDeleteExpense, onDelete: handleDeleteExpense,

View File

@@ -138,6 +138,7 @@ export function useExpensesTableColumns() {
accessor: (r) => moment(r.payment_date).format('YYYY MMM DD'), accessor: (r) => moment(r.payment_date).format('YYYY MMM DD'),
width: 140, width: 140,
className: 'payment_date', className: 'payment_date',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -145,6 +146,7 @@ export function useExpensesTableColumns() {
accessor: TotalAmountAccessor, accessor: TotalAmountAccessor,
className: 'amount', className: 'amount',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'payment_account', id: 'payment_account',
@@ -152,6 +154,7 @@ export function useExpensesTableColumns() {
accessor: 'payment_account.name', accessor: 'payment_account.name',
className: 'payment_account', className: 'payment_account',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'expense_account', id: 'expense_account',
@@ -160,6 +163,7 @@ export function useExpensesTableColumns() {
width: 160, width: 160,
className: 'expense_account', className: 'expense_account',
disableSortBy: true, disableSortBy: true,
clickable: true,
}, },
{ {
id: 'published', id: 'published',
@@ -167,6 +171,7 @@ export function useExpensesTableColumns() {
accessor: PublishAccessor, accessor: PublishAccessor,
width: 100, width: 100,
className: 'publish', className: 'publish',
clickable: true,
}, },
{ {
id: 'description', id: 'description',
@@ -175,6 +180,7 @@ export function useExpensesTableColumns() {
width: 150, width: 150,
className: 'description', className: 'description',
disableSortBy: true, disableSortBy: true,
clickable: true,
}, },
], ],
[], [],

View File

@@ -66,7 +66,12 @@ function InventoryAdjustmentDataTable({
}, },
[setInventoryAdjustmentTableState], [setInventoryAdjustmentTableState],
); );
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('inventory-adjustment-drawer', {
inventoryId: cell.row.original.id,
});
};
return ( return (
<DataTable <DataTable
columns={columns} columns={columns}
@@ -83,6 +88,7 @@ function InventoryAdjustmentDataTable({
pagesCount={pagination.pagesCount} pagesCount={pagination.pagesCount}
autoResetSortBy={false} autoResetSortBy={false}
autoResetPage={false} autoResetPage={false}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleDeleteAdjustment, onDelete: handleDeleteAdjustment,
onPublish: handlePublishInventoryAdjustment, onPublish: handlePublishInventoryAdjustment,

View File

@@ -143,6 +143,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: (r) => moment(r.date).format('YYYY MMM DD'), accessor: (r) => moment(r.date).format('YYYY MMM DD'),
width: 115, width: 115,
className: 'date', className: 'date',
clickable: true,
}, },
{ {
id: 'type', id: 'type',
@@ -150,6 +151,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: TypeAccessor, accessor: TypeAccessor,
className: 'type', className: 'type',
width: 100, width: 100,
clickable: true,
}, },
{ {
id: 'reason', id: 'reason',
@@ -157,6 +159,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: 'reason', accessor: 'reason',
className: 'reason', className: 'reason',
width: 115, width: 115,
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -164,6 +167,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: 'reference_no', accessor: 'reference_no',
className: 'reference_no', className: 'reference_no',
width: 100, width: 100,
clickable: true,
}, },
{ {
id: 'published_at', id: 'published_at',
@@ -171,6 +175,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: PublishAccessor, accessor: PublishAccessor,
width: 95, width: 95,
className: 'publish', className: 'publish',
clickable: true,
}, },
{ {
id: 'description', id: 'description',
@@ -179,6 +184,7 @@ export const useInventoryAdjustmentsColumns = () => {
disableSorting: true, disableSorting: true,
width: 85, width: 85,
className: 'description', className: 'description',
clickable: true,
}, },
{ {
id: 'created_at', id: 'created_at',
@@ -186,6 +192,7 @@ export const useInventoryAdjustmentsColumns = () => {
accessor: (r) => moment(r.created_at).format('YYYY MMM DD'), accessor: (r) => moment(r.created_at).format('YYYY MMM DD'),
width: 125, width: 125,
className: 'created_at', className: 'created_at',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

@@ -107,6 +107,11 @@ function ItemsDataTable({
return <ItemsEmptyStatus />; return <ItemsEmptyStatus />;
} }
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('item-detail-drawer', { itemId: cell.row.original.id });
};
return ( return (
<DashboardContentTable> <DashboardContentTable>
<DataTable <DataTable
@@ -132,6 +137,7 @@ function ItemsDataTable({
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ItemsActionMenuList} ContextMenu={ItemsActionMenuList}
onFetchData={handleFetchData} onFetchData={handleFetchData}
onCellClick={handleCellClick}
payload={{ payload={{
onDeleteItem: handleDeleteItem, onDeleteItem: handleDeleteItem,
onEditItem: handleEditItem, onEditItem: handleEditItem,

View File

@@ -155,6 +155,7 @@ export const useItemsTableColumns = () => {
accessor: 'name', accessor: 'name',
className: 'name', className: 'name',
width: 180, width: 180,
clickable: true,
}, },
{ {
id: 'code', id: 'code',
@@ -162,6 +163,7 @@ export const useItemsTableColumns = () => {
accessor: 'code', accessor: 'code',
className: 'code', className: 'code',
width: 120, width: 120,
clickable: true,
}, },
{ {
id: 'type', id: 'type',
@@ -169,6 +171,7 @@ export const useItemsTableColumns = () => {
accessor: ItemTypeAccessor, accessor: ItemTypeAccessor,
className: 'item_type', className: 'item_type',
width: 120, width: 120,
clickable: true,
}, },
{ {
id: 'category', id: 'category',
@@ -176,6 +179,7 @@ export const useItemsTableColumns = () => {
accessor: 'category.name', accessor: 'category.name',
className: 'category', className: 'category',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'sell_price', id: 'sell_price',
@@ -183,6 +187,7 @@ export const useItemsTableColumns = () => {
accessor: 'sell_price_formatted', accessor: 'sell_price_formatted',
className: 'sell-price', className: 'sell-price',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'cost_price', id: 'cost_price',
@@ -190,6 +195,7 @@ export const useItemsTableColumns = () => {
accessor: 'cost_price_formatted', accessor: 'cost_price_formatted',
className: 'cost-price', className: 'cost-price',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'quantity_on_hand', id: 'quantity_on_hand',
@@ -197,6 +203,7 @@ export const useItemsTableColumns = () => {
accessor: 'quantity_on_hand', accessor: 'quantity_on_hand',
Cell: QuantityOnHandCell, Cell: QuantityOnHandCell,
width: 140, width: 140,
clickable: true,
}, },
], ],
[], [],

View File

@@ -20,14 +20,14 @@ import { ERROR } from 'common/errors';
import { useBillFormContext } from './BillFormProvider'; import { useBillFormContext } from './BillFormProvider';
import { compose, orderingLinesIndexes, safeSumBy } from 'utils'; import { compose, orderingLinesIndexes, safeSumBy } from 'utils';
import { defaultBill, transformToEditForm } from './utils'; import { defaultBill, transformToEditForm } from './utils';
import withSettings from 'containers/Settings/withSettings'; import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
/** /**
* Bill form. * Bill form.
*/ */
function BillForm({ function BillForm({
// #withSettings // #withCurrentOrganization
baseCurrency, organization: { base_currency },
}) { }) {
const history = useHistory(); const history = useHistory();
@@ -41,14 +41,14 @@ function BillForm({
...(!isEmpty(bill) ...(!isEmpty(bill)
? { ? {
...transformToEditForm(bill), ...transformToEditForm(bill),
currency_code: baseCurrency, currency_code: base_currency,
} }
: { : {
...defaultBill, ...defaultBill,
currency_code: baseCurrency, currency_code: base_currency,
}), }),
}), }),
[bill, baseCurrency], [bill, base_currency],
); );
// Transform response error to fields. // Transform response error to fields.
@@ -142,8 +142,4 @@ function BillForm({
</div> </div>
); );
} }
export default compose( export default compose(withCurrentOrganization())(BillForm);
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(BillForm);

View File

@@ -8,22 +8,24 @@ import { CLASSES } from 'common/classes';
import BillFormHeaderFields from './BillFormHeaderFields'; import BillFormHeaderFields from './BillFormHeaderFields';
import { PageFormBigNumber } from 'components'; import { PageFormBigNumber } from 'components';
import withSettings from 'containers/Settings/withSettings'; import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { compose } from 'redux'; import { compose } from 'redux';
/** /**
* Fill form header. * Fill form header.
*/ */
function BillFormHeader({ function BillFormHeader({
// #withSettings // #withCurrentOrganization
baseCurrency, organization: { base_currency },
}) { }) {
const { values } = useFormikContext(); const { values } = useFormikContext();
// Calculate the total due amount of bill entries. // Calculate the total due amount of bill entries.
const totalDueAmount = useMemo(() => sumBy(values.entries, 'amount'), [ const totalDueAmount = useMemo(
values.entries, () => sumBy(values.entries, 'amount'),
]); [values.entries],
);
return ( return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}> <div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
@@ -31,13 +33,9 @@ function BillFormHeader({
<PageFormBigNumber <PageFormBigNumber
label={intl.get('due_amount')} label={intl.get('due_amount')}
amount={totalDueAmount} amount={totalDueAmount}
currencyCode={baseCurrency} currencyCode={base_currency}
/> />
</div> </div>
); );
} }
export default compose( export default compose(withCurrentOrganization())(BillFormHeader);
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(BillFormHeader);

View File

@@ -12,7 +12,6 @@ import BillsEmptyStatus from './BillsEmptyStatus';
import withBills from './withBills'; import withBills from './withBills';
import withBillActions from './withBillsActions'; import withBillActions from './withBillsActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
@@ -88,6 +87,11 @@ function BillsDataTable({
openDrawer('bill-drawer', { billId: id }); openDrawer('bill-drawer', { billId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('bill-drawer', { billId: cell.row.original.id });
};
if (isEmptyStatus) { if (isEmptyStatus) {
return <BillsEmptyStatus />; return <BillsEmptyStatus />;
} }
@@ -111,6 +115,7 @@ function BillsDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleDeleteBill, onDelete: handleDeleteBill,
onEdit: handleEditBill, onEdit: handleEditBill,
@@ -130,7 +135,4 @@ export default compose(
withAlertsActions, withAlertsActions,
withDrawerActions, withDrawerActions,
withDialogActions, withDialogActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(BillsDataTable); )(BillsDataTable);

View File

@@ -159,6 +159,7 @@ export function useBillsTableColumns() {
accessor: (r) => moment(r.bill_date).format('YYYY MMM DD'), accessor: (r) => moment(r.bill_date).format('YYYY MMM DD'),
width: 110, width: 110,
className: 'bill_date', className: 'bill_date',
clickable: true,
}, },
{ {
id: 'vendor', id: 'vendor',
@@ -166,6 +167,7 @@ export function useBillsTableColumns() {
accessor: 'vendor.display_name', accessor: 'vendor.display_name',
width: 180, width: 180,
className: 'vendor', className: 'vendor',
clickable: true,
}, },
{ {
id: 'bill_number', id: 'bill_number',
@@ -173,6 +175,7 @@ export function useBillsTableColumns() {
accessor: (row) => (row.bill_number ? `#${row.bill_number}` : null), accessor: (row) => (row.bill_number ? `#${row.bill_number}` : null),
width: 100, width: 100,
className: 'bill_number', className: 'bill_number',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -180,6 +183,7 @@ export function useBillsTableColumns() {
accessor: AmountAccessor, accessor: AmountAccessor,
width: 120, width: 120,
className: 'amount', className: 'amount',
clickable: true,
}, },
{ {
id: 'status', id: 'status',
@@ -187,6 +191,7 @@ export function useBillsTableColumns() {
accessor: StatusAccessor, accessor: StatusAccessor,
width: 160, width: 160,
className: 'status', className: 'status',
clickable: true,
}, },
{ {
id: 'due_date', id: 'due_date',
@@ -194,6 +199,7 @@ export function useBillsTableColumns() {
accessor: (r) => moment(r.due_date).format('YYYY MMM DD'), accessor: (r) => moment(r.due_date).format('YYYY MMM DD'),
width: 110, width: 110,
className: 'due_date', className: 'due_date',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -201,6 +207,7 @@ export function useBillsTableColumns() {
accessor: 'reference_no', accessor: 'reference_no',
width: 90, width: 90,
className: 'reference_no', className: 'reference_no',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,8 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withPaymentMadeActions from './withPaymentMadeActions'; import withPaymentMadeActions from './withPaymentMadeActions';
import withPaymentMade from './withPaymentMade'; import withPaymentMade from './withPaymentMade';
import withSettings from 'containers/Settings/withSettings'; import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { usePaymentMadesTableColumns, ActionsMenu } from './components'; import { usePaymentMadesTableColumns, ActionsMenu } from './components';
@@ -63,6 +64,13 @@ function PaymentMadesTable({
openDrawer('payment-made-detail-drawer', { paymentMadeId: id }); openDrawer('payment-made-detail-drawer', { paymentMadeId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('payment-made-detail-drawer', {
paymentMadeId: cell.row.original.id,
});
};
// Handle datatable fetch data once the table state change. // Handle datatable fetch data once the table state change.
const handleDataTableFetchData = useCallback( const handleDataTableFetchData = useCallback(
({ pageIndex, pageSize, sortBy }) => { ({ pageIndex, pageSize, sortBy }) => {
@@ -97,6 +105,7 @@ function PaymentMadesTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onEdit: handleEditPaymentMade, onEdit: handleEditPaymentMade,
onDelete: handleDeletePaymentMade, onDelete: handleDeletePaymentMade,
@@ -112,7 +121,5 @@ export default compose(
withPaymentMade(({ paymentMadesTableState }) => ({ paymentMadesTableState })), withPaymentMade(({ paymentMadesTableState }) => ({ paymentMadesTableState })),
withAlertsActions, withAlertsActions,
withDrawerActions, withDrawerActions,
withSettings(({ organizationSettings }) => ({ withCurrentOrganization(),
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentMadesTable); )(PaymentMadesTable);

View File

@@ -78,6 +78,7 @@ export function usePaymentMadesTableColumns() {
accessor: 'payment_date', accessor: 'payment_date',
width: 140, width: 140,
className: 'payment_date', className: 'payment_date',
clickable: true,
}, },
{ {
id: 'vendor', id: 'vendor',
@@ -85,6 +86,7 @@ export function usePaymentMadesTableColumns() {
accessor: 'vendor.display_name', accessor: 'vendor.display_name',
width: 140, width: 140,
className: 'vendor_id', className: 'vendor_id',
clickable: true,
}, },
{ {
id: 'payment_number', id: 'payment_number',
@@ -93,6 +95,7 @@ export function usePaymentMadesTableColumns() {
row.payment_number ? `#${row.payment_number}` : null, row.payment_number ? `#${row.payment_number}` : null,
width: 140, width: 140,
className: 'payment_number', className: 'payment_number',
clickable: true,
}, },
{ {
id: 'payment_account', id: 'payment_account',
@@ -100,6 +103,7 @@ export function usePaymentMadesTableColumns() {
accessor: 'payment_account.name', accessor: 'payment_account.name',
width: 140, width: 140,
className: 'payment_account_id', className: 'payment_account_id',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -107,6 +111,7 @@ export function usePaymentMadesTableColumns() {
accessor: AmountAccessor, accessor: AmountAccessor,
width: 140, width: 140,
className: 'amount', className: 'amount',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -114,6 +119,7 @@ export function usePaymentMadesTableColumns() {
accessor: 'reference', accessor: 'reference',
width: 140, width: 140,
className: 'reference', className: 'reference',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,6 @@ import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton'; import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withEstimatesActions from './withEstimatesActions'; import withEstimatesActions from './withEstimatesActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
@@ -91,6 +90,10 @@ function EstimatesDataTable({
openDialog('estimate-pdf-preview', { estimateId: id }); openDialog('estimate-pdf-preview', { estimateId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('estimate-detail-drawer', { estimateId: cell.row.original.id });
};
// Handles fetch data. // Handles fetch data.
const handleFetchData = useCallback( const handleFetchData = useCallback(
({ pageIndex, pageSize, sortBy }) => { ({ pageIndex, pageSize, sortBy }) => {
@@ -127,6 +130,7 @@ function EstimatesDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onApprove: handleApproveEstimate, onApprove: handleApproveEstimate,
onEdit: handleEditEstimate, onEdit: handleEditEstimate,
@@ -148,7 +152,4 @@ export default compose(
withAlertsActions, withAlertsActions,
withDrawerActions, withDrawerActions,
withDialogActions, withDialogActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(EstimatesDataTable); )(EstimatesDataTable);

View File

@@ -164,6 +164,7 @@ export function useEstiamtesTableColumns() {
Cell: DateCell, Cell: DateCell,
width: 140, width: 140,
className: 'estimate_date', className: 'estimate_date',
clickable: true,
}, },
{ {
id: 'customer', id: 'customer',
@@ -171,6 +172,7 @@ export function useEstiamtesTableColumns() {
accessor: 'customer.display_name', accessor: 'customer.display_name',
width: 140, width: 140,
className: 'customer_id', className: 'customer_id',
clickable: true,
}, },
{ {
id: 'expiration_date', id: 'expiration_date',
@@ -179,6 +181,7 @@ export function useEstiamtesTableColumns() {
Cell: DateCell, Cell: DateCell,
width: 140, width: 140,
className: 'expiration_date', className: 'expiration_date',
clickable: true,
}, },
{ {
id: 'estimate_number', id: 'estimate_number',
@@ -187,6 +190,7 @@ export function useEstiamtesTableColumns() {
row.estimate_number ? `#${row.estimate_number}` : null, row.estimate_number ? `#${row.estimate_number}` : null,
width: 140, width: 140,
className: 'estimate_number', className: 'estimate_number',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -194,6 +198,7 @@ export function useEstiamtesTableColumns() {
accessor: AmountAccessor, accessor: AmountAccessor,
width: 140, width: 140,
className: 'amount', className: 'amount',
clickable: true,
}, },
{ {
id: 'status', id: 'status',
@@ -201,6 +206,7 @@ export function useEstiamtesTableColumns() {
accessor: (row) => statusAccessor(row), accessor: (row) => statusAccessor(row),
width: 140, width: 140,
className: 'status', className: 'status',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -208,6 +214,7 @@ export function useEstiamtesTableColumns() {
accessor: 'reference', accessor: 'reference',
width: 90, width: 90,
className: 'reference', className: 'reference',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

@@ -11,7 +11,6 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withDashboardActions from 'containers/Dashboard/withDashboardActions'; import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withInvoices from './withInvoices'; import withInvoices from './withInvoices';
import withInvoiceActions from './withInvoiceActions'; import withInvoiceActions from './withInvoiceActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
@@ -29,9 +28,6 @@ function InvoicesDataTable({
// #withInvoices // #withInvoices
invoicesTableState, invoicesTableState,
// #withSettings
baseCurrency,
// #withAlertsActions // #withAlertsActions
openAlert, openAlert,
@@ -90,6 +86,10 @@ function InvoicesDataTable({
openDialog('invoice-pdf-preview', { invoiceId: id }); openDialog('invoice-pdf-preview', { invoiceId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('invoice-detail-drawer', { invoiceId: cell.row.original.id });
};
// Handles fetch data once the table state change. // Handles fetch data once the table state change.
const handleDataTableFetchData = useCallback( const handleDataTableFetchData = useCallback(
({ pageSize, pageIndex, sortBy }) => { ({ pageSize, pageIndex, sortBy }) => {
@@ -129,6 +129,7 @@ function InvoicesDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleDeleteInvoice, onDelete: handleDeleteInvoice,
onDeliver: handleDeliverInvoice, onDeliver: handleDeliverInvoice,
@@ -137,7 +138,6 @@ function InvoicesDataTable({
onQuick: handleQuickPaymentReceive, onQuick: handleQuickPaymentReceive,
onViewDetails: handleViewDetailInvoice, onViewDetails: handleViewDetailInvoice,
onPrint: handlePrintInvoice, onPrint: handlePrintInvoice,
baseCurrency,
}} }}
/> />
</DashboardContentTable> </DashboardContentTable>
@@ -151,7 +151,4 @@ export default compose(
withDrawerActions, withDrawerActions,
withDialogActions, withDialogActions,
withInvoices(({ invoicesTableState }) => ({ invoicesTableState })), withInvoices(({ invoicesTableState }) => ({ invoicesTableState })),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(InvoicesDataTable); )(InvoicesDataTable);

View File

@@ -174,6 +174,7 @@ export function useInvoicesTableColumns() {
accessor: (r) => moment(r.invoice_date).format('YYYY MMM DD'), accessor: (r) => moment(r.invoice_date).format('YYYY MMM DD'),
width: 110, width: 110,
className: 'invoice_date', className: 'invoice_date',
clickable: true,
}, },
{ {
id: 'customer', id: 'customer',
@@ -181,6 +182,7 @@ export function useInvoicesTableColumns() {
accessor: 'customer.display_name', accessor: 'customer.display_name',
width: 180, width: 180,
className: 'customer_id', className: 'customer_id',
clickable: true,
}, },
{ {
@@ -189,6 +191,7 @@ export function useInvoicesTableColumns() {
accessor: 'invoice_no', accessor: 'invoice_no',
width: 100, width: 100,
className: 'invoice_no', className: 'invoice_no',
clickable: true,
}, },
{ {
id: 'balance', id: 'balance',
@@ -198,6 +201,7 @@ export function useInvoicesTableColumns() {
), ),
width: 120, width: 120,
className: 'balance', className: 'balance',
clickable: true,
}, },
{ {
id: 'status', id: 'status',
@@ -205,6 +209,7 @@ export function useInvoicesTableColumns() {
accessor: (row) => statusAccessor(row), accessor: (row) => statusAccessor(row),
width: 160, width: 160,
className: 'status', className: 'status',
clickable: true,
}, },
{ {
id: 'due_date', id: 'due_date',
@@ -212,6 +217,7 @@ export function useInvoicesTableColumns() {
accessor: (r) => moment(r.due_date).format('YYYY MMM DD'), accessor: (r) => moment(r.due_date).format('YYYY MMM DD'),
width: 110, width: 110,
className: 'due_date', className: 'due_date',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -219,6 +225,7 @@ export function useInvoicesTableColumns() {
accessor: 'reference_no', accessor: 'reference_no',
width: 90, width: 90,
className: 'reference_no', className: 'reference_no',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

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

View File

@@ -12,7 +12,6 @@ import withPaymentReceives from './withPaymentReceives';
import withPaymentReceivesActions from './withPaymentReceivesActions'; import withPaymentReceivesActions from './withPaymentReceivesActions';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withSettings from 'containers/Settings/withSettings';
import { usePaymentReceivesColumns, ActionsMenu } from './components'; import { usePaymentReceivesColumns, ActionsMenu } from './components';
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider'; import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
@@ -67,6 +66,13 @@ function PaymentReceivesDataTable({
openDrawer('payment-receive-detail-drawer', { paymentReceiveId: id }); openDrawer('payment-receive-detail-drawer', { paymentReceiveId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('payment-receive-detail-drawer', {
paymentReceiveId: cell.row.original.id,
});
};
// Handle datatable fetch once the table's state changing. // Handle datatable fetch once the table's state changing.
const handleDataTableFetchData = useCallback( const handleDataTableFetchData = useCallback(
({ pageIndex, pageSize, sortBy }) => { ({ pageIndex, pageSize, sortBy }) => {
@@ -105,6 +111,7 @@ function PaymentReceivesDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onDelete: handleDeletePaymentReceive, onDelete: handleDeletePaymentReceive,
onEdit: handleEditPaymentReceive, onEdit: handleEditPaymentReceive,
@@ -123,7 +130,4 @@ export default compose(
withPaymentReceives(({ paymentReceivesTableState }) => ({ withPaymentReceives(({ paymentReceivesTableState }) => ({
paymentReceivesTableState, paymentReceivesTableState,
})), })),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentReceivesDataTable); )(PaymentReceivesDataTable);

View File

@@ -89,6 +89,7 @@ export function usePaymentReceivesColumns() {
accessor: PaymentDateAccessor, accessor: PaymentDateAccessor,
width: 140, width: 140,
className: 'payment_date', className: 'payment_date',
clickable: true,
}, },
{ {
id: 'customer', id: 'customer',
@@ -96,6 +97,7 @@ export function usePaymentReceivesColumns() {
accessor: 'customer.display_name', accessor: 'customer.display_name',
width: 160, width: 160,
className: 'customer_id', className: 'customer_id',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -103,6 +105,7 @@ export function usePaymentReceivesColumns() {
accessor: AmountAccessor, accessor: AmountAccessor,
width: 120, width: 120,
className: 'amount', className: 'amount',
clickable: true,
}, },
{ {
id: 'payment_receive_no', id: 'payment_receive_no',
@@ -111,6 +114,7 @@ export function usePaymentReceivesColumns() {
row.payment_receive_no ? `#${row.payment_receive_no}` : null, row.payment_receive_no ? `#${row.payment_receive_no}` : null,
width: 140, width: 140,
className: 'payment_receive_no', className: 'payment_receive_no',
clickable: true,
}, },
{ {
id: 'deposit_account', id: 'deposit_account',
@@ -118,6 +122,7 @@ export function usePaymentReceivesColumns() {
accessor: 'deposit_account.name', accessor: 'deposit_account.name',
width: 140, width: 140,
className: 'deposit_account_id', className: 'deposit_account_id',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -125,6 +130,7 @@ export function usePaymentReceivesColumns() {
accessor: 'reference_no', accessor: 'reference_no',
width: 140, width: 140,
className: 'reference_no', className: 'reference_no',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

@@ -13,7 +13,6 @@ import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
import withReceipts from './withReceipts'; import withReceipts from './withReceipts';
import withReceiptsActions from './withReceiptsActions'; import withReceiptsActions from './withReceiptsActions';
import withSettings from 'containers/Settings/withSettings';
import { useReceiptsListContext } from './ReceiptsListProvider'; import { useReceiptsListContext } from './ReceiptsListProvider';
import { useReceiptsTableColumns, ActionsMenu } from './components'; import { useReceiptsTableColumns, ActionsMenu } from './components';
@@ -28,9 +27,6 @@ function ReceiptsDataTable({
// #withReceipts // #withReceipts
receiptTableState, receiptTableState,
// #withSettings
baseCurrency,
// #withAlertsActions // #withAlertsActions
openAlert, openAlert,
@@ -99,6 +95,10 @@ function ReceiptsDataTable({
if (isEmptyStatus) { if (isEmptyStatus) {
return <ReceiptsEmptyStatus />; return <ReceiptsEmptyStatus />;
} }
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('receipt-detail-drawer', { receiptId: cell.row.original.id });
};
return ( return (
<DashboardContentTable> <DashboardContentTable>
@@ -122,6 +122,7 @@ function ReceiptsDataTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onEdit: handleEditReceipt, onEdit: handleEditReceipt,
onDelete: handleDeleteReceipt, onDelete: handleDeleteReceipt,
@@ -129,7 +130,6 @@ function ReceiptsDataTable({
onDrawer: handleDrawerReceipt, onDrawer: handleDrawerReceipt,
onViewDetails: handleViewDetailReceipt, onViewDetails: handleViewDetailReceipt,
onPrint: handlePrintInvoice, onPrint: handlePrintInvoice,
baseCurrency,
}} }}
/> />
</DashboardContentTable> </DashboardContentTable>
@@ -144,7 +144,4 @@ export default compose(
withReceipts(({ receiptTableState }) => ({ withReceipts(({ receiptTableState }) => ({
receiptTableState, receiptTableState,
})), })),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ReceiptsDataTable); )(ReceiptsDataTable);

View File

@@ -106,6 +106,7 @@ export function useReceiptsTableColumns() {
accessor: (r) => moment(r.receipt_date).format('YYYY MMM DD'), accessor: (r) => moment(r.receipt_date).format('YYYY MMM DD'),
width: 140, width: 140,
className: 'receipt_date', className: 'receipt_date',
clickable: true,
}, },
{ {
id: 'customer', id: 'customer',
@@ -113,6 +114,7 @@ export function useReceiptsTableColumns() {
accessor: 'customer.display_name', accessor: 'customer.display_name',
width: 140, width: 140,
className: 'customer_id', className: 'customer_id',
clickable: true,
}, },
{ {
id: 'receipt_number', id: 'receipt_number',
@@ -120,6 +122,7 @@ export function useReceiptsTableColumns() {
accessor: 'receipt_number', accessor: 'receipt_number',
width: 140, width: 140,
className: 'receipt_number', className: 'receipt_number',
clickable: true,
}, },
{ {
id: 'deposit_account', id: 'deposit_account',
@@ -127,6 +130,7 @@ export function useReceiptsTableColumns() {
accessor: 'deposit_account.name', accessor: 'deposit_account.name',
width: 140, width: 140,
className: 'deposit_account', className: 'deposit_account',
clickable: true,
}, },
{ {
id: 'amount', id: 'amount',
@@ -134,6 +138,7 @@ export function useReceiptsTableColumns() {
accessor: (r) => <Money amount={r.amount} currency={r.currency_code} />, accessor: (r) => <Money amount={r.amount} currency={r.currency_code} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
clickable: true,
}, },
{ {
id: 'status', id: 'status',
@@ -141,6 +146,7 @@ export function useReceiptsTableColumns() {
accessor: StatusAccessor, accessor: StatusAccessor,
width: 140, width: 140,
className: 'status', className: 'status',
clickable: true,
}, },
{ {
id: 'reference_no', id: 'reference_no',
@@ -148,6 +154,7 @@ export function useReceiptsTableColumns() {
accessor: 'reference_no', accessor: 'reference_no',
width: 140, width: 140,
className: 'reference_no', className: 'reference_no',
clickable: true,
}, },
], ],
[], [],

View File

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

View File

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

View File

@@ -86,6 +86,11 @@ function VendorsTable({
openDrawer('contact-detail-drawer', { contactId: id }); openDrawer('contact-detail-drawer', { contactId: id });
}; };
// Handle cell click.
const handleCellClick = (cell, event) => {
openDrawer('contact-detail-drawer', { contactId: cell.row.original.id });
};
// Handle fetch data once the page index, size or sort by of the table change. // Handle fetch data once the page index, size or sort by of the table change.
const handleFetchData = React.useCallback( const handleFetchData = React.useCallback(
({ pageSize, pageIndex, sortBy }) => { ({ pageSize, pageIndex, sortBy }) => {
@@ -125,6 +130,7 @@ function VendorsTable({
TableLoadingRenderer={TableSkeletonRows} TableLoadingRenderer={TableSkeletonRows}
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
payload={{ payload={{
onEdit: handleEditVendor, onEdit: handleEditVendor,
onDelete: handleDeleteVendor, onDelete: handleDeleteVendor,

View File

@@ -117,6 +117,7 @@ export function useVendorsTableColumns() {
width: 45, width: 45,
disableResizing: true, disableResizing: true,
disableSortBy: true, disableSortBy: true,
clickable: true,
}, },
{ {
id: 'display_name', id: 'display_name',
@@ -124,6 +125,7 @@ export function useVendorsTableColumns() {
accessor: 'display_name', accessor: 'display_name',
className: 'display_name', className: 'display_name',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'company_name', id: 'company_name',
@@ -131,6 +133,7 @@ export function useVendorsTableColumns() {
accessor: 'company_name', accessor: 'company_name',
className: 'company_name', className: 'company_name',
width: 150, width: 150,
clickable: true,
}, },
{ {
id: 'work_phone', id: 'work_phone',
@@ -138,6 +141,7 @@ export function useVendorsTableColumns() {
accessor: PhoneNumberAccessor, accessor: PhoneNumberAccessor,
className: 'work_phone', className: 'work_phone',
width: 100, width: 100,
clickable: true,
}, },
{ {
id: 'balance', id: 'balance',
@@ -145,6 +149,7 @@ export function useVendorsTableColumns() {
accessor: BalanceAccessor, accessor: BalanceAccessor,
className: 'receivable_balance', className: 'receivable_balance',
width: 100, width: 100,
clickable: true,
}, },
], ],
[], [],