mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix(webapp): fix credit note and receipt auto-increment
This commit is contained in:
@@ -11,8 +11,14 @@ export default function ReceiptFormDialogs() {
|
||||
|
||||
// Update the form once the receipt number form submit confirm.
|
||||
const handleReceiptNumberFormConfirm = (settings) => {
|
||||
// Set the receipt transaction no. that cames from dialog to the form.
|
||||
// the `receipt_no_manually` will be empty except the increment mode is not auto.
|
||||
setFieldValue('receipt_number', settings.transactionNumber);
|
||||
setFieldValue('receipt_number_manually', settings.transactionNumber);
|
||||
setFieldValue('receipt_number_manually', '');
|
||||
|
||||
if (settings.incrementMode !== 'auto') {
|
||||
setFieldValue('receipt_number_manually', settings.transactionNumber);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -70,6 +70,8 @@ const ReceiptFormReceiptNumberField = R.compose(
|
||||
const handleReceiptNoBlur = (event) => {
|
||||
const newValue = event.target.value;
|
||||
|
||||
// Show the confirmation dialog if the value has changed and auto-increment
|
||||
// mode is enabled.
|
||||
if (values.receipt_number !== newValue && receiptAutoIncrement) {
|
||||
openDialog('receipt-number-form', {
|
||||
initialFormValues: {
|
||||
@@ -78,6 +80,8 @@ const ReceiptFormReceiptNumberField = R.compose(
|
||||
},
|
||||
});
|
||||
}
|
||||
// Setting the receipt number to the form will be manually in case
|
||||
// auto-increment is disable.
|
||||
if (!receiptAutoIncrement) {
|
||||
setFieldValue('receipt_number', newValue);
|
||||
setFieldValue('receipt_number_manually', newValue);
|
||||
@@ -98,6 +102,7 @@ const ReceiptFormReceiptNumberField = R.compose(
|
||||
value={values.receipt_number}
|
||||
asyncControl={true}
|
||||
onBlur={handleReceiptNoBlur}
|
||||
onChange={() => {}}
|
||||
/>
|
||||
<InputPrependButton
|
||||
buttonProps={{
|
||||
|
||||
@@ -57,10 +57,13 @@ export const ReceiptSyncIncrementSettingsToForm = R.compose(
|
||||
const { setFieldValue } = useFormikContext();
|
||||
|
||||
useUpdateEffect(() => {
|
||||
// Do not update if the receipt auto-increment mode is disabled.
|
||||
if (!receiptAutoIncrement) return;
|
||||
|
||||
const receiptNo = transactionNumber(receiptNumberPrefix, receiptNextNumber);
|
||||
setFieldValue('receipt_number', receiptNo);
|
||||
setFieldValue(
|
||||
'receipt_number',
|
||||
transactionNumber(receiptNumberPrefix, receiptNextNumber),
|
||||
);
|
||||
}, [
|
||||
setFieldValue,
|
||||
receiptNumberPrefix,
|
||||
|
||||
@@ -36,6 +36,8 @@ export const defaultReceipt = {
|
||||
customer_id: '',
|
||||
deposit_account_id: '',
|
||||
receipt_number: '',
|
||||
// Holds the receipt number that entered manually only.
|
||||
receipt_number_manually: '',
|
||||
receipt_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
reference_no: '',
|
||||
receipt_message: '',
|
||||
|
||||
Reference in New Issue
Block a user