mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: add auto increment/ money in.
This commit is contained in:
@@ -14,10 +14,11 @@ import { CreateMoneyInFormSchema } from './MoneyInForm.schema';
|
||||
|
||||
import { useMoneyInDailogContext } from './MoneyInDialogProvider';
|
||||
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||
|
||||
import { compose } from 'utils';
|
||||
import { compose, transactionNumber } from 'utils';
|
||||
|
||||
const defaultInitialValues = {
|
||||
date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
@@ -37,6 +38,11 @@ function MoneyInForm({
|
||||
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
|
||||
// #withSettings
|
||||
transactionNextNumber,
|
||||
transactionNumberPrefix,
|
||||
transactionIncrementMode,
|
||||
}) {
|
||||
const {
|
||||
dialogName,
|
||||
@@ -46,11 +52,20 @@ function MoneyInForm({
|
||||
submitPayload,
|
||||
} = useMoneyInDailogContext();
|
||||
|
||||
// transaction number.
|
||||
const transactionNo = transactionNumber(
|
||||
transactionNumberPrefix,
|
||||
transactionNextNumber,
|
||||
);
|
||||
|
||||
// Initial form values.
|
||||
const initialValues = {
|
||||
...defaultInitialValues,
|
||||
currency_code: base_currency,
|
||||
transaction_type: accountType,
|
||||
...(transactionIncrementMode && {
|
||||
transaction_number: transactionNo,
|
||||
}),
|
||||
cashflow_account_id: accountId,
|
||||
};
|
||||
|
||||
@@ -91,4 +106,9 @@ function MoneyInForm({
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
withCurrentOrganization(),
|
||||
withSettings(({ cashflowSetting }) => ({
|
||||
transactionNextNumber: cashflowSetting?.nextNumber,
|
||||
transactionNumberPrefix: cashflowSetting?.numberPrefix,
|
||||
transactionIncrementMode: cashflowSetting?.autoIncrement,
|
||||
})),
|
||||
)(MoneyInForm);
|
||||
|
||||
Reference in New Issue
Block a user