mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
Merge branch 'master' of https://github.com/abouolia/Ratteb
This commit is contained in:
@@ -11,6 +11,8 @@ import PaymentViaVoucherDialog from 'containers/Dialogs/PaymentViaVoucherDialog'
|
|||||||
import KeyboardShortcutsDialog from 'containers/Dialogs/keyboardShortcutsDialog';
|
import KeyboardShortcutsDialog from 'containers/Dialogs/keyboardShortcutsDialog';
|
||||||
import ContactDuplicateDialog from 'containers/Dialogs/ContactDuplicateDialog';
|
import ContactDuplicateDialog from 'containers/Dialogs/ContactDuplicateDialog';
|
||||||
import QuickPaymentReceiveFormDialog from 'containers/Dialogs/QuickPaymentReceiveFormDialog';
|
import QuickPaymentReceiveFormDialog from 'containers/Dialogs/QuickPaymentReceiveFormDialog';
|
||||||
|
import QuickPaymentMadeFormDialog from 'containers/Dialogs/QuickPaymentMadeFormDialog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialogs container.
|
* Dialogs container.
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +28,8 @@ export default function DialogsContainer() {
|
|||||||
<PaymentViaVoucherDialog dialogName={'payment-via-voucher'} />
|
<PaymentViaVoucherDialog dialogName={'payment-via-voucher'} />
|
||||||
<KeyboardShortcutsDialog dialogName={'keyboard-shortcuts'} />
|
<KeyboardShortcutsDialog dialogName={'keyboard-shortcuts'} />
|
||||||
<ContactDuplicateDialog dialogName={'contact-duplicate'} />
|
<ContactDuplicateDialog dialogName={'contact-duplicate'} />
|
||||||
<QuickPaymentReceiveFormDialog dialogName={'quick-payment-receive'}/>
|
<QuickPaymentReceiveFormDialog dialogName={'quick-payment-receive'} />
|
||||||
|
<QuickPaymentMadeFormDialog dialogName={'quick-payment-made'} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
|
const Schema = Yup.object().shape({
|
||||||
|
vendor_id: Yup.string()
|
||||||
|
.label(formatMessage({ id: 'vendor_name_' }))
|
||||||
|
.required(),
|
||||||
|
payment_date: Yup.date()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_date_' })),
|
||||||
|
payment_number: Yup.string()
|
||||||
|
.nullable()
|
||||||
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
|
.label(formatMessage({ id: 'payment_no_' })),
|
||||||
|
payment_account_id: Yup.number()
|
||||||
|
.required()
|
||||||
|
.label(formatMessage({ id: 'payment_account_' })),
|
||||||
|
reference: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
|
// statement: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
|
entries: Yup.array().of(
|
||||||
|
Yup.object().shape({
|
||||||
|
payment_amount: Yup.number().nullable(),
|
||||||
|
bill_id: Yup.number()
|
||||||
|
.nullable()
|
||||||
|
.when(['payment_amount'], {
|
||||||
|
is: (payment_amount) => payment_amount,
|
||||||
|
then: Yup.number().required(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateQuickPaymentMadeFormSchema = Schema;
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
|
||||||
|
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
||||||
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
function QuickPaymentMadeFloatingActions({
|
||||||
|
// #withDialogActions
|
||||||
|
closeDialog,
|
||||||
|
}) {
|
||||||
|
// Formik context.
|
||||||
|
const { isSubmitting } = useFormikContext();
|
||||||
|
|
||||||
|
const { dialogName } = useQuickPaymentMadeContext();
|
||||||
|
|
||||||
|
// Handle close button click.
|
||||||
|
const handleCancelBtnClick = () => {
|
||||||
|
closeDialog(dialogName);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={Classes.DIALOG_FOOTER}>
|
||||||
|
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||||
|
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
||||||
|
<T id={'cancel'} />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
style={{ minWidth: '75px' }}
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
{<T id={'make_payment'} />}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(withDialogActions)(QuickPaymentMadeFloatingActions);
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Formik } from 'formik';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
|
import { pick } from 'lodash';
|
||||||
|
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
import { CreateQuickPaymentMadeFormSchema } from './QuickPaymentMade.schema';
|
||||||
|
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
||||||
|
import QuickPaymentMadeFormContent from './QuickPaymentMadeFormContent';
|
||||||
|
|
||||||
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
import { defaultPaymentMade, transformErrors } from './utils';
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick payment made form.
|
||||||
|
*/
|
||||||
|
function QuickPaymentMadeForm({
|
||||||
|
// #withDialogActions
|
||||||
|
closeDialog,
|
||||||
|
}) {
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
const {
|
||||||
|
bill,
|
||||||
|
dialogName,
|
||||||
|
createPaymentMadeMutate,
|
||||||
|
} = useQuickPaymentMadeContext();
|
||||||
|
|
||||||
|
// Initial form values
|
||||||
|
const initialValues = {
|
||||||
|
...defaultPaymentMade,
|
||||||
|
...bill,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handles the form submit.
|
||||||
|
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
||||||
|
const entries = [values]
|
||||||
|
.filter((entry) => entry.id && entry.payment_amount)
|
||||||
|
.map((entry) => ({
|
||||||
|
bill_id: entry.id,
|
||||||
|
...pick(entry, ['payment_amount']),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const form = {
|
||||||
|
...values,
|
||||||
|
vendor_id: values?.vendor?.id,
|
||||||
|
entries,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle request response success.
|
||||||
|
const onSuccess = () => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: formatMessage({
|
||||||
|
id: 'the_payment_made_has_been_created_successfully',
|
||||||
|
}),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
closeDialog(dialogName);
|
||||||
|
};
|
||||||
|
// Handle request response errors.
|
||||||
|
const onError = ({
|
||||||
|
response: {
|
||||||
|
data: { errors },
|
||||||
|
},
|
||||||
|
}) => {
|
||||||
|
if (errors) {
|
||||||
|
transformErrors(errors, { setFieldError });
|
||||||
|
}
|
||||||
|
setSubmitting(false);
|
||||||
|
};
|
||||||
|
createPaymentMadeMutate(form).then(onSuccess).catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Formik
|
||||||
|
validationSchema={CreateQuickPaymentMadeFormSchema}
|
||||||
|
initialValues={initialValues}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
component={QuickPaymentMadeFormContent}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(withDialogActions)(QuickPaymentMadeForm);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Form } from 'formik';
|
||||||
|
import QuickPaymentMadeFormFields from './QuickPaymentMadeFormFields';
|
||||||
|
import QuickPaymentMadeFloatingActions from './QuickPaymentMadeFloatingActions';
|
||||||
|
/**
|
||||||
|
* Quick payment made form content.
|
||||||
|
*/
|
||||||
|
export default function QuickPaymentMadeFormContent() {
|
||||||
|
return (
|
||||||
|
<Form>
|
||||||
|
<QuickPaymentMadeFormFields />
|
||||||
|
<QuickPaymentMadeFloatingActions />
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import 'style/pages/PaymentReceive/QuickPaymentReceiveDialog.scss';
|
||||||
|
|
||||||
|
import { QuickPaymentMadeFormProvider } from './QuickPaymentMadeFormProvider';
|
||||||
|
import QuickPaymentMadeForm from './QuickPaymentMadeForm';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick payment made form dialog content.
|
||||||
|
*/
|
||||||
|
export default function QuickPaymentMadeFormDialogContent({
|
||||||
|
// #ownProps
|
||||||
|
dialogName,
|
||||||
|
bill,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<QuickPaymentMadeFormProvider billId={bill} dialogName={dialogName}>
|
||||||
|
<QuickPaymentMadeForm />
|
||||||
|
</QuickPaymentMadeFormProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import {
|
||||||
|
Classes,
|
||||||
|
FormGroup,
|
||||||
|
InputGroup,
|
||||||
|
TextArea,
|
||||||
|
Position,
|
||||||
|
ControlGroup,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
|
import { useAutofocus } from 'hooks';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
|
import { FieldRequiredHint, Col, Row } from 'components';
|
||||||
|
import {
|
||||||
|
AccountsSelectList,
|
||||||
|
InputPrependText,
|
||||||
|
MoneyInputGroup,
|
||||||
|
Icon,
|
||||||
|
} from 'components';
|
||||||
|
import {
|
||||||
|
inputIntent,
|
||||||
|
momentFormatter,
|
||||||
|
tansformDateValue,
|
||||||
|
handleDateChange,
|
||||||
|
} from 'utils';
|
||||||
|
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick payment made form fields.
|
||||||
|
*/
|
||||||
|
export default function QuickPaymentMadeFormFields() {
|
||||||
|
const { accounts } = useQuickPaymentMadeContext();
|
||||||
|
const paymentMadeFieldRef = useAutofocus();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={Classes.DIALOG_BODY}>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
{/* ------------- Vendor name ------------- */}
|
||||||
|
<FastField name={'vendor_id'}>
|
||||||
|
{({ from, field, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'vendor_name'} />}
|
||||||
|
className={classNames('form-group--select-list', CLASSES.FILL)}
|
||||||
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name={'vendor'} />}
|
||||||
|
>
|
||||||
|
<InputGroup
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
minimal={true}
|
||||||
|
disabled={true}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
</Col>
|
||||||
|
<Col xs={5}>
|
||||||
|
{/* ------------ Payment number. ------------ */}
|
||||||
|
<FastField name={'payment_number'}>
|
||||||
|
{({ form, field, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'payment_no'} />}
|
||||||
|
className={('form-group--payment_number', CLASSES.FILL)}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name="payment_number" />}
|
||||||
|
>
|
||||||
|
<InputGroup
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
minimal={true}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
{/*------------ Amount Received -----------*/}
|
||||||
|
<FastField name={'payment_amount'}>
|
||||||
|
{({
|
||||||
|
form: { values, setFieldValue },
|
||||||
|
field: { value },
|
||||||
|
meta: { error, touched },
|
||||||
|
}) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'amount_received'} />}
|
||||||
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name="payment_amount" />}
|
||||||
|
>
|
||||||
|
<ControlGroup>
|
||||||
|
<InputPrependText text={values.currency_code} />
|
||||||
|
|
||||||
|
<MoneyInputGroup
|
||||||
|
value={value}
|
||||||
|
minimal={true}
|
||||||
|
onChange={(amount) => {
|
||||||
|
setFieldValue('payment_amount', amount);
|
||||||
|
}}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
|
||||||
|
/>
|
||||||
|
</ControlGroup>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
<Row>
|
||||||
|
<Col xs={5}>
|
||||||
|
{/* ------------- Payment date ------------- */}
|
||||||
|
<FastField name={'payment_date'}>
|
||||||
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'payment_date'} />}
|
||||||
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
className={classNames('form-group--select-list', CLASSES.FILL)}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name="payment_date" />}
|
||||||
|
>
|
||||||
|
<DateInput
|
||||||
|
{...momentFormatter('YYYY/MM/DD')}
|
||||||
|
value={tansformDateValue(value)}
|
||||||
|
onChange={handleDateChange((formattedDate) => {
|
||||||
|
form.setFieldValue('payment_date', formattedDate);
|
||||||
|
})}
|
||||||
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
|
inputProps={{
|
||||||
|
leftIcon: <Icon icon={'date-range'} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
</Col>
|
||||||
|
<Col xs={5}>
|
||||||
|
{/* ------------ payment account ------------ */}
|
||||||
|
<FastField name={'payment_account_id'}>
|
||||||
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'payment_account'} />}
|
||||||
|
className={classNames(
|
||||||
|
'form-group--payment_account_id',
|
||||||
|
'form-group--select-list',
|
||||||
|
CLASSES.FILL,
|
||||||
|
)}
|
||||||
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name={'payment_account_id'} />}
|
||||||
|
>
|
||||||
|
<AccountsSelectList
|
||||||
|
accounts={accounts}
|
||||||
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
onAccountSelected={(account) => {
|
||||||
|
form.setFieldValue('payment_account_id', account.id);
|
||||||
|
}}
|
||||||
|
selectedAccountId={value}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
{/* ------------ Reference No. ------------ */}
|
||||||
|
<FastField name={'reference'}>
|
||||||
|
{({ form, field, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'reference'} />}
|
||||||
|
className={classNames('form-group--reference', CLASSES.FILL)}
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
helperText={<ErrorMessage name="reference" />}
|
||||||
|
>
|
||||||
|
<InputGroup
|
||||||
|
intent={inputIntent({ error, touched })}
|
||||||
|
minimal={true}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
{/* --------- Statement --------- */}
|
||||||
|
<FastField name={'statement'}>
|
||||||
|
{({ form, field, meta: { error, touched } }) => (
|
||||||
|
<FormGroup
|
||||||
|
label={<T id={'statement'} />}
|
||||||
|
className={'form-group--statement'}
|
||||||
|
>
|
||||||
|
<TextArea growVertically={true} {...field} />
|
||||||
|
</FormGroup>
|
||||||
|
)}
|
||||||
|
</FastField>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { DialogContent } from 'components';
|
||||||
|
import { useBill, useAccounts, useCreatePaymentMade } from 'hooks/query';
|
||||||
|
|
||||||
|
import { pick } from 'lodash';
|
||||||
|
|
||||||
|
const QuickPaymentMadeContext = React.createContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick payment made dialog provider.
|
||||||
|
*/
|
||||||
|
function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
|
||||||
|
// Handle fetch bill details.
|
||||||
|
const { isLoading: isBillLoading, data: bill } = useBill(billId, {
|
||||||
|
enabled: !!billId,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle fetch accounts data.
|
||||||
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
|
// Create payment made mutations.
|
||||||
|
const { mutateAsync: createPaymentMadeMutate } = useCreatePaymentMade();
|
||||||
|
|
||||||
|
// State provider.
|
||||||
|
const provider = {
|
||||||
|
bill: {
|
||||||
|
...pick(bill, ['id', 'due_amount', 'vendor', 'currency_code']),
|
||||||
|
vendor_id: bill?.vendor?.display_name,
|
||||||
|
payment_amount: bill?.due_amount,
|
||||||
|
},
|
||||||
|
accounts,
|
||||||
|
dialogName,
|
||||||
|
createPaymentMadeMutate,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogContent isLoading={isAccountsLoading || isBillLoading}>
|
||||||
|
<QuickPaymentMadeContext.Provider value={provider} {...props} />
|
||||||
|
</DialogContent>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const useQuickPaymentMadeContext = () =>
|
||||||
|
React.useContext(QuickPaymentMadeContext);
|
||||||
|
|
||||||
|
export { QuickPaymentMadeFormProvider, useQuickPaymentMadeContext };
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import React, { lazy } from 'react';
|
||||||
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import { Dialog, DialogSuspense } from 'components';
|
||||||
|
import withDialogRedux from 'components/DialogReduxConnect';
|
||||||
|
import { compose } from 'redux';
|
||||||
|
|
||||||
|
const QuickPaymentMadeFormDialogContent = lazy(() =>
|
||||||
|
import('./QuickPaymentMadeFormDialogContent'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick payment made form dialog.
|
||||||
|
*/
|
||||||
|
function QuickPaymentMadeFormDialog({
|
||||||
|
dialogName,
|
||||||
|
payload = { billId: null },
|
||||||
|
isOpen,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
name={dialogName}
|
||||||
|
title={<T id={'quick_made_payment'} />}
|
||||||
|
isOpen={isOpen}
|
||||||
|
canEscapeJeyClose={true}
|
||||||
|
autoFocus={true}
|
||||||
|
className={'dialog--quick-payment-receive'}
|
||||||
|
>
|
||||||
|
<DialogSuspense>
|
||||||
|
<QuickPaymentMadeFormDialogContent
|
||||||
|
bill={payload.billId}
|
||||||
|
dialogName={dialogName}
|
||||||
|
/>
|
||||||
|
</DialogSuspense>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default compose(withDialogRedux())(QuickPaymentMadeFormDialog);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
import { formatMessage } from 'services/intl';
|
||||||
|
|
||||||
|
// Default initial values of payment made.
|
||||||
|
export const defaultPaymentMade = {
|
||||||
|
vendor_id: '',
|
||||||
|
payment_account_id: '',
|
||||||
|
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
|
reference: '',
|
||||||
|
payment_number: '',
|
||||||
|
// statement: '',
|
||||||
|
entries: [{ bill_id: '', payment_amount: '' }],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const transformErrors = (errors, { setFieldError }) => {
|
||||||
|
const getError = (errorType) => errors.find((e) => e.type === errorType);
|
||||||
|
|
||||||
|
if (getError('PAYMENT.NUMBER.NOT.UNIQUE')) {
|
||||||
|
setFieldError(
|
||||||
|
'payment_number',
|
||||||
|
formatMessage({ id: 'payment_number_is_not_unique' }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -13,6 +13,7 @@ import withBills from './withBills';
|
|||||||
import withBillActions from './withBillsActions';
|
import withBillActions from './withBillsActions';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
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 { useBillsTableColumns, ActionsMenu } from './components';
|
import { useBillsTableColumns, ActionsMenu } from './components';
|
||||||
import { useBillsListContext } from './BillsListProvider';
|
import { useBillsListContext } from './BillsListProvider';
|
||||||
|
|
||||||
@@ -28,6 +29,9 @@ function BillsDataTable({
|
|||||||
|
|
||||||
// #withAlerts
|
// #withAlerts
|
||||||
openAlert,
|
openAlert,
|
||||||
|
|
||||||
|
// #withDialogActions
|
||||||
|
openDialog,
|
||||||
}) {
|
}) {
|
||||||
// Bills list context.
|
// Bills list context.
|
||||||
const {
|
const {
|
||||||
@@ -69,6 +73,11 @@ function BillsDataTable({
|
|||||||
openAlert('bill-open', { billId: bill.id });
|
openAlert('bill-open', { billId: bill.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle quick payment made action.
|
||||||
|
const handleQuickPaymentMade = ({ id }) => {
|
||||||
|
openDialog('quick-payment-made', { billId: id });
|
||||||
|
};
|
||||||
|
|
||||||
if (isEmptyStatus) {
|
if (isEmptyStatus) {
|
||||||
return <BillsEmptyStatus />;
|
return <BillsEmptyStatus />;
|
||||||
}
|
}
|
||||||
@@ -95,6 +104,7 @@ function BillsDataTable({
|
|||||||
onDelete: handleDeleteBill,
|
onDelete: handleDeleteBill,
|
||||||
onEdit: handleEditBill,
|
onEdit: handleEditBill,
|
||||||
onOpen: handleOpenBill,
|
onOpen: handleOpenBill,
|
||||||
|
onQuick: handleQuickPaymentMade,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -104,6 +114,7 @@ export default compose(
|
|||||||
withBills(({ billsTableState }) => ({ billsTableState })),
|
withBills(({ billsTableState }) => ({ billsTableState })),
|
||||||
withBillActions,
|
withBillActions,
|
||||||
withAlertsActions,
|
withAlertsActions,
|
||||||
|
withDialogActions,
|
||||||
withSettings(({ organizationSettings }) => ({
|
withSettings(({ organizationSettings }) => ({
|
||||||
baseCurrency: organizationSettings?.baseCurrency,
|
baseCurrency: organizationSettings?.baseCurrency,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import moment from 'moment';
|
|||||||
* Actions menu.
|
* Actions menu.
|
||||||
*/
|
*/
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
payload: { onEdit, onOpen, onDelete },
|
payload: { onEdit, onOpen, onDelete, onQuick },
|
||||||
row: { original },
|
row: { original },
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
@@ -43,6 +43,13 @@ export function ActionsMenu({
|
|||||||
onClick={safeCallback(onOpen, original)}
|
onClick={safeCallback(onOpen, original)}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
|
<If condition={!original.is_fully_paid}>
|
||||||
|
<MenuItem
|
||||||
|
icon={<Icon icon="quick-payment-16" iconSize={16} />}
|
||||||
|
text={formatMessage({ id: 'add_payment' })}
|
||||||
|
onClick={safeCallback(onQuick, original)}
|
||||||
|
/>
|
||||||
|
</If>
|
||||||
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={formatMessage({ id: 'delete_bill' })}
|
text={formatMessage({ id: 'delete_bill' })}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const defaultPaymentMade = {
|
|||||||
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
reference: '',
|
reference: '',
|
||||||
payment_number: '',
|
payment_number: '',
|
||||||
statement: '',
|
// statement: '',
|
||||||
entries: [],
|
entries: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export function ActionsMenu({
|
|||||||
onClick={safeCallback(onDeliver, original)}
|
onClick={safeCallback(onDeliver, original)}
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
<If condition={!original.is_fully_paid}>
|
<If condition={original.is_delivered && !original.is_fully_paid}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="quick-payment-16" iconSize={16} />}
|
icon={<Icon icon="quick-payment-16" iconSize={16} />}
|
||||||
text={formatMessage({ id: 'add_payment' })}
|
text={formatMessage({ id: 'add_payment' })}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const Schema = Yup.object().shape({
|
|||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(formatMessage({ id: 'payment_receive_no_' })),
|
.label(formatMessage({ id: 'payment_receive_no_' })),
|
||||||
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING).nullable(),
|
||||||
statement: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
// statement: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
id: Yup.number().nullable(),
|
id: Yup.number().nullable(),
|
||||||
|
|||||||
@@ -1007,4 +1007,5 @@ export default {
|
|||||||
amount_received: 'Amount Received',
|
amount_received: 'Amount Received',
|
||||||
payment_no: 'Payment No.',
|
payment_no: 'Payment No.',
|
||||||
payment_receive_number_required: 'Payment receive number required',
|
payment_receive_number_required: 'Payment receive number required',
|
||||||
|
quick_made_payment: 'Quick Made Payment',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user