mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-11 02:10:30 +00:00
fix: create quick payment received and payment made transactions
This commit is contained in:
@@ -3,8 +3,7 @@ import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Formik } from 'formik';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { pick, omit } from 'lodash';
|
||||
|
||||
import { omit } from 'lodash';
|
||||
import { AppToaster } from '@/components';
|
||||
import { CreateQuickPaymentMadeFormSchema } from './QuickPaymentMade.schema';
|
||||
import { useQuickPaymentMadeContext } from './QuickPaymentMadeFormProvider';
|
||||
@@ -21,28 +20,25 @@ function QuickPaymentMadeForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
|
||||
const {
|
||||
bill,
|
||||
dialogName,
|
||||
createPaymentMadeMutate,
|
||||
} = useQuickPaymentMadeContext();
|
||||
|
||||
// Initial form values
|
||||
// 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 entries = [
|
||||
{
|
||||
payment_amount: values.amount,
|
||||
bill_id: values.id,
|
||||
},
|
||||
];
|
||||
const form = {
|
||||
...omit(values, ['payment_amount']),
|
||||
vendor_id: values?.vendor?.id,
|
||||
|
||||
@@ -124,7 +124,7 @@ function QuickPaymentMadeFormFields({
|
||||
</Col>
|
||||
</Row>
|
||||
{/*------------ Amount Received -----------*/}
|
||||
<FastField name={'payment_amount'}>
|
||||
<FastField name={'amount'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
@@ -135,7 +135,7 @@ function QuickPaymentMadeFormFields({
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="payment_amount" />}
|
||||
helperText={<ErrorMessage name="amount" />}
|
||||
>
|
||||
<ControlGroup>
|
||||
<InputPrependText text={values.currency_code} />
|
||||
@@ -144,7 +144,7 @@ function QuickPaymentMadeFormFields({
|
||||
value={value}
|
||||
minimal={true}
|
||||
onChange={(amount) => {
|
||||
setFieldValue('payment_amount', amount);
|
||||
setFieldValue('amount', amount);
|
||||
}}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inputRef={(ref) => (paymentMadeFieldRef.current = ref)}
|
||||
|
||||
@@ -16,6 +16,7 @@ export const defaultPaymentMade = {
|
||||
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
reference: '',
|
||||
payment_number: '',
|
||||
amount: '',
|
||||
// statement: '',
|
||||
exchange_rate: 1,
|
||||
branch_id: '',
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Formik } from 'formik';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { pick, defaultTo, omit } from 'lodash';
|
||||
import { defaultTo, omit } from 'lodash';
|
||||
|
||||
import { AppToaster } from '@/components';
|
||||
import { useQuickPaymentReceiveContext } from './QuickPaymentReceiveFormProvider';
|
||||
@@ -26,14 +26,10 @@ function QuickPaymentReceiveForm({
|
||||
paymentReceiveAutoIncrement,
|
||||
paymentReceiveNumberPrefix,
|
||||
paymentReceiveNextNumber,
|
||||
preferredDepositAccount
|
||||
preferredDepositAccount,
|
||||
}) {
|
||||
|
||||
const {
|
||||
dialogName,
|
||||
invoice,
|
||||
createPaymentReceiveMutate,
|
||||
} = useQuickPaymentReceiveContext();
|
||||
const { dialogName, invoice, createPaymentReceiveMutate } =
|
||||
useQuickPaymentReceiveContext();
|
||||
|
||||
// Payment receive number.
|
||||
const nextPaymentNumber = transactionNumber(
|
||||
@@ -53,13 +49,12 @@ function QuickPaymentReceiveForm({
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
|
||||
const entries = [values]
|
||||
.filter((entry) => entry.id && entry.payment_amount)
|
||||
.map((entry) => ({
|
||||
invoice_id: entry.id,
|
||||
...pick(entry, ['payment_amount']),
|
||||
}));
|
||||
|
||||
const entries = [
|
||||
{
|
||||
invoice_id: values.id,
|
||||
payment_amount: values.amount,
|
||||
},
|
||||
];
|
||||
const form = {
|
||||
...omit(values, ['payment_receive_no', 'payment_amount']),
|
||||
...(!paymentReceiveAutoIncrement && {
|
||||
|
||||
@@ -128,7 +128,7 @@ function QuickPaymentReceiveFormFields({
|
||||
</Col>
|
||||
</Row>
|
||||
{/*------------ Amount Received -----------*/}
|
||||
<FastField name={'payment_amount'}>
|
||||
<FastField name={'amount'}>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
@@ -139,7 +139,7 @@ function QuickPaymentReceiveFormFields({
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
className={classNames('form-group--payment_amount', CLASSES.FILL)}
|
||||
intent={inputIntent({ error, touched })}
|
||||
helperText={<ErrorMessage name="payment_amount" />}
|
||||
helperText={<ErrorMessage name="amount" />}
|
||||
>
|
||||
<ControlGroup>
|
||||
<InputPrependText text={values.currency_code} />
|
||||
@@ -148,7 +148,7 @@ function QuickPaymentReceiveFormFields({
|
||||
value={value}
|
||||
minimal={true}
|
||||
onChange={(amount) => {
|
||||
setFieldValue('payment_amount', amount);
|
||||
setFieldValue('amount', amount);
|
||||
}}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inputRef={(ref) => (paymentReceiveFieldRef.current = ref)}
|
||||
|
||||
@@ -15,6 +15,7 @@ export const defaultInitialValues = {
|
||||
payment_receive_no: '',
|
||||
payment_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
reference_no: '',
|
||||
amount: '',
|
||||
// statement: '',
|
||||
exchange_rate: 1,
|
||||
branch_id: '',
|
||||
|
||||
Reference in New Issue
Block a user