Merge pull request 'added offer for combo sales screen' (#36) from temp/gokul-offer-add-on-sales-sccreen-for-combo into main

Reviewed-on: Pozomind/pozo-retail-app#36
This commit is contained in:
karthikalakshmi 2026-01-30 10:39:46 +05:30
commit fadf942865
8 changed files with 3428 additions and 914 deletions

View File

@ -89,7 +89,9 @@ const BSBillingEditQuantity = (props) => {
const templateData = useSelector(getTemplateData);
const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some(
(item) => item?.OptionName == 'Offer'
);
) || (templateData?.BookingCombo1?.[1]?.some(
(item) => item?.OptionName == 'Offer'
));
const [ClearQuantity, setClearQuantity] = useState(false);
const CartOrderDetails = useSelector(GlobalOrderCardDetails);
const SettingDataSelector = useSelector(PreferenceData);
@ -702,7 +704,7 @@ const BSBillingEditQuantity = (props) => {
return (
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OfferMessage?.[0]?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
cartItem?.OfferMode === editedProduct?.OfferMode &&
cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
);
@ -836,7 +838,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName !==
editedProduct?.BookingTypeName &&
editedProduct?.BookingTypeName &&
!cartItem?.OfferMode &&
cartItem?.Offer === 0
);
@ -850,7 +852,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName !==
editedProduct?.BookingTypeName &&
editedProduct?.BookingTypeName &&
cartItem?.OfferMode === editedProduct?.OfferMode &&
cartItem?.Offer > 0
);
@ -983,7 +985,7 @@ const BSBillingEditQuantity = (props) => {
)
) &&
product?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
product?.OfferMode === editedProduct?.OfferMode
) {
const freeQty =
@ -1016,7 +1018,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1099,7 +1101,7 @@ const BSBillingEditQuantity = (props) => {
)
) &&
product?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
product?.OfferMode === editedProduct?.OfferMode
) {
return {
@ -1129,7 +1131,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1316,7 +1318,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1418,7 +1420,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1572,7 +1574,7 @@ const BSBillingEditQuantity = (props) => {
) &&
cartItem?.Offer &&
isFreeProductApplicable?.OfferId ===
cartItem?.OfferMessage?.[0]?.OfferId
cartItem?.OfferMessage?.[0]?.OfferId
);
}
);
@ -1861,11 +1863,11 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode)
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode)
) {
return {
...product,
@ -1899,11 +1901,11 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2044,7 +2046,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.Offer > 0 &&
isFreeProductApplicable?.OfferMode === cartItem?.OfferMode &&
isFreeProductApplicable?.OfferId ===
cartItem?.OfferMessage?.[0]?.OfferId
cartItem?.OfferMessage?.[0]?.OfferId
);
}
);
@ -2147,11 +2149,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2222,12 +2224,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -2261,13 +2263,13 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode);
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2349,11 +2351,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2406,11 +2408,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2499,11 +2501,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem?.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem?.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem?.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem?.OfferMode &&
cartItem?.Offer > 0
) {
@ -2532,11 +2534,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2566,11 +2568,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2669,12 +2671,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -2708,12 +2710,12 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2792,11 +2794,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2855,11 +2857,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2931,12 +2933,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -2970,12 +2972,12 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -3129,17 +3131,17 @@ const BSBillingEditQuantity = (props) => {
changeOrderCardDetails(
CartOrderDetails?.map((i) =>
i?.InwardDtlId == updatedProduct?.InwardDtlId &&
i?.BookingTypeName == updatedProduct?.BookingTypeName &&
i?.localId === updatedProduct?.localId
i?.BookingTypeName == updatedProduct?.BookingTypeName &&
i?.localId === updatedProduct?.localId
? {
...updatedProduct,
Offer: 0,
OfferType:
updatedProduct?.Type === 'C'
? updatedProduct?.OfferType
: null,
OfferMessage: null,
}
...updatedProduct,
Offer: 0,
OfferType:
updatedProduct?.Type === 'C'
? updatedProduct?.OfferType
: null,
OfferMessage: null,
}
: i
)
)
@ -3156,7 +3158,9 @@ const BSBillingEditQuantity = (props) => {
const UpdatedCartItemWithOffer = {
...updatedProduct,
Offer: updatedProduct.Offer || bestOffer?.OfferAmount,
Offer: (bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') ?
bestOffer?.OfferAmount || updatedProduct.Offer :
updatedProduct.Offer || bestOffer?.OfferAmount,
OfferType: updatedProduct?.OfferType || bestOffer?.OfferType,
OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage,
};
@ -3169,7 +3173,12 @@ const BSBillingEditQuantity = (props) => {
c.OrderRate === updatedProduct.OrderRate &&
c.BookingTypeName === updatedProduct.BookingTypeName &&
!c.SalesId &&
(c?.OfferType !== 'B' && c?.OfferType !== 'P' && c?.OfferType !== 'L'
((c?.OfferModeType && c?.OfferMode === 'B'
? true
: c?.OfferMode !== 'B')
&& c?.OfferMode !== 'P'
&& c?.OfferMode !== 'C' && c?.OfferMode !== 'O'
&& c?.OfferMode !== 'L'
? true
: c?.Offer === 0);
@ -3819,15 +3828,15 @@ const BSBillingEditQuantity = (props) => {
3
</div>
<div className="grid-item" onClick={() => AddQuantity(4)}>
4
</div>
<div className="grid-item" onClick={() => AddQuantity(5)}>
5
</div>
<div className="grid-item" onClick={() => AddQuantity(6)}>
6
</div>
<div className="grid-item" onClick={() => AddQuantity(4)}>
4
</div>
<div className="grid-item" onClick={() => AddQuantity(5)}>
5
</div>
<div className="grid-item" onClick={() => AddQuantity(6)}>
6
</div>
<div className="grid-item" onClick={() => AddQuantity(7)}>
7
@ -3853,23 +3862,23 @@ const BSBillingEditQuantity = (props) => {
per item{' '}
</label>
{!RadioDetails && (
<Form.Item
name="SellPrice"
rules={[
{
pattern: /^(0\d+|[1-9]\d*)(\.\d+)?$/,
message: 'Please Enter Number Only',
},
{
validator: async (_, value) => {
await validateSafeInput(value);
{!RadioDetails && (
<Form.Item
name="SellPrice"
rules={[
{
pattern: /^(0\d+|[1-9]\d*)(\.\d+)?$/,
message: 'Please Enter Number Only',
},
{
validator: async (_, value) => {
await validateSafeInput(value);
if (value && value.length > 10) {
return Promise.reject(
'Selling Price should not exceed 10 characters'
);
}
if (value && value.length > 10) {
return Promise.reject(
'Selling Price should not exceed 10 characters'
);
}
return Promise.resolve();
},
@ -3894,7 +3903,7 @@ const BSBillingEditQuantity = (props) => {
? `${parts[0]}.${parts.slice(1).join('')}`
: cleanedValue;
}}
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
/>
</Form.Item>
)}
@ -3957,7 +3966,7 @@ const BSBillingEditQuantity = (props) => {
? `${parts[0]}.${parts.slice(1).join('')}`
: cleanedValue;
}}
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
// isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false}
/>
</Form.Item>
{/* <input type="text"
@ -3993,14 +4002,14 @@ const BSBillingEditQuantity = (props) => {
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{((RadioBtnSelection == 'Price' && disableSubmitButton) ||
RadioBtnSelection == 'Quantity') && (
<Buttons
buttonText="Submit"
color="901D77"
htmlType
// handleSubmit={AddProductQuantity}
icon={<ArrowRightOutlined />}
></Buttons>
)}
<Buttons
buttonText="Submit"
color="901D77"
htmlType
// handleSubmit={AddProductQuantity}
icon={<ArrowRightOutlined />}
></Buttons>
)}
</div>
</Form>
</div>

View File

@ -137,13 +137,13 @@ const ComboSalesBillTable = () => {
OrderType === 'Hold'
? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway')
: tableData?.filter(
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
);
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
);
const OldtableDataTakeAway =
OrderType != 'Hold'
? tableData?.filter(
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
)
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
)
: [];
const [EditQuantity, setEditQuantity] = useState(false);
@ -1024,9 +1024,9 @@ const ComboSalesBillTable = () => {
)?.map((item, idx) =>
idx === 0
? {
...item,
FreeQty,
}
...item,
FreeQty,
}
: item
),
};
@ -2081,9 +2081,9 @@ const ComboSalesBillTable = () => {
{/* Delete */}
{item.OptionName === 'Delete' && (
<th className="deleteTh"
style={{ textAlign: 'center', width: '80px' }}
key={item.OptionId}>
<th className="deleteTh"
style={{ textAlign: 'center', width: '80px' }}
key={item.OptionId}>
{tableData?.length > 0 ? (
<Popconfirm
title="Delete the items"
@ -2091,18 +2091,18 @@ const ComboSalesBillTable = () => {
okText="Yes"
cancelText="No"
placement="leftTop"
onConfirm={() => {
Clearall();
}}
onConfirm={() => {
Clearall();
}}
>
<div className="del-all-btn">
{!isMobile ? (
<Tooltip title="Delete All" placement="left">
<AiFillDelete color="#ef4444" size={18} />
<AiFillDelete color="#ef4444" size={18} />
</Tooltip>
) : (
<div>
<AiFillDelete color="#ef4444" size={18} />
<AiFillDelete color="#ef4444" size={18} />
</div>
)}
</div>
@ -2146,20 +2146,20 @@ const ComboSalesBillTable = () => {
tableDataDinein?.length >= PreviousdataLength
? 'wheat'
: BookingType !== 'Dine In' &&
triggerAnimation &&
OldtableDataTakeAway?.length + index === 0 &&
tableDataDinein?.length >= PreviousdataLength &&
!HoldOrderDtl &&
!UnpaidData
triggerAnimation &&
OldtableDataTakeAway?.length + index === 0 &&
tableDataDinein?.length >= PreviousdataLength &&
!HoldOrderDtl &&
!UnpaidData
? 'wheat'
: 'inherit'
: 'none',
background: row?.SalesId
? 'rgb(243, 248, 213)'
: GlobEstBooking === 'ParEst' &&
GlobProdwisedata?.includes(
row?.InwardDtlId + ' ' + row?.BookingTypeName
)
GlobProdwisedata?.includes(
row?.InwardDtlId + ' ' + row?.BookingTypeName
)
? '#b2d1f7'
: (OldtableDataTakeAway?.length + index) % 2 === 0
? 'white'
@ -2194,39 +2194,39 @@ const ComboSalesBillTable = () => {
{/* Product Name / Item */}
{(item.OptionName === 'Item' ||
item.OptionName === 'Product Name') && (
<td
key={`prod-${index}`}
className="productNameTd"
onClick={() =>
row.FullProductIdentifierDtls?.length > 0 ||
row.ProductIdentifierDtls?.length > 0
? handleImeiDetails(row)
: editField && handleEditQuantity(row)
}
>
{row?.Type !== 'OS' ? row.ProdName : row.ServiceName}
{row?.BrandName ? ` ${row.BrandName}` : ''}
{row?.Type !== 'C' && (
<p className="Tbl3-Variant">
{/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */}
(
{!row?.ProdVariantName?.toLowerCase()?.includes(
'variant'
) && <span>{row?.ProdVariantName} </span>}
{row?.Size}
{row?.SinglePc == 'Y' ? 'PCS' : row?.UomName}
)
</p>
)}
{row?.Type === 'C' &&
row.ProdDetail?.map((prod, idx) => (
<p key={idx}>
{prod.ProdName} - {prod.Size} {prod.UomName}
<td
key={`prod-${index}`}
className="productNameTd"
onClick={() =>
row.FullProductIdentifierDtls?.length > 0 ||
row.ProductIdentifierDtls?.length > 0
? handleImeiDetails(row)
: editField && handleEditQuantity(row)
}
>
{row?.Type !== 'OS' ? row.ProdName : row.ServiceName}
{row?.BrandName ? ` ${row.BrandName}` : ''}
{row?.Type !== 'C' && (
<p className="Tbl3-Variant">
{/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */}
(
{!row?.ProdVariantName?.toLowerCase()?.includes(
'variant'
) && <span>{row?.ProdVariantName} </span>}
{row?.Size}
{row?.SinglePc == 'Y' ? 'PCS' : row?.UomName}
)
</p>
))}
</td>
)}
)}
{row?.Type === 'C' &&
row.ProdDetail?.map((prod, idx) => (
<p key={idx}>
{prod.ProdName} - {prod.Size} {prod.UomName}
</p>
))}
</td>
)}
{/* Barcode */}
{item.OptionName === 'Barcode' && (
@ -2270,9 +2270,12 @@ const ComboSalesBillTable = () => {
className="discPerTd"
onClick={() => editField && handleEditQuantity(row)}
>
{row?.OfferType === 'F'
? `${row.Offer}`
: `${row.Offer || '-'}`}
{row?.Offer > 0
? `${(
(row.Offer / (row?.OrderQty * row?.OrderRate)) *
100
).toFixed(2)}%`
: '-'}
</td>
)}
@ -2283,7 +2286,7 @@ const ComboSalesBillTable = () => {
className="discAmtTd"
onClick={() => editField && handleEditQuantity(row)}
>
{row.discAmt || '-'}
{row.Offer || '-'}
</td>
)}

View File

@ -230,6 +230,8 @@ import CardPopover from '../BSBillingTables/StandardTable/Utils/CardPopover.jsx'
import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx';
import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js';
import { getPaymentOptionsData } from '../../../../Features/BookingScreen/BookingData/KioskBookingData.js';
import { GlobalFreeProdList, GlobalOfferAppliedProducts, GlobalOverAllOfferAmt } from '../../../../Features/Offer/Offernew/BookingOffernew.js';
import BSNavBarTable from '../UtillComponents/BSNavBarTable.jsx';
const subDirectory = import.meta.env.ENV_BASE_URL;
const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL;
@ -449,6 +451,7 @@ const BSC1Payment = (props) => {
const [OpenFailData, SetOpenFailData] = useState(false);
const [paymentfeataddon, setpaymentfeataddon] = useState(false);
const [isFloatMenuOpen, setIsFloatMenuOpen] = useState(false);
const Discount = useSelector(GlobalOverAllOfferAmt);
const OverAllSales = useSelector(GlobalOverAllDiscSales);
const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate);
const [blink, setBlink] = useState(false);
@ -475,6 +478,8 @@ const BSC1Payment = (props) => {
// for customised invoice number
const { invoiceDate, clearInvoiceDate } = useDateStore();
const CurrentOrderId = useSelector(GlobalCurrentOrderId);
const FreeProdList = useSelector(GlobalFreeProdList);
const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts);
console.log(BSComboData, 'BSComboData');
const canHold =
@ -619,7 +624,9 @@ const BSC1Payment = (props) => {
}
let withdiscTotal =
Total - ((OverAllSales || 0) + (OverAllEstimate || 0));
Total - ((OverAllSales || 0) + (OverAllEstimate || 0) +
(Discount > 0 ? Discount : 0));
setTotalAmount(
withdiscTotal >= 0
@ -651,6 +658,7 @@ const BSC1Payment = (props) => {
OverAllEstimate,
globalTipAmount,
OtherServiceTicketClaim,
Discount
]);
useEffect(() => {
let data = {
@ -1590,7 +1598,7 @@ const BSC1Payment = (props) => {
const selectedStyle =
stylesMap[
printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle
printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle
];
if (selectedStyle) {
@ -1969,23 +1977,25 @@ const BSC1Payment = (props) => {
OrderStatus: 'O',
OrderType:
BookingType === 'Dine In' ||
BookingTypeBoth ||
Estimation?.SettingValue == 'N'
BookingTypeBoth ||
Estimation?.SettingValue == 'N'
? 'S'
: GlobEstBooking === 'OvrAllEst'
? 'E'
: GlobEstBooking === 'ParEst'
? GlobProdwisedata?.includes(
a.InwardDtlId + ' ' + a?.BookingTypeName
)
a.InwardDtlId + ' ' + a?.BookingTypeName
)
? 'E'
: 'S'
: 'S',
SinglePc: a.SinglePc,
BookingType: a.BookingTypeName === 'Dine In' ? DineinId : TakAwayId,
OfferValue: a?.Type === 'C' ? a?.OfferPrice : a.Offer,
OfferValue: a?.Type === 'C' ? a?.OfferValue : a.Offer,
OfferAmt: a?.Type === 'C' ? a?.TotalAmt : a.Offer,
OfferType: a?.Type === 'C' ? a?.OfferType : '',
OfferMode: a?.OfferMode,
OfferMessage: a?.OfferMessage,
CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null,
ProductIdentifierDtls: a.ProductIdentifierDtls,
ModelNumber: a.ModelNumber,
@ -1995,9 +2005,9 @@ const BSC1Payment = (props) => {
const NotSlectedTypeFind = temporderdetail?.find(
(a) => a?.BookingType != SelectedBookingType
);
let updatedOfferDetails = OrderOfferDetail;
let updatedOfferDetails = offerAppliedProducts;
if (GlobEstBooking !== 'Sales') {
updatedOfferDetails = OrderOfferDetail?.filter(
updatedOfferDetails = offerAppliedProducts?.filter(
(item) =>
!(
item.TableName === 'LoyaltyPoints' &&
@ -2059,7 +2069,7 @@ const BSC1Payment = (props) => {
: Paybtnnameselected?.toLowerCase() === 'credit'
? 'S'
: Paybtnnameselected?.toLowerCase() === 'upi' &&
SelectedUPIPayOption?.toLowerCase() === 'default'
SelectedUPIPayOption?.toLowerCase() === 'default'
? 'S'
: 'P',
OrderDtlDetails:
@ -2076,9 +2086,9 @@ const BSC1Payment = (props) => {
? globalTipAmount === 0
? SelectedTableDetails
: SelectedTableDetails?.map((item) => ({
...item,
TipsAmount: globalTipAmount,
}))
...item,
TipsAmount: globalTipAmount,
}))
: null,
// "Credit": TotalAmount,
// "Debit": 0,
@ -2112,23 +2122,23 @@ const BSC1Payment = (props) => {
ModeOfPayment:
SelectedUPIPayOption?.toLowerCase() === 'default'
? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId)
?.UPIDetailId
?.UPIDetailId
: null,
AccountDtl:
Paybtnnameselected?.toLowerCase() === 'upi' &&
SelectedUPIPayOption?.toLowerCase() === 'default'
SelectedUPIPayOption?.toLowerCase() === 'default'
? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find(
(upipay) => upipay?.UPIId === UpiId
)
(upipay) => upipay?.UPIId === UpiId
)
: (Paybtnnameselected?.toLowerCase() === 'upi' &&
SelectedUPIPayOption?.toLowerCase() === 'pd') ||
(Paybtnnameselected?.toLowerCase() === 'card' &&
SelectedCardOption?.toLowerCase() === 'pd')
SelectedUPIPayOption?.toLowerCase() === 'pd') ||
(Paybtnnameselected?.toLowerCase() === 'card' &&
SelectedCardOption?.toLowerCase() === 'pd')
? useOptions?.[0]?.PaymentDetails?.PaymentDevice
: (Paybtnnameselected?.toLowerCase() === 'upi' &&
SelectedUPIPayOption?.toLowerCase() === 'pg') ||
(Paybtnnameselected?.toLowerCase() === 'card' &&
SelectedCardOption?.toLowerCase() === 'pg')
SelectedUPIPayOption?.toLowerCase() === 'pg') ||
(Paybtnnameselected?.toLowerCase() === 'card' &&
SelectedCardOption?.toLowerCase() === 'pg')
? useOptions?.[0]?.PaymentDetails?.PaymentGateway
: [],
PaymentStatus:
@ -2137,7 +2147,7 @@ const BSC1Payment = (props) => {
: Paybtnnameselected?.toLowerCase() === 'credit'
? 'S'
: Paybtnnameselected?.toLowerCase() === 'upi' &&
SelectedUPIPayOption?.toLowerCase() === 'default'
SelectedUPIPayOption?.toLowerCase() === 'default'
? 'S'
: 'P',
Debit: 0,
@ -2148,6 +2158,12 @@ const BSC1Payment = (props) => {
},
],
OrderOfferDetail: updatedOfferDetails,
RefDetails: [
{
FreeProdList: FreeProdList,
OfferAppliedProductList: offerAppliedProducts,
},
],
};
let PostData = temppostdata;
@ -2196,14 +2212,14 @@ const BSC1Payment = (props) => {
setMessageType('success');
setMessageData(
response?.data?.response +
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
);
response?.data?.OrderDetails?.length > 0 &&
setPrintOrderDetails([response?.data]);
@ -2347,14 +2363,14 @@ const BSC1Payment = (props) => {
setMessageType('success');
setMessageData(
response?.data?.response +
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
);
response?.data?.OrderDetails?.length > 0 &&
setPrintOrderDetails([response?.data]);
@ -2456,14 +2472,14 @@ const BSC1Payment = (props) => {
}
setMessageData(
response?.data?.response +
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
' ' +
(response?.data?.OrderDetails?.length > 0
? response?.data?.OrderId &&
extractLastNumberOrderId(
response?.data?.OrderId,
response?.data?.OrderDetails?.[0]?.FYStatus
)
: '')
);
if (response?.data?.OrderDetails?.length > 0) {
setPrintOrderDetails([response?.data]);
@ -2560,14 +2576,14 @@ const BSC1Payment = (props) => {
setMessageType('success');
setMessageData(
bookingpaymentupdate?.data?.response +
' ' +
(bookingpaymentupdate?.data?.OrderDetails?.length > 0
? bookingpaymentupdate?.data?.OrderId &&
extractLastNumberOrderId(
bookingpaymentupdate?.data?.OrderId,
bookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus
)
: '')
' ' +
(bookingpaymentupdate?.data?.OrderDetails?.length > 0
? bookingpaymentupdate?.data?.OrderId &&
extractLastNumberOrderId(
bookingpaymentupdate?.data?.OrderId,
bookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus
)
: '')
);
bookingpaymentupdate?.data?.OrderDetails?.length > 0 &&
setPrintOrderDetails([bookingpaymentupdate?.data]);
@ -2585,7 +2601,7 @@ const BSC1Payment = (props) => {
if (
Date.now() - startTime >
useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes *
60000
60000
) {
// 60,000 ms = 1 minute
@ -3599,16 +3615,16 @@ const BSC1Payment = (props) => {
(BookingType === 'Dine In' ||
BookingTypeBoth ||
CheckOrderType?.length > 0) &&
!unpaidFlow &&
OrderStatus
!unpaidFlow &&
OrderStatus
? 'none'
: 'auto',
opacity:
(BookingType === 'Dine In' ||
BookingTypeBoth ||
CheckOrderType?.length > 0) &&
!unpaidFlow &&
OrderStatus
!unpaidFlow &&
OrderStatus
? 0.5
: 1,
}}
@ -3619,10 +3635,10 @@ const BSC1Payment = (props) => {
<button
className={
paybtnselected === payment.ModeId &&
(UpinotSelected || CardoptionnotSelected)
(UpinotSelected || CardoptionnotSelected)
? 'Btn-payment-mode-notupisel'
: paybtnselected === payment.ModeId &&
(!UpinotSelected || !CardoptionnotSelected)
(!UpinotSelected || !CardoptionnotSelected)
? 'Btn-payment-mode'
: 'Btn-payment-mode-sel'
}
@ -3700,16 +3716,16 @@ const BSC1Payment = (props) => {
(BookingType === 'Dine In' ||
BookingTypeBoth ||
CheckOrderType?.length > 0) &&
!unpaidFlow &&
OrderStatus
!unpaidFlow &&
OrderStatus
? 'none'
: 'auto',
opacity:
(BookingType === 'Dine In' ||
BookingTypeBoth ||
CheckOrderType?.length > 0) &&
!unpaidFlow &&
OrderStatus
!unpaidFlow &&
OrderStatus
? 0.5
: 1,
}}
@ -3729,14 +3745,14 @@ const BSC1Payment = (props) => {
style={{
cursor:
OrderCardDetail?.length === 0 ||
CheckBookingStatus == 'Close' ||
addnewAccess
CheckBookingStatus == 'Close' ||
addnewAccess
? 'not-allowed'
: 'pointer',
color:
OrderCardDetail?.length === 0 ||
CheckBookingStatus == 'Close' ||
addnewAccess
CheckBookingStatus == 'Close' ||
addnewAccess
? '#fff'
: '#ffffffff',
alignItems: 'center',
@ -3832,19 +3848,61 @@ const BSC1Payment = (props) => {
{/* {item?.OptionName=="Hold" && */}
{unpaidFlow == false
? item?.OptionName == 'Hold' &&
BookingType !== 'Dine In' &&
!BookingTypeBoth &&
OrderCardDetail?.length != 0 &&
CheckOrderType?.length === 0 &&
OrderType != 'Failed' &&
CheckBookingStatus != 'Close' &&
!addnewAccess && (
<TooltipWrapper title={'Hold'} isMobile={isMobile}>
{' '}
BookingType !== 'Dine In' &&
!BookingTypeBoth &&
OrderCardDetail?.length != 0 &&
CheckOrderType?.length === 0 &&
OrderType != 'Failed' &&
CheckBookingStatus != 'Close' &&
!addnewAccess && (
<TooltipWrapper title={'Hold'} isMobile={isMobile}>
{' '}
<div
style={{
backgroundColor: '' ? '#52c41a' : '#1292EE',
color: '' ? '#52c41a' : '#ffffffff',
height: '40px',
width: '45px',
borderRadius: '6px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '8px 8px 12px 8px',
}}
>
<PozoHoldIcon
className="BSBillingNav-icon-table-icon"
onClick={() => AddBookingDetails('Hold')}
style={{
cursor: 'pointer',
// color: '' ? '#52c41a' : '#1292EE',
}}
/>{' '}
{/* <p className="payOptionDecition"> Hold</p> */}
</div>
</TooltipWrapper>
)
: ''}
{unpaidFlow == false
? item?.OptionName == 'Hold' &&
BookingType !== 'Dine In' &&
!BookingTypeBoth &&
Holddata?.length > 0 &&
OrderCardDetail?.length == 0 &&
CheckBookingStatus != 'Close' &&
!addnewAccess && (
<TooltipWrapper title={'Recall'} isMobile={isMobile}>
{' '}
<Badge
count={Holddata?.length}
size={'small'}
offset={[0, 7]}
>
<div
style={{
backgroundColor: '' ? '#52c41a' : '#1292EE',
color: '' ? '#52c41a' : '#ffffffff',
backgroundColor: Holddata ? '#52c41a' : 'default',
color: Holddata ? '#ffffffff' : 'default',
height: '40px',
width: '45px',
borderRadius: '6px',
@ -3856,60 +3914,18 @@ const BSC1Payment = (props) => {
>
<PozoHoldIcon
className="BSBillingNav-icon-table-icon"
onClick={() => AddBookingDetails('Hold')}
onClick={() => HandleholdModelOpen()}
style={{
cursor: 'pointer',
// color: '' ? '#52c41a' : '#1292EE',
// color: Holddata ? '#52c41a' : 'default',
pointerEvents:
OrderType === 'Failed' ? 'none' : 'auto',
}}
/>{' '}
{/* <p className="payOptionDecition"> Hold</p> */}
/>
</div>
</TooltipWrapper>
)
: ''}
{unpaidFlow == false
? item?.OptionName == 'Hold' &&
BookingType !== 'Dine In' &&
!BookingTypeBoth &&
Holddata?.length > 0 &&
OrderCardDetail?.length == 0 &&
CheckBookingStatus != 'Close' &&
!addnewAccess && (
<TooltipWrapper title={'Recall'} isMobile={isMobile}>
{' '}
<Badge
count={Holddata?.length}
size={'small'}
offset={[0, 7]}
>
<div
style={{
backgroundColor: Holddata ? '#52c41a' : 'default',
color: Holddata ? '#ffffffff' : 'default',
height: '40px',
width: '45px',
borderRadius: '6px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '8px 8px 12px 8px',
}}
>
<PozoHoldIcon
className="BSBillingNav-icon-table-icon"
onClick={() => HandleholdModelOpen()}
style={{
cursor: 'pointer',
// color: Holddata ? '#52c41a' : 'default',
pointerEvents:
OrderType === 'Failed' ? 'none' : 'auto',
}}
/>
</div>
</Badge>
</TooltipWrapper>
)
</Badge>
</TooltipWrapper>
)
: ''}
{tabledata?.length > 0 && dinePreference && (
<>
@ -3978,9 +3994,9 @@ const BSC1Payment = (props) => {
style={{
backgroundColor:
OrderCardDetail?.length > 0 ||
(selOption?.value === undefined &&
GlobalAddCustomerDetails1?.length === 0 &&
GetCustId?.CustMobile === undefined)
(selOption?.value === undefined &&
GlobalAddCustomerDetails1?.length === 0 &&
GetCustId?.CustMobile === undefined)
? 'gray'
: '#1292eeff',
color: '#fff',
@ -4023,36 +4039,36 @@ const BSC1Payment = (props) => {
{FeatureAddonData?.FeatureDtls?.find(
(item) => item?.FeatureAddonName?.toLowerCase() === 'preorder'
) && (
<>
{
<div
style={{
pointerEvents:
OrderCardDetail?.length > 0 || OrderType === 'Failed'
? 'none'
: 'auto',
opacity: OrderCardDetail?.length > 0 ? 0.5 : 1,
}}
>
<TooltipWrapper title={'Pre Order'} isMobile={isMobile}>
<Badge
count={preOrderPendingCount}
offset={[-5, 10]}
size="small"
>
<PozoPreOrderIcon
className="BSBillingNav-icon"
fill={preOrderOpen ? '#52C41A' : '#1292EE'}
onClick={() => {
openPreOrder();
}}
/>
</Badge>
</TooltipWrapper>
</div>
}
</>
)}
<>
{
<div
style={{
pointerEvents:
OrderCardDetail?.length > 0 || OrderType === 'Failed'
? 'none'
: 'auto',
opacity: OrderCardDetail?.length > 0 ? 0.5 : 1,
}}
>
<TooltipWrapper title={'Pre Order'} isMobile={isMobile}>
<Badge
count={preOrderPendingCount}
offset={[-5, 10]}
size="small"
>
<PozoPreOrderIcon
className="BSBillingNav-icon"
fill={preOrderOpen ? '#52C41A' : '#1292EE'}
onClick={() => {
openPreOrder();
}}
/>
</Badge>
</TooltipWrapper>
</div>
}
</>
)}
{preOrderOpen && <BSNavBarPreOrder />}
{sportsAppPreference && <BSMembership />}
{dinePreference &&
@ -4210,9 +4226,9 @@ const BSC1Payment = (props) => {
addnewAccess
? 'BSC1Payment-div4-button-disable'
: FirstPaymentclick === false &&
OrderCardDetail?.length > 0 &&
paybtnselected &&
CheckBookingStatus != 'Close'
OrderCardDetail?.length > 0 &&
paybtnselected &&
CheckBookingStatus != 'Close'
? !OrderStatus
? 'BSC1Payment-div4-button'
: 'BSC1Payment-div4-button Order'
@ -4441,8 +4457,8 @@ const BSC1Payment = (props) => {
columns={columns}
data={TableData}
dataSource={TableData}
// pagination={handlePageChange}
// onChange={handleChange}
// pagination={handlePageChange}
// onChange={handleChange}
/>
</div>
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,27 +18,27 @@ export const useSaleswiseOfferWatcher = () => {
);
// Memoized calculations
const netAmount = useMemo(() =>
const netAmount = useMemo(() =>
cartItems?.reduce((sum, item) => sum + (item?.TotalAmt || 0), 0) || 0,
[cartItems]
);
const hasNonSalesOffers = useMemo(() =>
const hasNonSalesOffers = useMemo(() =>
offerAppliedProducts?.some(offer => offer.OfferType !== "S") || false,
[offerAppliedProducts]
);
const applicableOffers = useMemo(() => {
const offers = overAllProductBasedOfferData?.ProdDtl || [];
return offers.filter(offer => {
// Early returns for better performance
if (offer.OfferType !== "S") return false;
if (offer.LimitUsage !== null && offer.LimitUsage <= 0) return false;
const amountFrom = offer.AmountFrom ?? 0;
const amountTo = offer.AmountTo ?? Infinity;
return netAmount >= amountFrom && netAmount <= amountTo;
});
}, [overAllProductBasedOfferData?.ProdDtl, netAmount]);
@ -47,7 +47,7 @@ export const useSaleswiseOfferWatcher = () => {
if (!applicableOffers.length) return null;
return applicableOffers.reduce((best, current) => {
const currentDiscount = current.ValueType === "F"
const currentDiscount = current.ValueType === "F"
? current.OfferAmt || 0
: ((current.OfferAmt || 0) * netAmount) / 100;
@ -57,7 +57,7 @@ export const useSaleswiseOfferWatcher = () => {
? best.offer.OfferAmt || 0
: ((best.offer.OfferAmt || 0) * netAmount) / 100;
return currentDiscount > bestDiscount
return currentDiscount > bestDiscount
? { offer: current, discount: currentDiscount }
: best;
}, null);
@ -68,12 +68,12 @@ export const useSaleswiseOfferWatcher = () => {
const BOOKING_TYPE = "DineIn";
// Helper function to create offer payload
const createOfferPayload = (offer) => ({
const createOfferPayload = (offer, discount = null) => ({
OfferId: offer.OfferId || "",
OfferAmount: offer.OfferAmt || 0,
OfferAmount: discount || offer.OfferAmt || 0,
OfferMode: offer.OfferType,
AcuvalOfferAmount: offer.OfferAmt,
OfferValue: offer.OfferAmt || 0,
AcuvalOfferAmount: discount || offer.OfferAmt,
OfferValue: discount || offer.OfferAmt || 0,
TableName: offer.TableName || "",
TableUniqueName: offer.TableUniqueName || "",
TableUniqueId: offer.TableUniqueId || "",
@ -93,7 +93,7 @@ export const useSaleswiseOfferWatcher = () => {
if (!freeProducts) return [];
const productsArray = Array.isArray(freeProducts) ? freeProducts : [freeProducts];
return productsArray.map(fp => ({
FreeProdId: fp.FreeProdId || "",
FreeQty: fp.FreeQty || 0,
@ -116,8 +116,8 @@ export const useSaleswiseOfferWatcher = () => {
if (bestOffer) {
console.log("💡 NetAmount:", netAmount);
console.log("👉 Applying best offer:", bestOffer.offer);
dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer)));
dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer, bestOffer?.discount)));
} else {
// Remove any existing sales offers
dispatch(RemoveOfferAppliedProduct({

View File

@ -108,9 +108,12 @@ const BSCustomerSelect = ({ TopName = null }) => {
offerOption
} = useMemo(() => {
const navbarOptions = layoutData?.BookingNavbar?.[1];
const comboOptions = layoutData?.BookingCombo1?.[1];
return {
offerOption: navbarOptions?.find(
(option) => option?.OptionName?.toLowerCase() === 'offer'
) || comboOptions?.find(
(option) => option?.OptionName?.toLowerCase() === 'offer'
),
};
}, [layoutData]);
@ -121,7 +124,7 @@ const BSCustomerSelect = ({ TopName = null }) => {
}, [OrderOfferDetails]);
const loyaltyFreeProductsInCart = useMemo(() => {
return OrderOfferDetails?.filter((offer) => offer?.FreeProductsList?.OfferMode === 'L' && offer?.FreeProductsList?.TableUniqueName === "FreeProduct") || [];
return OrderOfferDetails?.filter((offer) => (offer?.FreeProductsList?.OfferMode === 'L' || offer?.OfferMode === 'L') && (offer?.FreeProductsList?.TableUniqueName === "FreeProduct" || offer?.TableUniqueName === "FreeProduct")) || [];
}, [OrderOfferDetails]);
const filteredLoyaltyFreeProducts = useMemo(() => {
@ -573,6 +576,23 @@ const BSCustomerSelect = ({ TopName = null }) => {
const updatedOrderOfferDetails = OrderOfferDetails?.filter(
offer => !(offer?.OfferMode === 'L' && offer?.TableUniqueName === "Cash")
);
let updatedOrderCardDetails = OrderCardDetail?.map(item => {
if (item?.OfferMode === 'L') {
return {
...item,
Offer: null,
OfferMessage: undefined,
OfferMode: undefined,
OfferModeType: false,
OfferType: undefined,
OfferValue: null,
}
} else {
return item
}
}) || [];
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
dispatch(changeFullOfferAppliedProducts(updatedOrderOfferDetails));
setLoyaltyModal(false);
};
@ -699,7 +719,19 @@ const BSCustomerSelect = ({ TopName = null }) => {
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
setClearPopoverVisible(false);
dispatch(ChangeFullFreeProductList(freeProductList.filter(item => item.OfferMode !== 'L')));
dispatch(changeFullOfferAppliedProducts(OrderOfferDetails?.filter(item => item.OfferMode !== 'L')));
dispatch(changeFullOfferAppliedProducts(OrderOfferDetails?.filter(item => {
// if OfferMode exists and is 'L' remove
if (item?.OfferMode && item.OfferMode === 'L') return false;
// if FreeProductsList OfferMode exists and is 'L' remove
if (
item?.FreeProductsList?.OfferMode &&
item.FreeProductsList.OfferMode === 'L'
)
return false;
return true;
})));
setSelectedProducts([]);
setProductQuantities({});
};

View File

@ -83,6 +83,7 @@ import {
changeTipAmount,
changeChairLevelServiceDefault,
changeDefaultBookingType,
getCustomerForHold,
} from '../../Features/BookingScreen/BookingData/BookingData';
import { ApplicationPreferences, getBranchDetail } from '../../Features/BrachLogin/BranchLogin';
import '../../Styles/Tablebooking/TableBooking.scss';
@ -130,6 +131,8 @@ import DiningTableCompass from './Compass.jsx';
import Compass from './Compass.jsx';
import { DropDowns } from "../../Components/Forms/DropDown.jsx";
import MergeBill from "./MergeBill/MergeBill.jsx";
import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, changeLoyaltyConsumedQuantities } from "../../Features/Offer/Offernew/BookingOffernew.js";
import { v4 as uuidv4 } from 'uuid';
const subDirectory = import.meta.env.BASE_URL;
const MainHomeUrl = import.meta.env.ENV_Main_BASE_URL;
@ -1038,32 +1041,84 @@ const TableBooking = ({ PaymentStatus }) => {
ExtraChargeDetails,
CustSuppId,
OrderOfferDetails,
RefDetails,
OrderId
} = OrderDetails;
RefDetails?.[0]?.FreeProdList &&
dispatch(ChangeFullFreeProductList(RefDetails?.[0]?.FreeProdList));
RefDetails?.[0]?.OfferAppliedProductList &&
dispatch(changeFullOfferAppliedProducts(RefDetails?.[0]?.OfferAppliedProductList));
const loyaltyFreeProductOfferApplied =
RefDetails?.[0]?.OfferAppliedProductList?.filter(
(off) =>
off?.FreeProductsList?.OfferMode === 'L' &&
off?.TableUniqueName === 'FreeProduct'
);
const updatedOrderCardDetails = OrderDtlDetails?.map((item) => ({
...item,
Offer: item?.OfferAmt,
localId: uuidv4(),
OfferMode: item?.OfferMode ? item?.OfferMode?.trim() : null,
}));
dispatch(changeOrderType('Reorder'));
dispatch(changeBookingType('Dine In'));
dispatch(changeReorderHoldDetails(OrderDetails));
dispatch(changeReorderProductDetails(OrderDtlDetails));
dispatch(changeReorderProductDetails(updatedOrderCardDetails));
dispatch(ChangeTotalAmount(ExtraChargeDetails));
dispatch(changeSelectedTableDetails(OrderDetails?.SalesTableLinkDetails));
dispatch(changeOrderCardDetails(OrderDtlDetails));
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
if (CustSuppId) {
dispatch(changeSelectedCustId(CustSuppId));
let res = await dispatch(
getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId })
getCustomerForHold({
CompId: CompId,
AppId: AppId,
branchId: BranchId,
OrderId: OrderId,
})
).unwrap();
if (res?.data?.statusCode === 1) {
const { CustId, CustName, CustMobile } = res?.data?.data?.find(
const { CustId, CustName, CustMobile, LoyaltyPointsDetail, TotalLoyaltyPoints } = res?.data?.data?.find(
(item) => item.CustId === CustSuppId
);
const data = {
CustId: CustId,
CustName: CustName,
label: CustName,
label: CustName ? CustName : CustMobile,
value: CustMobile,
LoyaltyPointsDetail: LoyaltyPointsDetail,
TotalLoyaltyPoints: TotalLoyaltyPoints
};
dispatch(changeOrderOfferDetail([...OrderOfferDetails]));
dispatch(changeSelectedOption(data));
dispatch(ChangeSelectedCustDisable(true));
if (loyaltyFreeProductOfferApplied?.length > 0) {
const loyaltyProdQuantities = {};
loyaltyFreeProductOfferApplied.forEach((off) => {
const freeProdDtls = off?.FreeProductsList;
const freeProdOfferId =
freeProdDtls?.ProdVariantDetails?.[0]?.StockDetails?.[0]
?.ProdOfferId;
const key = [
freeProdDtls?.OfferId,
freeProdDtls?.FreeProdId,
freeProdDtls?.FreeProdVariantName,
freeProdOfferId,
].join('|');
loyaltyProdQuantities[key] = freeProdDtls?.FreeQty || 0;
});
if (Object.keys(loyaltyProdQuantities).length > 0) {
dispatch(changeLoyaltyConsumedQuantities(loyaltyProdQuantities));
}
console.log(loyaltyProdQuantities, 'loyaltyProdQuantities');
}
} else if (res?.data?.statusCode == 0) {
const OrderOffer = OrderOfferDetails?.filter(
(fil) =>
@ -1072,18 +1127,18 @@ const TableBooking = ({ PaymentStatus }) => {
fil.TableUniqueName === 'UniqueId'
)
);
if (OfferCheckedInSetup && preferenceOffer) {
applyOffer(OrderDtlDetails, OrderOffer);
} else {
dispatch(changeOrderCardDetails(OrderDtlDetails));
}
// if (OfferCheckedInSetup && preferenceOffer) {
// applyOffer(OrderDtlDetails, OrderOffer);
// } else {
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
// }
}
} else {
if (OfferCheckedInSetup && preferenceOffer) {
applyOffer(OrderDtlDetails, OrderOfferDetails);
} else {
dispatch(changeOrderCardDetails(OrderDtlDetails));
}
// if (OfferCheckedInSetup && preferenceOffer) {
// applyOffer(OrderDtlDetails, OrderOfferDetails);
// } else {
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
// }
}
if (SelectedChair?.length > 0) {
@ -1219,12 +1274,12 @@ const TableBooking = ({ PaymentStatus }) => {
const UpiPayment = () => {
let TotalAmount = ModalType === 'ChairlevelSer'
? matchedChairData?.OrderDetails?.[0]?.NetAmount
: matchedChairData?.OrderDetails?.[0]
?.NetAmount
? matchedChairData?.OrderDetails?.[0]?.NetAmount
: matchedChairData?.OrderDetails?.[0]
?.NetAmount
if (SelectedUpiOption && TotalAmount == 0) {
Upimodel('Submit');
} else if (SelectedUpiOption) {
Upimodel('Submit');
} else if (SelectedUpiOption) {
setUpiOpen(true);
const customerDisplayWindow = getCustomerDisplayWindow();
if (customerDisplayWindow && !customerDisplayWindow.closed) {