Fix #264 Discount change based on preference

This commit is contained in:
karthikalakshmi 2026-03-09 14:42:45 +05:30
parent cc7a002f18
commit 6a07094d7f
2 changed files with 763 additions and 601 deletions

View File

@ -58,9 +58,16 @@ const PreferenceList = () => {
const settingsList = tableValue[0]?.SettingDtlDetails ?? preferenceConfigs; const settingsList = tableValue[0]?.SettingDtlDetails ?? preferenceConfigs;
const allSettingsMap = {}; const allSettingsMap = {};
settingsList?.forEach(({ SettingIdName, SettingValue, SettingCount, SettingTime,Comments }) => { settingsList?.forEach(
allSettingsMap[SettingIdName?.toLowerCase()] = { value: SettingValue, count: SettingCount, time: SettingTime?.split(' ')?.[0], comments: Comments }; ({ SettingIdName, SettingValue, SettingCount, SettingTime, Comments }) => {
}); allSettingsMap[SettingIdName?.toLowerCase()] = {
value: SettingValue,
count: SettingCount,
time: SettingTime?.split(' ')?.[0],
comments: Comments,
};
}
);
console.log(featureaddDetails, 'featureaddDetails'); console.log(featureaddDetails, 'featureaddDetails');
@ -89,16 +96,35 @@ const PreferenceList = () => {
wholesaleshortname: allSettingsMap['wholesaleshortname']?.comments || 'WS', wholesaleshortname: allSettingsMap['wholesaleshortname']?.comments || 'WS',
billitemsorder: allSettingsMap['billitemsorder']?.value === 'Y', billitemsorder: allSettingsMap['billitemsorder']?.value === 'Y',
preorderpricechange: allSettingsMap['preorderpricechange']?.value === 'Y', preorderpricechange: allSettingsMap['preorderpricechange']?.value === 'Y',
quantityrestriction: allSettingsMap['overalllimit']?.value === 'Y' || allSettingsMap['itemwiselimit']?.value === 'Y', quantityrestriction:
quantityrestrictiontype: allSettingsMap['overalllimit']?.value === 'Y' ? 'overall' : allSettingsMap['itemwiselimit']?.value === 'Y' ? 'itemwise' : 'overall', allSettingsMap['overalllimit']?.value === 'Y' ||
kiosktimelimit: allSettingsMap['hours']?.value === 'Y' || allSettingsMap['minutes']?.value === 'Y', allSettingsMap['itemwiselimit']?.value === 'Y',
kiosktimelimittype: allSettingsMap['hours']?.value === 'Y' ? 'hours' : allSettingsMap['minutes']?.value === 'Y' ? 'minutes' : 'minutes', quantityrestrictiontype:
maxquantity: allSettingsMap['overalllimit']?.value === 'Y' ? allSettingsMap['overalllimit']?.count || 1 : allSettingsMap['itemwiselimit']?.value === 'Y' ? allSettingsMap['itemwiselimit']?.count || 1 : 1, allSettingsMap['overalllimit']?.value === 'Y'
? 'overall'
: allSettingsMap['itemwiselimit']?.value === 'Y'
? 'itemwise'
: 'overall',
kiosktimelimit:
allSettingsMap['hours']?.value === 'Y' ||
allSettingsMap['minutes']?.value === 'Y',
kiosktimelimittype:
allSettingsMap['hours']?.value === 'Y'
? 'hours'
: allSettingsMap['minutes']?.value === 'Y'
? 'minutes'
: 'minutes',
maxquantity:
allSettingsMap['overalllimit']?.value === 'Y'
? allSettingsMap['overalllimit']?.count || 1
: allSettingsMap['itemwiselimit']?.value === 'Y'
? allSettingsMap['itemwiselimit']?.count || 1
: 1,
maxtime: maxtime:
allSettingsMap['hours']?.value === 'Y' allSettingsMap['hours']?.value === 'Y'
? (allSettingsMap['hours']?.time ? allSettingsMap['hours']?.time
? parseFloat(allSettingsMap['hours']?.time / 60) ? parseFloat(allSettingsMap['hours']?.time / 60)
: 0.5) : 0.5
: allSettingsMap['minutes']?.value === 'Y' : allSettingsMap['minutes']?.value === 'Y'
? parseFloat(allSettingsMap['minutes']?.time || 30) ? parseFloat(allSettingsMap['minutes']?.time || 30)
: 30, : 30,
@ -118,14 +144,19 @@ const PreferenceList = () => {
), ),
mobilea4: allSettingsMap['mobilea4']?.value === 'Y', mobilea4: allSettingsMap['mobilea4']?.value === 'Y',
estimateSettings: [ estimateSettings: [
...(allSettingsMap['estimateprintheader']?.value === 'Y' ? ['estimateprintheader'] : []), ...(allSettingsMap['estimateprintheader']?.value === 'Y'
...(allSettingsMap['estimatetitle']?.value === 'Y' ? ['estimatetitle'] : []), ? ['estimateprintheader']
: []),
...(allSettingsMap['estimatetitle']?.value === 'Y'
? ['estimatetitle']
: []),
], ],
scanlayout: allSettingsMap['scanlayout']?.value === 'Y', scanlayout: allSettingsMap['scanlayout']?.value === 'Y',
verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y', verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y',
imeidetails: allSettingsMap['imeidetails']?.value === 'Y', imeidetails: allSettingsMap['imeidetails']?.value === 'Y',
customisedbillnumber: allSettingsMap['customisedbillnumber']?.value === 'Y', customisedbillnumber: allSettingsMap['customisedbillnumber']?.value === 'Y',
upiqr: allSettingsMap['upiqr']?.value === 'Y', upiqr: allSettingsMap['upiqr']?.value === 'Y',
itemdiscount: allSettingsMap['itemdiscount']?.value === 'Y',
lowstockreport: allSettingsMap['lowstockreport']?.value === 'Y', lowstockreport: allSettingsMap['lowstockreport']?.value === 'Y',
weeklysalesreport: allSettingsMap['weeklysalesreport']?.value === 'Y', weeklysalesreport: allSettingsMap['weeklysalesreport']?.value === 'Y',
notificationblink: allSettingsMap['notificationblink']?.value === 'Y', notificationblink: allSettingsMap['notificationblink']?.value === 'Y',
@ -245,7 +276,7 @@ const PreferenceList = () => {
res?.data?.data?.map((i) => ({ res?.data?.data?.map((i) => ({
SettingIdName: i.ConfigName, SettingIdName: i.ConfigName,
SettingId: i.ConfigId, SettingId: i.ConfigId,
Comments: i.Comments || "", Comments: i.Comments || '',
SettingValue: 'N', SettingValue: 'N',
})) }))
); );
@ -305,9 +336,9 @@ const PreferenceList = () => {
const handleSubmit = async () => { const handleSubmit = async () => {
const values = formRef.current.getFieldsValue(); const values = formRef.current.getFieldsValue();
const salesMode = values.salesmode; const salesMode = values.salesmode;
console.log("Sales Mode:", values.salesmode); console.log('Sales Mode:', values.salesmode);
console.log("Retail Short Name:", values.retailshortname); console.log('Retail Short Name:', values.retailshortname);
console.log("Wholesale Short Name:", values.wholesaleshortname); console.log('Wholesale Short Name:', values.wholesaleshortname);
const settings = settingsList || []; const settings = settingsList || [];
console.log(values, 'values'); console.log(values, 'values');
const updatedSettings = settings.map((setting) => { const updatedSettings = settings.map((setting) => {
@ -325,7 +356,7 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
weightasquantity: values.weightasquantity, weightasquantity: values.weightasquantity,
expiredselection: values.expiredselection, expiredselection: values.expiredselection,
'sales mode': values?.['salesmode'], 'sales mode': values?.['salesmode'],
billitemsorder: values.billitemsorder, billitemsorder: values.billitemsorder,
preorderpricechange: values.preorderpricechange, preorderpricechange: values.preorderpricechange,
tokenonly: values.tokenonly, tokenonly: values.tokenonly,
@ -336,14 +367,20 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
imeidetails: values.imeidetails, imeidetails: values.imeidetails,
customisedbillnumber: values.customisedbillnumber, customisedbillnumber: values.customisedbillnumber,
upiqr: values.upiqr, upiqr: values.upiqr,
itemdiscount: values.itemdiscount,
lowstockreport: values.lowstockreport, lowstockreport: values.lowstockreport,
weeklysalesreport: values.weeklysalesreport, weeklysalesreport: values.weeklysalesreport,
notificationblink: values.notificationblink, notificationblink: values.notificationblink,
editbill: values.editbill, editbill: values.editbill,
overalllimit: values.quantityrestriction && values.quantityrestrictiontype === 'overall', overalllimit:
itemwiselimit: values.quantityrestriction && values.quantityrestrictiontype === 'itemwise', values.quantityrestriction &&
values.quantityrestrictiontype === 'overall',
itemwiselimit:
values.quantityrestriction &&
values.quantityrestrictiontype === 'itemwise',
hours: values.kiosktimelimit && values.kiosktimelimittype === 'hours', hours: values.kiosktimelimit && values.kiosktimelimittype === 'hours',
minutes: values.kiosktimelimit && values.kiosktimelimittype === 'minutes', minutes:
values.kiosktimelimit && values.kiosktimelimittype === 'minutes',
}; };
const arrayValues = { const arrayValues = {
@ -371,38 +408,38 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
? boolValues[key] ? boolValues[key]
: (arrayValues[key]?.includes(key) ?? false); : (arrayValues[key]?.includes(key) ?? false);
return { return {
ConfigName: setting.SettingIdName, ConfigName: setting.SettingIdName,
SettingId: setting.SettingId, SettingId: setting.SettingId,
Comments: Comments:
key === "retailshortname" key === 'retailshortname'
? values.retailshortname || "" ? values.retailshortname || ''
: key === "wholesaleshortname" : key === 'wholesaleshortname'
? values.wholesaleshortname || "" ? values.wholesaleshortname || ''
: setting.Comments || "", : setting.Comments || '',
SettingValue: SettingValue:
key === "retailshortname" || key === "wholesaleshortname" key === 'retailshortname' || key === 'wholesaleshortname'
? salesMode ? salesMode
? "Y" ? 'Y'
: "N" : 'N'
: isChecked : isChecked
? "Y" ? 'Y'
: "N", : 'N',
SettingCount: SettingCount:
(key === "overalllimit" || key === "itemwiselimit") && isChecked (key === 'overalllimit' || key === 'itemwiselimit') && isChecked
? parseFloat(values.maxquantity) || null ? parseFloat(values.maxquantity) || null
: null, : null,
SettingTime: SettingTime:
key === "hours" && isChecked key === 'hours' && isChecked
? (parseFloat(values.maxtime) * 60).toFixed(2) + " Minutes" ? (parseFloat(values.maxtime) * 60).toFixed(2) + ' Minutes'
: key === "minutes" && isChecked : key === 'minutes' && isChecked
? parseFloat(values.maxtime).toFixed(2) + " Minutes" ? parseFloat(values.maxtime).toFixed(2) + ' Minutes'
: null, : null,
}; };
}); });
const payload = { const payload = {
@ -542,95 +579,130 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
'decimal', 'decimal',
'Display values with 2 decimal places throughout the app?' 'Display values with 2 decimal places throughout the app?'
)} )}
{renderCheckbox( {renderCheckbox(
'salespageaskiosk', 'salespageaskiosk',
'Do you want to open sales page as kiosk layout?' 'Do you want to open sales page as kiosk layout?'
)} )}
{(allSettingsMap['onlineindividualslots'] !== undefined || {(allSettingsMap['onlineindividualslots'] !== undefined ||
allSettingsMap['allow individual booking'] !== undefined || allSettingsMap['allow individual booking'] !== undefined ||
allSettingsMap['single booking only'] !== undefined) && ( allSettingsMap['single booking only'] !== undefined) && (
<Form.Item <Form.Item
name="BookingOptionsandmethod" name="BookingOptionsandmethod"
label="Individual Selling Setup" label="Individual Selling Setup"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['allow individual booking'] !== {allSettingsMap['allow individual booking'] !==
undefined && ( undefined && (
<Checkbox value="allow individual booking"> <Checkbox value="allow individual booking">
Allow online individual booking Allow online individual booking
</Checkbox> </Checkbox>
)} )}
{allSettingsMap['single booking only'] !== undefined && ( {allSettingsMap['single booking only'] !== undefined && (
<Checkbox value="single booking only"> <Checkbox value="single booking only">
Allow single booking Only Allow single booking Only
</Checkbox> </Checkbox>
)} )}
</Checkbox.Group> </Checkbox.Group>
</Form.Item> </Form.Item>
)}
{featureaddDetails?.find(
(item) =>
item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
) &&
renderCheckbox(
'kioskotp',
'Enable OTP verification for Kiosk Orders?'
)} )}
{featureaddDetails?.find( {featureaddDetails?.find(
(item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' (item) =>
) && renderCheckbox('kioskotp', 'Enable OTP verification for Kiosk Orders?')} item?.FeatureAddonName?.toLowerCase() === 'kiosk sales'
{featureaddDetails?.find( ) &&
(item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' (allSettingsMap['hours'] !== undefined ||
) && (allSettingsMap['hours'] !== undefined || allSettingsMap['minutes'] !== undefined) && <> allSettingsMap['minutes'] !== undefined) && (
<Form.Item name="kiosktimelimit" label="Restrict orders for the same customer within a time limit?" valuePropName="checked"> <>
<Checkbox>Yes</Checkbox> <Form.Item
</Form.Item> name="kiosktimelimit"
<Form.Item noStyle shouldUpdate={(prev, curr) => prev.kiosktimelimit !== curr.kiosktimelimit}> label="Restrict orders for the same customer within a time limit?"
{({ getFieldValue }) => getFieldValue('kiosktimelimit') && ( valuePropName="checked"
<> >
<Form.Item name="kiosktimelimittype" label="How would you like to apply the time restriction?"> <Checkbox>Yes</Checkbox>
<Radio.Group onChange={() => formRef.current?.setFieldsValue({ maxtime: undefined })}> </Form.Item>
{allSettingsMap['minutes'] !== undefined && ( <Form.Item
<Radio value="minutes">Minutes</Radio> noStyle
)} shouldUpdate={(prev, curr) =>
{allSettingsMap['hours'] !== undefined && ( prev.kiosktimelimit !== curr.kiosktimelimit
<Radio value="hours">Hours</Radio> }
)} >
</Radio.Group> {({ getFieldValue }) =>
</Form.Item> getFieldValue('kiosktimelimit') && (
<>
<Form.Item <Form.Item
noStyle name="kiosktimelimittype"
shouldUpdate={(prev, curr) => label="How would you like to apply the time restriction?"
prev.kiosktimelimittype !== curr.kiosktimelimittype >
} <Radio.Group
> onChange={() =>
{({ getFieldValue }) => { formRef.current?.setFieldsValue({
const type = getFieldValue('kiosktimelimittype'); maxtime: undefined,
})
const isHours = type === 'hours'; }
return (
<Form.Item
name="maxtime"
label={`Maximum Time Limit (${isHours ? 'Hours' : 'Minutes'}):`}
rules={[
{ required: true, message: 'Please enter maximum time' },
{
type: 'number',
min: isHours ? 0.25 : 1,
message: isHours
? 'Minimum allowed is 0.25 hours'
: 'Minimum allowed is 1 minute',
},
]}
> >
<InputNumber {allSettingsMap['minutes'] !== undefined && (
min={isHours ? 0.25 : 1} <Radio value="minutes">Minutes</Radio>
step={isHours ? 0.25 : 1} )}
precision={isHours ? 2 : 0} {allSettingsMap['hours'] !== undefined && (
style={{ width: '200px' }} <Radio value="hours">Hours</Radio>
/> )}
</Form.Item> </Radio.Group>
); </Form.Item>
}}
</Form.Item> <Form.Item
</> noStyle
)} shouldUpdate={(prev, curr) =>
</Form.Item> prev.kiosktimelimittype !==
</>} curr.kiosktimelimittype
}
>
{({ getFieldValue }) => {
const type =
getFieldValue('kiosktimelimittype');
const isHours = type === 'hours';
return (
<Form.Item
name="maxtime"
label={`Maximum Time Limit (${isHours ? 'Hours' : 'Minutes'}):`}
rules={[
{
required: true,
message: 'Please enter maximum time',
},
{
type: 'number',
min: isHours ? 0.25 : 1,
message: isHours
? 'Minimum allowed is 0.25 hours'
: 'Minimum allowed is 1 minute',
},
]}
>
<InputNumber
min={isHours ? 0.25 : 1}
step={isHours ? 0.25 : 1}
precision={isHours ? 2 : 0}
style={{ width: '200px' }}
/>
</Form.Item>
);
}}
</Form.Item>
</>
)
}
</Form.Item>
</>
)}
</div> </div>
<Divider /> <Divider />
@ -662,23 +734,23 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
{(allSettingsMap['onbilltime'] !== undefined || {(allSettingsMap['onbilltime'] !== undefined ||
allSettingsMap['1daybefore'] !== undefined || allSettingsMap['1daybefore'] !== undefined ||
allSettingsMap['1hourbefore'] !== undefined) && ( allSettingsMap['1hourbefore'] !== undefined) && (
<Form.Item <Form.Item
name="notification" name="notification"
label="Choose notification timing:" label="Choose notification timing:"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['onbilltime'] !== undefined && ( {allSettingsMap['onbilltime'] !== undefined && (
<Checkbox value="onbilltime">On Bill Time</Checkbox> <Checkbox value="onbilltime">On Bill Time</Checkbox>
)} )}
{allSettingsMap['1daybefore'] !== undefined && ( {allSettingsMap['1daybefore'] !== undefined && (
<Checkbox value="1daybefore">1 Day Before</Checkbox> <Checkbox value="1daybefore">1 Day Before</Checkbox>
)} )}
{allSettingsMap['1hourbefore'] !== undefined && ( {allSettingsMap['1hourbefore'] !== undefined && (
<Checkbox value="1hourbefore">1 Hour Before</Checkbox> <Checkbox value="1hourbefore">1 Hour Before</Checkbox>
)} )}
</Checkbox.Group> </Checkbox.Group>
</Form.Item> </Form.Item>
)} )}
</div> </div>
<div <div
@ -705,45 +777,45 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
{(allSettingsMap['offer'] !== undefined || {(allSettingsMap['offer'] !== undefined ||
allSettingsMap['parking'] !== undefined) && ( allSettingsMap['parking'] !== undefined) && (
<Form.Item <Form.Item
name="enabledFeatures" name="enabledFeatures"
label="Select the features you want to enable:" label="Select the features you want to enable:"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['parking'] !== undefined && ( {allSettingsMap['parking'] !== undefined && (
<Checkbox value="parking">Parking</Checkbox> <Checkbox value="parking">Parking</Checkbox>
)} )}
{allSettingsMap['offer'] !== undefined && ( {allSettingsMap['offer'] !== undefined && (
<Checkbox value="offer">Offer</Checkbox> <Checkbox value="offer">Offer</Checkbox>
)} )}
</Checkbox.Group> </Checkbox.Group>
</Form.Item> </Form.Item>
)} )}
{((allSettingsMap['dinein'] !== undefined && dinePreference) || {((allSettingsMap['dinein'] !== undefined && dinePreference) ||
allSettingsMap['estimation'] !== undefined) && ( allSettingsMap['estimation'] !== undefined) && (
<Form.Item <Form.Item
name="enabledModules" name="enabledModules"
label="Select the modules you want to enable:" label="Select the modules you want to enable:"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['dinein'] !== undefined && {allSettingsMap['dinein'] !== undefined &&
dinePreference && ( dinePreference && (
<Checkbox value="dinein">Dine-In</Checkbox> <Checkbox value="dinein">Dine-In</Checkbox>
)}
{allSettingsMap['estimation'] !== undefined && (
<Checkbox value="estimation">Estimation</Checkbox>
)} )}
</Checkbox.Group> {allSettingsMap['estimation'] !== undefined && (
</Form.Item> <Checkbox value="estimation">Estimation</Checkbox>
)} )}
</Checkbox.Group>
</Form.Item>
)}
{renderCheckbox('stockselection', 'Enable stock selection?')} {renderCheckbox('stockselection', 'Enable stock selection?')}
{renderCheckbox('weightasquantity', 'Use Weight as Quantity?')} {renderCheckbox('weightasquantity', 'Use Weight as Quantity?')}
{renderCheckbox('expiredselection', 'Show product expiry date?')} {renderCheckbox('expiredselection', 'Show product expiry date?')}
{/* {renderCheckbox('sales mode', 'Retail or Wholesale mode?')} */} {/* {renderCheckbox('sales mode', 'Retail or Wholesale mode?')} */}
{(allSettingsMap['sales mode'] !== undefined ) && ( {allSettingsMap['sales mode'] !== undefined && (
<> <>
<Form.Item <Form.Item
name="salesmode" name="salesmode"
label="Retail or Wholesale mode?" label="Retail or Wholesale mode?"
valuePropName="checked" valuePropName="checked"
@ -751,42 +823,49 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
<Checkbox>Yes</Checkbox> <Checkbox>Yes</Checkbox>
</Form.Item> </Form.Item>
</> </>
)} )}
<Form.Item <Form.Item
noStyle noStyle
shouldUpdate={(prev, curr) => prev.salesmode !== curr.salesmode} shouldUpdate={(prev, curr) => prev.salesmode !== curr.salesmode}
> >
{({ getFieldValue }) => {({ getFieldValue }) =>
getFieldValue('salesmode') && ( getFieldValue('salesmode') && (
<> <>
<Form.Item <Form.Item
name="retailshortname" name="retailshortname"
label="Retail Short Name" label="Retail Short Name"
rules={[
rules={[ {
{ required: true, message: "Please enter Retail Short Name" }, required: true,
]} message: 'Please enter Retail Short Name',
> },
<InputField placeholder="Enter Retail Short Name" style={{ width: 250 }} /> ]}
</Form.Item> >
<InputField
placeholder="Enter Retail Short Name"
style={{ width: 250 }}
/>
</Form.Item>
<Form.Item <Form.Item
name="wholesaleshortname" name="wholesaleshortname"
label="Wholesale Short Name" label="Wholesale Short Name"
rules={[
rules={[ {
{ required: true, message: "Please enter Wholesale Short Name" }, required: true,
]} message: 'Please enter Wholesale Short Name',
> },
<InputField ]}
placeholder="Enter Wholesale Short Name" >
style={{ width: 250 }} <InputField
/> placeholder="Enter Wholesale Short Name"
</Form.Item> style={{ width: 250 }}
</> />
) </Form.Item>
} </>
</Form.Item> )
}
</Form.Item>
{renderCheckbox( {renderCheckbox(
'billitemsorder', 'billitemsorder',
'Show selected items first in Order Summary?' 'Show selected items first in Order Summary?'
@ -809,40 +888,77 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
)} )}
{renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')} {renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')}
{renderCheckbox('upiqr', 'Do you want to show the UPI QR code?')} {renderCheckbox('upiqr', 'Do you want to show the UPI QR code?')}
{renderCheckbox(
'itemdiscount',
'Do you want to show the Item Discount in Price OverRide?'
)}
{/* {renderCheckbox('editbill', 'Do you want to edit the previously created bill?')} */} {/* {renderCheckbox('editbill', 'Do you want to edit the previously created bill?')} */}
{(allSettingsMap['overalllimit'] !== undefined || allSettingsMap['itemwiselimit'] !== undefined) && ( {(allSettingsMap['overalllimit'] !== undefined ||
allSettingsMap['itemwiselimit'] !== undefined) && (
<> <>
<Form.Item name="quantityrestriction" label="Do you want to restrict the quantity that can be sold in a single order?" valuePropName="checked"> <Form.Item
name="quantityrestriction"
label="Do you want to restrict the quantity that can be sold in a single order?"
valuePropName="checked"
>
<Checkbox>Yes</Checkbox> <Checkbox>Yes</Checkbox>
</Form.Item> </Form.Item>
<Form.Item noStyle shouldUpdate={(prev, curr) => prev.quantityrestriction !== curr.quantityrestriction}> <Form.Item
{({ getFieldValue }) => getFieldValue('quantityrestriction') && ( noStyle
<> shouldUpdate={(prev, curr) =>
<Form.Item name="quantityrestrictiontype" label="How would you like to apply the quantity restriction?"> prev.quantityrestriction !== curr.quantityrestriction
<Radio.Group onChange={() => formRef.current?.setFieldsValue({ maxquantity: undefined })}> }
{allSettingsMap['overalllimit'] !== undefined && ( >
<Radio value="overall">Overall Order Quantity</Radio> {({ getFieldValue }) =>
)} getFieldValue('quantityrestriction') && (
{allSettingsMap['itemwiselimit'] !== undefined && ( <>
<Radio value="itemwise">Item-wise Quantity</Radio> <Form.Item
)} name="quantityrestrictiontype"
</Radio.Group> label="How would you like to apply the quantity restriction?"
</Form.Item> >
<Radio.Group
onChange={() =>
formRef.current?.setFieldsValue({
maxquantity: undefined,
})
}
>
{allSettingsMap['overalllimit'] !== undefined && (
<Radio value="overall">
Overall Order Quantity
</Radio>
)}
{allSettingsMap['itemwiselimit'] !==
undefined && (
<Radio value="itemwise">
Item-wise Quantity
</Radio>
)}
</Radio.Group>
</Form.Item>
<Form.Item <Form.Item
name="maxquantity" name="maxquantity"
label="Maximum quantity allowed:" label="Maximum quantity allowed:"
rules={[ rules={[
{ required: true, message: 'Please enter maximum quantity' }, {
{ type: 'number', min: 1, message: 'Quantity must be greater than 0' } required: true,
]} message: 'Please enter maximum quantity',
> },
<InputNumber min={1} style={{ width: '200px' }} /> {
</Form.Item> type: 'number',
</> min: 1,
)} message: 'Quantity must be greater than 0',
},
]}
>
<InputNumber min={1} style={{ width: '200px' }} />
</Form.Item>
</>
)
}
</Form.Item> </Form.Item>
</> </>
)} )}
@ -868,46 +984,46 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
{['whatsapp', 'sms', 'email'].some( {['whatsapp', 'sms', 'email'].some(
(k) => allSettingsMap[k] !== undefined (k) => allSettingsMap[k] !== undefined
) && ( ) && (
<> <>
<Form.Item <Form.Item
name="billOption" name="billOption"
label="Choose how to handle bills:" label="Choose how to handle bills:"
> >
<Radio.Group> <Radio.Group>
<Radio value="print">Print Bill</Radio> <Radio value="print">Print Bill</Radio>
<Radio value="pdf">Send PDF</Radio> <Radio value="pdf">Send PDF</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
noStyle noStyle
shouldUpdate={(prev, curr) => shouldUpdate={(prev, curr) =>
prev.billOption !== curr.billOption prev.billOption !== curr.billOption
} }
> >
{({ getFieldValue }) => {({ getFieldValue }) =>
getFieldValue('billOption') === 'pdf' && ( getFieldValue('billOption') === 'pdf' && (
<Form.Item <Form.Item
name="pdfSendOptions" name="pdfSendOptions"
label="Select how to send the PDF:" label="Select how to send the PDF:"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['whatsapp'] !== undefined && ( {allSettingsMap['whatsapp'] !== undefined && (
<Checkbox value="whatsapp">WhatsApp</Checkbox> <Checkbox value="whatsapp">WhatsApp</Checkbox>
)} )}
{allSettingsMap['email'] !== undefined && ( {allSettingsMap['email'] !== undefined && (
<Checkbox value="email">Email</Checkbox> <Checkbox value="email">Email</Checkbox>
)} )}
{allSettingsMap['sms'] !== undefined && ( {allSettingsMap['sms'] !== undefined && (
<Checkbox value="sms">SMS</Checkbox> <Checkbox value="sms">SMS</Checkbox>
)} )}
</Checkbox.Group> </Checkbox.Group>
</Form.Item> </Form.Item>
) )
} }
</Form.Item> </Form.Item>
</> </>
)} )}
{renderCheckbox( {renderCheckbox(
'tokenonly', 'tokenonly',
@ -937,25 +1053,25 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
{['printuom', 'printlogo', 'printgreetings'].some( {['printuom', 'printlogo', 'printgreetings'].some(
(k) => allSettingsMap[k] !== undefined (k) => allSettingsMap[k] !== undefined
) && ( ) && (
<Form.Item <Form.Item
name="printOptions" name="printOptions"
label="Select what you want to include in the print:" label="Select what you want to include in the print:"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['printuom'] !== undefined && ( {allSettingsMap['printuom'] !== undefined && (
<Checkbox value="printuom"> <Checkbox value="printuom">
Unit of Measure (UOM) Unit of Measure (UOM)
</Checkbox> </Checkbox>
)} )}
{allSettingsMap['printlogo'] !== undefined && ( {allSettingsMap['printlogo'] !== undefined && (
<Checkbox value="printlogo">Branch Logo</Checkbox> <Checkbox value="printlogo">Branch Logo</Checkbox>
)} )}
{allSettingsMap['printgreetings'] !== undefined && ( {allSettingsMap['printgreetings'] !== undefined && (
<Checkbox value="printgreetings">Greetings</Checkbox> <Checkbox value="printgreetings">Greetings</Checkbox>
)} )}
</Checkbox.Group> </Checkbox.Group>
</Form.Item> </Form.Item>
)} )}
{renderCheckbox( {renderCheckbox(
'mobilea4', 'mobilea4',
@ -963,20 +1079,24 @@ console.log("Wholesale Short Name:", values.wholesaleshortname);
)} )}
{(allSettingsMap['estimateprintheader'] !== undefined || {(allSettingsMap['estimateprintheader'] !== undefined ||
allSettingsMap['estimatetitle'] !== undefined) && ( allSettingsMap['estimatetitle'] !== undefined) && (
<Form.Item <Form.Item
name="estimateSettings" name="estimateSettings"
label="Estimate Print Settings :" label="Estimate Print Settings :"
> >
<Checkbox.Group> <Checkbox.Group>
{allSettingsMap['estimateprintheader'] !== undefined && ( {allSettingsMap['estimateprintheader'] !== undefined && (
<Checkbox value="estimateprintheader">Show shop header (Name, Address, GST)</Checkbox> <Checkbox value="estimateprintheader">
)} Show shop header (Name, Address, GST)
{allSettingsMap['estimatetitle'] !== undefined && ( </Checkbox>
<Checkbox value="estimatetitle">Show Estimate (R/W) title</Checkbox> )}
)} {allSettingsMap['estimatetitle'] !== undefined && (
</Checkbox.Group> <Checkbox value="estimatetitle">
</Form.Item> Show Estimate (R/W) title
)} </Checkbox>
)}
</Checkbox.Group>
</Form.Item>
)}
</div> </div>
<div className="PreferencesBTN"> <div className="PreferencesBTN">
<Buttons <Buttons