From 1fc026f2b28ad7f48988557df9630ad1055dc9a4 Mon Sep 17 00:00:00 2001 From: vignesh Date: Thu, 19 Mar 2026 15:50:18 +0530 Subject: [PATCH] SalesScreen Table payment Design Optimization --- src/Components/Menu/PozoMenu.jsx | 142 +- .../BSBillingTable1/BSBTOverall1.jsx | 24 +- .../BSBillingTable1/BST1Payment.jsx | 515 ++- .../BSBillingTable2/BSBillingTable2.jsx | 1185 +----- .../BSBillingTable2/BsBill2.jsx | 2664 ++++---------- .../BSBillingTable3/BSBillingTable3.jsx | 3163 +++++++++-------- .../BSBillingTable3overall.jsx | 108 +- .../BSBillingTable3/BSBillingTable3pay.jsx | 1988 ++++++----- .../BSBillingTable3/BSBillingTablePay.scss | 33 + .../BSBillingTable4/BSBilling4Payment.jsx | 2561 +++++++------ .../BSBillingTable4/BSBillingTable4Full.jsx | 4 +- .../BSBillingTable5/BSBillingTable5.jsx | 902 +---- .../BSBillingTable5/BsBill.jsx | 6 +- .../BSBillingTable6/BSBTOverall6.jsx | 3 +- .../BSBillingTable6/BSBillingTable6.jsx | 8 +- .../BSBillingTable7Overall.jsx | 7 +- .../StandardTable/StandardTable.jsx | 5 - .../StandardTable/StandardTable.scss | 16 +- .../StandardTable/StandardTablePayment.jsx | 13 +- .../Components/BSCombo/BSC1Payment.jsx | 2 +- .../Components/BSItemCards/BSItemCard.jsx | 4 +- .../Components/BSNavbar/BSNavbar1.jsx | 10 +- .../Template/BSLayout1/BSLayout1.jsx | 60 +- .../Template/BSLayout2/BSLayout2.jsx | 41 +- .../Template/BSLayout3/BSLayout3.jsx | 37 +- .../Template/BSLayout4/BSLayout4.jsx | 44 +- .../Template/BSLayout5/BSLayout5.jsx | 12 +- .../Template/BSLayout6/BSLayout6.jsx | 49 +- .../Template/BSLayout7/BSCombo1.jsx | 41 +- .../BSBillingTable1/BSBPayment.scss | 75 +- .../BSBillingTable1/BSBTOverall.scss | 94 +- .../BSBillingTable2/BSBIllingTable2.scss | 195 +- .../BSBillingTable4/BSBillingTable4.scss | 7 +- .../BSBillingTable6/BSBillingTable6.scss | 12 +- .../BSBillingTable6/BST6Payment.scss | 19 +- .../BSBillingTable7/BSBillingTable7.scss | 4 +- .../BSBillingTables3/BSBillingTable3.scss | 377 +- .../Components/BSItemCards/BSItemCard.scss | 3 +- .../Components/BSNavbar/BSNavbar1.scss | 10 +- .../Components/BSNavbar/BSNavbar2.scss | 4 +- .../Template/BSLayout1/BSLayout1.scss | 112 +- .../Template/BSLayout2/BSLayout2.scss | 29 +- .../Template/BSLayout3/BSLayout3.scss | 19 +- .../Template/BSLayout4/BSLayout4.scss | 10 +- .../Template/BSLayout5/BSLayout5.scss | 9 +- .../Template/BSLayout6/BSLayout6.scss | 8 +- 46 files changed, 6021 insertions(+), 8613 deletions(-) create mode 100644 src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTablePay.scss diff --git a/src/Components/Menu/PozoMenu.jsx b/src/Components/Menu/PozoMenu.jsx index 0290a11..8f3bd31 100644 --- a/src/Components/Menu/PozoMenu.jsx +++ b/src/Components/Menu/PozoMenu.jsx @@ -1,15 +1,23 @@ import { useState, useRef, useEffect } from 'react'; -import { FaCaretRight } from "react-icons/fa"; +import { FaCaretRight } from 'react-icons/fa'; import './PozoMenu.scss'; import { getSession, sessionStore } from '../../Services/Others'; -const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse = false, selectedKey: propSelectedKey, isBottomMenu = false }) => { +const PozoMenu = ({ + items = [], + mode = 'vertical', + style = {}, + onClick, + collapse = false, + selectedKey: propSelectedKey, + isBottomMenu = false, +}) => { const [openKeys, setOpenKeys] = useState([]); const [selectedKey, setSelectedKey] = useState(''); const [dropdownPositions, setDropdownPositions] = useState({}); const [isMobile, setIsMobile] = useState(window.innerWidth <= 768); - const BranchId = getSession("BranchId"); + const BranchId = getSession('BranchId'); const menuRef = useRef(); // Update selected key when prop changes @@ -44,14 +52,14 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse if (openKeys.length > 0) { // Find all currently open menu elements and recalculate their positions const newPositions = {}; - openKeys.forEach(key => { + openKeys.forEach((key) => { const element = document.querySelector(`[data-menu-key="${key}"]`); if (element) { const level = key.split('-').length - 1; newPositions[key] = calculatePosition(element, level); } }); - setDropdownPositions(prev => ({ ...prev, ...newPositions })); + setDropdownPositions((prev) => ({ ...prev, ...newPositions })); } }; @@ -77,7 +85,9 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse // Dynamic dropdown dimensions - responsive const dropdownWidth = isMobile ? Math.min(280, viewportWidth - 20) - : (level > 0 ? 220 : 250); + : level > 0 + ? 220 + : 250; const dropdownHeight = Math.min( isMobile ? viewportHeight * 0.5 : 400, viewportHeight * 0.6 @@ -94,7 +104,7 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse top: rect.top + scrollY, left: rect.right + gap + scrollX, direction: 'right', - verticalDirection: 'down' + verticalDirection: 'down', }; // 🎯 FIXED: HORIZONTAL POSITIONING - Exactly like your images @@ -103,7 +113,7 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse spaceRight, spaceLeft, spaceNeeded, - elementPosition: { left: rect.left, right: rect.right } + elementPosition: { left: rect.left, right: rect.right }, }); if (spaceRight >= spaceNeeded) { @@ -115,7 +125,6 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse // Image 2: No space on right, space on left - open to LEFT position.left = rect.left - dropdownWidth - gap + scrollX; position.direction = 'left'; - } else { // Edge case: Limited space on both sides if (spaceRight >= spaceLeft) { @@ -130,9 +139,10 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse } else { // Nested menu positioning const parentKeys = Object.keys(dropdownPositions); - const parentDirection = parentKeys.length > 0 - ? dropdownPositions[parentKeys[level - 1]]?.direction || 'right' - : 'right'; + const parentDirection = + parentKeys.length > 0 + ? dropdownPositions[parentKeys[level - 1]]?.direction || 'right' + : 'right'; if (parentDirection.includes('right')) { if (spaceRight >= spaceNeeded) { @@ -173,7 +183,9 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse position.top = rect.bottom - dropdownHeight + scrollY; position.verticalDirection = 'up'; } else { - position.top = Math.max(edgePadding, (viewportHeight - dropdownHeight) / 2) + scrollY; + position.top = + Math.max(edgePadding, (viewportHeight - dropdownHeight) / 2) + + scrollY; position.verticalDirection = 'center'; } } @@ -181,12 +193,18 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse // 🎯 FIXED: Final boundary checks position.left = Math.max( edgePadding + scrollX, - Math.min(position.left, viewportWidth - dropdownWidth - edgePadding + scrollX) + Math.min( + position.left, + viewportWidth - dropdownWidth - edgePadding + scrollX + ) ); position.top = Math.max( edgePadding + scrollY, - Math.min(position.top, viewportHeight - dropdownHeight - edgePadding + scrollY) + Math.min( + position.top, + viewportHeight - dropdownHeight - edgePadding + scrollY + ) ); // Store dimensions for reference @@ -194,10 +212,20 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse position.height = dropdownHeight; console.log('🎯 FIXED Position:', { - clicked: { top: rect.top, left: rect.left, right: rect.right, bottom: rect.bottom }, - spaces: { right: spaceRight, left: spaceLeft, above: spaceAbove, below: spaceBelow }, + clicked: { + top: rect.top, + left: rect.left, + right: rect.right, + bottom: rect.bottom, + }, + spaces: { + right: spaceRight, + left: spaceLeft, + above: spaceAbove, + below: spaceBelow, + }, calculated: position, - direction: position.direction + direction: position.direction, }); return position; @@ -205,9 +233,9 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse // Handle menu item click const handleMenuClick = (item, event, parentKeys = []) => { - if (item?.label === "Branch Signin") { + if (item?.label === 'Branch Signin') { if (BranchId) { - sessionStorage.removeItem("BranchId") + sessionStorage.removeItem('BranchId'); } } event.stopPropagation(); @@ -219,13 +247,15 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse if (isOpen) { // Close this submenu and all its children - setOpenKeys(prev => prev.filter(key => { - // Keep only keys that are not this item or its descendants - return !key.startsWith(itemKey) && key !== itemKey; - })); - setDropdownPositions(prev => { + setOpenKeys((prev) => + prev.filter((key) => { + // Keep only keys that are not this item or its descendants + return !key.startsWith(itemKey) && key !== itemKey; + }) + ); + setDropdownPositions((prev) => { const newPos = { ...prev }; - Object.keys(newPos).forEach(key => { + Object.keys(newPos).forEach((key) => { if (key.startsWith(itemKey) || key === itemKey) { delete newPos[key]; } @@ -235,27 +265,33 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse } else { // Close all submenus at the same level or deeper const currentPath = [...parentKeys, itemKey]; - const newOpenKeys = openKeys.filter(key => { + const newOpenKeys = openKeys.filter((key) => { // Keep only parent keys in the current path - return currentPath.some(pathKey => key === pathKey) || + return ( + currentPath.some((pathKey) => key === pathKey) || currentPath.every((pathKey, index) => { const keyParts = key.split('-'); const pathParts = pathKey.split('-'); - return index < keyParts.length && keyParts[index] === pathParts[index]; - }); + return ( + index < keyParts.length && keyParts[index] === pathParts[index] + ); + }) + ); }); // Add current item to open keys newOpenKeys.push(itemKey); // Calculate position and add to dropdown positions - const position = calculatePosition(event.currentTarget, parentKeys.length); + const position = calculatePosition( + event.currentTarget, + parentKeys.length + ); - - setDropdownPositions(prev => { + setDropdownPositions((prev) => { // Remove positions for closed items const newPos = {}; - newOpenKeys.forEach(key => { + newOpenKeys.forEach((key) => { if (prev[key]) newPos[key] = prev[key]; }); newPos[itemKey] = position; @@ -270,16 +306,23 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse setOpenKeys([]); setDropdownPositions({}); + // Fullscreen on Sales Entry click + + if (item.label === 'Sales Entry') { + if (!document.fullscreenElement) { + document.documentElement.requestFullscreen().catch(() => {}); + } + } + // Trigger onClick callback if provided if (onClick) { onClick({ key: item.key, keyPath: [...parentKeys, item.key], item: item, - domEvent: event + domEvent: event, }); } - } }; @@ -294,7 +337,7 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse if (!item.children) return false; const checkChildren = (children, currentPath) => { - return children.some(child => { + return children.some((child) => { const childPath = [...currentPath, child.key]; if (child.key === selectedKey) return true; if (child.children) { @@ -333,10 +376,13 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse className={`pozo-menu-item ${isItemSelected ? 'selected' : ''} ${isItemOpen ? 'open' : ''} ${isItemInActivePath ? 'active-path' : ''} ${hasChildren ? 'has-children' : ''} ${item.type === 'group' ? 'group-item' : ''}`} onClick={(e) => handleMenuClick(item, e, parentKeys)} data-menu-key={item.key} - style={{ justifyContent: "flex-start" }} + style={{ justifyContent: 'flex-start' }} > {item.icon && ( - + {item.icon} )} @@ -345,10 +391,9 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse {hasChildren && !collapse && ( // - + - )} @@ -363,7 +408,8 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse top: (() => { const defaultTop = positions[item.key]?.top || 0; const submenuHeight = - submenuRefs.current[item.key]?.getBoundingClientRect()?.height || 0; + submenuRefs.current[item.key]?.getBoundingClientRect() + ?.height || 0; const screenHeight = window.innerHeight; // ✅ If submenu would overflow screen bottom, adjust top @@ -379,7 +425,7 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse // width: 220, width: 200, maxHeight: 400, - zIndex: 1000 + level + zIndex: 1000 + level, }} >
@@ -396,11 +442,11 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse useEffect(() => { const updated = {}; for (const [key, el] of Object.entries(menuRefs.current)) { - if (el && typeof el.getBoundingClientRect === "function") { + if (el && typeof el.getBoundingClientRect === 'function') { const rect = el.getBoundingClientRect(); updated[key] = { top: rect.top + window.scrollY, - left: rect.right + window.scrollX + left: rect.right + window.scrollX, }; } } @@ -413,12 +459,8 @@ const PozoMenu = ({ items = [], mode = "vertical", style = {}, onClick, collapse setPositions(updated); }, [items, openKeys]); - return ( -
+
{renderMenuItems(items)}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx index 4ec4479..296cd1f 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx @@ -16,10 +16,9 @@ import { isMobile } from 'react-device-detect'; import { getTemplateData } from '../../../../../Features/ThemeChange/ThemeChange.js'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; +import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3.jsx'; // jsx File -const BSBillingTable1 = lazy( - () => import('../BSBillingTable1/BSBillingTable1.jsx') -); + const BST1Payment = lazy(() => import('../BSBillingTable1/BST1Payment')); const BSSummery = lazy(() => import('../BSBillingTableSummery/BSSummery')); const FeaturesFunctionalities = lazy( @@ -39,11 +38,13 @@ export default function BSBTOverall1() { const tableData = useSelector(GlobalOrderStatus); const selOption = useSelector(GlobalSelOption); const GetCustId = useSelector(GlobalCustId); - const templateData = useSelector(getTemplateData); const [hold, setHold] = useState(false); const [addcustomer, setAddCustomer] = useState(false); const [responsiveBill, setResponsiveBill] = useState(true); + const templateData = useSelector(getTemplateData); + const tableName = templateData?.BookingBilling?.[0]; + const handleAddCustomer = () => { if (Custdisable === false) { setAddCustomer(true); @@ -72,7 +73,7 @@ export default function BSBTOverall1() { containerHeight = isMobile ? ExpDate <= 7 ? '500px' - : '470px' + : '500px' : ExpDate <= 7 ? '82vh' : ''; @@ -137,7 +138,7 @@ export default function BSBTOverall1() { } style={{ height: containerHeight }} > - {width > 768 && } + {width > 768 && } {(addcustomer || hold) && ( )} -
+
{width <= 768 && (
- {tableData && } + {tableData && }
)}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx index f0664fb..6af8c08 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState, useRef } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; -import { Badge, Modal, Tooltip } from 'antd'; +import { Badge, Button, Modal, Popover, Tooltip } from 'antd'; import { Tables } from '../../../../../Components/Tables/Table'; import { DefaultModal } from '../../../../../Components/Modal/DefaultModal.jsx'; import paygate from '../../../../../Images/paygate.png'; @@ -125,6 +125,8 @@ import { changePreviousOrderOfferDetail, GlobalAllBookingType, changeSearchedData, + GlobalSelectedCustDisable, + GlobalOrderStatus, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; import { @@ -211,6 +213,13 @@ import pozologoimg from '../../../../../Images/pozologoimg.png'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; +import { AiOutlineClose } from 'react-icons/ai'; +import BSSummery from '../BSBillingTableSummery/BSSummery.jsx'; +import { IoIosArrowUp } from 'react-icons/io'; +import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; +import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; +import PozoCartIcon from '../../UtillComponents/PozoCartIcon.jsx'; +import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; @@ -338,6 +347,13 @@ export default function BST1Payment() { const [currentOrderNetAmount, setCurrentOrderNetAmount] = useState(0); const [previousNetAmount, setPreviousNetAmount] = useState(0); + const Custdisable = useSelector(GlobalSelectedCustDisable); + const tableData = useSelector(GlobalOrderStatus); + const [summeryopen, setSummeryopen] = useState(false); + const [responsiveBill, setResponsiveBill] = useState(true); + const [width, setWidth] = useState(window.innerWidth); + const [open, setOpen] = useState(false); + const [addcustomer, setAddCustomer] = useState(false); const [PrintOrderDetails, setPrintOrderDetails] = useState([]); //Total calculation @@ -637,39 +653,42 @@ export default function BST1Payment() { Discount, ]); useEffect(() => { - - const fetchPrinterMapping = async () => { - try { - if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { - const data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - }; - // && isMobile && MobileA4Print - const response = await dispatch(getPrinterMappingDetails(data)).unwrap(); - if (response?.data?.statusCode === 0) { - handlePrintMappingClick() - } - console.log(response, "printer mapping response"); - } - } catch (error) { - console.error("Error fetching printer mapping:", error); - } - }; - - fetchPrinterMapping(); - - }, []); + const fetchPrinterMapping = async () => { + try { + if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { + const data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + UserId: UserId, + }; + // && isMobile && MobileA4Print + const response = await dispatch( + getPrinterMappingDetails(data) + ).unwrap(); + if (response?.data?.statusCode === 0) { + handlePrintMappingClick(); + } + console.log(response, 'printer mapping response'); + } + } catch (error) { + console.error('Error fetching printer mapping:', error); + } + }; + + fetchPrinterMapping(); + }, []); const handlePrintMappingClick = () => { - // setReprint1(true) - window.dispatchEvent(new Event('CLICK PRINTER MAPPING')); - }; + // setReprint1(true) + window.dispatchEvent(new Event('CLICK PRINTER MAPPING')); + }; //mohan stoped data useEffect(() => { if (CompId && BranchId && AppId) { - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } // getUnpaiddatas(); @@ -924,7 +943,7 @@ export default function BST1Payment() { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1867,7 +1886,10 @@ export default function BST1Payment() { setUpinotSelected(false); setCurrentOrderNetAmount(0); setPreviousNetAmount(0); - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } if (defaultBookingType === 'Both') { @@ -2046,15 +2068,15 @@ export default function BST1Payment() { 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', @@ -2073,7 +2095,7 @@ export default function BST1Payment() { SetCount: a.SetCount, ...(a?.DiscountValue && { DiscountValue: a.DiscountValue }), ...(a?.DiscountType && { DiscountType: a.DiscountType }), - ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }) + ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }), })); const NotSlectedTypeFind = temporderdetail?.find( (a) => a?.BookingType != SelectedBookingType @@ -2147,7 +2169,7 @@ export default function BST1Payment() { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2164,9 +2186,9 @@ export default function BST1Payment() { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', @@ -2182,8 +2204,8 @@ export default function BST1Payment() { ? PaymentgatewayUPI?.[0]?.ModeId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId + (busupi) => busupi?.ModeId === UpiId + )?.ModeId : paybtnselected : paybtnselected ? paybtnselected @@ -2196,15 +2218,15 @@ export default function BST1Payment() { salesBillEdit && currentOrderNetAmount < previousNetAmount ? null : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId + ?.MerchantId : null, PaymentOptionType: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - (refundPaySelectedName?.toLowerCase() === 'cash' || - refundPaySelectedName?.toLowerCase() === 'credit') + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : Paybtnnameselected?.toLowerCase() === 'cash' ? 'PC' @@ -2224,29 +2246,29 @@ export default function BST1Payment() { ? null : SelectedUPIPayOption?.toLowerCase() === 'default' ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId + ?.UPIDetailId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.MerchantUPIId + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId : null, AccountDtl: salesBillEdit && currentOrderNetAmount < previousNetAmount ? [] : 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: @@ -2257,13 +2279,13 @@ export default function BST1Payment() { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', Debit: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - refundPaySelectedName?.toLowerCase() === 'credit' + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, Credit: salesBillEdit @@ -2339,14 +2361,14 @@ export default function BST1Payment() { 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]); @@ -2503,14 +2525,14 @@ export default function BST1Payment() { 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]); @@ -2611,14 +2633,14 @@ export default function BST1Payment() { } 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]); @@ -2793,14 +2815,14 @@ export default function BST1Payment() { 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]); @@ -2818,7 +2840,7 @@ export default function BST1Payment() { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3496,6 +3518,31 @@ export default function BST1Payment() { } }; + const hide = () => { + setOpen(false); + }; + + const handleOpenChange = (newOpen) => { + setOpen(newOpen); + }; + + const handleAddCustomer = () => { + if (Custdisable === false) { + setAddCustomer(true); + } + }; + + const handleResponsiveBill = () => { + setResponsiveBill(!responsiveBill); + }; + + useEffect(() => { + function handleResize() { + setWidth(window.innerWidth); + } + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, [width]); const vehiclesvalues = (vehicleData) => { const updated = OrderCardDetail.map((item) => { const key = @@ -3540,6 +3587,84 @@ export default function BST1Payment() { return ( <>
+ {width <= 768 && ( +
+ {tableData && } +
+ )} +
+ {summeryopen == true && ( +
+ +
+ )} + + + + + + + + ) + } + trigger="click" + open={open} + onOpenChange={handleOpenChange} + > + + +
+
+ {tableOptions.find( + (item) => item.OptionName === 'AddCustomer' + ) && ( +
+ + + + {' '} + + +
+ )} +
+
+
+ {/* */}
@@ -3598,31 +3723,31 @@ export default function BST1Payment() { (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, }} > {paybtns?.length > 0 && - currentOrderNetAmount >= previousNetAmount ? ( + currentOrderNetAmount >= previousNetAmount ? ( paybtns?.map((payment) => (
-
- )) - ) : currentOrderNetAmount < previousNetAmount && - salesBillEdit && - refundPayBtns.length > 0 ? ( - refundPayBtns.map((payment) => ( -
- -
- )) - ) : ( -
- Please Set Payment Options -
- )} -
- - {tableOptions?.filter((item) => item.OptionName === 'AddCustomer') - .length === 1 || navCust === true ? ( -
- {Object.keys(useOptions)?.length > 0 && - useOptions?.some((flow) => - flow.OptionDetails.some( - (option) => - option.OptionName === 'Pay at the counter' && - option.ModeDetails.some( - (mode) => mode.ModeName === 'Credit' - ) - ) - ) && ( - - {!OtherServicesglobal && ( - - {' '} - 0 && 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', - }} - /> - - )} - - )} -
- ) : ( - '' - )} - - {/* Customer Orders */} - {SelCustId && - tableOptions?.filter( - (item) => item.OptionName === 'PreviousBillFetch' - ).length === 1 && ( - - {' '} -
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(OrderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); - } - }} - style={{ - cursor: OrderCardDetail?.length > 0 && 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (OrderCardDetail?.length > 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '25px', - display: 'flex', - alignItems: 'center', - height: '2.46rem', - width: '1.5rem', - }} - > - -
-
- )} - {tabledata?.length > 0 && ( -
- {tableOptions - ?.filter((item) => item.OptionName === 'UnpaidBill') - .map((filteredItem) => ( - - {!OtherServicesglobal && ( - - {' '} - { - (setUnpaidOpen(true), getUnpaiddatas()); - }} - /> - - )} - - ))} -
- )} - - {dinePreference && ( -
- {(BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - SelectedTableDetails?.length !== 0 && ( -
- - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - /> - - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } -
- )} -
- )} - {!OtherServicesglobal && ( -
- {tableOptions?.map((item) => ( - <> - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length != 0 && - !OrderStatus && - OrderType != 'Failed' && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - <> - - - - - ) - : ''} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - paybtns?.length > 0 && - !addnewAccess && ( - - {' '} - - HandleholdModelOpen()} - style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - - ) - : ''} - - ))} -
- )} -
- -
- - - -
- {UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
-
-
- -
- -
-

- {' '} - RS : - {OrderType === 'Failed' - ? FailedTotalAmt - : Math.round(TotalAmount)}{' '} -

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text -
- )} - -
- } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> -
-
-
- } - /> - )} - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ))} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ))} - {CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - /> -
- )} - {unpaidopen && ( - { - setUnpaidOpen(false); - }} - footer={false} - children={ -
- -
- } - /> - )} - {UnpaidConfirmation && ( - -
- You have already selected a table. If you click 'OK,' the - table selection will be removed, and the unpaid flow will - continue. If you click 'Cancel,' the dine-in flow will proceed - as selected. -
- - } - onOk={UnpaidOk} - onCancel={Unpaidclose} - /> - )} - {Splitpayment && ( - data?.TotalAmt + acc, - 0 - ) - - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)) - ) - } - failedOrderData={failedOrderData} - /> - )} - {PrintOrderDetails?.length > 0 && ( -
- {filteredSettingNames?.includes('whatsapp') && - MobileNoWhatsApp?.value && ( - - )} - - - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} -
- )} - - { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
- } - /> - - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ) - // )) - } - - { - setOtherServicesModal(false); - }} - // handleSubmit={Handlevehiclenumbers} - footer={false} - children={ -
- {OrderCardDetail.map((item, i) => { - const isGroup = item.ServiceType === 'G'; - const groupKey = item.id; // 🔁 using `id` for groups now - const uniqueKey = `${item.ServiceId}__${item.__index}`; - - // For G-type: render input only once for the group - if ( - isGroup && - i !== OrderCardDetail.findIndex((o) => o.id === groupKey) - ) { - return null; - } - - const qty = isGroup - ? OrderCardDetail.filter((o) => o.id === groupKey).reduce( - (sum, o) => sum + (o.OrderQty || 1), - 0 - ) - : item.OrderQty || 1; - - return ( -
-

{item.ServiceName}

- - {Array.from({ length: qty }).map((_, index) => { - const inputKey = isGroup - ? item.id - : `${item.ServiceId}__${item.__index}`; - const value = vehicleInputs[inputKey]?.[index] || ''; - const error = errors[inputKey]?.[index] || ''; - - return ( -
- - handleInputChange( - isGroup ? item.id : item.ServiceId, - index, - e.target.value, - item.ServiceType, - item - ) - } - onKeyPress={(e) => { - if (!/[A-Za-z0-9]/.test(e.key)) { - e.preventDefault(); - } - }} - style={{ - width: '100%', - padding: 8, - borderRadius: 4, - border: error - ? '1px solid red' - : '1px solid #ccc', - }} - /> - {error && ( - - {error} - - )} -
- ); - })} -
- ); - })} -
- -
-
- } - /> - - setShowCancelConfirm(true)} - footer={false} - width={500} - children={ - <> - - - } - /> - {showCancelConfirm && ( - { - setBusinessUPI(false); - setShowCancelConfirm(false); - ClearAllGlobalStateDatas(); - CustomerDisplay(); - }} - onCancel={() => setShowCancelConfirm(false)} - okText="Yes" - cancelText="No" - > - Do you want to cancel the payment? - - )} - {customerPreviesOrders && ( - setCustomerPreviesOrders(false)} - footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} - children={ - <> - setCustomerPreviesOrders(false)} - /> - - } - /> - )} -
+
); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx index 8b15246..3066d9c 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx @@ -43,7 +43,6 @@ import { SelectedGlobalBillingFont, } from '../../../../../Features/ThemeChange/ThemeChange'; import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; -import { settingDataSelector } from '../../../../../Features/PreferenceMaster/PreferenceMaster'; import WebFont from 'webfontloader'; import dineInIcon from '../../../../../Images/Dine In.svg'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; @@ -62,69 +61,328 @@ import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js'; const MinusOutlined = React.lazy( () => import('@ant-design/icons/MinusOutlined') ); - const PlusOutlined = React.lazy(() => import('@ant-design/icons/PlusOutlined')); - const EditOutlined = React.lazy(() => import('@ant-design/icons/EditOutlined')); +// ─── Helpers ──────────────────────────────────────────────────────────────── + +/** Returns true when a cart item matches the identity of the given item. */ +const itemMatches = (cartItem, item, ignoreSalesId = false) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + (ignoreSalesId ? true : !cartItem?.SalesId); + +/** Builds an updated cart item object with recalculated amounts for a new qty. */ +const calcCartItem = (base, newQty) => ({ + ...base, + OrderQty: newQty, + TotalAmt: newQty * base.OrderRate, + TaxAmt: ( + (newQty * base.OrderRate * base.TaxPercentage) / + (100 + base.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + newQty * base.OrderRate - + (newQty * base.OrderRate * base.TaxPercentage) / (100 + base.TaxPercentage), +}); + +/** + * Rebuilds the cart array with `updatedItem` spliced in. + * Respects BillOrderPre: 'Y' puts updated item first, otherwise last. + */ +const buildUpdatedCart = (others, updatedItem, billOrderPre) => + billOrderPre === 'Y' ? [updatedItem, ...others] : [...others, updatedItem]; + +// ─── Sub-components ────────────────────────────────────────────────────────── + +const CartItem = ({ + item, + index, + globalIndex, + selectedFont, + selectedBillColor, + billOrderPre, + bookingType, + bookingTypeBoth, + globEstBooking, + globProdwisedata, + triggerAnimation, + previousDataLength, + holdOrderDtl, + unpaidData, + tableLength, + productBasedExtraCharges, + getCustId, + imeiModal, + onIncrease, + onDecline, + onEditQuantity, + onImeiDetails, + onCustomerPriceHistory, + returnCount, +}) => { + const isDisabled = bookingType === 'Dine In' && item?.SalesId; + + const rowBackground = (() => { + if (item?.SalesId && bookingType === 'Dine In' && !bookingTypeBoth) + return 'rgb(243, 248, 213)'; + if ( + globEstBooking === 'ParEst' && + globProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) + ) + return '#b2d1f7'; + return globalIndex % 2 === 0 + ? 'white' + : selectedBillColor?.['OverallBackgroundColor'] || '#d6d6d6'; + })(); + + const splashActive = + billOrderPre === 'Y' && + !bookingTypeBoth && + triggerAnimation && + globalIndex === 0 && + !item?.SalesId && + tableLength >= previousDataLength && + !holdOrderDtl && + !unpaidData; + + const extraCharge = productBasedExtraCharges?.find( + (c) => c.ProdId === item.ProdId + ); + + const canIncrease = + item.Type === 'P' || item.Type === 'C' || item.ServiceType === 'G'; + + return ( +
+ pozo + +
+ {/* Name row */} +

+ (item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 || + imeiModal) && + onImeiDetails(item) + } + > + {item?.Type !== 'OS' ? item.ProdName : item.ServiceName}  + {item.BrandName !== null ? item.BrandName : ''} +

+ {item?.Type !== 'C' && item?.Type !== 'OS' && ( + <> +

+ ( + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } + {item?.Size} + {item?.SinglePc === 'Y' ? 'PCS' : item?.UomName}) +

+ {item?.OfferMessage && !Array.isArray(item.OfferMessage) && ( +

+ {item.OfferMessage?.split('>')?.[0] + + `> ${item?.OrderQty} Eligible Free`} +

+ )} + + )} + {item?.Type === 'C' && ( +
+ {item.ProdDetail?.map((prod, i) => ( +

+ {prod.ProdName} - {prod.Size} {prod.UomName} +

+ ))} +
+ )} +

+ {extraCharge !== undefined && ( +
+ Extra Charges : {extraCharge.TotalAmt} +
+ )} +

+ + {/* Price row */} +

{ + e.stopPropagation(); + if (getCustId) onCustomerPriceHistory(item); + }} + > + + {(item?.OfferPrice > 0 || item?.Offer > 0) && ( + <> + -{' '} + {item?.Type !== 'C' + ? item.Offer || '-' + : item?.OfferPrice || '-'}{' '} + /- + + )} + + Rs {item?.TotalAmt}/- +

+ + {/* Controls */} +
+
+ onDecline(item)} /> + + {item?.StockAvailable === 'Y' ? ( + returnCount(item) > 0 && ( + canIncrease && onIncrease(item)} /> + ) + ) : ( + canIncrease && onIncrease(item)} /> + )} + onEditQuantity(item)} + /> +
+
+
+
+ ); +}; + +const CartSection = ({ + items, + bookingTypeBoth, + sidebarColor, + sidebarIcon, + globalOffset, + editQuantity, + editQuantityProps, + itemProps, +}) => ( +
+ {items.map((item, index) => ( +
+ {bookingTypeBoth && ( +
+ {index === Math.round(items.length / 2 - 0.1) && ( + + )} +
+ )} + +
+ ))} + + {items.length > 0 && editQuantity && ( + + )} +
+); + +// ─── Main Component ────────────────────────────────────────────────────────── + const BsBill2 = () => { const { removeExtraCharge } = useUtilsComponent(); const dispatch = useDispatch(); + + // ── Selectors ── const templateData = useSelector(getTemplateData); - const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - ); - const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData); - const preferenceOffer = - preferenceDatas?.[0]?.['SettingDtlDetails']?.find( - (item) => item.SettingIdName === 'Offer' - )?.SettingValue === 'Y'; - const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'decimal' && - setting?.SettingValue === 'Y' - ); - const [shortKeyMethod, setshortKeyMethod] = useState(''); - const preferenceshortcutkey = preferenceDatas?.[0]?.SettingDtlDetails?.find( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'shortcutkeys' && - setting?.SettingValue === 'Y' - ); - const imeiModal = preferenceDatas?.[0]?.SettingDtlDetails?.some( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'imeidetails' && - setting?.SettingValue === 'Y' - ); - console.log(imeiModal, "imeiModalimeiModal") - const [count, setCount] = useState(1); const ReorderProductData = useSelector(GlobalReorderProductDetails); const CartOrderDetails = useSelector(GlobalOrderCardDetails); const BookingType = useSelector(GlobalBookingType); const defaultBookingType = useSelector(GlobalDefaultBookingType); - const PreviousOrderLength = useSelector(GlobalPreviousOrderLength); const HoldOrderDtl = useSelector(GlobalHoldOrderDtl); const UnpaidData = useSelector(GlobalUnpaidData); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail); - const SettingDataSelector = useSelector(PreferenceData); const SelectedFont = useSelector(SelectedGlobalBillingFont); const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); const OrderType = useSelector(GlobalOrderType); const GlobEstBooking = useSelector(GlobalEstimateBooking); - const OtherServicesglobal = useSelector(GlobalOtherSevices); const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); + const GlobalExtraCharge = useSelector(globalExtraTotalAmount); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = - useState(false); - const [customerProduct, setCustomerProduct] = useState(null); + // ── Preference helpers ── + const getPref = (name) => + preferenceDatas?.[0]?.SettingDtlDetails?.find( + (s) => s.SettingIdName?.toLowerCase() === name.toLowerCase() + ); + const isPrefOn = (name) => getPref(name)?.SettingValue === 'Y'; - const BillOrderPre = preferenceDatas?.[0]?.SettingDtlDetails?.find( - (item) => item.SettingIdName === 'BillItemsOrder' - )?.SettingValue; + const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( + (item) => item?.OptionName === 'Offer' + ); + const applyOffer = useApplyOfferto_CardDetail(); + const preferenceOffer = isPrefOn('Offer'); + const allowDecimal = isPrefOn('decimal'); + const preferenceshortcutkey = isPrefOn('shortcutkeys'); + const imeiModal = isPrefOn('imeidetails'); + const BillOrderPre = getPref('BillItemsOrder')?.SettingValue; + const overAllLimitPreference = isPrefOn('overalllimit') + ? getPref('overalllimit') + : null; + const itemWiseLimitPreference = isPrefOn('itemwiselimit') + ? getPref('itemwiselimit') + : null; + const maxQtyLimit = + itemWiseLimitPreference?.SettingCount || + overAllLimitPreference?.SettingCount || + null; + + // ── State ── + const [shortKeyMethod, setShortKeyMethod] = useState(''); + const [count, setCount] = useState(1); const [PreviousdataLength, setPreviousdataLength] = useState(PreviousOrderLength); const [Index, setIndex] = useState(null); @@ -132,1163 +390,305 @@ const BsBill2 = () => { const [EditQuantity, setEditQuantity] = useState(false); const [Modaldata, setModaldata] = useState([]); const [OpenImeiDetail, setOpenImeiDetail] = useState(false); - const GlobalExtraCharge = useSelector(globalExtraTotalAmount); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); + const [customerProduct, setCustomerProduct] = useState(null); + + // ── Derived data ── const productBasedExtraCharges = GlobalExtraCharge.filter( - (obj) => 'ProdName' in obj + (o) => 'ProdName' in o ); - const overAllLimitPreferenece = preferenceDatas?.[0]?.[ - 'SettingDtlDetails' - ]?.find( - (item) => - item.SettingIdName?.toLowerCase() === 'overalllimit' && - item?.SettingValue === 'Y' - ); - const itemWiseLimitPreferenece = preferenceDatas?.[0]?.[ - 'SettingDtlDetails' - ]?.find( - (item) => - item.SettingIdName?.toLowerCase() === 'itemwiselimit' && - item?.SettingValue === 'Y' - ); - const maxQtyLimit = - itemWiseLimitPreferenece?.SettingCount || - overAllLimitPreferenece?.SettingCount || - null; const tableDataDinein = CartOrderDetails?.filter( - (a, b) => a.BookingTypeName === 'Dine In' && !a?.SalesId + (a) => a.BookingTypeName === 'Dine In' && !a?.SalesId ); const tableDataTakeAway = OrderType === 'Hold' - ? CartOrderDetails?.filter((a, b) => a.BookingTypeName === 'TakeAway') + ? CartOrderDetails?.filter((a) => a.BookingTypeName === 'TakeAway') : CartOrderDetails?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId - ); + (a) => a.BookingTypeName === 'TakeAway' && !a?.SalesId + ); const OldtableDataDinein = CartOrderDetails?.filter( - (a, b) => a.BookingTypeName === 'Dine In' && a?.SalesId + (a) => a.BookingTypeName === 'Dine In' && a?.SalesId ); const OldtableDataTakeAway = - OrderType != 'Hold' + OrderType !== 'Hold' ? CartOrderDetails?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; + // ── Effects ── useEffect(() => { - if (SelectedFont) { - WebFont.load({ - google: { - families: [SelectedFont], // Load the selected font - }, - }); - } + if (SelectedFont) WebFont.load({ google: { families: [SelectedFont] } }); }, [SelectedFont]); useEffect(() => { const handleKeyDown = (e) => { if (e.ctrlKey && e.key.toLowerCase() === 'i') { e.preventDefault(); - const prodId = CartOrderDetails?.[0]?.ProdId; - if (GetCustId && prodId) { setCustomerPriceHistoryOpen(true); setCustomerProduct(prodId); } } }; - window.addEventListener('keydown', handleKeyDown); - - return () => { - window.removeEventListener('keydown', handleKeyDown); - }; + return () => window.removeEventListener('keydown', handleKeyDown); }, [GetCustId, CartOrderDetails]); useEffect(() => { - if (CartOrderDetails?.length === 0) { - dispatch(ClearOfferAppliedProducts()); - } - setTriggerAnimation(true); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - userData: CartOrderDetails, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } - const timer = setTimeout(() => { - setTriggerAnimation(false); - }, 400); + if (CartOrderDetails?.length === 0) dispatch(ClearOfferAppliedProducts()); + setTriggerAnimation(true); + const win = getCustomerDisplayWindow(); + if (win && !win.closed) + win.postMessage({ userData: CartOrderDetails }, '*'); + + const timer = setTimeout(() => setTriggerAnimation(false), 400); return () => clearTimeout(timer); }, [CartOrderDetails]); useEffect(() => { const getSelectedItem = () => { - const getItem = (data = []) => { - if (!data.length) return null; - return BillOrderPre === 'Y' ? data[0] : data[data.length - 1]; - }; - - if (tableDataTakeAway?.length > 0) { - return getItem(tableDataTakeAway); - } else if (tableDataDinein?.length > 0) { - return getItem(tableDataDinein); - } - return null; - }; - - const handleShortcut = (method) => { - const item = getSelectedItem(); - if (!item) return; - - handleEditQuantity(item); - setshortKeyMethod(method); + const pick = (data = []) => + data.length + ? BillOrderPre === 'Y' + ? data[0] + : data[data.length - 1] + : null; + return tableDataTakeAway?.length > 0 + ? pick(tableDataTakeAway) + : pick(tableDataDinein); }; const handleKeyDown = (event) => { - if (!preferenceshortcutkey) return; - if (!event.ctrlKey) return; - + if (!preferenceshortcutkey || !event.ctrlKey) return; const key = event.key.toLowerCase(); - - if (key === 'q') { + if (key === 'q' || key === 'e') { event.preventDefault(); - handleShortcut('qty'); - } - - if (key === 'e') { - event.preventDefault(); - handleShortcut('price'); + const item = getSelectedItem(); + if (!item) return; + handleEditQuantity(item); + setShortKeyMethod(key === 'q' ? 'qty' : 'price'); } }; window.addEventListener('keydown', handleKeyDown); - - return () => { - window.removeEventListener('keydown', handleKeyDown); - }; + return () => window.removeEventListener('keydown', handleKeyDown); }, [preferenceshortcutkey, tableDataTakeAway, tableDataDinein, BillOrderPre]); + + // ── Helpers ── function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; - - const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); - const num = Number(cleaned); - + const num = Number(String(amountStr).replace(/[^0-9.-]+/g, '')); if (isNaN(num)) return allowDecimal ? '0.00' : '0'; - return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } - // useEffect(() => { - // setPreviousdataLength(PreviousOrderLength); - // }, [PreviousOrderLength]); + const dispatchCartUpdate = async (updatedData) => { + if (OfferCheckedInSetup && preferenceOffer) { + await applyOffer(updatedData); + } else { + dispatch(changeOrderCardDetails(updatedData)); + } + }; - const handleImeiDetails = (value) => { - setOpenImeiDetail(true); - setModaldata(value); + /** Resets all cart-related state when the last item is removed. */ + const resetCartState = async (keepBookingType = false) => { + await dispatch(changeReorderHoldDetails({})); + await dispatch(changeReorderProductDetails([])); + await dispatch(changeUnpaidData(false)); + await dispatch( + changeBookingType( + keepBookingType ? defaultBookingType || 'TakeAway' : 'TakeAway' + ) + ); + await dispatch(changeTokenOnly(false)); + await dispatch(changeAllProductTokenAvailable(false)); + await dispatch(changeSelProdWiseEst([])); + await dispatch(ChangeTotalAmount([])); + dispatch(changeBillEditingMode(false)); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); + await dispatch(changePreviousOrderPayment([])); + await dispatch(changePreviousOrderOfferDetail([])); }; - const handleImeiDetailClose = () => { - setOpenImeiDetail(false); - }; - const handleCustomerProductPriceHistory = (item) => { - setCustomerPriceHistoryOpen(true); - setCustomerProduct(item?.ProdId); + + /** + * Core logic for increase/decline: finds the matching item, builds the + * updated cart, and dispatches it. + */ + const adjustQty = async (item, delta) => { + const isDineIn = item?.BookingTypeName === 'Dine In'; + const isHold = OrderType === 'Hold'; + + // For Hold orders, match including SalesId items + const matchFn = isHold + ? (c) => itemMatches(c, item, true) + : (c) => itemMatches(c, item, false); + + const found = CartOrderDetails?.find(matchFn); + if (!found) return; + + const newQty = found.OrderQty + delta; + + if (newQty < 1) return; // decline handles removal separately + + const updated = calcCartItem(found, newQty); + + // Others = everything except the found item (same SalesId scope) + const others = isHold + ? CartOrderDetails?.filter((c) => !itemMatches(c, item, true)) + : CartOrderDetails?.filter((c) => !itemMatches(c, item, false)); + + await dispatchCartUpdate(buildUpdatedCart(others, updated, BillOrderPre)); + await dispatch(changeothersdata({})); + setCount((prev) => prev + delta); }; + + // ── Increase ── const increase = async (item) => { - if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { - if (overAllLimitPreferenece) { - const calculatedOverAllQty = calculateOverAllQtyLimit(CartOrderDetails); - if (calculatedOverAllQty + 1 > maxQtyLimit) { + // Quantity limit checks + if ((overAllLimitPreference || itemWiseLimitPreference) && maxQtyLimit) { + if (overAllLimitPreference) { + if (calculateOverAllQtyLimit(CartOrderDetails) + 1 > maxQtyLimit) { message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); return; } - } else if (itemWiseLimitPreferenece) { - - const inwardQtyMap = CartOrderDetails.reduce((acc, curr) => { - const inwardId = curr.InwardDtlId; - const qty = Number(curr.OrderQty) || 0; - - if (acc[inwardId]) { - acc[inwardId] += qty; - } else { - acc[inwardId] = qty; - } - + } else { + const qtyMap = CartOrderDetails.reduce((acc, c) => { + acc[c.InwardDtlId] = + (acc[c.InwardDtlId] || 0) + (Number(c.OrderQty) || 0); return acc; }, {}); - - const currentInwardId = item?.InwardDtlId; - const addQty = 1; - - if (inwardQtyMap[currentInwardId]) { - inwardQtyMap[currentInwardId] += addQty; - } else { - inwardQtyMap[currentInwardId] = addQty; - } - - console.log("Final InwardDtlId Qty Map:", inwardQtyMap); - const isExceeded = Object.values(inwardQtyMap).some( - (qty) => qty > maxQtyLimit - ); - - if (isExceeded) { + qtyMap[item?.InwardDtlId] = (qtyMap[item?.InwardDtlId] || 0) + 1; + if (Object.values(qtyMap).some((q) => q > maxQtyLimit)) { message.warning(`Item Quantity Limit Exceeds than ${maxQtyLimit}`); return; } } } - const OtherOrderDatas = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) && !cartItem?.SalesId - ); - const OtherOrderDatawithsales = CartOrderDetails?.filter( - (cartItem) => cartItem?.SalesId - ); - const OtherorderDataforNormal = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ) - ); - const isItemInCart = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemNotInDine = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemInCartHold = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ); // check if the item is already in the cart - const OtherorderDataforNormalWithoutSalesId = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) - ); - - const BookingTypeProd = item?.BookingTypeName; - if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold') { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } - //mohan for both - else if ( - isItemInCart && - BookingTypeProd === 'Dine In' && - OrderType != 'Hold' - ) { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } else if (isItemInCartHold && OrderType === 'Hold') { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate, - TaxAmt: ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [ - UpdatedCartItem, - ...OtherorderDataforNormalWithoutSalesId, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate, - TaxAmt: ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [ - ...OtherorderDataforNormalWithoutSalesId, - UpdatedCartItem, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } else if ( - isItemNotInDine && - BookingTypeProd == 'Dine In' && - OrderType != 'Hold' - ) { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = { - ...isItemNotInDine, - OrderQty: isItemNotInDine?.OrderQty + 1, - TotalAmt: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, - TaxAmt: ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - const UpdatedData = [ - UpdatedCartItem, - ...OtherOrderDatas, - ...OtherOrderDatawithsales, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = { - ...isItemNotInDine, - OrderQty: isItemNotInDine?.OrderQty + 1, - TotalAmt: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, - TaxAmt: ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - ( - ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - const UpdatedData = [ - ...OtherOrderDatawithsales, - ...OtherOrderDatas, - UpdatedCartItem, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } - await dispatch(changeothersdata({})); - - setCount(count + 1); + await adjustQty(item, 1); }; + + // ── Decline ── const decline = async (item) => { setPreviousdataLength(CartOrderDetails?.length); - const isItemInCart = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ); // check if the item is already in the cart - if (isItemInCart) { - if (isItemInCart?.OrderQty > 1) { - const OtherOrderDatas = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) && !cartItem?.SalesId - ); - const OtherOrderDatawithsales = CartOrderDetails?.filter( - (cartItem) => cartItem?.SalesId - ); - const OtherorderDataforNormal = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ) - ); - const isItemInCart = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemNotInDine = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ); // check if the item is already in the cart - const isItemInCartHold = CartOrderDetails?.find( - (cartItem) => - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ); // check if the item is already in the cart - const OtherorderDataforNormalWithoutSalesId = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) - ); + const found = CartOrderDetails?.find((c) => itemMatches(c, item, true)); + if (!found) return; - const BookingTypeProd = item?.BookingTypeName; - if ( - isItemInCart && - BookingTypeProd !== 'Dine In' && - OrderType !== 'Hold' - ) { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty - 1, - TotalAmt: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + if (found.OrderQty > 1) { + await adjustQty(item, -1); + return; + } - const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; + // Qty === 1 → remove item + removeExtraCharge(item); + await dispatch( + ChangeTotalAmount( + GlobalExtraCharge?.filter((extra) => { + if (BookingType === 'Dine In') + return !(extra.ProdId === item?.ProdId && !extra.SalesId); + if (BookingType === 'TakeAway') return extra.ProdId !== item?.ProdId; + return true; + }) + ) + ); - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty - 1, - TotalAmt: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + const isHold = OrderType === 'Hold'; + const isDineIn = item?.BookingTypeName === 'Dine In'; - const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; + const updatedData = isHold + ? CartOrderDetails?.filter((c) => !itemMatches(c, item, true)) + : isDineIn + ? CartOrderDetails?.filter((c) => !itemMatches(c, item, false)) + : CartOrderDetails?.filter((c) => !itemMatches(c, item, false)); - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } - //mohan for both - else if ( - isItemInCart && - BookingTypeProd === 'Dine In' && - OrderType != 'Hold' - ) { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty - 1, - TotalAmt: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + await dispatchCartUpdate(updatedData); - const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty - 1, - TotalAmt: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, - TaxAmt: ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } else if (isItemInCartHold && OrderType === 'Hold') { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty - 1, - TotalAmt: - (isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate, - TaxAmt: ( - ((isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [ - UpdatedCartItem, - ...OtherorderDataforNormalWithoutSalesId, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty - 1, - TotalAmt: - (isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate, - TaxAmt: ( - ((isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate - - ( - ((isItemInCartHold?.OrderQty - 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.TaxPercentage) / - (100 + isItemInCartHold?.TaxPercentage) - ).toFixed(2), - }; - - const UpdatedData = [ - ...OtherorderDataforNormalWithoutSalesId, - UpdatedCartItem, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } else if ( - isItemNotInDine && - BookingTypeProd == 'Dine In' && - OrderType != 'Hold' - ) { - if (BillOrderPre === 'Y') { - const UpdatedCartItem = { - ...isItemNotInDine, - OrderQty: isItemNotInDine?.OrderQty - 1, - TotalAmt: - (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate, - TaxAmt: ( - ((isItemNotInDine?.OrderQty - 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate - - ( - ((isItemNotInDine?.OrderQty - 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - const UpdatedData = [ - UpdatedCartItem, - ...OtherOrderDatas, - ...OtherOrderDatawithsales, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else { - const UpdatedCartItem = { - ...isItemNotInDine, - OrderQty: isItemNotInDine?.OrderQty - 1, - TotalAmt: - (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate, - TaxAmt: ( - ((isItemNotInDine?.OrderQty - 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: - (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate - - ( - ((isItemNotInDine?.OrderQty - 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.TaxPercentage) / - (100 + isItemNotInDine?.TaxPercentage) - ).toFixed(2), - }; - // otherwise, return the cart item - const UpdatedData = [ - ...OtherOrderDatawithsales, - ...OtherOrderDatas, - UpdatedCartItem, - ]; - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } - } - } else { - removeExtraCharge(item); - await dispatch( - ChangeTotalAmount( - GlobalExtraCharge?.filter((extra) => { - if (BookingType === 'Dine In') { - // Remove extra charges linked to the removed product - return !(extra.ProdId === item?.ProdId && !extra.SalesId); - } else if (BookingType === 'TakeAway') { - // Remove extra charges only if SalesId is not present - return extra.ProdId !== item?.ProdId; - } - return true; // Keep everything else - }) - ) - ); // if the quantity of the item is 1, remove the item from the cart - if (item?.BookingTypeName !== 'Dine In' && OrderType !== 'Hold') { - const UpdatedData = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ) - ); - // if the quantity of the item is 1, remove the item from the cart - if (CartOrderDetails?.length <= 1) { - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); - await dispatch(changeUnpaidData(false)); - await dispatch(changeBookingType(defaultBookingType || 'TakeAway')); - await dispatch(changeTokenOnly(false)); - await dispatch(changeAllProductTokenAvailable(false)); - await dispatch(changeSelProdWiseEst([])); - await dispatch(ChangeTotalAmount([])); - dispatch(changeBillEditingMode(false)); - await dispatch(changeSelectedOption(null)); - await dispatch(ChangeSelectedCustDisable(false)); - await dispatch(changePreviousOrderPayment([])); - await dispatch(changePreviousOrderOfferDetail([])); - } - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - } else if ( - item?.BookingTypeName !== 'Dine In' && - OrderType === 'Hold' - ) { - const UpdatedData = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName - ) - ); - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - - // if the quantity of the item is 1, remove the item from the cart - if (CartOrderDetails?.length <= 1) { - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeUnpaidData(false)); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeTokenOnly(false)); - await dispatch(changeAllProductTokenAvailable(false)); - await dispatch(changeSelProdWiseEst([])); - await dispatch(ChangeTotalAmount([])); - dispatch(changeBillEditingMode(false)); - await dispatch(changeSelectedOption(null)); - await dispatch(ChangeSelectedCustDisable(false)); - await dispatch(changePreviousOrderPayment([])); - await dispatch(changePreviousOrderOfferDetail([])); - } - } else if (item?.BookingTypeName === 'Dine In') { - const UpdatedData = CartOrderDetails?.filter( - (cartItem) => - !( - cartItem?.ProdId === item?.ProdId && - cartItem?.InwardDtlId === item?.InwardDtlId && - cartItem?.OrderRate === item?.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName && - !cartItem?.SalesId - ) - ); - - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - if (CartOrderDetails?.length <= 1) { - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeUnpaidData(false)); - await dispatch(ChangeSelectedCustDisable(false)); - await dispatch(changeSelectedOption(false)); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeTokenOnly(false)); - await dispatch(changeAllProductTokenAvailable(false)); - await dispatch(changeSelProdWiseEst([])); - await dispatch(ChangeTotalAmount([])); - dispatch(changeBillEditingMode(false)); - await dispatch(changePreviousOrderPayment([])); - await dispatch(changePreviousOrderOfferDetail([])); - } - } - } + if (CartOrderDetails?.length <= 1) { + await resetCartState(!isHold); } }; + + // ── Stock count display ── const returnCount = (item) => { - console.log(item, 'itemitem'); - if (item?.SinglePc === 'Y') { - let SelectedProduct = ReorderProductData?.filter( - (a) => - a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId - ); - let totalSelectedProductQty = SelectedProduct?.reduce( - (accumulator, card) => { - return ( - accumulator + - parseInt( - card?.StockAvailable === 'Y' - ? card.SinglePc !== 'Y' - ? card.OrderQty * card.NoOfPcs - : card.OrderQty - : 0 - ) - ); - }, - 0 - ); - let getCurrentProdDtl = CartOrderDetails?.filter( - (a) => - a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId - ); - let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { - return ( - accumulator + - parseInt( - card.SinglePc !== 'Y' ? card.OrderQty * card.NoOfPcs : card.OrderQty - ) - ); - }, 0); + const isSinglePc = item?.SinglePc === 'Y'; - let OverallProdQty = totalOrderQty - totalSelectedProductQty; - if ( - parseInt(item?.OverAllPcs) > - parseInt( - Object.keys(ReorderProductData)?.length > 0 && totalOrderQty - ? OverallProdQty - : getCurrentProdDtl - ? totalOrderQty - : 0 - ) - ) { - let count = - parseInt(item?.OverAllPcs) - - parseInt( - Object.keys(ReorderProductData)?.length > 0 && totalOrderQty - ? OverallProdQty - : getCurrentProdDtl - ? totalOrderQty - : 0 - ); - return parseInt(count); - } else { - let count = 0; - return count; + const selectedProducts = ReorderProductData?.filter( + (a) => a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId + ); + const currentProducts = CartOrderDetails?.filter( + (a) => a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId + ); + + const toQty = (card, single) => { + if (card?.StockAvailable !== 'Y') return 0; + if (single) return card.OrderQty; + // pack-based + const rem = card.OverAllPcs % card.NoOfPcs; + if (card.OrderQty * 1 === card.OrderQty) { + return card.OrderQty % card.NoOfPcs === 0 + ? Math.floor(card.OrderQty / card.NoOfPcs) + : Math.floor(card.OrderQty / card.NoOfPcs) + 1; } - } else { - let SelectedProduct = ReorderProductData?.filter( - (a) => - a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId - ); - let totalSelectedProductQty = SelectedProduct?.reduce( - (accumulator, card) => { - return ( - accumulator + - parseInt( - card?.StockAvailable === 'Y' - ? card.SinglePc !== 'Y' - ? card.OrderQty - : card.OverAllPcs % card.NoOfPcs >= card.OrderQty - ? 0 - : card.OrderQty % card.NoOfPcs === 0 - ? Math.floor(card.OrderQty / card.NoOfPcs) - : Math.floor(card.OrderQty / card.NoOfPcs) + 1 - : 0 - ) - ); - }, + return rem >= card.OrderQty + ? 0 + : Math.floor(card.OrderQty / card.NoOfPcs) + 1; + }; + + const toOrderQty = (card, single) => { + if (single) return card.OrderQty; + return card.SinglePc !== 'Y' + ? card.OrderQty + : card.OverAllPcs % card.NoOfPcs >= card.OrderQty + ? 0 + : card.OrderQty % card.NoOfPcs === 0 + ? Math.floor(card.OrderQty / card.NoOfPcs) + : Math.floor(card.OrderQty / card.NoOfPcs) + 1; + }; + + const totalSelected = + selectedProducts?.reduce( + (acc, c) => acc + parseInt(toQty(c, isSinglePc)), 0 - ); - let getCurrentProdDtl = CartOrderDetails?.filter( - (a) => - a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId - ); + ) || 0; + const totalOrder = + currentProducts?.reduce( + (acc, c) => acc + parseInt(toOrderQty(c, isSinglePc)), + 0 + ) || 0; - let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { - return ( - accumulator + - parseInt( - card.SinglePc !== 'Y' - ? card.OrderQty - : card.OverAllPcs % card.NoOfPcs >= card.OrderQty - ? 0 - : card.OrderQty % card.NoOfPcs === 0 - ? Math.floor(card.OrderQty / card.NoOfPcs) - : Math.floor(card.OrderQty / card.NoOfPcs) + 1 - ) - ); - }, 0); + const hasReorder = Object.keys(ReorderProductData ?? {}).length > 0; + const effective = + hasReorder && totalOrder ? totalOrder - totalSelected : totalOrder; + const limit = isSinglePc + ? parseInt(item?.OverAllPcs) + : parseInt(item?.BalanceQty); - let OverallProdQty = totalOrderQty - totalSelectedProductQty; - - if ( - parseInt(item?.BalanceQty) > - parseInt( - Object.keys(ReorderProductData)?.length > 0 && totalOrderQty - ? OverallProdQty - : getCurrentProdDtl - ? totalOrderQty - : 0 - ) - ) { - let count = - parseInt(item?.BalanceQty) - - parseInt( - Object.keys(ReorderProductData)?.length > 0 && totalOrderQty - ? OverallProdQty - : getCurrentProdDtl - ? totalOrderQty - : 0 - ); - return parseInt(count); - } else { - let count = 0; - return count; - } - } + return Math.max(0, limit - effective); }; - const handleEditQuantityCancel = () => { - setEditQuantity(false); + // ── Modal handlers ── + const handleImeiDetails = (value) => { + setOpenImeiDetail(true); + setModaldata(value); + }; + const handleImeiDetailClose = () => setOpenImeiDetail(false); + const handleCustomerProductPriceHistory = (item) => { + setCustomerPriceHistoryOpen(true); + setCustomerProduct(item?.ProdId); }; - const handleEditQuantity = (value) => { - if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') { - setEditQuantity(false); - } else { - setEditQuantity(true); - setModaldata(value); - setIndex(value?.localId); - } + if (OtherServicesglobal && value.Type === 'OS' && value.ServiceType === 'I') + return; + setEditQuantity(true); + setModaldata(value); + setIndex(value?.localId); }; + const handleEditQuantityCancel = () => setEditQuantity(false); const ClearAllFun = async () => { await dispatch(changeOrderType('')); @@ -1303,6 +703,44 @@ const BsBill2 = () => { await dispatch(changeBookingType('TakeAway')); }; + // ── Shared props for CartItem ── + const sharedItemProps = { + selectedFont: SelectedFont, + selectedBillColor: SelectedBillColor, + billOrderPre: BillOrderPre, + bookingType: BookingType, + bookingTypeBoth: BookingTypeBoth, + globEstBooking: GlobEstBooking, + globProdwisedata: GlobProdwisedata, + triggerAnimation, + previousDataLength: PreviousdataLength, + holdOrderDtl: HoldOrderDtl, + unpaidData: UnpaidData, + productBasedExtraCharges, + getCustId: GetCustId, + imeiModal, + onIncrease: increase, + onDecline: decline, + onEditQuantity: handleEditQuantity, + onImeiDetails: handleImeiDetails, + onCustomerPriceHistory: handleCustomerProductPriceHistory, + returnCount, + }; + + const editQuantityProps = { + handleEditQuantityCancel, + BSBillingEditQuantity: EditQuantity, + Productdata: Modaldata, + Index, + shortKeyMethod, + }; + + const oldTakeAwayOffset = 0; + const oldDineInOffset = OldtableDataTakeAway?.length; + const takeAwayOffset = + OldtableDataTakeAway?.length + OldtableDataDinein?.length; + const dineInOffset = takeAwayOffset + tableDataTakeAway?.length; + return ( <>
{ borderRadius: '5px', cursor: 'pointer', }} - onClick={() => { - ClearAllFun(); - }} + onClick={ClearAllFun} > Clear )}
+
- {/* oldTakeAway */} -
- {OldtableDataTakeAway?.map((item, index) => ( -
- {BookingTypeBoth && ( -
- {index === - Math.floor((OldtableDataTakeAway.length - 1) / 2) && ( - - )} -
- )} -
- backgroundColor: - BillOrderPre === 'Y' - ? item?.SalesId && OrderType !== 'Hold' - ? 'rgb(243, 248, 213)' - : triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength - ? 'wheat' - : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: - item?.SalesId && OrderType !== 'Hold' - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : index % 2 === 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - pozo -
-

- (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 || imeiModal) && - handleImeiDetails(item) - } - > - {' '} - {item?.ProdName}  {' '} - {item.BrandName !== null ? item.BrandName : ''} -

- {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} -

- {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -

+ {/* Old Dine In */} + -

{ - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - - -{' '} - {item?.Type != 'C' - ? item.Offer - ? item.Offer - : '-' - : item?.OfferPrice - ? item.OfferPrice - : '-'}{' '} - /- - - Rs {item?.TotalAmt}/- -

- -
-
- decline(item)} /> - - - {' '} - - {item?.StockAvailable === 'Y' ? ( - returnCount(item) > 0 && ( - increase(item)} /> - ) - ) : ( - increase(item)} /> - )} - - handleEditQuantity(item)} - /> -
-
-
-
-
- ))} - {EditQuantity && OldtableDataTakeAway?.length > 0 && ( - - )} -
- {/* oldDineAway */} -
- {OldtableDataDinein?.map((item, index) => ( -
- {BookingTypeBoth && ( -
- {index == - Math.round(OldtableDataDinein?.length / 2 - 0.1) && ( - - )} -
- )} -
= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: item?.SalesId - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataTakeAway?.length + index) % 2 === 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - pozo -
-

- {' '} - {item?.ProdName}  {' '} - {item.BrandName !== null ? item.BrandName : ''} -

- {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} -

- {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -

- -

{ - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - - -{' '} - {item?.Type != 'C' - ? item.Offer - ? item.Offer - : '-' - : item?.OfferPrice - ? item.OfferPrice - : '-'}{' '} - /- - - Rs {item?.TotalAmt}/- -

- -
-
- {/* decline(item)} /> - */} - decline(item)} /> - - {' '} - - {item?.StockAvailable === 'Y' ? ( - returnCount(item) > 0 && ( - increase(item)} /> - ) - ) : ( - increase(item)} /> - )} - - handleEditQuantity(item)} - /> -
-
-
-
-
- ))} - {OldtableDataDinein?.length > 0 && EditQuantity && ( - - )} -
{/* TakeAway */} -
- {tableDataTakeAway?.map((item, index) => ( -
- {BookingTypeBoth && ( -
- {index == - Math.round(tableDataTakeAway?.length / 2 - 0.1) && ( - - )} -
- )} -
- backgroundColor: - BillOrderPre === 'Y' - ? BookingType === 'Dine In' && item?.SalesId - ? 'rgb(243, 248, 213)' - : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.[ - 'OverallBackgroundColor' - ] - : '#d6d6d6' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - background: - BookingType === 'Dine In' && item?.SalesId - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - pozo -
-

- (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 || imeiModal) && - handleImeiDetails(item) - } - > - {' '} - {item?.Type !== 'OS' - ? item.ProdName - : item.ServiceName}{' '} -   {item.BrandName !== null ? item.BrandName : ''} -

-

- {item?.Type !== 'OS' && ( - <> - ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) - - )} -

- {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} -

- {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -

- -

{ - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - - {item?.OfferPrice > 0 || - (item?.Offer > 0 && ( - <> - -{' '} - {item?.Type !== 'C' - ? item.Offer - ? item.Offer - : '-' - : item?.OfferPrice - ? item.OfferPrice - : '-'}{' '} - /- - - ))} - - Rs {item?.TotalAmt}/- -

- -
-
- decline(item)} /> - - {' '} - - {item?.StockAvailable === 'Y' ? ( - returnCount(item) > 0 && ( - - item.Type == 'P' || item.Type == 'C' - ? increase(item) - : item.ServiceType == 'G' - ? increase(item) - : '' - } - /> - ) - ) : ( - - item.Type == 'P' || item.Type == 'C' - ? increase(item) - : item.ServiceType == 'G' - ? increase(item) - : '' - } - /> - )} - - handleEditQuantity(item)} - /> -
-
-
-
-
- ))} - {tableDataTakeAway?.length > 0 && EditQuantity && ( - - )} -
- {/* Dine in */} -
- {tableDataDinein?.map((item, index) => ( -
- {BookingTypeBoth && ( -
- {index == Math.round(tableDataDinein?.length / 2 - 0.1) && ( - - )} -
- )} -
= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: - BookingType === 'Dine In' && - item?.SalesId && - !BookingTypeBoth - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - pozo -
-

- {' '} - {item?.ProdName}  {' '} - {item.BrandName !== null ? item.BrandName : ''} -

- {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} -

- {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -

- -

{ - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - - -{' '} - {item?.Type != 'C' - ? item.Offer - ? item.Offer - : '-' - : item?.OfferPrice - ? item.OfferPrice - : '-'}{' '} - /- - - Rs {item?.TotalAmt}/- -

- -
-
- decline(item)} /> - - {' '} - - {item?.StockAvailable === 'Y' ? ( - returnCount(item) > 0 && ( - increase(item)} /> - ) - ) : ( - increase(item)} /> - )} - - handleEditQuantity(item)} - /> -
-
-
-
-
- ))} - {tableDataDinein?.length > 0 && EditQuantity && ( - - )} - {OpenImeiDetail && ( - - )} - {customerPriceHistoryOpen && GetCustId && ( - - )} -
+ {/* Dine In */} +
+ + {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx index 6a9f74d..7e8b8cc 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { Popconfirm, Tooltip } from 'antd'; import WebFont from 'webfontloader'; @@ -16,7 +16,6 @@ import { puttinghold, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import { getTemplateData, SelectedGlobalBillingColorDetail, @@ -62,11 +61,10 @@ import { changePreviousOrderPayment, changePreviousOrderOfferDetail, GlobalSalesBillEdit, + GlobalReorderProductDetails, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTables3/BSBillingTable3.scss'; import { - ChangeOfferAppliedProducts, - ChangeFreeProductList, ChangeFullFreeProductList, GlobalFreeProdList, GlobalOfferAppliedProducts, @@ -74,19 +72,71 @@ import { changeLoyaltyConsumedQuantities, ClearOfferAppliedProducts, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; -import { useRemoveProducts } from './RemoveCartWithOffer.jsx'; import { useUtilsComponent } from '../../../../../Services/utils.js'; import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; // jsx Files import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; +import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js'; +import { Messages } from '../../../../../../ownLib/my-ui-lib.js'; -const BSBillingTable3 = () => { +const buildSections = ( + OldtableDataTakeAway, + OldtableDataDinein, + tableDataTakeAway, + tableDataDinein +) => { + const oldTA = OldtableDataTakeAway?.length ?? 0; + const oldDI = OldtableDataDinein?.length ?? 0; + const newTA = tableDataTakeAway?.length ?? 0; + + return [ + { + key: 'old-takeaway', + data: OldtableDataTakeAway, + offset: 0, + icon: TakeAwayIcon, + iconBg: '#CFB59D', + isOld: true, + orderTypeSection: 'TakeAway', + showQtyButtons: true, + }, + { + key: 'old-dinein', + data: OldtableDataDinein, + offset: oldTA, + icon: dineInIcon, + iconBg: '#A2C3CD', + isOld: true, + orderTypeSection: 'DineIn', + showQtyButtons: true, + }, + { + key: 'new-takeaway', + data: tableDataTakeAway, + offset: oldTA + oldDI, + icon: TakeAwayIcon, + iconBg: '#CFB59D', + isOld: false, + orderTypeSection: 'TakeAway', + showQtyButtons: true, + }, + { + key: 'new-dinein', + data: tableDataDinein, + offset: oldTA + oldDI + newTA, + icon: dineInIcon, + iconBg: '#A2C3CD', + isOld: false, + orderTypeSection: 'DineIn', + showQtyButtons: true, + }, + ]; +}; +const BSBillingTable3 = (Props) => { const { removeExtraCharge } = useUtilsComponent(); const dispatch = useDispatch(); - const removeProducts = useRemoveProducts(); - const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData); const preferenceDetails = preferenceDatas?.[0]?.SettingDtlDetails; const preferenceOffer = @@ -100,16 +150,13 @@ const BSBillingTable3 = () => { setting?.SettingIdName?.toLowerCase() === 'decimal' && setting?.SettingValue === 'Y' ); - const salesaskiosk = preferenceDatas?.[0]?.SettingDtlDetails?.find( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'salespageaskiosk' && - setting?.SettingValue === 'Y' - ); + const SessionData = useSelector(StoredSessionData); const BranchId = SessionData?.BranchId; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const templateData = useSelector(getTemplateData); + const tableName = templateData?.BookingBilling?.[0]; const tableOptions = templateData?.BookingBilling?.[1]; const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( (item) => item?.OptionName == 'Offer' @@ -121,10 +168,13 @@ const BSBillingTable3 = () => { ); const [Index, setIndex] = useState(null); + const OrderCardDetail = useSelector(GlobalOrderCardDetails); + const BookingType = useSelector(GlobalBookingType); const defaultBookingType = useSelector(GlobalDefaultBookingType); const tableData = useSelector(GlobalOrderCardDetails, shallowEqual); const PreviousOrderLength = useSelector(GlobalPreviousOrderLength); + const ReorderProductData = useSelector(GlobalReorderProductDetails); const HoldOrderDtl = useSelector(GlobalHoldOrderDtl); const UnpaidData = useSelector(GlobalUnpaidData); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); @@ -141,6 +191,7 @@ const BSBillingTable3 = () => { const OtherServicesglobal = useSelector(GlobalOtherSevices); const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); + const salesBillEdit = useSelector(GlobalSalesBillEdit); const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); @@ -161,26 +212,35 @@ const BSBillingTable3 = () => { const tableDataDinein = tableData?.filter( (a, b) => a.BookingTypeName === 'Dine In' && !a?.SalesId ); + const tableDataTakeAway = 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 OldtableDataDinein = tableData?.filter( (a, b) => a.BookingTypeName === 'Dine In' && 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); const [Modaldata, setModaldata] = useState([]); const [triggerAnimation, setTriggerAnimation] = useState(true); - const editField = - tableOptions?.some((item) => item.OptionName === 'Edit') ?? false; + const editField = useState( + tableOptions?.some((item) => item.OptionName === 'Edit') ?? false + ); + const [messageType, setMessageType] = useState(null); + const [messageData, setMessageData] = useState(null); + const deleteField = useState( + tableOptions?.some((item) => item.OptionName === 'Delete') ?? false + ); + const [editdelete, seteditdelete] = useState(''); + console.log(editdelete, 'editdeleteeditdeleteeditdeleteeditdeleteeditdelete'); const [OpenEditTotalAmt, setOpenEditTotalAmt] = useState(false); const [OpenImeiDetail, setOpenImeiDetail] = useState(false); @@ -188,6 +248,26 @@ const BSBillingTable3 = () => { const productBasedExtraCharges = GlobalExtraCharge.filter( (obj) => 'ProdName' in obj ); + + const overAllLimitPreferenece = preferenceDatas?.[0]?.[ + 'SettingDtlDetails' + ]?.find( + (item) => + item.SettingIdName?.toLowerCase() === 'overalllimit' && + item?.SettingValue === 'Y' + ); + const itemWiseLimitPreferenece = preferenceDatas?.[0]?.[ + 'SettingDtlDetails' + ]?.find( + (item) => + item.SettingIdName?.toLowerCase() === 'itemwiselimit' && + item?.SettingValue === 'Y' + ); + const maxQtyLimit = + itemWiseLimitPreferenece?.SettingCount || + overAllLimitPreferenece?.SettingCount || + null; + useEffect(() => { if (SelectedFont) { WebFont.load({ @@ -318,6 +398,851 @@ const BSBillingTable3 = () => { } }; + const decline = async (item) => { + setPreviousdataLength(tableData?.length); + const isItemInCart = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ); // check if the item is already in the cart + if (isItemInCart) { + if (isItemInCart?.OrderQty > 1) { + const OtherOrderDatas = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ) && !cartItem?.SalesId + ); + const OtherOrderDatawithsales = tableData?.filter( + (cartItem) => cartItem?.SalesId + ); + + const OtherorderDataforNormal = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ) + ); + const isItemInCart = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ); // check if the item is already in the cart + const isItemNotInDine = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ); // check if the item is already in the cart + const isItemInCartHold = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ); // check if the item is already in the cart + const OtherorderDataforNormalWithoutSalesId = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ) + ); + + const BookingTypeProd = item?.BookingTypeName; + if ( + isItemInCart && + BookingTypeProd != 'Dine In' && + OrderType != 'Hold' + ) { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty - 1, + TotalAmt: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty - 1, + TotalAmt: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } + //mohan for both + else if ( + isItemInCart && + BookingTypeProd === 'Dine In' && + OrderType != 'Hold' + ) { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty - 1, + TotalAmt: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty - 1, + TotalAmt: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } else if (isItemInCartHold && OrderType === 'Hold') { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty - 1, + TotalAmt: + (isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate, + TaxAmt: ( + ((isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate - + ( + ((isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [ + UpdatedCartItem, + ...OtherorderDataforNormalWithoutSalesId, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty - 1, + TotalAmt: + (isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate, + TaxAmt: ( + ((isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate - + ( + ((isItemInCartHold?.OrderQty - 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [ + ...OtherorderDataforNormalWithoutSalesId, + UpdatedCartItem, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } else if ( + isItemNotInDine && + BookingTypeProd == 'Dine In' && + OrderType != 'Hold' + ) { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = { + ...isItemNotInDine, + OrderQty: isItemNotInDine?.OrderQty - 1, + TotalAmt: + (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate, + TaxAmt: ( + ((isItemNotInDine?.OrderQty - 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate - + ( + ((isItemNotInDine?.OrderQty - 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + }; + // otherwise, return the cart item + const UpdatedData = [ + UpdatedCartItem, + ...OtherOrderDatas, + ...OtherOrderDatawithsales, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = { + ...isItemNotInDine, + OrderQty: isItemNotInDine?.OrderQty - 1, + TotalAmt: + (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate, + TaxAmt: ( + ((isItemNotInDine?.OrderQty - 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemNotInDine?.OrderQty - 1) * isItemNotInDine?.OrderRate - + ( + ((isItemNotInDine?.OrderQty - 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + }; + // otherwise, return the cart item + const UpdatedData = [ + ...OtherOrderDatawithsales, + ...OtherOrderDatas, + UpdatedCartItem, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } + } else { + await dispatch( + ChangeTotalAmount( + GlobalExtraCharge?.filter((extra) => { + if (BookingType === 'Dine In') { + // Remove extra charges linked to the removed product + return !(extra.ProdId === item?.ProdId && !extra.SalesId); + } else if (BookingType === 'TakeAway') { + // Remove extra charges only if SalesId is not present + return extra.ProdId !== item?.ProdId; + } + return true; // Keep everything else + }) + ) + ); // if the quantity of the item is 1, remove the item from the cart + if (item?.BookingTypeName !== 'Dine In' && OrderType !== 'Hold') { + const UpdatedData = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ) + ); + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + + // if the quantity of the item is 1, remove the item from the cart + if (tableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); + await dispatch(changeReorderHoldDetails({})); + await dispatch(changeReorderProductDetails([])); + await dispatch(changeUnpaidData(false)); + await dispatch(changeBookingType('TakeAway')); + await dispatch(ChangeOverAllDiscSales(null)); + await dispatch(ChangeOverAllDiscEstimate(null)); + await dispatch(changeSelProdWiseEst([])); + await dispatch(ChangeTotalAmount([])); + } + } else if ( + item?.BookingTypeName !== 'Dine In' && + OrderType === 'Hold' + ) { + const UpdatedData = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ) + ); + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + + // if the quantity of the item is 1, remove the item from the cart + if (tableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); + await dispatch(changeReorderHoldDetails({})); + await dispatch(changeReorderProductDetails([])); + await dispatch(changeUnpaidData(false)); + await dispatch(changeBookingType('TakeAway')); + await dispatch(ChangeOverAllDiscSales(null)); + await dispatch(ChangeOverAllDiscEstimate(null)); + await dispatch(changeSelProdWiseEst([])); + await dispatch(ChangeTotalAmount([])); + } + } else if (item?.BookingTypeName === 'Dine In') { + const UpdatedData = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ) + ); + + // if (OfferCheckedInSetup && preferenceOffer) { + // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + await dispatch(ChangeTotalAmount([])); + if (tableData?.length <= 1) { + await dispatch(changeReorderHoldDetails({})); + await dispatch(changeReorderProductDetails([])); + await dispatch(changeUnpaidData(false)); + await dispatch(ChangeSelectedCustDisable(false)); + await dispatch(changeSelectedOption(false)); + await dispatch(changeBookingType('TakeAway')); + await dispatch(ChangeOverAllDiscSales(null)); + await dispatch(ChangeOverAllDiscEstimate(null)); + await dispatch(changeSelProdWiseEst([])); + await dispatch(ChangeTotalAmount([])); + } + } + } + } + }; + + const increase = async (item) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(tableData); + if (calculatedOverAllQty + 1 > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } else if (itemWiseLimitPreferenece) { + const inwardQtyMap = tableData.reduce((acc, curr) => { + const inwardId = curr?.InwardDtlId; + const qty = Number(curr?.OrderQty) || 0; + + if (acc[inwardId]) { + acc[inwardId] += qty; + } else { + acc[inwardId] = qty; + } + + return acc; + }, {}); + + const currentInwardId = item?.InwardDtlId; + const addQty = 1; + + if (inwardQtyMap[currentInwardId]) { + inwardQtyMap[currentInwardId] += addQty; + } else { + inwardQtyMap[currentInwardId] = addQty; + } + + console.log('Final InwardDtlId Qty Map:', inwardQtyMap); + const isExceeded = Object.values(inwardQtyMap).some( + (qty) => qty > maxQtyLimit + ); + + if (isExceeded) { + setMessageData(`Item Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } + } + const OtherOrderDatas = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ) && !cartItem?.SalesId + ); + const OtherOrderDatawithsales = tableData?.filter( + (cartItem) => cartItem?.SalesId + ); + + const OtherorderDataforNormal = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ) + ); + const isItemInCart = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ); // check if the item is already in the cart + const isItemNotInDine = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName && + !cartItem?.SalesId + ); // check if the item is already in the cart + const isItemInCartHold = tableData?.find( + (cartItem) => + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ); // check if the item is already in the cart + const OtherorderDataforNormalWithoutSalesId = tableData?.filter( + (cartItem) => + !( + cartItem?.ProdId === item?.ProdId && + cartItem?.InwardDtlId === item?.InwardDtlId && + cartItem?.OrderRate === item?.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName + ) + ); + + const BookingTypeProd = item?.BookingTypeName; + if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold') { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } + //mohan for both + else if ( + isItemInCart && + BookingTypeProd === 'Dine In' && + OrderType != 'Hold' + ) { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + ( + ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } else if (isItemInCartHold && OrderType === 'Hold') { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate, + TaxAmt: ( + ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - + ( + ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [ + UpdatedCartItem, + ...OtherorderDataforNormalWithoutSalesId, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate, + TaxAmt: ( + ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate - + ( + ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.TaxPercentage) / + (100 + isItemInCartHold?.TaxPercentage) + ).toFixed(2), + }; + + const UpdatedData = [ + ...OtherorderDataforNormalWithoutSalesId, + UpdatedCartItem, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } else if ( + isItemNotInDine && + BookingTypeProd == 'Dine In' && + OrderType != 'Hold' + ) { + if (BillOrderPre === 'Y') { + const UpdatedCartItem = { + ...isItemNotInDine, + OrderQty: isItemNotInDine?.OrderQty + 1, + TotalAmt: + (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, + TaxAmt: ( + ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - + ( + ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + }; + // otherwise, return the cart item + const UpdatedData = [ + UpdatedCartItem, + ...OtherOrderDatas, + ...OtherOrderDatawithsales, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } else { + const UpdatedCartItem = { + ...isItemNotInDine, + OrderQty: isItemNotInDine?.OrderQty + 1, + TotalAmt: + (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, + TaxAmt: ( + ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - + ( + ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.TaxPercentage) / + (100 + isItemNotInDine?.TaxPercentage) + ).toFixed(2), + }; + // otherwise, return the cart item + const UpdatedData = [ + ...OtherOrderDatawithsales, + ...OtherOrderDatas, + UpdatedCartItem, + ]; + + // if (OfferCheckedInSetup && preferenceOffer) { + // // await applyOffer(UpdatedData); + // } else { + dispatch(changeOrderCardDetails(UpdatedData)); + // } + } + } + // await dispatch(changeothersdata({})); + + // setCount(count + 1); + }; + const ClearOfferDetails = () => { dispatch(changeFullOfferAppliedProducts([])); dispatch(ChangeFullFreeProductList([])); @@ -1065,9 +1990,9 @@ const BSBillingTable3 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1080,6 +2005,106 @@ const BSBillingTable3 = () => { dispatch(changeFullOfferAppliedProducts(ModifyedData)); }; + const returnCount = (item) => { + if (item?.SinglePc === 'Y') { + let SelectedProduct = ReorderProductData?.filter( + (a) => + a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId + ); + let totalSelectedProductQty = SelectedProduct?.reduce( + (accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, + 0 + ); + let getCurrentProdDtl = tableData?.filter( + (a) => + a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId + ); + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card.SinglePc !== 'Y' ? card.OrderQty * card.NoOfPcs : card.OrderQty + ) + ); + }, 0); + + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + + if ( + parseInt(item?.OverAllPcs) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(item?.OverAllPcs) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; + } + } else { + let getCurrentProdDtl = tableData?.filter( + (a) => + a?.ProdId === item?.ProdId && a?.InwardDtlId === item?.InwardDtlId + ); + + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card.SinglePc !== 'Y' + ? card.OrderQty + : card.OverAllPcs % card.NoOfPcs >= card.OrderQty + ? 0 + : card.OrderQty % card.NoOfPcs === 0 + ? Math.floor(card.OrderQty / card.NoOfPcs) + : Math.floor(card.OrderQty / card.NoOfPcs) + 1 + ) + ); + }, 0); + + if ( + parseInt(item?.BalanceQty) > parseInt(totalOrderQty ? totalOrderQty : 0) + ) { + let count = + parseInt(item?.BalanceQty) - + parseInt(totalOrderQty ? totalOrderQty : 0); + return parseInt(count); + } else { + let count = 0; + return count; + } + } + }; + + const onComplete = useCallback(() => { + setMessageData(null); + setMessageType(null); + }, []); + const removeFromCart = async (item) => { removeExtraCharge(item); @@ -1476,7 +2501,6 @@ const BSBillingTable3 = () => { BuyInwardDtlId: null, Offer: item?.Offer, OrderRate: item?.OrderRate, - }); await ChangeOfferAppliedProdsFn({ inwardDtlId: item?.InwardDtlId, @@ -1667,7 +2691,7 @@ const BSBillingTable3 = () => { InwardDtlId: item?.InwardDtlId, BuyInwardDtlId: null, Offer: item?.Offer, - OrderRate: item?.OrderRate + OrderRate: item?.OrderRate, }); } else { const isCheck = GlobalOfferAppliedProductsData?.find( @@ -1814,8 +2838,6 @@ const BSBillingTable3 = () => { insideinwardDtlId: false, }); } else { - let data = isCheckFreeProductOutside?.FreeQty - item?.OrderQty; - //First i Calculate Another Booking Type Qty let anotherBookingType = tableData?.find( (e) => e?.InwardDtlId == item?.InwardDtlId && @@ -1829,21 +2851,6 @@ const BSBillingTable3 = () => { e?.BookingTypeName != item?.BookingTypeName ); - let diff = - item?.OrderQty - FreeProductSameBookingType?.OrderQty; - - //SameBookingFreeQty - //FreeProductSameBookingType?.OrderQty - - //Another BookingType Paid Qty - //anotherBookingType - - //anotherBookingType?.Free OrderQty - //ischeckBothBookingType - - //anotherBookingType?.OrderQty-ischeckBothBookingType?.OrderQty - //convert another Booking Type Qty also Free to Paid - if ( (anotherBookingType?.OrderQty || 0) < anotherBookingTypeOffer?.OrderQty @@ -1969,7 +2976,7 @@ const BSBillingTable3 = () => { InwardDtlId: item?.InwardDtlId, BuyInwardDtlId: item?.InwardDtlId, Offer: item?.Offer, - OrderRate: item?.OrderRate + OrderRate: item?.OrderRate, }); await ChangeFreeprodlistFn({ OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty, @@ -1989,7 +2996,6 @@ const BSBillingTable3 = () => { BuyInwardDtlId: item?.InwardDtlId, Offer: item?.Offer, OrderRate: item?.OrderRate, - }); await ChangeFreeprodlistFn({ OverAllFreeQty: item?.OrderQty, @@ -2006,147 +3012,7 @@ const BSBillingTable3 = () => { } }; - // const removeFromCart = async (item) => { - // setPreviousdataLength(tableData?.length); - // if (item?.BookingTypeName !== 'Dine In' && OrderType !== 'Hold') { - // const UpdatedData = tableData?.filter( - // (cartItem) => - // !( - // cartItem?.ProdId === item?.ProdId && - // cartItem?.InwardDtlId === item?.InwardDtlId && - // cartItem?.OrderRate === item?.OrderRate && - // cartItem?.BookingTypeName === item?.BookingTypeName && - // !cartItem?.SalesId - // ) - // ); - - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(UpdatedData); - // } else { - // dispatch(changeOrderCardDetails(UpdatedData)); - // } - - // await dispatch( - // ChangeTotalAmount( - // GlobalExtraCharge?.filter((extra) => { - // if (BookingType === 'Dine In') { - // // Remove extra charges linked to the removed product - // return !(extra.ProdId === item?.ProdId && !extra.SalesId); - // } else if (BookingType === 'TakeAway') { - // // Remove extra charges only if SalesId is not present - // return extra.ProdId !== item?.ProdId; - // } - // return true; // Keep everything else - // }) - // ) - // ); - // // if the quantity of the item is 1, remove the item from the cart - // if (tableData?.length <= 1) { - // await dispatch(changeReorderHoldDetails({})); - // await dispatch(changeReorderProductDetails([])); - // await dispatch(changeUnpaidData(false)); - // await dispatch(changeBookingType('TakeAway')); - // await dispatch(changeTokenOnly(false)); - // await dispatch(ChangeTotalAmount([])); - // await dispatch(changeAllProductTokenAvailable(false)); - // await dispatch(ChangeOverAllDiscSales(null)); - // await dispatch(ChangeOverAllDiscEstimate(null)); - // await dispatch(changeSelProdWiseEst([])); - // } - // } else if (item?.BookingTypeName !== 'Dine In' && OrderType === 'Hold') { - // const UpdatedData = tableData?.filter( - // (cartItem) => - // !( - // cartItem?.ProdId === item?.ProdId && - // cartItem?.InwardDtlId === item?.InwardDtlId && - // cartItem?.OrderRate === item?.OrderRate && - // cartItem?.BookingTypeName === item?.BookingTypeName - // ) - // ); - - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(UpdatedData); - // } else { - // dispatch(changeOrderCardDetails(UpdatedData)); - // } - - // await dispatch( - // ChangeTotalAmount( - // GlobalExtraCharge?.filter((extra) => { - // if (BookingType === 'Dine In') { - // // Remove extra charges linked to the removed product - // return !(extra.ProdId === item?.ProdId && !extra.SalesId); - // } else if (BookingType === 'TakeAway') { - // // Remove extra charges only if SalesId is not present - // return extra.ProdId !== item?.ProdId; - // } - // return true; // Keep everything else - // }) - // ) - // ); - // // if the quantity of the item is 1, remove the item from the cart - // if (tableData?.length <= 1) { - // await dispatch(changeReorderHoldDetails({})); - // await dispatch(changeReorderProductDetails([])); - // await dispatch(changeUnpaidData(false)); - // await dispatch(changeBookingType('TakeAway')); - // await dispatch(changeTokenOnly(false)); - // await dispatch(changeAllProductTokenAvailable(false)); - // await dispatch(ChangeOverAllDiscSales(null)); - // await dispatch(ChangeOverAllDiscEstimate(null)); - // await dispatch(changeSelProdWiseEst([])); - // await dispatch(ChangeTotalAmount([])); - // } - // } else if (item?.BookingTypeName === 'Dine In') { - // const UpdatedData = tableData?.filter( - // (cartItem) => - // !( - // cartItem?.ProdId === item?.ProdId && - // cartItem?.InwardDtlId === item?.InwardDtlId && - // cartItem?.OrderRate === item?.OrderRate && - // cartItem?.BookingTypeName === item?.BookingTypeName && - // !cartItem?.SalesId - // ) - // ); - - // if (OfferCheckedInSetup && preferenceOffer) { - // await applyOffer(UpdatedData); - // } else { - // dispatch(changeOrderCardDetails(UpdatedData)); - // } - // await dispatch( - // ChangeTotalAmount( - // GlobalExtraCharge?.filter((extra) => { - // if (BookingType === 'Dine In') { - // // Remove extra charges linked to the removed product - // return !(extra.ProdId === item?.ProdId && !extra.SalesId); - // } else if (BookingType === 'TakeAway') { - // // Remove extra charges only if SalesId is not present - // return extra.ProdId !== item?.ProdId; - // } - // return true; // Keep everything else - // }) - // ) - // ); // if the quantity of the item is 1, remove the item from the cart - // if (tableData?.length <= 1) { - // await dispatch(changeReorderHoldDetails({})); - // await dispatch(changeReorderProductDetails([])); - // await dispatch(changeUnpaidData(false)); - // await dispatch(ChangeSelectedCustDisable(false)); - // await dispatch(changeSelectedOption(false)); - // await dispatch(changeBookingType('TakeAway')); - // await dispatch(changeTokenOnly(false)); - // await dispatch(changeAllProductTokenAvailable(false)); - // await dispatch(ChangeOverAllDiscSales(null)); - // await dispatch(ChangeOverAllDiscEstimate(null)); - // await dispatch(changeSelProdWiseEst([])); - // await dispatch(ChangeTotalAmount([])); - // } - // } - // }; - useEffect(() => { - // setTriggerAnimation(true); if (tableData?.length === 0) { dispatch(ClearOfferAppliedProducts()); } @@ -2164,6 +3030,14 @@ const BSBillingTable3 = () => { return () => clearTimeout(timer); } }, [tableData]); + const tableScrollRef = useRef(null); + + useEffect(() => { + if (tableScrollRef.current) { + tableScrollRef.current.scrollTop = tableScrollRef.current.scrollHeight; + } + }, [tableData]); + useEffect(() => { setPreviousdataLength(PreviousOrderLength); }, [PreviousOrderLength]); @@ -2197,9 +3071,591 @@ const BSBillingTable3 = () => { setEditQuantity(false); }; + const handlechange33 = () => { + if (editdelete === 'Edit') { + seteditdelete(''); + } else { + seteditdelete('Edit'); + } + }; + + const handlechange22 = async () => { + if (editdelete === 'Delete') { + seteditdelete(''); + } else { + seteditdelete('Delete'); + if (OrderType === 'Failed') { + await dispatch(changeOrderType('')); + await dispatch(changeOrderCardDetails([])); + await dispatch(ChangeTotalAmount([])); + await dispatch(changeReorderHoldDetails({})); + await dispatch(changeReorderProductDetails([])); + // setFirstPaymentclick(false); + // await dispatch(ChangeNavHoldData(false)); + // await dispatch(changeCustomerID(null)); + // await dispatch(changeSelectedCustId()); + await dispatch(changeSelectedOption(null)); + await dispatch(changeBookingType(defaultBookingType || 'TakeAway')); + } + } + }; + // ─── BillingTableSection component ────────────────────────────────────────── + + const BillingTableSection = ({ + // section config + section, + // shared data + tableOptions, + tableData, + // state flags + BookingType, + BookingTypeBoth, + BillOrderPre, + OrderType, + triggerAnimation, + PreviousdataLength, + HoldOrderDtl, + UnpaidData, + SelectedFont, + SelectedBillColor, + GlobEstBooking, + GlobProdwisedata, + allowDecimal, + GetCustId, + editField, + editdelete, + imeiModal, + isMobile, + productBasedExtraCharges, + EditQuantity, + Modaldata, + Index, + shortKeyMethod, + Props, + // handlers + removeFromCart, + handleEditQuantity, + handleEditQuantityCancel, + handleImeiDetails, + handleCustomerProductPriceHistory, + decline, + increase, + returnCount, + safeRound, + }) => { + const { + key, + data, + offset, + icon, + iconBg, + isOld, + orderTypeSection, + showQtyButtons, + } = section; + + if (!data?.length) return null; + + // ── Disabled check ────────────────────────────────────────────────────────── + const isDisabled = (item) => { + if (isOld) { + return orderTypeSection === 'TakeAway' + ? item?.SalesId && OrderType !== 'Hold' + : !!item?.SalesId; + } + // new data sections + return BookingType === 'Dine In' && !!item?.SalesId; + }; + + // ── Row backgroundColor ───────────────────────────────────────────────────── + const getBackgroundColor = (item, index) => { + const globalIdx = offset + index; + + if (isOld) { + if (BillOrderPre !== 'Y') return 'none'; + + if (isDisabled(item)) return 'rgb(243, 248, 213)'; + + // old-dinein uses BookingType branch; old-takeaway does not + if (orderTypeSection === 'DineIn') { + if ( + BookingType === 'Dine In' && + triggerAnimation && + globalIdx === 0 && + !item?.SalesId && + data?.length >= PreviousdataLength + ) + return 'wheat'; + if ( + BookingType !== 'Dine In' && + triggerAnimation && + globalIdx === 0 && + data?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ) + return 'wheat'; + } else { + // old-takeaway + if ( + triggerAnimation && + index === 0 && + !item?.SalesId && + data?.length >= PreviousdataLength // tableDataTakeAway in original + ) + return 'wheat'; + if ( + triggerAnimation && + index === 0 && + data?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ) + return 'wheat'; + } + return 'inherit'; + } + + // ── new sections ──────────────────────────────────────────────────────── + if (orderTypeSection === 'DineIn') { + // new-dinein: BillOrderPre=Y && !BookingTypeBoth guard + if (BillOrderPre === 'Y' && !BookingTypeBoth) { + if (isDisabled(item)) return 'rgb(243, 248, 213)'; + if ( + BookingType === 'Dine In' && + triggerAnimation && + globalIdx === 0 && + !item?.SalesId && + data?.length >= PreviousdataLength + ) + return 'wheat'; + if ( + BookingType !== 'Dine In' && + triggerAnimation && + globalIdx === 0 && + data?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ) + return 'wheat'; + return 'inherit'; + } + return 'none'; + } + + // new-takeaway + if (BillOrderPre === 'Y') { + if (isDisabled(item)) return 'rgb(243, 248, 213)'; + if ( + BookingType === 'Dine In' && + triggerAnimation && + globalIdx === 0 && + !item?.SalesId && + data?.length >= PreviousdataLength + ) + return 'wheat'; + if ( + BookingType !== 'Dine In' && + triggerAnimation && + globalIdx === 0 && + data?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ) + return 'wheat'; + } + return globalIdx % 2 === 0 + ? 'white' + : (SelectedBillColor?.['OverallBackgroundColor'] ?? '#d6d6d6'); + }; + + // ── Row background (CSS background, overrides backgroundColor) ───────────── + const getBackground = (item, index) => { + const globalIdx = offset + index; + + if (isOld) { + if (isDisabled(item)) return 'rgb(243, 248, 213)'; + } else { + // new-dinein has extra !BookingTypeBoth guard + const disabledCond = + orderTypeSection === 'DineIn' + ? BookingType === 'Dine In' && item?.SalesId && !BookingTypeBoth + : BookingType === 'Dine In' && item?.SalesId; + if (disabledCond) return 'rgb(243, 248, 213)'; + } + + if ( + GlobEstBooking === 'ParEst' && + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) + ) + return '#b2d1f7'; + + return globalIdx % 2 === 0 + ? 'white' + : (SelectedBillColor?.['OverallBackgroundColor'] ?? '#d6d6d6'); + }; + + // ── Row animation ─────────────────────────────────────────────────────────── + const getAnimation = (item, index) => { + const globalIdx = offset + index; + + if (BillOrderPre !== 'Y' || BookingTypeBoth) return 'none'; + // old-takeaway uses local index===0; others use globalIdx===0 + const idxCheck = + isOld && orderTypeSection === 'TakeAway' + ? index === 0 + : globalIdx === 0; + + return triggerAnimation && + idxCheck && + !item?.SalesId && + data?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ? 'splashAnimation 0.5s ease-in-out' + : 'none'; + }; + + // ── Generic cell click ────────────────────────────────────────────────────── + const handleCellClick = (item, index) => { + if (Props?.TableName === 'Table7') { + if (editdelete === 'Delete') removeFromCart(item); + else if (editdelete === 'Edit') handleEditQuantity(item, index); + } else if (editField) { + handleEditQuantity(item, index); + } + }; + + // ── Discount display ──────────────────────────────────────────────────────── + const getDiscount = (item) => + item?.Type !== 'C' + ? item.Offer && item.Offer > 0 + ? item.Offer + : item.DiscountAmt || '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : item.DiscountAmt || '-'; + + // ── Amount display ────────────────────────────────────────────────────────── + const getAmount = (item) => + allowDecimal + ? Number(item?.TotalAmt - (item?.Offer || 0) || 0).toFixed(2) + : Number(item?.TotalAmt - (item?.Offer || 0) || 0); + + return ( + + {data.map((item, index) => ( + + {tableOptions?.map((tableitem, tIdx) => ( + + {/* ── Section icon column (BookingTypeBoth only) ── */} + {BookingTypeBoth && + index === 0 && + tableitem.OptionName === 'Sl.No' && ( + + + + )} + + {/* ── Sl.No ── */} + {tableitem.OptionName === 'Sl.No' && ( + handleCellClick(item, index)} + > + {offset + index + 1} + + )} + + {/* ── Item ── */} + {tableitem.OptionName === 'Item' && ( + + item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 || + imeiModal + ? handleImeiDetails(item) + : editField && handleEditQuantity(item, index) + } + > + {item?.Type !== 'OS' ? item.ProdName : item.ServiceName} +  {item?.BrandName ?? ''} + {item?.Type !== 'C' && ( + <> +

+ {/* old sections always show parens wrapper */} + {isOld && '('} + {item?.Type !== 'OS' && ( + <> + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } + {item?.Size} + {item?.SinglePc === 'Y' ? 'PCS' : item?.UomName} + + )} + {isOld && ')'} +

+ {item?.OfferMessage && + !Array.isArray(item.OfferMessage) && ( +

+ {item.OfferMessage?.split('>')?.[0] + + `> ${item?.OrderQty} Eligible Free`} +

+ )} + + )} + {item?.Type === 'C' && ( +
+ {item.ProdDetail?.map((prod, i) => ( +

+ {prod.ProdName} - {prod.Size} {prod.UomName} +

+ ))} +
+ )} + {productBasedExtraCharges?.find( + (f) => f.ProdId === item.ProdId + ) !== undefined && ( +
+ Extra Charges :{' '} + { + productBasedExtraCharges.find( + (f) => f.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} + + )} + + {/* ── MRP ── */} + {tableitem.OptionName === 'MRP' && ( + handleCellClick(item, index)} + > + {item?.MRP} + + )} + + {/* ── Discount ── */} + {tableitem.OptionName === 'Discount' && ( + handleCellClick(item, index)} + > + {getDiscount(item)} + + )} + + {/* ── Quantity ── */} + {tableitem.OptionName === 'Quantity' && ( + <> + {tableName === 'Billing5' ? ( +
+ {showQtyButtons && ( + + )} + + handleCellClick(item, index)} + > + {item?.OrderQty} + + + {item?.StockAvailable === 'Y' ? ( + returnCount(item) > 0 && ( + + ) + ) : ( + + )} +
+ ) : ( + handleCellClick(item, index)} + > + {item?.OrderQty} + + )} + + )} + + {/* ── Rate ── */} + {tableitem.OptionName === 'Rate' && ( + handleCellClick(item, index)} + > + {allowDecimal + ? Number(item?.OrderRate || 0).toFixed(2) + : Number(item?.OrderRate || 0)} + + )} + + {/* ── Amount ── */} + {tableitem.OptionName === 'Amount' && ( + + GetCustId && handleCustomerProductPriceHistory(item) + } + > + {getAmount(item)} + + )} + + {/* ── Delete ── */} + {tableitem.OptionName === 'Delete' && + Props?.TableName !== 'Table7' && ( + + removeFromCart(item)} + style={{ color: '#FF4D4F', cursor: 'pointer' }} + /> + + )} +
+ ))} + + ))} + + {EditQuantity && ( + + )} + + ); + }; return ( -
- +
+ + {tableName === 'Billing7' && ( +
+ {editField && ( +
+ + +
+ )} + {deleteField && ( +
+ + +
+ )} +
+ )} + {tableName === 'StandardBilling' && ( +
+ Shopping cart +

{OrderCardDetail?.length} Items

+
+ )} +
{ )} {item.OptionName == 'Sl.No' && ( )} - {item.OptionName == 'Delete' && ( - - )} + )} + + )} ))} - {/* For Reorder TakeWay */} - {OldtableDataTakeAway?.length > 0 && ( - - {OldtableDataTakeAway?.map((item, index) => ( - = PreviousdataLength - ? 'wheat' - : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: - item?.SalesId && OrderType !== 'Hold' - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : index % 2 === 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( - - )} - - {tableitem.OptionName == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - <> - - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - - {EditQuantity && OldtableDataTakeAway?.length > 0 && ( - - )} - - )} - - {/* Reorder DineIn */} - {OldtableDataDinein?.length > 0 && ( - - {OldtableDataDinein?.map((item, index) => ( - = PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: item?.SalesId - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataTakeAway?.length + index) % 2 === 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( - - )} - - {tableitem.OptionName == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - <> - - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - - {OldtableDataDinein?.length > 0 && EditQuantity && ( - - )} - - )} - {/* TakeWay */} - - {tableDataTakeAway?.length > 0 && ( - - {tableDataTakeAway?.map((item, index) => ( - = PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - background: - BookingType === 'Dine In' && item?.SalesId - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( - - )} - - {tableitem.OptionName == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - <> - - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - - {tableDataTakeAway?.length > 0 && EditQuantity && ( - - )} - - )} - {/* DineIn */} - {tableDataDinein?.length > 0 && ( - - {tableDataDinein?.map((item, index) => ( - = PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: - BookingType === 'Dine In' && - item?.SalesId && - !BookingTypeBoth - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - animation: - BillOrderPre === 'Y' && !BookingTypeBoth - ? triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'splashAnimation 0.5s ease-in-out' - : 'none' - : 'none', - }} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( - - )} - - {tableitem.OptionName == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - <> - - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - - {tableDataDinein?.length > 0 && EditQuantity && ( - - )} - - )} + {buildSections( + OldtableDataTakeAway, + OldtableDataDinein, + tableDataTakeAway, + tableDataDinein + ).map((section) => ( + + ))}
{ )} {item.OptionName == 'Item' && ( { )} {item.OptionName == 'MRP' && ( { )} {item.OptionName == 'Discount' && ( { )} {item.OptionName == 'Quantity' && ( { )} {item.OptionName == 'Rate' && ( { )} {item.OptionName == 'Amount' && ( { - {(tableData?.length > 0) ? ( - { - Clearall(); - }} - > + {item.OptionName == 'Delete' && + Props?.TableName !== 'Table7' && ( + + {tableData?.length > 0 ? ( + { + Clearall(); + }} + > +
+ {' '} + {!isMobile ? ( + + {' '} + {' '} + + ) : ( +
+ {' '} + {' '} +
+ )} +
+
+ ) : (
- {' '} {!isMobile ? ( - - {' '} - {' '} + + ) : (
@@ -2387,1219 +3859,62 @@ const BSBillingTable3 = () => {
)}
- - ) : ( -
- {!isMobile ? ( - - - - ) : ( -
- {' '} - {' '} -
- )} -
- )} -
- - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {index + 1} - - - (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 || imeiModal) - ? handleImeiDetails(item) - : editField && handleEditQuantity(item) - } - > - {item?.ProdName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : item.DiscountAmt ? item.DiscountAmt : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : item.DiscountAmt ? item.DiscountAmt : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {allowDecimal - ? Number(item?.OrderRate || 0).toFixed(2) - : Number(item?.OrderRate || 0)} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {allowDecimal - ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) - : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} - - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
- - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataTakeAway?.length + index + 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.ProdName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : item.DiscountAmt ? item.DiscountAmt : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : item.DiscountAmt ? item.DiscountAmt : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {allowDecimal - ? Number(item?.OrderRate || 0).toFixed(2) - : Number(item?.OrderRate || 0)} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {allowDecimal - ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) - : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} - - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
- - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index + - 1} - - - (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 || imeiModal) - ? handleImeiDetails(item) - : editField && handleEditQuantity(item, index) - } - > - {item?.Type !== 'OS' - ? item.ProdName - : item.ServiceName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

- {item?.Type !== 'OS' && ( - <> - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.UomName} - - )} -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -
{ - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : item.DiscountAmt ? item.DiscountAmt : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : item.DiscountAmt ? item.DiscountAmt : '-'} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.OrderQty} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {allowDecimal - ? Number(item?.OrderRate || 0).toFixed(2) - : Number(item?.OrderRate || 0)} - { - // if (editField) { - // handleEditQuantity(item, index); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {allowDecimal - ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) - : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} - - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
- - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index + - 1} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.ProdName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) -

- {item?.OfferMessage && - !Array.isArray(item.OfferMessage) && ( -

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} -

- )} - - )} - {item?.Type === 'C' && ( -
- {item.ProdDetail?.map((prod, index) => ( -

- {prod.ProdName} - {prod.Size} {prod.UomName} -

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} -
{ - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : item.DiscountAmt ? item.DiscountAmt : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : item.DiscountAmt ? item.DiscountAmt : '-'} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.OrderQty} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {allowDecimal - ? Number(item?.OrderRate || 0).toFixed(2) - : Number(item?.OrderRate || 0)} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {allowDecimal - ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) - : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} - - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
{OpenEditTotalAmt && ( { const templateData = useSelector(getTemplateData); const ExpDate = useSelector(GlobalExpDateforHeight); + const tableData = useSelector(GlobalOrderStatus); + + const [isSmallScreen, setIsSmallScreen] = useState(window.innerWidth <= 768); + const [isCartOpen, setIsCartOpen] = useState(window.innerWidth > 768); + + // ✅ Handle resize properly + useEffect(() => { + const handleResize = () => { + const isMobileView = window.innerWidth <= 768; + setIsSmallScreen(isMobileView); + + // Desktop la always open + if (!isMobileView) { + setIsCartOpen(true); + } else { + setIsCartOpen(false); + } + }; + + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, []); + + const tableName = templateData?.BookingBilling?.[0]; let containerHeight = ''; - if (templateData?.BookingLayout?.[0] === 'Layout5') { + const layout = templateData?.BookingLayout?.[0]; + + if (layout === 'Layout5') { containerHeight = isMobile ? ExpDate <= 7 ? '500px' @@ -21,15 +53,15 @@ const BSBillingTable3overall = () => { : ExpDate <= 7 ? '86vh' : ''; - } else if (templateData?.BookingLayout?.[0] === 'Layout2') { + } else if (layout === 'Layout2') { containerHeight = isMobile ? ExpDate <= 7 ? '505px' - : '475px' // billing table 3 height in POS -- Layout 2 + : '475px' : ExpDate <= 7 ? '85vh' : ''; - } else if (templateData?.BookingLayout?.[0] === 'Layout6') { + } else if (layout === 'Layout6') { containerHeight = isMobile ? ExpDate <= 7 ? '420px' @@ -37,15 +69,15 @@ const BSBillingTable3overall = () => { : ExpDate <= 7 ? '74vh' : ''; - } else if (templateData?.BookingLayout?.[0] === 'Layout1') { + } else if (layout === 'Layout1') { containerHeight = isMobile ? ExpDate <= 7 ? '490px' - : '470px' // billing table 3 height in POS -- Layout 1 + : '470px' : ExpDate <= 7 ? '83vh' : ''; - } else if (templateData?.BookingLayout?.[0] === 'Layout3') { + } else if (layout === 'Layout3') { containerHeight = isMobile ? ExpDate <= 7 ? '490px' @@ -53,7 +85,7 @@ const BSBillingTable3overall = () => { : ExpDate <= 7 ? '83.5vh' : ''; - } else if (templateData?.BookingLayout?.[0] === 'Layout4') { + } else if (layout === 'Layout4') { containerHeight = isMobile ? ExpDate <= 7 ? '510px' @@ -64,26 +96,52 @@ const BSBillingTable3overall = () => { } return ( - <> -
-
+
+ {/* ✅ Cart/Table */} + {isCartOpen && (!isSmallScreen || tableData) && ( +
+ )} -
+
+ {/* ✅ Toggle only in mobile */} + {isSmallScreen && tableData && ( +
setIsCartOpen((prev) => !prev)} + > + {isCartOpen ? ( + + ) : ( + + )} +
+ )} + + {/* ✅ Payment */} + {tableName === 'StandardBilling' ? ( + + ) : tableName === 'Billing1' || tableName === 'Billing6' ? ( + + ) : ( -
+ )}
- +
); }; + export default BSBillingTable3overall; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx index 9ab0850..8e59af6 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx @@ -1,10 +1,4 @@ -import React, { - useCallback, - useEffect, - useState, - useRef, - lazy, -} from 'react'; +import React, { useCallback, useEffect, useState, useRef, lazy } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; @@ -193,6 +187,7 @@ import { Global_OverallOfferAmount } from '../../../../../Features/Offer/Offer.j import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; import { useAuth } from '../../../../../AuthContext.jsx'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTables3/BSBillingTable3.scss'; +import './BSBillingTablePay.scss'; import { GlobalBookingStatus } from '../../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; import { changeSalesPaymentoption, @@ -214,7 +209,7 @@ import CardPopover from '../StandardTable/Utils/CardPopover.jsx'; import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; - import CustomerMobileNumberModal from '../../BookingFunctionality/CustomerOTP.jsx'; +import CustomerMobileNumberModal from '../../BookingFunctionality/CustomerOTP.jsx'; const PaymentGatewayEmbedded = lazy( () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') ); @@ -323,7 +318,7 @@ const BSBillingTable3Pay = () => { const ProdSubCat = useSelector(GlobalProductSubCategorie); const BSLayoutData = useSelector(getTemplateData); const Combodata = useSelector(GlobalCombocarddata, shallowEqual); - console.log(PaymentOptions, "PaymentOptions") + console.log(PaymentOptions, 'PaymentOptions'); const Custdisable = useSelector(GlobalSelectedCustDisable); const SettingDataSelector = useSelector(PreferenceData); @@ -435,7 +430,7 @@ const BSBillingTable3Pay = () => { const [PaymentgatewayUPI, setPaymentgatewayUPI] = useState([]); const [PaymentDeviceUPI, setPaymentDeviceUPI] = useState([]); const [UpiPayOption, setUpiPayOption] = useState([]); - console.log(UpiPayOption, "UpiPayOption") + console.log(UpiPayOption, 'UpiPayOption'); const [BusinessPayOption, setBusinessPayoption] = useState([]); const [CardPayOption, setCardPayOption] = useState([]); const [Splitpayment, setSplitpayment] = useState(false); @@ -482,7 +477,7 @@ const BSBillingTable3Pay = () => { const [OrderStatus, setOrderStatus] = useState(true); const GlobaluseOptions = useSelector(GlobalCommonPaymentOptions); - console.log(GlobaluseOptions, "GlobaluseOptions") + console.log(GlobaluseOptions, 'GlobaluseOptions'); const [useOptions, setuseOptions] = useState([]); const paymentloader = useSelector(GlobalPayementloader); const [UnpaidConfirmation, setUnpaidConfirmation] = useState(false); @@ -536,6 +531,10 @@ const BSBillingTable3Pay = () => { item.SettingIdName.toLowerCase() === 'shortcutkeys' && item.SettingValue === 'Y' ); + + const templateData = useSelector(getTemplateData); + const tableName = templateData?.BookingBilling?.[0]; + console.log(templateData, 'tableName', tableName); useEffect(() => { const fetchCreditCustomer = async () => { const selectedMode = paybtns?.find( @@ -709,38 +708,41 @@ const BSBillingTable3Pay = () => { OtherServiceTicketClaim, Discount, ]); - useEffect(() => { - - const fetchPrinterMapping = async () => { - try { - if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { - const data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - }; -// && isMobile && MobileA4Print - const response = await dispatch(getPrinterMappingDetails(data)).unwrap(); - if (response?.data?.statusCode === 0) { - handlePrintMappingClick() + useEffect(() => { + const fetchPrinterMapping = async () => { + try { + if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { + const data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + UserId: UserId, + }; + // && isMobile && MobileA4Print + const response = await dispatch( + getPrinterMappingDetails(data) + ).unwrap(); + if (response?.data?.statusCode === 0) { + handlePrintMappingClick(); } - console.log(response, "printer mapping response"); + console.log(response, 'printer mapping response'); + } + } catch (error) { + console.error('Error fetching printer mapping:', error); } - } catch (error) { - console.error("Error fetching printer mapping:", error); - } - }; + }; - fetchPrinterMapping(); - -}, []); - const handlePrintMappingClick = () => { + fetchPrinterMapping(); + }, []); + const handlePrintMappingClick = () => { // setReprint1(true) window.dispatchEvent(new Event('CLICK PRINTER MAPPING')); }; useEffect(() => { - (!CustomerMobileNumber && isOtpEnabled && salesaskiosk) && setCustomerOtpmodalopen(true); + !CustomerMobileNumber && + isOtpEnabled && + salesaskiosk && + setCustomerOtpmodalopen(true); }, [PrintOrderDetails, CustomerMobileNumber]); useEffect(() => { @@ -797,7 +799,10 @@ const BSBillingTable3Pay = () => { }; useEffect(() => { if (CompId && BranchId && AppId) { - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } @@ -1029,7 +1034,7 @@ const BSBillingTable3Pay = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1110,7 +1115,7 @@ const BSBillingTable3Pay = () => { }; // if (salesBillEdit) { setDefaultPaymentOption(); - // } + // } }, [defaultPaymentTrigger, salesBillEdit]); const TokenPrint = async (index) => { @@ -1650,7 +1655,6 @@ const BSBillingTable3Pay = () => { //dhana const getPaymentOptionFeature = async () => { - const FiltersalesPayment = GlobaluseOptions?.filter( (item) => item.FlowName?.toLowerCase() === 'sales' ); @@ -2063,7 +2067,10 @@ const BSBillingTable3Pay = () => { setCurrentOrderNetAmount(0); setPreviousNetAmount(0); setUpinotSelected(false); - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } if (defaultBookingType === 'Both') { @@ -2228,7 +2235,6 @@ const BSBillingTable3Pay = () => { }; const Booking = async (value, pay) => { - const TakAwayId = ConfigDataList?.find( (a) => a?.ConfigName === 'TakeAway' )?.ConfigId; @@ -2254,15 +2260,15 @@ const BSBillingTable3Pay = () => { 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', @@ -2281,8 +2287,7 @@ const BSBillingTable3Pay = () => { SetCount: a.SetCount, ...(a?.DiscountValue && { DiscountValue: a.DiscountValue }), ...(a?.DiscountType && { DiscountType: a.DiscountType }), - ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }) - + ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }), })); const NotSlectedTypeFind = temporderdetail?.find( (a) => a?.BookingType != SelectedBookingType @@ -2358,7 +2363,7 @@ const BSBillingTable3Pay = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2375,9 +2380,9 @@ const BSBillingTable3Pay = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ @@ -2392,8 +2397,8 @@ const BSBillingTable3Pay = () => { ? PaymentgatewayUPI?.[0]?.ModeId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId + (busupi) => busupi?.ModeId === UpiId + )?.ModeId : paybtnselected : paybtnselected ? paybtnselected @@ -2406,15 +2411,15 @@ const BSBillingTable3Pay = () => { salesBillEdit && currentOrderNetAmount < previousNetAmount ? null : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId + ?.MerchantId : null, PaymentOptionType: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - (refundPaySelectedName?.toLowerCase() === 'cash' || - refundPaySelectedName?.toLowerCase() === 'credit') + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : Paybtnnameselected?.toLowerCase() === 'cash' ? 'PC' @@ -2434,29 +2439,29 @@ const BSBillingTable3Pay = () => { ? null : SelectedUPIPayOption?.toLowerCase() === 'default' ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId + ?.UPIDetailId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.MerchantUPIId + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId : null, AccountDtl: salesBillEdit && currentOrderNetAmount < previousNetAmount ? [] : 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: @@ -2467,13 +2472,13 @@ const BSBillingTable3Pay = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', Debit: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - refundPaySelectedName?.toLowerCase() === 'credit' + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, Credit: salesBillEdit @@ -2551,14 +2556,14 @@ const BSBillingTable3Pay = () => { 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]); @@ -2718,14 +2723,14 @@ const BSBillingTable3Pay = () => { 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]); @@ -2828,14 +2833,14 @@ const BSBillingTable3Pay = () => { } 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]); @@ -3012,14 +3017,14 @@ const BSBillingTable3Pay = () => { 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]); @@ -3038,7 +3043,7 @@ const BSBillingTable3Pay = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3631,63 +3636,41 @@ const BSBillingTable3Pay = () => { (arr) => Array.isArray(arr) && arr.some((err) => err) ); }; - return ( - <> -
- {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && } -
- )} - -
- - {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( -
handleResponsiveBill()} - className="Btn-responsiveBill" - style={{ color: responsiveBill ? '#52c41a' : '#1292ee' }} - > - {screenwidth <= 768 && ( -
- {' '} - {' '} -
- )} -
- )} -
+ return ( + <> +
+ {screenwidth <= 768 && ( +
+ {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( + )} +
+ )} + + {/* Left Section */} +
+ + +
{(addcustomer || hold) && ( { 'not-allowed', color: OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) + (selOption?.value === undefined && + GlobalAddCustomerDetails1?.length === 0 && + GetCustId?.CustMobile === undefined) ? 'gray' : 'rgb(18, 146, 238)', fontSize: '28px', @@ -3780,16 +3763,16 @@ const BSBillingTable3Pay = () => { (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, width: '2rem', @@ -3812,14 +3795,14 @@ const BSBillingTable3Pay = () => { width: '1.5rem', cursor: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'not-allowed' : 'pointer', color: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'gray' : 'rgb(18, 146, 238)', display: 'flex', @@ -3834,8 +3817,10 @@ const BSBillingTable3Pay = () => {
)} {/* Customer Orders */} - {(SelCustId && tableOptions?.filter((item) => item.OptionName === 'PreviousBillFetch') - .length === 1) && ( + {SelCustId && + tableOptions?.filter( + (item) => item.OptionName === 'PreviousBillFetch' + ).length === 1 && ( {' '}
{ cursor: OrderCardDetail?.length > 0 && 'not-allowed', color: OrderCardDetail?.length > 0 || - (OrderCardDetail?.length > 0 && - GetCustId?.CustMobile === undefined) + (OrderCardDetail?.length > 0 && + GetCustId?.CustMobile === undefined) ? 'gray' : 'rgb(18, 146, 238)', fontSize: '25px', @@ -3941,65 +3926,65 @@ const BSBillingTable3Pay = () => { <> {unpaidFlow == false ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length != 0 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - CheckBookingStatus != 'Close' && - paybtns?.length > 0 && - !addnewAccess && ( - - {' '} - AddBookingDetails('Hold', false)} - style={{ - fontSize: '30px', - cursor: 'pointer', - color: '' ? '#52c41a' : '#1292EE', - }} - /> - - ) + BookingType !== 'Dine In' && + !BookingTypeBoth && + OrderCardDetail?.length != 0 && + CheckOrderType?.length === 0 && + OrderType != 'Failed' && + CheckBookingStatus != 'Close' && + paybtns?.length > 0 && + !addnewAccess && ( + + {' '} + AddBookingDetails('Hold', false)} + style={{ + fontSize: '30px', + cursor: 'pointer', + color: '' ? '#52c41a' : '#1292EE', + }} + /> + + ) : ''} {unpaidFlow == false ? item?.OptionName == 'Hold' && - paybtns?.length > 0 && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - 0 && + BookingType !== 'Dine In' && + !BookingTypeBoth && + Holddata?.length > 0 && + OrderCardDetail?.length == 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + - HandleholdModelOpen()} - style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - - ) + {' '} + + HandleholdModelOpen()} + style={{ + fontSize: '28px', + cursor: 'pointer', + color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> + + + ) : ''} ))} @@ -4045,14 +4030,14 @@ const BSBillingTable3Pay = () => { width: '1.5rem', cursor: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'not-allowed' : 'pointer', color: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'gray' : 'rgb(18, 146, 238)', display: 'flex', @@ -4064,6 +4049,42 @@ const BSBillingTable3Pay = () => {
)} + + {/* {screenwidth <= 768 && ( +
+ {Array.isArray(OrderCardDetail) && + OrderCardDetail?.length >= 1 && ( +
handleResponsiveBill()} + className="Btn-responsiveBill" + style={{ + color: responsiveBill ? '#52c41a' : '#1292ee', + }} + > + {screenwidth <= 768 && ( +
+ {' '} + {' '} +
+ )} +
+ )} +
+ )} */}
@@ -4101,401 +4122,391 @@ const BSBillingTable3Pay = () => { ))}
- -
+
+ +
+
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + }} + > + {paybtns?.length > 0 && + currentOrderNetAmount >= previousNetAmount ? ( + paybtns?.map((payment) => ( +
+ +
+ )) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => ( +
+ +
+ )) + ) : ( +
+ Please Set Payment Options +
+ )} +
+ {PrintOrderDetails?.length > 0 && (
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, + display: 'flex', + gap: '1rem', + justifyContent: 'center', }} > - {paybtns?.length > 0 && - currentOrderNetAmount >= previousNetAmount ? ( - paybtns?.map((payment) => ( -
- -
- )) - ) : currentOrderNetAmount < previousNetAmount && - salesBillEdit && - refundPayBtns.length > 0 ? ( - refundPayBtns.map((payment) => ( -
- -
- )) - ) : ( -
- Please Set Payment Options -
+ onClick={handleSMSClick} + title="Send SMS" + /> + )} + {/* WhatsAppShare modal/component */} + {showWhatsAppShare && ( + closePrintOption(false)} + /> + )} + {showSMSShare && isMobile && ( + closePrintOption(false)} + /> )}
- {PrintOrderDetails?.length > 0 && ( -
+ +
+ + {/* Vertical Line */} + + {/* Right Section */} +
+
+
+ + + + + + + + +
+

+ Items :  +

+
- {filteredSettingNames?.includes('whatsapp') && - MobileNoWhatsApp?.value && ( - +
+

+ Qty :  +

+
+ {' '} + {Qty} +
+
+ {OrderCardDetail?.length > 0 && + ParkingDisplay && + !OtherServicesglobal && ( +
+ +
+ )} +
+ {!OtherServicesglobal && unpaidFlow == true ? ( + + {' '} + { + Recipt(); + }} + /> + + ) : ( + '' + )} +
+ + + + + + + + } + trigger="click" + open={open2} + onOpenChange={handleOpenChange2} + > + {!isMobile ? ( + + {!open2 ? ( + { + handleOpenChange2; + }} + /> + ) : ( + { + handleOpenChange2; + }} /> )} - - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} -
- )} -
- -
- - - -
-
-
- - - - - - - - - -
-

- Items :  -

-
- {TotalItems} -
-

- Qty :  -

-
- {' '} - {Qty} -
-
- {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} -
- {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} -
- - - - - - - - } - trigger="click" - open={open2} - onOpenChange={handleOpenChange2} - > - {!isMobile ? ( - - {!open2 ? ( - { - handleOpenChange2; - }} - /> - ) : ( - { - handleOpenChange2; - }} - /> - )} - - ) : ( -
- {!open2 ? ( - { - handleOpenChange2; - }} - /> - ) : ( - { - handleOpenChange2; - }} - /> - )} -
- )} - - {/* - {!open2 ? ( - - ) : ( - - )} - */} -
-
+ + ) : ( +
+ {!open2 ? ( + { + handleOpenChange2; + }} + /> + ) : ( + { + handleOpenChange2; + }} + /> + )} +
+ )} +
- +
+ +
0 && - paybtnselected && - CheckBookingStatus != 'Close' + OrderCardDetail?.length > 0 && + paybtnselected && + CheckBookingStatus != 'Close' ? !OrderStatus ? salesBillEdit && currentOrderNetAmount < previousNetAmount @@ -4504,16 +4515,7 @@ const BSBillingTable3Pay = () => { : 'BSBillingTable3-paybtn Order' : 'BSBillingTable3-paybtn-deactive' } - //dhana - // onClick={() => { - // (qrCode && SelectedUPIPayOption === "Default") ? UpiPayment() : OrderStatus ? AddBookingDetails("Dine-In", false) : AddBookingDetails(BookingType, true); - // }} - onClick={ - // BranchFinancialStatus==='N'? - // financialYearError: - handleButtonClick - } - //dhana + onClick={handleButtonClick} > {!OrderStatus ? ( salesBillEdit && currentOrderNetAmount < previousNetAmount ? ( @@ -4560,415 +4562,409 @@ const BSBillingTable3Pay = () => {
ORDER
)}
- - {UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
+
+ + {UpiOpen && ( + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+
+
+ +
+ +
+

+ {' '} + RS : + {OrderType === 'Failed' + ? FailedTotalAmt + : Math.round(TotalAmount)}{' '} +

+
+
+ +
+ {(selOption || SelCustId) && ( +
+ Sent Payment Link + Your Alt Text +
+ )} +
-
- -
- -
-

- {' '} - RS : - {OrderType === 'Failed' - ? FailedTotalAmt - : Math.round(TotalAmount)}{' '} -

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text -
- )} - -
} + handleSubmit={() => { + Upimodel('Submit'); }} - > - } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> -
+ />
- } - /> - )} - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} - {CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - /> -
- )} -
-
- {unpaidopen && ( - { - setUnpaidOpen(false); - }} - footer={false} - children={ -
- -
- } - /> - )} - {UnpaidConfirmation && ( - -
- You have already selected a table. If you click 'OK,' the - table selection will be removed, and the unpaid flow will - continue. If you click 'Cancel,' the dine-in flow will proceed - as selected.
- - } - onOk={UnpaidOk} - onCancel={Unpaidclose} - /> - )} - {Splitpayment && ( - + )} + {PrintOrderDetails?.length > 0 && + PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ))} + {PrintOrderDetails?.length > 0 && + (TokenOnly?.SettingValue === 'Y' || + IndividualToken?.SettingValue === 'Y') && + PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ))} + {CreditCustomer && ( +
+ { + handleCreditCustomer('Cancel'); + }} + handleOk={() => { + handleCreditCustomer('Submit'); + }} + /> +
+ )} +
+
+ {unpaidopen && ( + { + setUnpaidOpen(false); + }} + footer={false} + children={ +
+ +
+ } + /> + )} + {UnpaidConfirmation && ( + +
+ You have already selected a table. If you click 'OK,' the table + selection will be removed, and the unpaid flow will continue. If + you click 'Cancel,' the dine-in flow will proceed as selected. +
+ + } + onOk={UnpaidOk} + onCancel={Unpaidclose} + /> + )} + {Splitpayment && ( + data?.TotalAmt + acc, 0 ) - - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)) + ((OverAllSales > 0 ? OverAllSales : 0) + + (OverAllEstimate > 0 ? OverAllEstimate : 0) + + (Discount > 0 ? Discount : 0)) ) - } - failedOrderData={failedOrderData} - /> - )} - - { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
} + failedOrderData={failedOrderData} /> + )} - { - OtherServicesPrintDetails?.length > 0 && ( -
- -
- ) - // )) + { + dispatch(changeSalesPaymentoption(false)); + }} + footer={false} + children={ +
+ +
} + /> - { - setOtherServicesModal(false); - }} - footer={false} - children={ -
- {OrderCardDetail.map((item, i) => { - const isGroup = item.ServiceType === 'G'; - const groupKey = item.id; // 🔁 using `id` for groups now - const uniqueKey = `${item.ServiceId}__${item.__index}`; + { + OtherServicesPrintDetails?.length > 0 && ( +
+ +
+ ) + // )) + } - // For G-type: render input only once for the group - if ( - isGroup && - i !== OrderCardDetail.findIndex((o) => o.id === groupKey) - ) { - return null; - } + { + setOtherServicesModal(false); + }} + footer={false} + children={ +
+ {OrderCardDetail.map((item, i) => { + const isGroup = item.ServiceType === 'G'; + const groupKey = item.id; // 🔁 using `id` for groups now + const uniqueKey = `${item.ServiceId}__${item.__index}`; - const qty = isGroup - ? OrderCardDetail.filter((o) => o.id === groupKey).reduce( + // For G-type: render input only once for the group + if ( + isGroup && + i !== OrderCardDetail.findIndex((o) => o.id === groupKey) + ) { + return null; + } + + const qty = isGroup + ? OrderCardDetail.filter((o) => o.id === groupKey).reduce( (sum, o) => sum + (o.OrderQty || 1), 0 ) - : item.OrderQty || 1; + : item.OrderQty || 1; - return ( -
-

{item.ServiceName}

- - {Array.from({ length: qty }).map((_, index) => { - const inputKey = isGroup - ? item.id - : `${item.ServiceId}__${item.__index}`; - const value = vehicleInputs[inputKey]?.[index] || ''; - const error = errors[inputKey]?.[index] || ''; - - return ( -
- - handleInputChange( - isGroup ? item.id : item.ServiceId, - index, - e.target.value, - item.ServiceType, - item - ) - } - onKeyPress={(e) => { - if (!/[A-Za-z0-9]/.test(e.key)) { - e.preventDefault(); - } - }} - style={{ - width: '100%', - padding: 8, - borderRadius: 4, - border: error - ? '1px solid red' - : '1px solid #ccc', - }} - /> - {error && ( - - {error} - - )} -
- ); - })} -
- ); - })} -
- -
+

{item.ServiceName}

+ + {Array.from({ length: qty }).map((_, index) => { + const inputKey = isGroup + ? item.id + : `${item.ServiceId}__${item.__index}`; + const value = vehicleInputs[inputKey]?.[index] || ''; + const error = errors[inputKey]?.[index] || ''; + + return ( +
+ + handleInputChange( + isGroup ? item.id : item.ServiceId, + index, + e.target.value, + item.ServiceType, + item + ) + } + onKeyPress={(e) => { + if (!/[A-Za-z0-9]/.test(e.key)) { + e.preventDefault(); + } + }} + style={{ + width: '100%', + padding: 8, + borderRadius: 4, + border: error ? '1px solid red' : '1px solid #ccc', + }} + /> + {error && ( + + {error} + + )} +
+ ); + })} +
+ ); + })} +
+
- } - /> +
+ } + /> + setShowCancelConfirm(true)} + footer={false} + width={500} + children={ + <> + + + } + /> + {showCancelConfirm && ( + { + setBusinessUPI(false); + setShowCancelConfirm(false); + ClearAllGlobalStateDatas(); + CustomerDisplay(); + }} + onCancel={() => setShowCancelConfirm(false)} + okText="Yes" + cancelText="No" + > + Do you want to cancel the payment? + + )} + {customerPreviesOrders && ( setShowCancelConfirm(true)} + open={customerPreviesOrders} + handleCancel={() => setCustomerPreviesOrders(false)} footer={false} - width={500} + width={700} + className={'ModalPaymentGatewayEmbedded'} children={ <> - setCustomerPreviesOrders(false)} /> } /> - {showCancelConfirm && ( - { - setBusinessUPI(false); - setShowCancelConfirm(false); - ClearAllGlobalStateDatas(); - CustomerDisplay(); - }} - onCancel={() => setShowCancelConfirm(false)} - okText="Yes" - cancelText="No" - > - Do you want to cancel the payment? - - )} - {customerPreviesOrders && ( - setCustomerPreviesOrders(false)} - footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} - children={ - <> - setCustomerPreviesOrders(false)} - /> - - } - /> - )} + )} - {(CustomerOtpmodalopen && isOtpEnabled && salesaskiosk) && ( - setCustomerOtpmodalopen(false)} - /> - )} - + {CustomerOtpmodalopen && isOtpEnabled && salesaskiosk && ( + setCustomerOtpmodalopen(false)} + /> + )} + ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTablePay.scss b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTablePay.scss new file mode 100644 index 0000000..0e74c61 --- /dev/null +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTablePay.scss @@ -0,0 +1,33 @@ +.All-TablePay-BTN { + width: 100%; +} +// Table 4 Pay BTN + +.Table4-PayBTN { + width: 100%; + font-family: "Poppins", sans-serif; + + .BSBillingTable3-paybtn-deactive { + background-color: #52c41a; + border: none; + .BSBillingTable3-pay { + background-color: unset; + color: #000; + } + } + .BSBillingTable3-paybtn { + background-color: #52c41a; + color: #fff; + font-family: "Poppins"; + border: none; + padding: 10px 8px; + .BSBillingTable3-pay { + background-color: unset; + color: #fff; + } + &:hover { + background-color: #52c41a !important; + color: #fff !important; + } + } +} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx index 184d891..8691f94 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx @@ -5,7 +5,7 @@ import moment from 'moment'; import { Badge, Modal, Popover, Tooltip } from 'antd'; import { BiRightArrowAlt } from 'react-icons/bi'; import { AiOutlineClose } from 'react-icons/ai'; -import BSBillingTable4 from './BSBillingTable4'; +// import BSBillingTable4 from './BSBillingTable4'; import { UpCircleOutlined } from '@ant-design/icons'; const BSSummery = lazy(() => import('../BSBillingTableSummery/BSSummery')); @@ -539,35 +539,35 @@ const BSBilling4Payment = () => { } }, [OrderCardDetail]); useEffect(() => { - - const fetchPrinterMapping = async () => { - try { - if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { - const data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - }; - // && isMobile && MobileA4Print - const response = await dispatch(getPrinterMappingDetails(data)).unwrap(); - if (response?.data?.statusCode === 0) { - handlePrintMappingClick() - } - console.log(response, "printer mapping response"); - } - } catch (error) { - console.error("Error fetching printer mapping:", error); - } - }; - - fetchPrinterMapping(); - - }, []); + const fetchPrinterMapping = async () => { + try { + if (UserType !== 'Super Admin' && isMobile && MobileA4Print) { + const data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + UserId: UserId, + }; + // && isMobile && MobileA4Print + const response = await dispatch( + getPrinterMappingDetails(data) + ).unwrap(); + if (response?.data?.statusCode === 0) { + handlePrintMappingClick(); + } + console.log(response, 'printer mapping response'); + } + } catch (error) { + console.error('Error fetching printer mapping:', error); + } + }; + + fetchPrinterMapping(); + }, []); const handlePrintMappingClick = () => { - // setReprint1(true) - window.dispatchEvent(new Event('CLICK PRINTER MAPPING')); - }; + // setReprint1(true) + window.dispatchEvent(new Event('CLICK PRINTER MAPPING')); + }; useEffect(() => { if (salesBillEdit) { @@ -900,7 +900,7 @@ const BSBilling4Payment = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; console.log(selectedStyle, style, 'style'); if (selectedStyle) { @@ -1298,7 +1298,10 @@ const BSBilling4Payment = () => { }, [OrderCardDetail]); useEffect(() => { if (CompId && BranchId && AppId) { - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } // getUnpaiddatas(); @@ -1969,7 +1972,10 @@ const BSBilling4Payment = () => { setCurrentOrderNetAmount(0); setPreviousNetAmount(0); setUpinotSelected(false); - if (holdCheckedSalesSetup || NavBarOptions?.some((e) => e?.OptionName == 'Hold')) { + if ( + holdCheckedSalesSetup || + NavBarOptions?.some((e) => e?.OptionName == 'Hold') + ) { getHolddata(); } if (defaultBookingType === 'Both') { @@ -2148,15 +2154,15 @@ const BSBilling4Payment = () => { 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', @@ -2176,7 +2182,7 @@ const BSBilling4Payment = () => { BookingDate: AvailableDate ? a.BookedDate : null, ...(a?.DiscountValue && { DiscountValue: a.DiscountValue }), ...(a?.DiscountType && { DiscountType: a.DiscountType }), - ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }) + ...(a?.DiscountAmt && { DiscountAmt: a.DiscountAmt }), })); const NotSlectedTypeFind = temporderdetail?.find( (a) => a?.BookingType != SelectedBookingType @@ -2252,7 +2258,7 @@ const BSBilling4Payment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2269,9 +2275,9 @@ const BSBilling4Payment = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ @@ -2286,8 +2292,8 @@ const BSBilling4Payment = () => { ? PaymentgatewayUPI?.[0]?.ModeId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId + (busupi) => busupi?.ModeId === UpiId + )?.ModeId : paybtnselected : paybtnselected ? paybtnselected @@ -2300,15 +2306,15 @@ const BSBilling4Payment = () => { salesBillEdit && currentOrderNetAmount < previousNetAmount ? null : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId + ?.MerchantId : null, PaymentOptionType: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - (refundPaySelectedName?.toLowerCase() === 'cash' || - refundPaySelectedName?.toLowerCase() === 'credit') + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : Paybtnnameselected?.toLowerCase() === 'cash' ? 'PC' @@ -2328,29 +2334,29 @@ const BSBilling4Payment = () => { ? null : SelectedUPIPayOption?.toLowerCase() === 'default' ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId + ?.UPIDetailId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.MerchantUPIId + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId : null, AccountDtl: salesBillEdit && currentOrderNetAmount < previousNetAmount ? [] : 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: @@ -2361,13 +2367,13 @@ const BSBilling4Payment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', Debit: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - refundPaySelectedName?.toLowerCase() === 'credit' + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, Credit: salesBillEdit @@ -2445,14 +2451,14 @@ const BSBilling4Payment = () => { 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]); @@ -2613,14 +2619,14 @@ const BSBilling4Payment = () => { 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]); @@ -2727,14 +2733,14 @@ const BSBilling4Payment = () => { } 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]); @@ -2910,14 +2916,14 @@ const BSBilling4Payment = () => { 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]); @@ -2936,7 +2942,7 @@ const BSBilling4Payment = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3173,9 +3179,9 @@ const BSBilling4Payment = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -3187,9 +3193,9 @@ const BSBilling4Payment = () => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3200,9 +3206,9 @@ const BSBilling4Payment = () => { prodCat: prodCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3645,404 +3651,399 @@ const BSBilling4Payment = () => { ); }; - return ( -
-
-
- - {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( - - )} -
- )} - {/* {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( + return ( +
+
+
+ + {screenwidth <= 768 && ( +
+ {Array.isArray(OrderCardDetail) && + OrderCardDetail?.length >= 1 && ( + + )} +
+ )} + {/* {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( {" "} )} */} -
-
-
- {tableOptions - .filter((item) => item.OptionName === 'AddCustomer') - .map((filteredItem) => ( - -
- +
+
+
+ {tableOptions + .filter((item) => item.OptionName === 'AddCustomer') + .map((filteredItem) => ( + +
+ - - - -
-
- ))} -
- - {screenwidth <= 768 && ( - <> - {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( -
- {responsiveBill ? ( -
- {' '} - {' '} -
- ) : ( -
- {' '} - {' '} -
- )} -
- )} - - )} + + +
+ + ))}
-
- {(addcustomer || hold) && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- -
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( -
- -
- )} - {PaymentUpiOptions?.length > 0 && OrderId && ( + {screenwidth <= 768 && ( + <> + {Array.isArray(OrderCardDetail) && + OrderCardDetail?.length >= 1 && ( +
+ {responsiveBill ? ( +
+ {' '} + {' '} +
+ ) : ( +
+ {' '} + {' '} +
+ )} +
+ )} + + )} +
+
+ {(addcustomer || hold) && ( + + )} + {creditCustomerOpen && ( + + )} + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelectedUpiOption && (
)} - {tableOptions?.filter( - (item) => item.OptionName === 'AddCustomer' - ).length === 1 || navCust === true ? ( -
- {Object.keys(useOptions)?.length > 0 && - useOptions?.some((flow) => - flow.OptionDetails.some( - (option) => - option.OptionName === 'Pay at the counter' && - option.ModeDetails.some( - (mode) => mode.ModeName === 'Credit' - ) - ) - ) && ( - - {!OtherServicesglobal && ( - - {' '} - 0 && - 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', - }} - /> - - )} - - )} -
- ) : ( - '' - )} - {paybtns?.length > 1 && ( -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - width: '2rem', - }} - > - {/* */} - {!OtherServicesglobal && ( - - {' '} -
- -
-
- )} - {OtherServicesglobal && OrderCardDetail.length >= 1 && ( - - {' '} -
- -
-
+ {PaymentUpiOptions?.length > 0 && OrderId && ( +
+ +
+ )} + {tableOptions?.filter((item) => item.OptionName === 'AddCustomer') + .length === 1 || navCust === true ? ( +
+ {Object.keys(useOptions)?.length > 0 && + useOptions?.some((flow) => + flow.OptionDetails.some( + (option) => + option.OptionName === 'Pay at the counter' && + option.ModeDetails.some( + (mode) => mode.ModeName === 'Credit' + ) + ) + ) && ( + + {!OtherServicesglobal && ( + + {' '} + 0 && 'not-allowed', + color: + OrderCardDetail?.length > 0 || + (selOption?.value === undefined && + GlobalAddCustomerDetails1?.length === 0 && + GetCustId?.CustMobile === undefined) + ? 'gray' + : 'rgb(18, 146, 238)', + fontSize: '28px', + }} + /> + + )} + )} - {/* */} -
- )} - - {/* Customer Orders */} - {(SelCustId && tableOptions?.filter((item) => item.OptionName === 'PreviousBillFetch') - .length === 1) && ( - +
+ ) : ( + '' + )} + {paybtns?.length > 1 && ( +
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + width: '2rem', + }} + > + {/* */} + {!OtherServicesglobal && ( + {' '}
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(OrderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); - } - }} + onClick={ + CheckBookingStatus != 'Close' && !addnewAccess + ? SplitPaymentOpen + : '' + } style={{ - cursor: OrderCardDetail?.length > 0 && 'not-allowed', + width: '1.5rem', + cursor: + OrderCardDetail?.length === 0 || + CheckBookingStatus == 'Close' || + addnewAccess + ? 'not-allowed' + : 'pointer', color: - OrderCardDetail?.length > 0 || - (OrderCardDetail?.length > 0 && - GetCustId?.CustMobile === undefined) + OrderCardDetail?.length === 0 || + CheckBookingStatus == 'Close' || + addnewAccess ? 'gray' : 'rgb(18, 146, 238)', - fontSize: '25px', display: 'flex', alignItems: 'center', height: '2.46rem', - width: '1.5rem', }} > - +
- +
)} - {tabledata?.length > 0 && ( -
- {tableOptions - .filter((item) => item.OptionName === 'UnpaidBill') - .map((filteredItem) => ( - - {!OtherServicesglobal && ( - - {' '} - { - (setUnpaidOpen(true), getUnpaiddatas()); - }} - /> - - )} - - ))} -
+ + {OtherServicesglobal && OrderCardDetail.length >= 1 && ( + + {' '} +
+ +
+
+ )} + {/*
*/} +
+ )} + + {/* Customer Orders */} + {SelCustId && + tableOptions?.filter( + (item) => item.OptionName === 'PreviousBillFetch' + ).length === 1 && ( + + {' '} +
{ + if ( + CheckBookingStatus !== 'Close' && + !addnewAccess && + !(OrderCardDetail?.length > 0) + ) { + setCustomerPreviesOrders(true); + } + }} + style={{ + cursor: OrderCardDetail?.length > 0 && 'not-allowed', + color: + OrderCardDetail?.length > 0 || + (OrderCardDetail?.length > 0 && + GetCustId?.CustMobile === undefined) + ? 'gray' + : 'rgb(18, 146, 238)', + fontSize: '25px', + display: 'flex', + alignItems: 'center', + height: '2.46rem', + width: '1.5rem', + }} + > + +
+
)} - {dinePreference && ( -
- {(BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - SelectedTableDetails?.length !== 0 && ( - <> - + {tabledata?.length > 0 && ( +
+ {tableOptions + .filter((item) => item.OptionName === 'UnpaidBill') + .map((filteredItem) => ( + + {!OtherServicesglobal && ( + {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } + { + (setUnpaidOpen(true), getUnpaiddatas()); + }} /> - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } - - )} -
- )} - {!OtherServicesglobal && ( -
- {tableOptions?.map((item) => ( + )} + + ))} +
+ )} + {dinePreference && ( +
+ {(BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + SelectedTableDetails?.length !== 0 && ( <> - {unpaidFlow == false - ? item?.OptionName == 'Hold' && + + {' '} + + FirstPaymentclick === false && !addnewAccess + ? changeOrderStatus() + : '' + } + /> + + {FirstPaymentclick === false && + !addnewAccess && + !OrderStatus && } + + )} +
+ )} + {!OtherServicesglobal && ( +
+ {tableOptions?.map((item) => ( + <> + {unpaidFlow == false + ? item?.OptionName == 'Hold' && BookingType !== 'Dine In' && !BookingTypeBoth && OrderCardDetail?.length != 0 && @@ -4051,10 +4052,7 @@ const BSBilling4Payment = () => { paybtns?.length > 0 && CheckBookingStatus != 'Close' && !addnewAccess && ( - + {' '} { /> ) - : ''} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && + : ''} + {unpaidFlow == false + ? item?.OptionName == 'Hold' && BookingType !== 'Dine In' && !BookingTypeBoth && Holddata?.length > 0 && @@ -4095,354 +4093,387 @@ const BSBilling4Payment = () => { cursor: 'pointer', color: Holddata ? '#52c41a' : 'default', pointerEvents: - OrderType === 'Failed' - ? 'none' - : 'auto', + OrderType === 'Failed' ? 'none' : 'auto', }} /> ) - : ''} - - ))} -
- )} -
-
- -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - }} - > - {paybtns?.length > 0 && - currentOrderNetAmount >= previousNetAmount ? ( - paybtns?.map((payment) => ( -
- -
- )) - ) : currentOrderNetAmount < previousNetAmount && - salesBillEdit && - refundPayBtns.length > 0 ? ( - refundPayBtns.map((payment) => ( -
- -
- )) - ) : ( -
- Please Set Payment Options -
- )} -
-
- {PrintOrderDetails?.length > 0 && ( -
- {filteredSettingNames?.includes('whatsapp') && - MobileNoWhatsApp?.value && ( - - )} - - - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} + : ''} + + ))}
)} +
+ +
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + }} + > + {paybtns?.length > 0 && + currentOrderNetAmount >= previousNetAmount ? ( + paybtns?.map((payment) => ( +
+ +
+ )) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => ( +
+ +
+ )) + ) : ( +
+ Please Set Payment Options +
+ )} +
+
+ {PrintOrderDetails?.length > 0 && ( +
+ {filteredSettingNames?.includes('whatsapp') && + MobileNoWhatsApp?.value && ( + + )} + + + + {filteredSettingNames?.includes('SMS') && isMobile && ( + + )} + {/* WhatsAppShare modal/component */} + {showWhatsAppShare && ( + closePrintOption(false)} + /> + )} + {showSMSShare && isMobile && ( + closePrintOption(false)} + /> + )} +
+ )} +
+ + {/* {(selectCustomerDisplay === true || paymentModeDisplay === true) && (
)} */} -
-
-
-
- - - - - +
+
+
+
+
- Items: - - {TotalItems} -
+ + + + - - - - -
+ Items: + + {TotalItems} +
- Qty: - - {Qty} -
-
-
- {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
+ + Qty: + + + {Qty} + + + +
+
+ {OrderCardDetail?.length > 0 && + ParkingDisplay && + !OtherServicesglobal && ( +
+ +
+ )} +
+ {' '} + {!OtherServicesglobal && unpaidFlow == true ? ( + + {' '} + - -
- )} -
- {' '} - {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} -
+ onClick={() => { + Recipt(); + }} + /> + + ) : ( + '' + )} +
-
- - - - - {/* +
+ + + + + {/* {" "} */} - - - } - trigger="click" - // width={1000} - open={open} - onOpenChange={handleOpenChange} - > + + + } + trigger="click" + // width={1000} + open={open} + onOpenChange={handleOpenChange} + > + + +
+ +
+ + + + + {/* + + */} + + + } + trigger="click" + // width={1000} + open={open2} + onOpenChange={handleOpenChange2} + > + { color: '' ? '#52c41a' : '#1292EE', }} /> - -
- -
- - - - - {/* - - */} - - - } - trigger="click" - // width={1000} - open={open2} - onOpenChange={handleOpenChange2} - > - - - - -
+ +
-
- - + +
+ { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+ {/*

UPI PAYMENT

*/} + +
+
+ +
+ +
+

+ {' '} + RS : + {OrderType === 'Failed' + ? FailedTotalAmt + : Math.round(TotalAmount)}{' '} +

+
+
+ +
+ {(selOption || SelCustId) && ( +
+ Sent Payment Link + Your Alt Text + {/* */} +
)} - - -
- { - Upimodel('Cancel'); - }} - footer={false} - children={ -
- {/*

UPI PAYMENT

*/}
-
- -
- -
-

- {' '} - RS : - {OrderType === 'Failed' - ? FailedTotalAmt - : Math.round(TotalAmount)}{' '} -

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text - {/* */} -
- )} - -
} + handleSubmit={() => { + Upimodel('Submit'); }} - > - } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> -
+ />
- } - /> - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} - {CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - />
+ } + /> + {PrintOrderDetails?.length > 0 && + PrintOrderDetails?.[0]?.OrderDetails?.map( + (orderDetail, index) => ( +
+ +
+ ) )} -
+ {PrintOrderDetails?.length > 0 && + (TokenOnly?.SettingValue === 'Y' || + IndividualToken?.SettingValue === 'Y') && + PrintOrderDetails?.[0]?.OrderDetails?.map( + (orderDetail, index) => ( +
+ +
+ ) + )} + {CreditCustomer && ( +
+ { + handleCreditCustomer('Cancel'); + }} + handleOk={() => { + handleCreditCustomer('Submit'); + }} + /> +
+ )}
+
- { - setUnpaidOpen(false); - }} - footer={false} - children={ -
- { + setUnpaidOpen(false); + }} + footer={false} + children={ +
+ -
+ /> +
+ } + /> + {UnpaidConfirmation && ( + +
+ You have already selected a table. If you click 'OK,' the table + selection will be removed, and the unpaid flow will continue. If + you click 'Cancel,' the dine-in flow will proceed as selected. +
+ } + onOk={UnpaidOk} + onCancel={Unpaidclose} /> - {UnpaidConfirmation && ( - -
- You have already selected a table. If you click 'OK,' the - table selection will be removed, and the unpaid flow will - continue. If you click 'Cancel,' the dine-in flow will proceed - as selected. -
- - } - onOk={UnpaidOk} - onCancel={Unpaidclose} - /> - )} - {Splitpayment && ( - data?.TotalAmt + acc, 0 ) - - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)) + ((OverAllSales > 0 ? OverAllSales : 0) + + (OverAllEstimate > 0 ? OverAllEstimate : 0) + + (Discount > 0 ? Discount : 0)) ) - } - failedOrderData={failedOrderData} - /> - )} - { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
} + failedOrderData={failedOrderData} /> - - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ) - // )) + )} + { + dispatch(changeSalesPaymentoption(false)); + }} + footer={false} + children={ +
+ +
} + /> - { - setOtherServicesModal(false); - }} - // handleSubmit={Handlevehiclenumbers} - footer={false} - children={ -
- {OrderCardDetail.map((item, i) => { - const isGroup = item.ServiceType === 'G'; - const groupKey = item.id; // 🔁 using `id` for groups now - const uniqueKey = `${item.ServiceId}__${item.__index}`; + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ) + // )) + } - // For G-type: render input only once for the group - if ( - isGroup && - i !== OrderCardDetail.findIndex((o) => o.id === groupKey) - ) { - return null; - } + { + setOtherServicesModal(false); + }} + // handleSubmit={Handlevehiclenumbers} + footer={false} + children={ +
+ {OrderCardDetail.map((item, i) => { + const isGroup = item.ServiceType === 'G'; + const groupKey = item.id; // 🔁 using `id` for groups now + const uniqueKey = `${item.ServiceId}__${item.__index}`; - const qty = isGroup - ? OrderCardDetail.filter((o) => o.id === groupKey).reduce( + // For G-type: render input only once for the group + if ( + isGroup && + i !== OrderCardDetail.findIndex((o) => o.id === groupKey) + ) { + return null; + } + + const qty = isGroup + ? OrderCardDetail.filter((o) => o.id === groupKey).reduce( (sum, o) => sum + (o.OrderQty || 1), 0 ) - : item.OrderQty || 1; + : item.OrderQty || 1; - return ( -
-

{item.ServiceName}

- - {Array.from({ length: qty }).map((_, index) => { - const inputKey = isGroup - ? item.id - : `${item.ServiceId}__${item.__index}`; - const value = vehicleInputs[inputKey]?.[index] || ''; - const error = errors[inputKey]?.[index] || ''; - - return ( -
- - handleInputChange( - isGroup ? item.id : item.ServiceId, - index, - e.target.value, - item.ServiceType, - item - ) - } - onKeyPress={(e) => { - if (!/[A-Za-z0-9]/.test(e.key)) { - e.preventDefault(); - } - }} - style={{ - width: '100%', - padding: 8, - borderRadius: 4, - border: error - ? '1px solid red' - : '1px solid #ccc', - }} - /> - {error && ( - - {error} - - )} -
- ); - })} -
- ); - })} -
- -
+

{item.ServiceName}

+ + {Array.from({ length: qty }).map((_, index) => { + const inputKey = isGroup + ? item.id + : `${item.ServiceId}__${item.__index}`; + const value = vehicleInputs[inputKey]?.[index] || ''; + const error = errors[inputKey]?.[index] || ''; + + return ( +
+ + handleInputChange( + isGroup ? item.id : item.ServiceId, + index, + e.target.value, + item.ServiceType, + item + ) + } + onKeyPress={(e) => { + if (!/[A-Za-z0-9]/.test(e.key)) { + e.preventDefault(); + } + }} + style={{ + width: '100%', + padding: 8, + borderRadius: 4, + border: error ? '1px solid red' : '1px solid #ccc', + }} + /> + {error && ( + + {error} + + )} +
+ ); + })} +
+ ); + })} +
+
- } - /> +
+ } + /> + setShowCancelConfirm(true)} + footer={false} + width={500} + children={ + <> + + + } + /> + {showCancelConfirm && ( + { + setBusinessUPI(false); + setShowCancelConfirm(false); + ClearAllGlobalStateDatas(); + CustomerDisplay(); + }} + onCancel={() => setShowCancelConfirm(false)} + okText="Yes" + cancelText="No" + > + Do you want to cancel the payment? + + )} + {customerPreviesOrders && ( setShowCancelConfirm(true)} + open={customerPreviesOrders} + handleCancel={() => setCustomerPreviesOrders(false)} footer={false} - width={500} + width={700} + className={'ModalPaymentGatewayEmbedded'} children={ <> - setCustomerPreviesOrders(false)} /> } /> - {showCancelConfirm && ( - { - setBusinessUPI(false); - setShowCancelConfirm(false); - ClearAllGlobalStateDatas(); - CustomerDisplay(); - }} - onCancel={() => setShowCancelConfirm(false)} - okText="Yes" - cancelText="No" - > - Do you want to cancel the payment? - - )} - {customerPreviesOrders && ( - setCustomerPreviesOrders(false)} - footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} - children={ - <> - setCustomerPreviesOrders(false)} - /> - - } - /> - )} -
- + )} +
); }; export default BSBilling4Payment; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full.jsx index 83a540d..14a3b7e 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4Full.jsx @@ -1,10 +1,10 @@ import React from 'react'; import { useSelector } from 'react-redux'; -import BSBillingTable4 from './BSBillingTable4'; import BSBilling4Payment from './BSBilling4Payment'; import { getTemplateData } from '../../../../../Features/ThemeChange/ThemeChange'; import { isMobile } from 'react-device-detect'; import { GlobalExpDateforHeight } from '../../../../../Features/BookingScreen/BookingData/BookingData'; +import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3'; const BSBillingTable4Full = () => { const templateData = useSelector(getTemplateData); @@ -72,7 +72,7 @@ const BSBillingTable4Full = () => { style={{ height: containerHeight }} >
- +
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx index 67122c6..33450db 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx @@ -199,6 +199,8 @@ import CardPopover from '../StandardTable/Utils/CardPopover.jsx'; import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; +import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3.jsx'; +import BSBillingTable3Pay from '../BSBillingTable3/BSBillingTable3pay.jsx'; // Jsx Files const OtherServicePrintStyle1 = lazy( () => @@ -3106,14 +3108,7 @@ const BSBillingTable5 = () => { OrderCardDetail?.length > 0 && (BookingType === 'Dine In' || BookingTypeBoth) ) { - // await dispatch(changeOrderCardDetails([])) - // await dispatch(changeOrderCardDetails(tabledata?.[event]?.productDetails)) - // await dispatch(ChangeTotalAmount(tabledata?.[event]?.ExtraChargeDetails)) - // await dispatch(changeUnpaidData(true)) - // await dispatch(changeReorderHoldDetails([tabledata?.[event]]?.[0])); - // await dispatch(changeReorderProductDetails(tabledata?.[event]?.productDetails)) - // setUnpaidOpen(false) - setUnpaidConfirmation(true); + setUnpaidConfirmation(true); setunpaidselectedindex(event); } else { const UpdatedData = tabledata?.[event]?.productDetails; @@ -3228,15 +3223,7 @@ const BSBillingTable5 = () => { let datas = response?.data?.data; await dispatch(ChangeComboCarddata(datas)); if (response?.data?.statusCode === 1) { - // let Data = response?.data?.data - // let comboList = Data?.map((item, index) => ({ - // ...item, - // id: `${item.ComboName || 'Combo'}-${index}`, - // ProdName:item?.ComboName, - // OverAllQty:item?.OverallQuantity - // })); - // setCombocardata(comboList); - } + } }; const Upimodel = (type) => { @@ -3686,890 +3673,13 @@ const BSBillingTable5 = () => { className="BS5Billtble" style={{ height: 'inherit', overflow: 'auto' }} > - +
)} {/* bill table */} -
- {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && - (isMobile || screenwidth <= 768) && } -
- )} - {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( -
- {responsiveBill ? ( -
- {' '} - {' '} -
- ) : ( -
- {' '} - {' '} -
- )} -
- )} -
- )} -
-
-
- -
- -
- -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - }} - > - {paybtns?.length > 0 && - currentOrderNetAmount >= previousNetAmount ? ( - paybtns?.map((payment) => ( -
- -
- )) - ) : currentOrderNetAmount < previousNetAmount && - salesBillEdit && - refundPayBtns.length > 0 ? ( - refundPayBtns.map((payment) => ( -
- -
- )) - ) : ( -
- Please Set Payment Options -
- )} -
-
-
- -
-
- -
- - - - - - - - - -
- Items :  - - {TotalItems}{' '} -
- Qty :  - - {Qty} -
-
-
- {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} - {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} -
- - - - - - - - } - trigger="click" - open={open2} - onOpenChange={handleOpenChange2} - > - - {!open2 ? ( - - ) : ( - - )} - - -
-
-
-
-
- {tableOptions - .filter((item) => item.OptionName === 'AddCustomer') - .map((filteredItem) => ( - -
- - - - {' '} - - -
-
- ))} -
- {paybtns?.length > 1 && ( -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - width: '2rem', - }} - > - {!OtherServicesglobal && ( - - {' '} -
- -
-
- )} -
- )} -
- - {/* btns */} - -
- {tableOptions?.filter((item) => item.OptionName === 'AddCustomer') - .length === 1 || navCust === true ? ( -
- {Object.keys(useOptions)?.length > 0 && - useOptions?.some((flow) => - flow.OptionDetails.some( - (option) => - option.OptionName === 'Pay at the counter' && - option.ModeDetails.some( - (mode) => mode.ModeName === 'Credit' - ) - ) - ) && - !OtherServicesglobal && ( - - - {' '} - 0 && 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', - }} - /> - - - )} -
- ) : ( - '' - )} - {/* Customer Orders */} - {SelCustId && - tableOptions?.filter( - (item) => item.OptionName === 'PreviousBillFetch' - ).length === 1 && ( - - {' '} -
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(OrderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); - } - }} - style={{ - cursor: OrderCardDetail?.length > 0 && 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (OrderCardDetail?.length > 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '25px', - display: 'flex', - alignItems: 'center', - height: '2.46rem', - width: '1.5rem', - }} - > - -
-
- )} - {tabledata?.length > 0 && dinePreference && ( -
- {tableOptions - .filter((item) => item.OptionName === 'UnpaidBill') - .map((filteredItem) => ( - - {!OtherServicesglobal && ( - - {' '} - { - (setUnpaidOpen(true), getUnpaiddatas()); - }} - /> - - )} - - ))} -
- )} - {OtherServicesglobal && OrderCardDetail.length >= 1 && ( - - {' '} -
- -
-
- )} - {dinePreference && ( -
- {(BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - SelectedTableDetails?.length !== 0 && ( - <> - - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - /> - - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } - - )} -
- )} - {!OtherServicesglobal && ( -
- {tableOptions?.map((item) => ( - <> - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - !BookingTypeBoth && - BookingType !== 'Dine In' && - OrderCardDetail?.length != 0 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - - - ) - : ''} - {unpaidFlow === false && - item?.OptionName === 'Hold' && - !BookingTypeBoth && - BookingType !== 'Dine In' && - Holddata?.length > 0 && - OrderCardDetail?.length === 0 && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - - - - - )} - - ))} -
- )} - - - -
- { - Upimodel('Cancel'); - }} - footer={false} - children={ -
- {/*

UPI PAYMENT

*/} - -
-
- -
- -
-

- {' '} - RS : - {OrderType === 'Failed' - ? FailedTotalAmt - : Math.round(TotalAmount)}{' '} -

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text - {/* */} -
- )} - -
- } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> -
-
-
- } - /> - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ))} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ))} - {CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - /> -
- )} -
+ {unpaidopen && ( { {tableDataTakeAway?.length > 0 && tableDataTakeAway?.map((item, index) => ( - { const templateData = useSelector(getTemplateData); @@ -74,7 +75,7 @@ const BSBTOverall6 = () => { style={{ height: containerHeight }} >
- +
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx index 76dd20c..dc9bfdd 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx @@ -2283,7 +2283,7 @@ const BSBillingTable6 = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -2544,7 +2544,7 @@ const BSBillingTable6 = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -2836,7 +2836,7 @@ const BSBillingTable6 = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -3130,7 +3130,7 @@ const BSBillingTable6 = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx index 25fbe25..26d3e1f 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7Overall.jsx @@ -9,6 +9,7 @@ import { GlobalScreenSize, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.scss'; +import BSBillingTable3 from '../BSBillingTable3/BSBillingTable3'; const BSBillingTable7Overall = () => { const templateData = useSelector(getTemplateData); @@ -20,7 +21,7 @@ const BSBillingTable7Overall = () => { containerHeight = isMobile ? ExpDate <= 7 ? '480px' - : '468px' // billing table 7 height in POS + : '468px' // billing table 7 height in POS : ExpDate <= 7 ? '82vh' : ''; @@ -30,7 +31,7 @@ const BSBillingTable7Overall = () => { containerHeight = isMobile ? ExpDate <= 7 ? '490px' - : '475px' // billing table 7 height in POS + : '475px' // billing table 7 height in POS : ExpDate <= 7 ? '84vh' : ''; @@ -79,7 +80,7 @@ const BSBillingTable7Overall = () => { > {screenwidth > 768 && (
- +
)}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx index f6e57b5..2f539cb 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx @@ -5,20 +5,15 @@ import WebFont from 'webfontloader'; import { AiOutlineClose, AiFillDelete } from 'react-icons/ai'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; import dineInIcon from '../../../../../Images/Dine In.svg'; - import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; const BSEditTotalAmt = lazy( () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') ); - const StandardTablePayment = lazy(() => import('./StandardTablePayment.jsx')); - const CustomerPriceHistory = lazy( () => import('../../UtillComponents/CustomerPriceHistory.jsx') ); - const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); - const BSBillingEditQuantity = lazy( () => import('../BSBillingEditQuantity/BSBillingEditQuantity') ); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss index 4eb52e7..3ce5388 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss @@ -27,7 +27,6 @@ width: 100%; border-spacing: 0 0px; text-align: center; - padding: 0 10px; @media (max-width: 768px) { font-size: 0.875rem; @@ -1086,7 +1085,7 @@ width: 100%; height: max-content; overflow: hidden; - position: fixed; + // position: fixed; bottom: 0; padding-bottom: 0; } @@ -1213,8 +1212,7 @@ .booking-table-footer { width: 100%; - // padding: 1rem 1rem 0rem 1rem; - padding: 10px 10px 4px 10px; + padding: 10px 10px 4px 10px; display: flex; flex-direction: column; gap: 3px; @@ -1291,8 +1289,7 @@ display: flex; align-items: center; justify-content: center; - // justify-content: space-around; - gap: 0.5rem; + gap: 0.5rem; opacity: 1; background-color: #0d9488; color: #fff; @@ -1505,6 +1502,7 @@ align-items: center; gap: 1rem; justify-content: space-between; + padding: 0 4px; } .summaryopenClose { @@ -1513,7 +1511,8 @@ gap: 5px; background-color: #2564eb2f; color: #2563eb; - font-size: 13px; + font-size: 10px; + font-weight: 500; padding: 1px 10px 4px 10px; border-radius: 50px; cursor: pointer; @@ -1580,8 +1579,7 @@ height: max-content !important; max-height: 30vh !important; position: fixed; - // bottom: 23%; - bottom: 140px; + bottom: 140px; width: 100%; } } diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx index afcc3aa..25f61ce 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx @@ -230,6 +230,10 @@ import { BiRightArrowAlt } from 'react-icons/bi'; import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon'; import { MdSms } from 'react-icons/md'; +import '../../../../BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.scss'; +import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; +import BSNavBarAddUser from '../../UtillComponents/BSNavBarAddUser.jsx'; + // const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; @@ -3503,7 +3507,7 @@ const StandardTablePayment = () => {
)}
-
+
{' '} @@ -3714,11 +3718,16 @@ const StandardTablePayment = () => {
)} + +
+ + +