This commit is contained in:
a.bouhuolia
2021-01-09 21:56:44 +02:00
14 changed files with 125 additions and 75 deletions

View File

@@ -3,7 +3,7 @@ import { Formik, Form } from 'formik';
import moment from 'moment'; import moment from 'moment';
import { Intent } from '@blueprintjs/core'; import { Intent } from '@blueprintjs/core';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { pick } from 'lodash'; import { pick, defaultTo } from 'lodash';
import classNames from 'classnames'; import classNames from 'classnames';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@@ -78,7 +78,7 @@ function MakeJournalEntriesForm({
// #withSettings // #withSettings
journalNextNumber, journalNextNumber,
journalNumberPrefix, journalNumberPrefix,
baseCurrency,
// #ownProps // #ownProps
manualJournalId, manualJournalId,
manualJournal, manualJournal,
@@ -126,7 +126,8 @@ function MakeJournalEntriesForm({
} }
: { : {
...defaultInitialValues, ...defaultInitialValues,
journal_number: journalNumber, journal_number: defaultTo(journalNumber, ''),
currency_code: defaultTo(baseCurrency, ''),
entries: orderingLinesIndexes(defaultInitialValues.entries), entries: orderingLinesIndexes(defaultInitialValues.entries),
}), }),
}), }),
@@ -239,7 +240,7 @@ function MakeJournalEntriesForm({
validationSchema={isNewMode ? CreateJournalSchema : EditJournalSchema} validationSchema={isNewMode ? CreateJournalSchema : EditJournalSchema}
onSubmit={handleSubmit} onSubmit={handleSubmit}
> >
{({ isSubmitting}) => ( {({ isSubmitting }) => (
<Form> <Form>
<MakeJournalEntriesHeader <MakeJournalEntriesHeader
manualJournal={manualJournalId} manualJournal={manualJournalId}
@@ -274,9 +275,10 @@ export default compose(
withAccountsActions, withAccountsActions,
withDashboardActions, withDashboardActions,
withMediaActions, withMediaActions,
withSettings(({ manualJournalsSettings }) => ({ withSettings(({ manualJournalsSettings, organizationSettings }) => ({
journalNextNumber: parseInt(manualJournalsSettings?.nextNumber, 10), journalNextNumber: parseInt(manualJournalsSettings?.nextNumber, 10),
journalNumberPrefix: manualJournalsSettings?.numberPrefix, journalNumberPrefix: manualJournalsSettings?.numberPrefix,
baseCurrency: organizationSettings?.baseCurrency,
})), })),
withManualJournalsActions, withManualJournalsActions,
)(MakeJournalEntriesForm); )(MakeJournalEntriesForm);

View File

@@ -48,6 +48,7 @@ function MakeJournalEntriesHeader({
return ( return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}> <div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
{/*------------ Posting date -----------*/}
<FastField name={'date'}> <FastField name={'date'}>
{({ form, field: { value }, meta: { error, touched } }) => ( {({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup <FormGroup
@@ -77,6 +78,7 @@ function MakeJournalEntriesHeader({
)} )}
</FastField> </FastField>
{/*------------ Journal number -----------*/}
<FastField name={'journal_number'}> <FastField name={'journal_number'}>
{({ form, field, meta: { error, touched } }) => ( {({ form, field, meta: { error, touched } }) => (
<FormGroup <FormGroup
@@ -115,6 +117,7 @@ function MakeJournalEntriesHeader({
)} )}
</FastField> </FastField>
{/*------------ Reference -----------*/}
<FastField name={'reference'}> <FastField name={'reference'}>
{({ form, field, meta: { error, touched } }) => ( {({ form, field, meta: { error, touched } }) => (
<FormGroup <FormGroup
@@ -136,14 +139,12 @@ function MakeJournalEntriesHeader({
)} )}
</FastField> </FastField>
{/*------------ Journal type -----------*/}
<FastField name={'journal_type'}> <FastField name={'journal_type'}>
{({ form, field, meta: { error, touched } }) => ( {({ form, field, meta: { error, touched } }) => (
<FormGroup <FormGroup
label={<T id={'journal_type'} />} label={<T id={'journal_type'} />}
className={classNames( className={classNames('form-group--account-type', CLASSES.FILL)}
'form-group--account-type',
CLASSES.FILL,
)}
inline={true} inline={true}
> >
<InputGroup <InputGroup
@@ -155,14 +156,12 @@ function MakeJournalEntriesHeader({
)} )}
</FastField> </FastField>
<FastField name={'currency'}> {/*------------ Currency -----------*/}
<FastField name={'currency_code'}>
{({ form, field: { value }, meta: { error, touched } }) => ( {({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup <FormGroup
label={<T id={'currency'} />} label={<T id={'currency'} />}
className={classNames( className={classNames('form-group--currency', CLASSES.FILL)}
'form-group--currency',
CLASSES.FILL,
)}
inline={true} inline={true}
> >
<CurrencySelectList <CurrencySelectList

View File

@@ -7,11 +7,18 @@ 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 { compose } from 'redux';
/** /**
* Fill form header. * Fill form header.
*/ */
export default function BillFormHeader({ onBillNumberChanged }) { function BillFormHeader({
onBillNumberChanged,
// #withSettings
baseCurrency,
}) {
const { values } = useFormikContext(); const { values } = useFormikContext();
// Calculate the total due amount of bill entries. // Calculate the total due amount of bill entries.
@@ -25,8 +32,13 @@ export default function BillFormHeader({ onBillNumberChanged }) {
<PageFormBigNumber <PageFormBigNumber
label={'Due Amount'} label={'Due Amount'}
amount={totalDueAmount} amount={totalDueAmount}
currencyCode={'LYD'} currencyCode={baseCurrency}
/> />
</div> </div>
); );
} }
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(BillFormHeader);

View File

@@ -23,6 +23,7 @@ import PaymentMadesEmptyStatus from './PaymentMadesEmptyStatus';
import withPaymentMade from './withPaymentMade'; import withPaymentMade from './withPaymentMade';
import withPaymentMadeActions from './withPaymentMadeActions'; import withPaymentMadeActions from './withPaymentMadeActions';
import withCurrentView from 'containers/Views/withCurrentView'; import withCurrentView from 'containers/Views/withCurrentView';
import withSettings from 'containers/Settings/withSettings';
/** /**
* Payment made datatable transactions. * Payment made datatable transactions.
@@ -38,6 +39,9 @@ function PaymentMadeDataTable({
// #withPaymentMadeActions // #withPaymentMadeActions
addPaymentMadesTableQueries, addPaymentMadesTableQueries,
// #withSettings
baseCurrency,
// #ownProps // #ownProps
onEditPaymentMade, onEditPaymentMade,
onDeletePaymentMade, onDeletePaymentMade,
@@ -110,7 +114,8 @@ function PaymentMadeDataTable({
{ {
id: 'payment_number', id: 'payment_number',
Header: formatMessage({ id: 'payment_number' }), Header: formatMessage({ id: 'payment_number' }),
accessor: (row) => (row.payment_number ? `#${row.payment_number}` : null), accessor: (row) =>
row.payment_number ? `#${row.payment_number}` : null,
width: 140, width: 140,
className: 'payment_number', className: 'payment_number',
}, },
@@ -124,7 +129,7 @@ function PaymentMadeDataTable({
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: formatMessage({ id: 'amount' }),
accessor: (r) => <Money amount={r.amount} currency={'USD'} />, accessor: (r) => <Money amount={r.amount} currency={baseCurrency} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
}, },
@@ -238,4 +243,7 @@ export default compose(
paymentMadesCurrentViewId, paymentMadesCurrentViewId,
}), }),
), ),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(PaymentMadeDataTable); )(PaymentMadeDataTable);

View File

@@ -45,6 +45,7 @@ export default function PaymentMadeFloatingActions({
onSubmitForm(); onSubmitForm();
saveInvoke(onSubmitClick, event, { saveInvoke(onSubmitClick, event, {
redirect: false, redirect: false,
resetForm: true,
}); });
}; };

View File

@@ -156,13 +156,14 @@ function PaymentMadeForm({
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
setSubmitting(false); setSubmitting(false);
// resetForm(); // changePageSubtitle('');
changePageSubtitle('');
if (submitPayload.redirect) { if (submitPayload.redirect) {
history.push('/payment-mades'); history.push('/payment-mades');
} }
if (submitPayload.resetForm) {
resetForm();
}
}; };
const onError = (errors) => { const onError = (errors) => {
@@ -193,6 +194,7 @@ function PaymentMadeForm({
values, values,
handleSubmit, handleSubmit,
isSubmitting, isSubmitting,
resetForm,
submitForm, submitForm,
} = useFormik({ } = useFormik({
validationSchema, validationSchema,
@@ -244,13 +246,13 @@ function PaymentMadeForm({
// Handle cancel button click. // Handle cancel button click.
const handleCancelClick = useCallback(() => { const handleCancelClick = useCallback(() => {
history.push('/payment-mades'); history.goBack();
}, [history]); }, [history]);
// Handle clear all lines button click. // Handle clear all lines button click.
const handleClearAllLines = () => { const handleClearAllLines = useCallback(() => {
setClearLinesAlert(true); setClearLinesAlert(true);
}; },[setClearLinesAlert]);
const handleCancelClearLines = useCallback(() => { const handleCancelClearLines = useCallback(() => {
setClearLinesAlert(false); setClearLinesAlert(false);
@@ -284,6 +286,7 @@ function PaymentMadeForm({
: {}), : {}),
}); });
setClearFormAlert(false); setClearFormAlert(false);
resetForm();
}; };
// Payable full amount. // Payable full amount.
const payableFullAmount = useMemo(() => sumBy(values.entries, 'due_amount'), [ const payableFullAmount = useMemo(() => sumBy(values.entries, 'due_amount'), [
@@ -314,7 +317,6 @@ function PaymentMadeForm({
[setSubmitPayload], [setSubmitPayload],
); );
return ( return (
<div <div
className={classNames( className={classNames(
@@ -382,12 +384,14 @@ function PaymentMadeForm({
<Alert <Alert
cancelButtonText={<T id={'cancel'} />} cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'ok'} />} confirmButtonText={<T id={'ok'} />}
intent={Intent.DANGER} intent={Intent.WARNING}
isOpen={clearFormAlert} isOpen={clearFormAlert}
onCancel={handleCancelClearFormAlert} onCancel={handleCancelClearFormAlert}
onConfirm={handleConfirmCancelClearFormAlert} onConfirm={handleConfirmCancelClearFormAlert}
> >
<p>Are you sure you want to clear this transaction?</p> <p>
<T id={'are_you_sure_you_want_to_clear_this_transaction'} />
</p>
</Alert> </Alert>
<PaymentMadeFooter getFieldProps={getFieldProps} /> <PaymentMadeFooter getFieldProps={getFieldProps} />

View File

@@ -170,7 +170,7 @@ function PaymentMadeFormHeader({
className={'receive-full-amount'} className={'receive-full-amount'}
> >
Receive full amount ( Receive full amount (
<Money amount={payableFullAmount} currency={'USD'} />) <Money amount={payableFullAmount} currency={baseCurrency} />)
</a> </a>
</FormGroup> </FormGroup>
@@ -250,7 +250,7 @@ function PaymentMadeFormHeader({
<div class="big-amount"> <div class="big-amount">
<span class="big-amount__label">Amount Received</span> <span class="big-amount__label">Amount Received</span>
<h1 class="big-amount__number"> <h1 class="big-amount__number">
<Money amount={amountPaid} currency={'USD'} /> <Money amount={amountPaid} currency={baseCurrency} />
</h1> </h1>
</div> </div>
</div> </div>

View File

@@ -23,6 +23,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';
// Estimates transactions datatable. // Estimates transactions datatable.
function EstimatesDataTable({ function EstimatesDataTable({
@@ -36,6 +37,9 @@ function EstimatesDataTable({
// #withEstimatesActions // #withEstimatesActions
addEstimatesTableQueries, addEstimatesTableQueries,
// #withSettings
baseCurrency,
// #ownProps // #ownProps
onEditEstimate, onEditEstimate,
onDeleteEstimate, onDeleteEstimate,
@@ -160,7 +164,7 @@ function EstimatesDataTable({
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: formatMessage({ id: 'amount' }),
accessor: (r) => <Money amount={r.amount} currency={'USD'} />, accessor: (r) => <Money amount={r.amount} currency={baseCurrency} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
@@ -282,4 +286,7 @@ export default compose(
estimatesCurrentViewId, estimatesCurrentViewId,
}), }),
), ),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(EstimatesDataTable); )(EstimatesDataTable);

View File

@@ -97,9 +97,10 @@ function InvoiceList({
const handleConfirmInvoiceDelete = useCallback(() => { const handleConfirmInvoiceDelete = useCallback(() => {
requestDeleteInvoice(deleteInvoice.id) requestDeleteInvoice(deleteInvoice.id)
.then(() => { .then(() => {
setDeleteInvoice(false);
AppToaster.show({ AppToaster.show({
message: formatMessage({ message: formatMessage({
id: 'the_invocie_has_been_successfully_deleted', id: 'the_invoice_has_been_successfully_deleted',
}), }),
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}); });
@@ -109,7 +110,7 @@ function InvoiceList({
setDeleteInvoice(false); setDeleteInvoice(false);
}); });
}, [deleteInvoice, requestDeleteInvoice, formatMessage]); }, [deleteInvoice, requestDeleteInvoice, formatMessage]);
// Handle cancel/confirm invoice deliver. // Handle cancel/confirm invoice deliver.
const handleDeliverInvoice = useCallback((invoice) => { const handleDeliverInvoice = useCallback((invoice) => {
setDeliverInvoice(invoice); setDeliverInvoice(invoice);

View File

@@ -35,6 +35,7 @@ import withViewDetails from 'containers/Views/withViewDetails';
import withInvoices from './withInvoices'; import withInvoices from './withInvoices';
import withInvoiceActions from './withInvoiceActions'; import withInvoiceActions from './withInvoiceActions';
import withCurrentView from 'containers/Views/withCurrentView'; import withCurrentView from 'containers/Views/withCurrentView';
import withSettings from 'containers/Settings/withSettings';
// Invoices datatable. // Invoices datatable.
function InvoicesDataTable({ function InvoicesDataTable({
@@ -47,6 +48,9 @@ function InvoicesDataTable({
// #withInvoicesActions // #withInvoicesActions
addInvoiceTableQueries, addInvoiceTableQueries,
// #withSettings
baseCurrency,
// #OwnProps // #OwnProps
onEditInvoice, onEditInvoice,
onDeleteInvoice, onDeleteInvoice,
@@ -141,7 +145,7 @@ function InvoicesDataTable({
{ {
id: 'balance', id: 'balance',
Header: formatMessage({ id: 'balance' }), Header: formatMessage({ id: 'balance' }),
accessor: (r) => <Money amount={r.balance} currency={'USD'} />, accessor: (r) => <Money amount={r.balance} currency={baseCurrency} />,
width: 140, width: 140,
className: 'balance', className: 'balance',
}, },
@@ -263,5 +267,8 @@ export default compose(
invoicesCurrentViewId, invoicesCurrentViewId,
}), }),
), ),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
withViewDetails(), withViewDetails(),
)(InvoicesDataTable); )(InvoicesDataTable);

View File

@@ -28,6 +28,7 @@ import withViewDetails from 'containers/Views/withViewDetails';
import withPaymentReceives from './withPaymentReceives'; import withPaymentReceives from './withPaymentReceives';
import withPaymentReceivesActions from './withPaymentReceivesActions'; import withPaymentReceivesActions from './withPaymentReceivesActions';
import withCurrentView from 'containers/Views/withCurrentView'; import withCurrentView from 'containers/Views/withCurrentView';
import withSettings from 'containers/Settings/withSettings';
function PaymentReceivesDataTable({ function PaymentReceivesDataTable({
// #withPaymentReceives // #withPaymentReceives
@@ -40,6 +41,9 @@ function PaymentReceivesDataTable({
// #withPaymentReceivesActions // #withPaymentReceivesActions
addPaymentReceivesTableQueries, addPaymentReceivesTableQueries,
// #withSettings
baseCurrency,
// #OwnProps // #OwnProps
onEditPaymentReceive, onEditPaymentReceive,
onDeletePaymentReceive, onDeletePaymentReceive,
@@ -146,7 +150,7 @@ function PaymentReceivesDataTable({
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: formatMessage({ id: 'amount' }),
accessor: (r) => <Money amount={r.amount} currency={'USD'} />, accessor: (r) => <Money amount={r.amount} currency={baseCurrency} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
}, },
@@ -186,40 +190,40 @@ function PaymentReceivesDataTable({
const showEmptyStatus = [ const showEmptyStatus = [
paymentReceivesCurrentViewId === -1, paymentReceivesCurrentViewId === -1,
PaymentReceivesCurrentPage.length === 0, PaymentReceivesCurrentPage.length === 0,
].every(condition => condition === true); ].every((condition) => condition === true);
return ( return (
<div className={classNames(CLASSES.DASHBOARD_DATATABLE)}> <div className={classNames(CLASSES.DASHBOARD_DATATABLE)}>
<LoadingIndicator <LoadingIndicator
loading={paymentReceivesLoading && !isLoaded} loading={paymentReceivesLoading && !isLoaded}
mount={false} mount={false}
> >
<Choose> <Choose>
<Choose.When condition={showEmptyStatus}> <Choose.When condition={showEmptyStatus}>
<PaymentReceivesEmptyStatus /> <PaymentReceivesEmptyStatus />
</Choose.When> </Choose.When>
<Choose.Otherwise> <Choose.Otherwise>
<DataTable <DataTable
columns={columns} columns={columns}
data={PaymentReceivesCurrentPage} data={PaymentReceivesCurrentPage}
onFetchData={handleDataTableFetchData} onFetchData={handleDataTableFetchData}
manualSortBy={true} manualSortBy={true}
selectionColumn={true} selectionColumn={true}
noInitialFetch={true} noInitialFetch={true}
sticky={true} sticky={true}
onSelectedRowsChange={handleSelectedRowsChange} onSelectedRowsChange={handleSelectedRowsChange}
rowContextMenu={onRowContextMenu} rowContextMenu={onRowContextMenu}
pagination={true} pagination={true}
autoResetSortBy={false} autoResetSortBy={false}
autoResetPage={false} autoResetPage={false}
pagesCount={paymentReceivesPageination.pagesCount} pagesCount={paymentReceivesPageination.pagesCount}
initialPageSize={paymentReceivesTableQuery.page_size} initialPageSize={paymentReceivesTableQuery.page_size}
initialPageIndex={paymentReceivesTableQuery.page - 1} initialPageIndex={paymentReceivesTableQuery.page - 1}
/> />
</Choose.Otherwise> </Choose.Otherwise>
</Choose> </Choose>
</LoadingIndicator> </LoadingIndicator>
</div> </div>
); );
} }
@@ -245,5 +249,8 @@ export default compose(
paymentReceivesCurrentViewId, paymentReceivesCurrentViewId,
}), }),
), ),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
withViewDetails(), withViewDetails(),
)(PaymentReceivesDataTable); )(PaymentReceivesDataTable);

View File

@@ -34,6 +34,7 @@ import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withReceipts from './withReceipts'; import withReceipts from './withReceipts';
import withReceiptActions from './withReceiptActions'; import withReceiptActions from './withReceiptActions';
import withSettings from 'containers/Settings/withSettings';
function ReceiptsDataTable({ function ReceiptsDataTable({
// #withReceipts // #withReceipts
@@ -46,6 +47,9 @@ function ReceiptsDataTable({
// #withReceiptsActions // #withReceiptsActions
addReceiptsTableQueries, addReceiptsTableQueries,
// #withSettings
baseCurrency,
// #ownProps // #ownProps
loading, loading,
onEditReceipt, onEditReceipt,
@@ -138,17 +142,10 @@ function ReceiptsDataTable({
width: 140, width: 140,
className: 'deposit_account', className: 'deposit_account',
}, },
// {
// id: 'send_to_email',
// Header: formatMessage({ id: 'email' }),
// accessor: 'send_to_email',
// width: 140,
// className: 'send_to_email',
// },
{ {
id: 'amount', id: 'amount',
Header: formatMessage({ id: 'amount' }), Header: formatMessage({ id: 'amount' }),
accessor: (r) => <Money amount={r.amount} currency={'USD'} />, accessor: (r) => <Money amount={r.amount} currency={baseCurrency} />,
width: 140, width: 140,
className: 'amount', className: 'amount',
@@ -287,4 +284,7 @@ export default compose(
receiptsCurrentViewId, receiptsCurrentViewId,
}), }),
), ),
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ReceiptsDataTable); )(ReceiptsDataTable);

View File

@@ -635,7 +635,7 @@ export default {
'The invoice #{number} has been successfully edited.', 'The invoice #{number} has been successfully edited.',
the_invocie_has_been_successfully_created: the_invocie_has_been_successfully_created:
'The invoice #{number} has been successfully created.', 'The invoice #{number} has been successfully created.',
the_invocie_has_been_successfully_deleted: the_invoice_has_been_successfully_deleted:
'The invoice has been successfully deleted.', 'The invoice has been successfully deleted.',
once_delete_this_invoice_you_will_able_to_restore_it: `Once you delete this invoice, you won\'t be able to restore it later. Are you sure you want to delete this invoice?`, once_delete_this_invoice_you_will_able_to_restore_it: `Once you delete this invoice, you won\'t be able to restore it later. Are you sure you want to delete this invoice?`,
receipt_list: 'Receipt List', receipt_list: 'Receipt List',

View File

@@ -51,11 +51,13 @@
line-height: 1.5; line-height: 1.5;
} }
.fully-paid-status { .fully-paid-status {
height: 19px;
width: 19px;
display: inline-block; display: inline-block;
border-radius: 50%;
background: #2ba01d; background: #2ba01d;
color: #ffffff; border-radius: 50%;
margin-right: 6px; margin-right: 6px;
color: #ffffff;
} }
.bp3-progress-bar { .bp3-progress-bar {