mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
Fix:Connect preferred sell, cost and inventory account with item form.
This commit is contained in:
@@ -19,6 +19,7 @@ import withMediaActions from 'containers/Media/withMediaActions';
|
|||||||
import useMedia from 'hooks/useMedia';
|
import useMedia from 'hooks/useMedia';
|
||||||
import withItemDetail from 'containers/Items/withItemDetail';
|
import withItemDetail from 'containers/Items/withItemDetail';
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
|
|
||||||
import { compose, transformToForm } from 'utils';
|
import { compose, transformToForm } from 'utils';
|
||||||
|
|
||||||
@@ -54,6 +55,11 @@ function ItemForm({
|
|||||||
changePageTitle,
|
changePageTitle,
|
||||||
changePageSubtitle,
|
changePageSubtitle,
|
||||||
|
|
||||||
|
// #withSettings
|
||||||
|
preferredCostAccount,
|
||||||
|
preferredSellAccount,
|
||||||
|
preferredInventoryAccount,
|
||||||
|
|
||||||
// #withMediaActions
|
// #withMediaActions
|
||||||
requestSubmitMedia,
|
requestSubmitMedia,
|
||||||
requestDeleteMedia,
|
requestDeleteMedia,
|
||||||
@@ -89,14 +95,16 @@ function ItemForm({
|
|||||||
sku: Yup.string().trim(),
|
sku: Yup.string().trim(),
|
||||||
cost_price: Yup.number().when(['purchasable'], {
|
cost_price: Yup.number().when(['purchasable'], {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.number().required()
|
then: Yup.number()
|
||||||
.label(formatMessage({ id: 'cost_price_' })),
|
.required()
|
||||||
|
.label(formatMessage({ id: 'cost_price_' })),
|
||||||
otherwise: Yup.number().nullable(true),
|
otherwise: Yup.number().nullable(true),
|
||||||
}),
|
}),
|
||||||
sell_price: Yup.number().when(['sellable'], {
|
sell_price: Yup.number().when(['sellable'], {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.number().required()
|
then: Yup.number()
|
||||||
.label(formatMessage({ id: 'sell_price_' })),
|
.required()
|
||||||
|
.label(formatMessage({ id: 'sell_price_' })),
|
||||||
otherwise: Yup.number().nullable(true),
|
otherwise: Yup.number().nullable(true),
|
||||||
}),
|
}),
|
||||||
cost_account_id: Yup.number()
|
cost_account_id: Yup.number()
|
||||||
@@ -132,7 +140,9 @@ function ItemForm({
|
|||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
|
cost_account_id: parseInt(preferredCostAccount),
|
||||||
|
sell_account_id: parseInt(preferredSellAccount),
|
||||||
|
inventory_account_id: parseInt(preferredInventoryAccount),
|
||||||
/**
|
/**
|
||||||
* We only care about the fields in the form. Previously unfilled optional
|
* We only care about the fields in the form. Previously unfilled optional
|
||||||
* values such as `notes` come back from the API as null, so remove those
|
* values such as `notes` come back from the API as null, so remove those
|
||||||
@@ -283,4 +293,9 @@ export default compose(
|
|||||||
withItemDetail,
|
withItemDetail,
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
withMediaActions,
|
withMediaActions,
|
||||||
|
withSettings(({ itemsSettings }) => ({
|
||||||
|
preferredCostAccount: itemsSettings.preferredCostAccount,
|
||||||
|
preferredSellAccount: itemsSettings.preferredSellAccount,
|
||||||
|
preferredInventoryAccount: itemsSettings.preferredInventoryAccount,
|
||||||
|
})),
|
||||||
)(ItemForm);
|
)(ItemForm);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export default (mapState) => {
|
|||||||
estimatesSettings: state.settings.data.salesEstimates,
|
estimatesSettings: state.settings.data.salesEstimates,
|
||||||
receiptSettings: state.settings.data.salesReceipts,
|
receiptSettings: state.settings.data.salesReceipts,
|
||||||
invoiceSettings: state.settings.data.salesInvoices,
|
invoiceSettings: state.settings.data.salesInvoices,
|
||||||
|
itemsSettings: state.settings.data.items,
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,12 +105,26 @@ export default {
|
|||||||
],
|
],
|
||||||
payment_receives: [
|
payment_receives: [
|
||||||
{
|
{
|
||||||
key: 'next_number',
|
key: "next_number",
|
||||||
type: 'number',
|
type: "number",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'number_prefix',
|
key: "number_prefix",
|
||||||
type: 'string',
|
type: "string",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: "preferred_sell_account",
|
||||||
|
type: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "preferred_cost_account",
|
||||||
|
type: "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "preferred_inventory_account",
|
||||||
|
type: "number",
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user