diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx index 073cbf6..af7eb6a 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx @@ -102,15 +102,33 @@ const BSBillingEditQuantity = (props) => { const SettingDataSelector = useSelector(PreferenceData); const OrderType = useSelector(GlobalOrderType); const [BillOrderPre, setBillOrderPre] = useState(null); - const [RadioBtnSelection, setRadioBtnSelection] = useState( - props?.shortKeyMethod == 'price' - ? 'Price' - : ItemData?.ScaleType !== 'weight' - ? 'Quantity' - : PriceChangeaccess - ? 'Price' - : 'Parcel' - ); + const SHORTKEY_TO_RADIO = { + price: 'Price', + quantity: 'qty', + Parcel: 'Parcel', + weightAmount: 'weightAmount' +}; +const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { + if (props?.shortKeyMethod && SHORTKEY_TO_RADIO[props.shortKeyMethod]) { + return SHORTKEY_TO_RADIO[props.shortKeyMethod]; + } + if (ItemData?.ScaleType !== 'weight') { + return 'Quantity'; + } + if (PriceChangeaccess) { + return 'Price'; + } + return 'Parcel'; +}); + // const [RadioBtnSelection, setRadioBtnSelection] = useState( + // props?.shortKeyMethod == 'price' + // ? 'Price' + // : ItemData?.ScaleType !== 'weight' + // ? 'Quantity' + // : PriceChangeaccess + // ? 'Price' + // : 'Parcel' + // ); const [PercentageSelection, setPercentageSelection] = useState('Fixed'); const [RadioDetails, setRadioDetails] = useState(false); const [editedPrice, setEditedPrice] = useState(0); @@ -3552,13 +3570,13 @@ const BSBillingEditQuantity = (props) => { {isKg && ()} @@ -3766,7 +3784,7 @@ const BSBillingEditQuantity = (props) => { /> )} - {RadioBtnSelection == 'AddWeight' && ( + {RadioBtnSelection == 'weightAmount' && ( <> { const [enteredPrice, setEnteredPrice] = useState(''); + const [enteredQty, setEnteredQty] = useState(''); const [calculatedQty, setCalculatedQty] = useState(0); + const [calcMode, setCalcMode] = useState('amt'); + const priceInputRef = useRef(null); const [form] = Form.useForm(); - const basePrice = parseFloat(itemData?.OrderRate || itemData?.SellingPrice || 0); + const basePrice = parseFloat( + itemData?.OrderRate || itemData?.SellingPrice || 0 + ); + // Auto focus input useEffect(() => { setTimeout(() => { - const inputElement = priceInputRef.current?.querySelector('input'); - if (inputElement) { - inputElement.focus(); - } + const input = priceInputRef.current?.querySelector('input'); + if (input) input.focus(); }, 100); - }, []); + }, [calcMode]); - // Calculate quantity based on entered price + // AMT → calculate QTY const handlePriceChange = (e) => { const value = e.target.value; setEnteredPrice(value); if (value && basePrice > 0) { - const price = parseFloat(value); - const qty = price / basePrice; + const qty = parseFloat(value) / basePrice; setCalculatedQty(qty); } else { setCalculatedQty(0); } }; - const handleSubmit = (e) => { - if (e && e.preventDefault) { - e.preventDefault(); + // KGS → calculate AMT + const handleQtyChange = (e) => { + const value = e.target.value; + setEnteredQty(value); + + if (value && basePrice > 0) { + const qty = parseFloat(value); + const price = qty * basePrice; + setEnteredPrice(price.toFixed(2)); + setCalculatedQty(qty); + } else { + setEnteredPrice(''); + setCalculatedQty(0); } + }; - if (enteredPrice && calculatedQty > 0) { - console.log('Submitting weight calculation:', { + const handleSubmit = (e) => { + if (e && e.preventDefault) e.preventDefault(); + + if (calculatedQty > 0 && enteredPrice > 0) { + onSubmit?.({ price: parseFloat(enteredPrice), - quantity: calculatedQty, + quantity: parseFloat(calculatedQty), }); - - // Pass the calculated values back to parent component - if (onSubmit) { - onSubmit({ - price: parseFloat(enteredPrice), - quantity: calculatedQty, - }); - } } }; return (
-
e.preventDefault()} - > + + {/* MODE SELECTION */}
-
-

Product: {itemData?.ProdName}

-

Variant: {itemData?.ProdVariantName}

-

Base Price: ₹{basePrice.toFixed(2)} per {itemData?.UomName || 'unit'}

+
+ { + setCalcMode(e.target.value); + setEnteredPrice(''); + setEnteredQty(''); + setCalculatedQty(0); + form.resetFields(); + }} + > + AMT + KGS + + +

+ Base Price: ₹{basePrice.toFixed(2)} per{' '} + {itemData?.UomName || 'unit'} +

- - { - const cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); - const parts = cleanedValue.split('.'); - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> - + {/* AMOUNT INPUT */} + {calcMode === 'amt' && ( + + { + e.target.value = e.target.value.replace(/[^0-9.]/g, ''); + }} + /> + + )} + {/* QUANTITY INPUT */} + {calcMode === 'kgs' && ( + + { + e.target.value = e.target.value.replace(/[^0-9.]/g, ''); + }} + /> + + )}
- - - {calculatedQty > 0 ? calculatedQty.toFixed(3) : '0.000'} {itemData?.UomName || 'units'} + + + {calculatedQty > 0 ? calculatedQty.toFixed(3) : '0.000'}{' '} + {itemData?.UomName || 'units'}
- {calculatedQty > 0 && ( + + {enteredPrice > 0 && (
- ₹{parseFloat(enteredPrice || 0).toFixed(2)} + ₹{parseFloat(enteredPrice).toFixed(2)}
)}
-
+
{ ); }; -export default WeightCalculatePrice; \ No newline at end of file +export default WeightCalculatePrice; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss new file mode 100644 index 0000000..5f7b2dd --- /dev/null +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/WeightCalculatePrice.scss @@ -0,0 +1,9 @@ +.productils { + margin: 10px 0; +} + +.weightCalBTN { + width: 100%; + display: flex; + justify-content: flex-end; +} \ No newline at end of file diff --git a/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx b/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx index 360ae3e..e22bab0 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx @@ -15,8 +15,10 @@ const ShortcutKeyHelper = ({ }) => { { key: 'F4', description: 'Quick Pay' }, { key: 'Alt + W', description: 'Hold and Recall' }, { key: 'Ctrl + Q', description: 'Qty Change' }, - { key: 'Alt + P', description: 'Change Total Amount' }, { key: 'Ctrl + E', description: 'Price Change' }, + { key: 'Ctrl + Y', description: 'Weight / Amount' }, + { key: 'Ctrl + B', description: 'Packing' }, + { key: 'Alt + P', description: 'Change Total Amount' }, { key: 'Ctrl + I', description: 'Customer Rate History' }, ];