diff --git a/src/components/Dashboard/Inventory/StockTransfers/NewStockTransfer.jsx b/src/components/Dashboard/Inventory/StockTransfers/NewStockTransfer.jsx index 675da7d2..f6e0a859 100644 --- a/src/components/Dashboard/Inventory/StockTransfers/NewStockTransfer.jsx +++ b/src/components/Dashboard/Inventory/StockTransfers/NewStockTransfer.jsx @@ -1,19 +1,14 @@ import PropTypes from 'prop-types' -import dayjs from 'dayjs' import ObjectInfo from '../../common/ObjectInfo' import NewObjectForm from '../../common/NewObjectForm' import WizardView from '../../common/WizardView' -const defaultTransferName = () => - `Transfer ${dayjs().format('YYYY-MM-DD HH:mm:ss')}` - const NewStockTransfer = ({ onOk, reset }) => { return ( { return ( parentData?.fromLocation?._id == null, masterFilter: ['filamentStock', 'partStock', 'productStock'] }, { @@ -242,7 +248,13 @@ export const StockTransfer = { objectType: (row) => row?.fromStockType, required: true, showHyperlink: true, - columnWidth: 230 + columnWidth: 230, + masterFilter: (_row, parentData) => { + const fromLocation = + parentData?.fromLocation?._id ?? parentData?.fromLocation + if (!fromLocation) return {} + return { stockLocation: fromLocation } + } }, { name: 'quantity', @@ -251,6 +263,12 @@ export const StockTransfer = { required: true, min: 0, columnWidth: 140, + disabled: (row, parentData) => { + return ( + parentData?.fromLocation?._id == null || + row?.fromStock?._id == undefined + ) + }, suffix: (row) => row?.fromStockType === 'filamentStock' ? 'g net' : null }, @@ -286,23 +304,6 @@ export const StockTransfer = { suffix: (row) => row?.fromStockType === 'filamentStock' ? 'g net' : null }, - { - name: 'toStockLocation', - label: 'To location', - type: 'object', - objectType: 'stockLocation', - required: true, - showHyperlink: true, - columnWidth: 230 - }, - { - name: 'toStockType', - label: 'To type', - type: 'objectType', - readOnly: true, - columnWidth: 180, - visible: (row) => Boolean(row?.toStockType) - }, { name: 'toStock', label: 'To stock', @@ -310,8 +311,7 @@ export const StockTransfer = { objectType: (row) => row?.toStockType, readOnly: true, showHyperlink: true, - columnWidth: 230, - visible: (row) => Boolean(row?.toStock) + columnWidth: 230 } ] }