mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: inject default message value to sales forms
This commit is contained in:
@@ -59,6 +59,12 @@ export default {
|
|||||||
auto_increment: {
|
auto_increment: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
customer_notes: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
terms_conditions: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sales_receipts: {
|
sales_receipts: {
|
||||||
next_number: {
|
next_number: {
|
||||||
@@ -73,6 +79,12 @@ export default {
|
|||||||
preferred_deposit_account: {
|
preferred_deposit_account: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
},
|
},
|
||||||
|
receipt_message: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
terms_conditions: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sales_invoices: {
|
sales_invoices: {
|
||||||
next_number: {
|
next_number: {
|
||||||
@@ -84,6 +96,12 @@ export default {
|
|||||||
auto_increment: {
|
auto_increment: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
customer_notes: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
terms_conditions: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
payment_receives: {
|
payment_receives: {
|
||||||
next_number: {
|
next_number: {
|
||||||
@@ -147,6 +165,12 @@ export default {
|
|||||||
auto_increment: {
|
auto_increment: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
customer_notes: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
terms_conditions: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
vendor_credit: {
|
vendor_credit: {
|
||||||
next_number: {
|
next_number: {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { isEmpty } from 'lodash';
|
import { defaultTo, isEmpty } from 'lodash';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import {
|
import {
|
||||||
CreateCreditNoteFormSchema,
|
CreateCreditNoteFormSchema,
|
||||||
@@ -48,6 +48,8 @@ function CreditNoteForm({
|
|||||||
creditAutoIncrement,
|
creditAutoIncrement,
|
||||||
creditNumberPrefix,
|
creditNumberPrefix,
|
||||||
creditNextNumber,
|
creditNextNumber,
|
||||||
|
creditCustomerNotes,
|
||||||
|
creditTermsConditions,
|
||||||
|
|
||||||
// #withCurrentOrganization
|
// #withCurrentOrganization
|
||||||
organization: { base_currency },
|
organization: { base_currency },
|
||||||
@@ -68,8 +70,7 @@ function CreditNoteForm({
|
|||||||
const creditNumber = transactionNumber(creditNumberPrefix, creditNextNumber);
|
const creditNumber = transactionNumber(creditNumberPrefix, creditNextNumber);
|
||||||
|
|
||||||
// Initial values.
|
// Initial values.
|
||||||
const initialValues = React.useMemo(
|
const initialValues = {
|
||||||
() => ({
|
|
||||||
...(!isEmpty(creditNote)
|
...(!isEmpty(creditNote)
|
||||||
? { ...transformToEditForm(creditNote) }
|
? { ...transformToEditForm(creditNote) }
|
||||||
: {
|
: {
|
||||||
@@ -79,11 +80,11 @@ function CreditNoteForm({
|
|||||||
}),
|
}),
|
||||||
entries: orderingLinesIndexes(defaultCreditNote.entries),
|
entries: orderingLinesIndexes(defaultCreditNote.entries),
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
terms_conditions: defaultTo(creditTermsConditions, ''),
|
||||||
|
note: defaultTo(creditCustomerNotes, ''),
|
||||||
...newCreditNote,
|
...newCreditNote,
|
||||||
}),
|
}),
|
||||||
}),
|
};
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handles form submit.
|
// Handles form submit.
|
||||||
const handleFormSubmit = (
|
const handleFormSubmit = (
|
||||||
@@ -178,6 +179,8 @@ export default compose(
|
|||||||
creditAutoIncrement: creditNoteSettings?.autoIncrement,
|
creditAutoIncrement: creditNoteSettings?.autoIncrement,
|
||||||
creditNextNumber: creditNoteSettings?.nextNumber,
|
creditNextNumber: creditNoteSettings?.nextNumber,
|
||||||
creditNumberPrefix: creditNoteSettings?.numberPrefix,
|
creditNumberPrefix: creditNoteSettings?.numberPrefix,
|
||||||
|
creditCustomerNotes: creditNoteSettings?.customerNotes,
|
||||||
|
creditTermsConditions: creditNoteSettings?.termsConditions,
|
||||||
})),
|
})),
|
||||||
withCurrentOrganization(),
|
withCurrentOrganization(),
|
||||||
)(CreditNoteForm);
|
)(CreditNoteForm);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import intl from 'react-intl-universal';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { sumBy, isEmpty } from 'lodash';
|
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
|
|
||||||
@@ -43,6 +43,8 @@ function EstimateForm({
|
|||||||
estimateNextNumber,
|
estimateNextNumber,
|
||||||
estimateNumberPrefix,
|
estimateNumberPrefix,
|
||||||
estimateAutoIncrementMode,
|
estimateAutoIncrementMode,
|
||||||
|
estimateCustomerNotes,
|
||||||
|
estimateTermsConditions,
|
||||||
|
|
||||||
// #withCurrentOrganization
|
// #withCurrentOrganization
|
||||||
organization: { base_currency },
|
organization: { base_currency },
|
||||||
@@ -60,10 +62,8 @@ function EstimateForm({
|
|||||||
estimateNumberPrefix,
|
estimateNumberPrefix,
|
||||||
estimateNextNumber,
|
estimateNextNumber,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initial values in create and edit mode.
|
// Initial values in create and edit mode.
|
||||||
const initialValues = useMemo(
|
const initialValues = {
|
||||||
() => ({
|
|
||||||
...(!isEmpty(estimate)
|
...(!isEmpty(estimate)
|
||||||
? { ...transformToEditForm(estimate) }
|
? { ...transformToEditForm(estimate) }
|
||||||
: {
|
: {
|
||||||
@@ -75,10 +75,10 @@ function EstimateForm({
|
|||||||
}),
|
}),
|
||||||
entries: orderingLinesIndexes(defaultEstimate.entries),
|
entries: orderingLinesIndexes(defaultEstimate.entries),
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
terms_conditions: defaultTo(estimateTermsConditions, ''),
|
||||||
|
note: defaultTo(estimateCustomerNotes, ''),
|
||||||
}),
|
}),
|
||||||
}),
|
};
|
||||||
[estimate, estimateNumber, estimateAutoIncrementMode, base_currency],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handles form submit.
|
// Handles form submit.
|
||||||
const handleFormSubmit = (
|
const handleFormSubmit = (
|
||||||
@@ -181,6 +181,8 @@ export default compose(
|
|||||||
estimateNextNumber: estimatesSettings?.nextNumber,
|
estimateNextNumber: estimatesSettings?.nextNumber,
|
||||||
estimateNumberPrefix: estimatesSettings?.numberPrefix,
|
estimateNumberPrefix: estimatesSettings?.numberPrefix,
|
||||||
estimateAutoIncrementMode: estimatesSettings?.autoIncrement,
|
estimateAutoIncrementMode: estimatesSettings?.autoIncrement,
|
||||||
|
estimateCustomerNotes: estimatesSettings?.customerNotes,
|
||||||
|
estimateTermsConditions: estimatesSettings?.termsConditions,
|
||||||
})),
|
})),
|
||||||
withCurrentOrganization(),
|
withCurrentOrganization(),
|
||||||
)(EstimateForm);
|
)(EstimateForm);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import intl from 'react-intl-universal';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import { sumBy, isEmpty } from 'lodash';
|
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
import {
|
import {
|
||||||
@@ -44,6 +44,8 @@ function InvoiceForm({
|
|||||||
invoiceNextNumber,
|
invoiceNextNumber,
|
||||||
invoiceNumberPrefix,
|
invoiceNumberPrefix,
|
||||||
invoiceAutoIncrementMode,
|
invoiceAutoIncrementMode,
|
||||||
|
invoiceCustomerNotes,
|
||||||
|
invoiceTermsConditions,
|
||||||
|
|
||||||
// #withCurrentOrganization
|
// #withCurrentOrganization
|
||||||
organization: { base_currency },
|
organization: { base_currency },
|
||||||
@@ -79,6 +81,8 @@ function InvoiceForm({
|
|||||||
}),
|
}),
|
||||||
entries: orderingLinesIndexes(defaultInvoice.entries),
|
entries: orderingLinesIndexes(defaultInvoice.entries),
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
invoice_message: defaultTo(invoiceCustomerNotes, ''),
|
||||||
|
terms_conditions: defaultTo(invoiceTermsConditions, ''),
|
||||||
...newInvoice,
|
...newInvoice,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -192,6 +196,8 @@ export default compose(
|
|||||||
invoiceNextNumber: invoiceSettings?.nextNumber,
|
invoiceNextNumber: invoiceSettings?.nextNumber,
|
||||||
invoiceNumberPrefix: invoiceSettings?.numberPrefix,
|
invoiceNumberPrefix: invoiceSettings?.numberPrefix,
|
||||||
invoiceAutoIncrementMode: invoiceSettings?.autoIncrement,
|
invoiceAutoIncrementMode: invoiceSettings?.autoIncrement,
|
||||||
|
invoiceCustomerNotes: invoiceSettings?.customerNotes,
|
||||||
|
invoiceTermsConditions: invoiceSettings?.termsConditions,
|
||||||
})),
|
})),
|
||||||
withCurrentOrganization(),
|
withCurrentOrganization(),
|
||||||
)(InvoiceForm);
|
)(InvoiceForm);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React, { useMemo } from 'react';
|
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Formik, Form } from 'formik';
|
import { Formik, Form } from 'formik';
|
||||||
@@ -45,6 +44,8 @@ function ReceiptForm({
|
|||||||
receiptNextNumber,
|
receiptNextNumber,
|
||||||
receiptNumberPrefix,
|
receiptNumberPrefix,
|
||||||
receiptAutoIncrement,
|
receiptAutoIncrement,
|
||||||
|
receiptTermsConditions,
|
||||||
|
receiptMessage,
|
||||||
preferredDepositAccount,
|
preferredDepositAccount,
|
||||||
|
|
||||||
// #withCurrentOrganization
|
// #withCurrentOrganization
|
||||||
@@ -67,8 +68,7 @@ function ReceiptForm({
|
|||||||
receiptNextNumber,
|
receiptNextNumber,
|
||||||
);
|
);
|
||||||
// Initial values in create and edit mode.
|
// Initial values in create and edit mode.
|
||||||
const initialValues = useMemo(
|
const initialValues = {
|
||||||
() => ({
|
|
||||||
...(!isEmpty(receipt)
|
...(!isEmpty(receipt)
|
||||||
? { ...transformToEditForm(receipt) }
|
? { ...transformToEditForm(receipt) }
|
||||||
: {
|
: {
|
||||||
@@ -79,11 +79,10 @@ function ReceiptForm({
|
|||||||
deposit_account_id: parseInt(preferredDepositAccount),
|
deposit_account_id: parseInt(preferredDepositAccount),
|
||||||
entries: orderingLinesIndexes(defaultReceipt.entries),
|
entries: orderingLinesIndexes(defaultReceipt.entries),
|
||||||
currency_code: base_currency,
|
currency_code: base_currency,
|
||||||
|
receipt_message: receiptMessage,
|
||||||
|
terms_conditions: receiptTermsConditions,
|
||||||
}),
|
}),
|
||||||
}),
|
};
|
||||||
[receipt, preferredDepositAccount, nextReceiptNumber, receiptAutoIncrement],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handle the form submit.
|
// Handle the form submit.
|
||||||
const handleFormSubmit = (
|
const handleFormSubmit = (
|
||||||
values,
|
values,
|
||||||
@@ -184,6 +183,8 @@ export default compose(
|
|||||||
receiptNextNumber: receiptSettings?.nextNumber,
|
receiptNextNumber: receiptSettings?.nextNumber,
|
||||||
receiptNumberPrefix: receiptSettings?.numberPrefix,
|
receiptNumberPrefix: receiptSettings?.numberPrefix,
|
||||||
receiptAutoIncrement: receiptSettings?.autoIncrement,
|
receiptAutoIncrement: receiptSettings?.autoIncrement,
|
||||||
|
receiptMessage: receiptSettings?.receiptMessage,
|
||||||
|
receiptTermsConditions: receiptSettings?.termsConditions,
|
||||||
preferredDepositAccount: receiptSettings?.preferredDepositAccount,
|
preferredDepositAccount: receiptSettings?.preferredDepositAccount,
|
||||||
})),
|
})),
|
||||||
withCurrentOrganization(),
|
withCurrentOrganization(),
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { omit, first } from 'lodash';
|
|||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
defaultFastFieldShouldUpdate,
|
defaultFastFieldShouldUpdate,
|
||||||
transactionNumber,
|
|
||||||
repeatValue,
|
repeatValue,
|
||||||
transformToForm,
|
transformToForm,
|
||||||
formattedAmount,
|
formattedAmount,
|
||||||
@@ -50,7 +49,7 @@ export const defaultReceipt = {
|
|||||||
receipt_date: moment(new Date()).format('YYYY-MM-DD'),
|
receipt_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
reference_no: '',
|
reference_no: '',
|
||||||
receipt_message: '',
|
receipt_message: '',
|
||||||
statement: '',
|
terms_conditions: '',
|
||||||
closed: '',
|
closed: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
warehouse_id: '',
|
warehouse_id: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user