From 9cb84f309d06279a22dac4d032fcaec0080be1c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 23 Feb 2026 09:39:46 +0530 Subject: [PATCH] optimization Code --- package-lock.json | 796 +- package.json | 3 + src/Components/AddProduct/AddProduct.jsx | 3 + src/Components/Modal/ProductDetailsModal.jsx | 63 +- src/Components/Modal/ReceivedStocksModal.jsx | 56 +- .../BookingScreen/BookingData/BookingData.js | 34 +- .../Payment/PaymentOptions/PaymentOptions.js | 2 +- src/Features/WholeSale/WholesaleData.js | 8 +- .../BSBillingTable1/BSBTOverall1.jsx | 255 +- .../BSBillingTable1/BSBillingTable1.jsx | 2927 ++-- .../BSBillingTable1/BST1Payment.jsx | 628 +- .../BSBillingTable2/BSBillingTable2.jsx | 2763 ++-- .../BSBillingTable3/BSBillingTable3.jsx | 381 +- .../BSBillingTable3/BSBillingTable3pay.jsx | 2980 ++-- .../BSBillingTable4/BSBilling4Payment.jsx | 2769 ++-- .../BSBillingTable4/BSBillingTable4.jsx | 2742 ++-- .../BSBillingTable5/BSBillingTable5.jsx | 2811 ++-- .../BSBillingTable6/BSBillingTable6.jsx | 2642 ++-- .../BSBillingTable6/BST6Payment.jsx | 2924 ++-- .../BSBillingTable7/BSBilling7Payment.jsx | 52 +- .../BSBillingTable7/BSBillingTable7.jsx | 2443 ++-- .../ComboBillTableEdit/ComboEditQty.jsx | 27 +- .../ComboEditQtyAndRate.jsx | 79 +- .../ComboSalesBillTable.jsx | 184 +- .../StandardTable/StandardTable.jsx | 731 +- .../StandardTable/StandardTablePayment.jsx | 2066 +-- .../BSCategories/BSCategoryHorizontal.jsx | 82 +- .../BSCategories/BSCategoryVertical.jsx | 28 +- .../BSOtherServicesHorizontalcat.jsx | 131 +- .../BSOtherServicesVerticalcat.jsx | 223 +- .../Components/BSCombo/BSC1NavBar.jsx | 363 +- .../Components/BSCombo/BSC1Payment.jsx | 2959 ++-- .../Components/BSCombo/BSC1Search.jsx | 655 +- .../Components/BSItemCards/BSItemCard.jsx | 2 +- .../BSItemCards/BSOtherServiceItemCard.jsx | 1648 ++- .../BSItemCards/BsBookingitemCard.jsx | 727 +- .../BSItemCards/RemoveFromCartFunction.jsx | 48 +- .../Components/BSNavbar/BSNavBarUserInfo.jsx | 111 +- .../Components/BSNavbar/BSNavbar1.jsx | 1438 +- .../Components/BSNavbar/BSNavbar2.jsx | 1365 +- .../Components/BSNavbar/BSNavbar3.jsx | 1219 +- .../CreditCustSplitPayment.jsx | 257 +- .../FeaturesFunctionalities.jsx | 253 +- .../BookingFunctionality/SplitPayment.jsx | 693 +- .../MainPage/SelectionComponent.jsx | 859 +- .../OtherConponents/Reprint/BSReprint.jsx | 115 +- src/Pages/Product/ProductForm.jsx | 28 +- src/check.jsx | 11896 ++++++++++------ src/routesConfig.jsx | 2 +- 49 files changed, 29624 insertions(+), 25847 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3b2f07..aeda0dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@ant-design/plots": "^1.2.6", "@autocomplete/material-ui": "0.0.17", + "@capacitor-mlkit/barcode-scanning": "^8.0.1", "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@emotion/react": "^11.11.4", @@ -19,6 +20,8 @@ "@reduxjs/toolkit": "^1.9.5", "@tanstack/react-query": "^5.90.11", "@tanstack/react-query-devtools": "^5.91.1", + "@tanstack/react-virtual": "^3.13.18", + "@zxing/library": "^0.21.3", "antd": "^5.17.4", "antd-img-crop": "^4.22.0", "aos": "^2.3.4", @@ -48,6 +51,7 @@ "mui-autocomplete": "^2.0.1", "number-to-words": "^1.2.4", "pdf-lib": "^1.17.1", + "qr-scanner": "^1.4.2", "qrcode": "^1.5.3", "qrcode.react": "^4.2.0", "react": "^18.3.1", @@ -581,7 +585,6 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.6.tgz", "integrity": "sha512-2lfu57JtzctfIrcGMz992hyLlByuzgIk58+hhGCxjKZ3rWI82NnVLjXcaTqkI2NvlcvOskZaiZ5kjUALo3Lpxg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -590,7 +593,6 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.6.tgz", "integrity": "sha512-H3mcG6ZDLTlYfaSNi0iOKkigqMFvkTKlGUYlD8GW7nNOYRrevuA46iTypPyv+06V3fEmvvazfntkBU34L0azAw==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.28.6", "@babel/generator": "^7.28.6", @@ -619,8 +621,7 @@ "node_modules/@babel/core/node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, "node_modules/@babel/generator": { "version": "7.28.6", @@ -637,11 +638,23 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz", + "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/types": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/helper-compilation-targets": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz", "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==", - "dev": true, "dependencies": { "@babel/compat-data": "^7.28.6", "@babel/helper-validator-option": "^7.27.1", @@ -657,7 +670,6 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, "dependencies": { "yallist": "^3.0.2" } @@ -665,8 +677,7 @@ "node_modules/@babel/helper-compilation-targets/node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "node_modules/@babel/helper-globals": { "version": "7.28.0", @@ -692,7 +703,6 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz", "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==", - "dev": true, "dependencies": { "@babel/helper-module-imports": "^7.28.6", "@babel/helper-validator-identifier": "^7.28.5", @@ -709,7 +719,6 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz", "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -734,7 +743,6 @@ "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -743,7 +751,6 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.6.tgz", "integrity": "sha512-xOBvwq86HHdB7WUDTfKfT/Vuxh7gElQ+Sfti2Cy6yIWNW05P8iUslOVcZ4/sKbE+/jQaukQAdz/gf3724kYdqw==", - "dev": true, "dependencies": { "@babel/template": "^7.28.6", "@babel/types": "^7.28.6" @@ -766,6 +773,74 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.28.6.tgz", + "integrity": "sha512-wgEmr06G6sIpqr8YDwA2dSRTE3bJ+V0IfpzfSY3Lfgd7YWOaAdlykvJi13ZKBt8cZHfgH1IXN+CL656W3uUa4w==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-display-name": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.28.0.tgz", + "integrity": "sha512-D6Eujc2zMxKjfa4Zxl4GHMsmhKKZ9VpcqIchJLvwTxad9zWIYulwYItBovpDOoNLISpcZSXoDJ5gaGbQUDqViA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.28.6.tgz", + "integrity": "sha512-61bxqhiRfAACulXSLd/GxqmAedUSrRZIu/cbaT18T1CetkTmtDN15it7i80ru4DVqRK1WMxQhXs+Lf9kajm5Ow==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.3", + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", + "@babel/plugin-syntax-jsx": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-development": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.27.1.tgz", + "integrity": "sha512-ykDdF5yI4f1WrAolLqeF3hmYU12j9ntLQl/AOG1HAS21jxyg1Q0/J/tpREuYLfatGdGmXp/3yS0ZA76kOlVq9Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-react-jsx-self": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.27.1.tgz", @@ -796,6 +871,44 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-react-pure-annotations": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.27.1.tgz", + "integrity": "sha512-JfuinvDOsD9FVMTHpzA/pBLisxpv1aSf+OIV8lgH3MuWrks19R27e6a6DipIg4aX1Zm9Wpb04p8wljfKrVSnPA==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-react": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.28.5.tgz", + "integrity": "sha512-Z3J8vhRq7CeLjdC58jLv4lnZ5RKFUJWqH5emvxmv9Hv3BD1T9R/Im713R4MTKwvFaV74ejZ3sM01LyEKk4ugNQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-validator-option": "^7.27.1", + "@babel/plugin-transform-react-display-name": "^7.28.0", + "@babel/plugin-transform-react-jsx": "^7.27.1", + "@babel/plugin-transform-react-jsx-development": "^7.27.1", + "@babel/plugin-transform-react-pure-annotations": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/runtime": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", @@ -846,6 +959,35 @@ "node": ">=6.9.0" } }, + "node_modules/@capacitor-mlkit/barcode-scanning": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@capacitor-mlkit/barcode-scanning/-/barcode-scanning-8.0.1.tgz", + "integrity": "sha512-94SyxzbcQ2HBd7yxS34dqc0PzwdOw8/98xBrjw1ioznE/Ksky/iwsip5Bm8P8Qg+dgnJYWz7NcIPjd+6bLjVoQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/capawesome-team/" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/capawesome" + } + ], + "license": "Apache-2.0", + "peerDependencies": { + "@capacitor/core": ">=8.0.0" + } + }, + "node_modules/@capacitor/core": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-8.1.0.tgz", + "integrity": "sha512-UfMBMWc1v7J+14AhH03QmeNwV3HZx3qnOWhpwnHfzALEwAwlV/itQOQqcasMQYhOHWL0tiymc5ByaLTn7KKQxw==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/@dnd-kit/accessibility": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.1.tgz", @@ -1479,6 +1621,30 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, "node_modules/@eslint/eslintrc/node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -1769,7 +1935,6 @@ "version": "2.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", - "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" @@ -2803,6 +2968,381 @@ } } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.58.0.tgz", + "integrity": "sha512-mr0tmS/4FoVk1cnaeN244A/wjvGDNItZKR8hRhnmCzygyRXYtKF5jVDSIILR1U97CTzAYmbgIj/Dukg62ggG5w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.58.0.tgz", + "integrity": "sha512-+s++dbp+/RTte62mQD9wLSbiMTV+xr/PeRJEc/sFZFSBRlHPNPVaf5FXlzAL77Mr8FtSfQqCN+I598M8U41ccQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.58.0.tgz", + "integrity": "sha512-MFWBwTcYs0jZbINQBXHfSrpSQJq3IUOakcKPzfeSznONop14Pxuqa0Kg19GD0rNBMPQI2tFtu3UzapZpH0Uc1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.58.0.tgz", + "integrity": "sha512-yiKJY7pj9c9JwzuKYLFaDZw5gma3fI9bkPEIyofvVfsPqjCWPglSHdpdwXpKGvDeYDms3Qal8qGMEHZ1M/4Udg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.58.0.tgz", + "integrity": "sha512-x97kCoBh5MOevpn/CNK9W1x8BEzO238541BGWBc315uOlN0AD/ifZ1msg+ZQB05Ux+VF6EcYqpiagfLJ8U3LvQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.58.0.tgz", + "integrity": "sha512-Aa8jPoZ6IQAG2eIrcXPpjRcMjROMFxCt1UYPZZtCxRV68WkuSigYtQ/7Zwrcr2IvtNJo7T2JfDXyMLxq5L4Jlg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.58.0.tgz", + "integrity": "sha512-Ob8YgT5kD/lSIYW2Rcngs5kNB/44Q2RzBSPz9brf2WEtcGR7/f/E9HeHn1wYaAwKBni+bdXEwgHvUd0x12lQSA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.58.0.tgz", + "integrity": "sha512-K+RI5oP1ceqoadvNt1FecL17Qtw/n9BgRSzxif3rTL2QlIu88ccvY+Y9nnHe/cmT5zbH9+bpiJuG1mGHRVwF4Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.58.0.tgz", + "integrity": "sha512-T+17JAsCKUjmbopcKepJjHWHXSjeW7O5PL7lEFaeQmiVyw4kkc5/lyYKzrv6ElWRX/MrEWfPiJWqbTvfIvjM1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.58.0.tgz", + "integrity": "sha512-cCePktb9+6R9itIJdeCFF9txPU7pQeEHB5AbHu/MKsfH/k70ZtOeq1k4YAtBv9Z7mmKI5/wOLYjQ+B9QdxR6LA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.58.0.tgz", + "integrity": "sha512-iekUaLkfliAsDl4/xSdoCJ1gnnIXvoNz85C8U8+ZxknM5pBStfZjeXgB8lXobDQvvPRCN8FPmmuTtH+z95HTmg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.58.0.tgz", + "integrity": "sha512-68ofRgJNl/jYJbxFjCKE7IwhbfxOl1muPN4KbIqAIe32lm22KmU7E8OPvyy68HTNkI2iV/c8y2kSPSm2mW/Q9Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.58.0.tgz", + "integrity": "sha512-dpz8vT0i+JqUKuSNPCP5SYyIV2Lh0sNL1+FhM7eLC457d5B9/BC3kDPp5BBftMmTNsBarcPcoz5UGSsnCiw4XQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.58.0.tgz", + "integrity": "sha512-4gdkkf9UJ7tafnweBCR/mk4jf3Jfl0cKX9Np80t5i78kjIH0ZdezUv/JDI2VtruE5lunfACqftJ8dIMGN4oHew==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.58.0.tgz", + "integrity": "sha512-YFS4vPnOkDTD/JriUeeZurFYoJhPf9GQQEF/v4lltp3mVcBmnsAdjEWhr2cjUCZzZNzxCG0HZOvJU44UGHSdzw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.58.0.tgz", + "integrity": "sha512-x2xgZlFne+QVNKV8b4wwaCS8pwq3y14zedZ5DqLzjdRITvreBk//4Knbcvm7+lWmms9V9qFp60MtUd0/t/PXPw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.58.0.tgz", + "integrity": "sha512-jIhrujyn4UnWF8S+DHSkAkDEO3hLX0cjzxJZPLF80xFyzyUIYgSMRcYQ3+uqEoyDD2beGq7Dj7edi8OnJcS/hg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.58.0.tgz", + "integrity": "sha512-+410Srdoh78MKSJxTQ+hZ/Mx+ajd6RjjPwBPNd0R3J9FtL6ZA0GqiiyNjCO9In0IzZkCNrpGymSfn+kgyPQocg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.58.0.tgz", + "integrity": "sha512-ZjMyby5SICi227y1MTR3VYBpFTdZs823Rs/hpakufleBoufoOIB6jtm9FEoxn/cgO7l6PM2rCEl5Kre5vX0QrQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.58.0.tgz", + "integrity": "sha512-ds4iwfYkSQ0k1nb8LTcyXw//ToHOnNTJtceySpL3fa7tc/AsE+UpUFphW126A6fKBGJD5dhRvg8zw1rvoGFxmw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.58.0.tgz", + "integrity": "sha512-fd/zpJniln4ICdPkjWFhZYeY/bpnaN9pGa6ko+5WD38I0tTqk9lXMgXZg09MNdhpARngmxiCg0B0XUamNw/5BQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.58.0.tgz", + "integrity": "sha512-YpG8dUOip7DCz3nr/JUfPbIUo+2d/dy++5bFzgi4ugOGBIox+qMbbqt/JoORwvI/C9Kn2tz6+Bieoqd5+B1CjA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.58.0.tgz", + "integrity": "sha512-b9DI8jpFQVh4hIXFr0/+N/TzLdpBIoPzjt0Rt4xJbW3mzguV3mduR9cNgiuFcuL/TeORejJhCWiAXe3E/6PxWA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.58.0.tgz", + "integrity": "sha512-CSrVpmoRJFN06LL9xhkitkwUcTZtIotYAF5p6XOR2zW0Zz5mzb3IPpcoPhB02frzMHFNo1reQ9xSF5fFm3hUsQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.58.0.tgz", + "integrity": "sha512-QFsBgQNTnh5K0t/sBsjJLq24YVqEIVkGpfN2VHsnN90soZyhaiA9UUHufcctVNL4ypJY0wrwad0wslx2KJQ1/w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, "node_modules/@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -2936,6 +3476,33 @@ "react": "^18 || ^19" } }, + "node_modules/@tanstack/react-virtual": { + "version": "3.13.18", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.13.18.tgz", + "integrity": "sha512-dZkhyfahpvlaV0rIKnvQiVoWPyURppl6w4m9IwMDpuIjcJ1sD9YGWrt0wISvgU7ewACXx2Ct46WPgI6qAD4v6A==", + "license": "MIT", + "dependencies": { + "@tanstack/virtual-core": "3.13.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/virtual-core": { + "version": "3.13.18", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.13.18.tgz", + "integrity": "sha512-Mx86Hqu1k39icq2Zusq+Ey2J6dDWTjDvEv43PJtRCoEYTLyfaPnxIQ6iy7YAOK0NV/qOEmZQ/uCufrppZxTgcg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -3119,6 +3686,12 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==" }, + "node_modules/@types/offscreencanvas": { + "version": "2019.7.3", + "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", + "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==", + "license": "MIT" + }, "node_modules/@types/pako": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz", @@ -3263,6 +3836,28 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, + "node_modules/@zxing/library": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.21.3.tgz", + "integrity": "sha512-hZHqFe2JyH/ZxviJZosZjV+2s6EDSY0O24R+FQmlWZBZXP9IqMo7S3nb3+2LBWxodJQkSurdQGnqE7KXqrYgow==", + "license": "MIT", + "dependencies": { + "ts-custom-error": "^3.2.1" + }, + "engines": { + "node": ">= 10.4.0" + }, + "optionalDependencies": { + "@zxing/text-encoding": "~0.9.0" + } + }, + "node_modules/@zxing/text-encoding": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", + "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", + "license": "(Unlicense OR Apache-2.0)", + "optional": true + }, "node_modules/acorn": { "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", @@ -3293,18 +3888,16 @@ } }, "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha512-Ajr4IcMXq/2QmMkEmSvxqfLN5zGmJ92gHXAeOXq1OekoH2rfDNsgdDoL2f7QaRCy7G/E6TpxBVdRuNraMztGHw==", + "license": "MIT", + "peer": true, "dependencies": { - "fast-deep-equal": "^3.1.1", + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" + "json-schema-traverse": "^0.3.0" } }, "node_modules/ajv-formats": { @@ -3346,6 +3939,13 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true }, + "node_modules/ajv/node_modules/fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha512-fueX787WZKCV0Is4/T2cyAdM4+x1S3MXXOAhavE1ys/W42SHAPacLTQhucja22QBYrfGw50M2sRiXPtTGv9Ymw==", + "license": "MIT", + "peer": true + }, "node_modules/align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -3363,6 +3963,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==", + "license": "BSD-3-Clause OR MIT", "engines": { "node": ">=0.4.2" } @@ -3418,6 +4019,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -3426,6 +4028,7 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -3888,7 +4491,6 @@ "version": "2.9.18", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.18.tgz", "integrity": "sha512-e23vBV1ZLfjb9apvfPk4rHVu2ry6RIr2Wfs+O324okSidrX7pTAnEJPCh/O5BtRlr7QtZI7ktOP3vsqr7Z5XoA==", - "dev": true, "bin": { "baseline-browser-mapping": "dist/cli.js" } @@ -4086,7 +4688,6 @@ "version": "4.28.1", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", - "dev": true, "funding": [ { "type": "opencollective", @@ -4268,7 +4869,6 @@ "version": "1.0.30001766", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001766.tgz", "integrity": "sha512-4C0lfJ0/YPjJQHagaE9x2Elb69CIqEPZeG0anQt9SIvIoOH4a4uaRl73IavyO+0qZh6MDLH//DrXThEYKHkmYA==", - "dev": true, "funding": [ { "type": "opencollective", @@ -4358,6 +4958,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", + "license": "MIT", "dependencies": { "ansi-styles": "^2.2.1", "escape-string-regexp": "^1.0.2", @@ -4476,6 +5077,17 @@ "node": ">=6" } }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "license": "MIT", + "peer": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, "node_modules/codepage": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", @@ -5335,8 +5947,7 @@ "node_modules/electron-to-chromium": { "version": "1.5.279", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.279.tgz", - "integrity": "sha512-0bblUU5UNdOt5G7XqGiJtpZMONma6WAfq9vsFmtn9x1+joAObr6x1chfqyxFSDCAFwFhCQDrqeAr6MYdpwJ9Hg==", - "dev": true + "integrity": "sha512-0bblUU5UNdOt5G7XqGiJtpZMONma6WAfq9vsFmtn9x1+joAObr6x1chfqyxFSDCAFwFhCQDrqeAr6MYdpwJ9Hg==" }, "node_modules/electron/node_modules/@types/node": { "version": "16.18.126", @@ -5628,7 +6239,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, "engines": { "node": ">=6" } @@ -5807,6 +6417,23 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/eslint/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -5898,6 +6525,13 @@ "node": ">=8" } }, + "node_modules/eslint/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, "node_modules/eslint/node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -6229,7 +6863,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", @@ -6397,6 +7032,20 @@ "uglify-js": "^2.6.2" } }, + "node_modules/fmin/node_modules/rollup": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.25.8.tgz", + "integrity": "sha512-a2S4Bh3bgrdO4BhKr2E4nZkjTvrJ2m2bWjMTzVYtoqSCn0HnuxosXnaJUHrMEziOWr3CzL9GjilQQKcyCQpJoA==", + "license": "MIT", + "dependencies": { + "chalk": "^1.1.1", + "minimist": "^1.2.0", + "source-map-support": "^0.3.2" + }, + "bin": { + "rollup": "bin/rollup" + } + }, "node_modules/follow-redirects": { "version": "1.15.11", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", @@ -6552,7 +7201,6 @@ "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -6816,6 +7464,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "license": "MIT", "dependencies": { "ansi-regex": "^2.0.0" }, @@ -8028,9 +8677,11 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" }, "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha512-4JD/Ivzg7PoW8NzdrBSr3UFwC9mHgvI7Z6z3QGBsSHgKaRTUDmyZAAKJo2UbG1kUVfS9WS8bi36N49U1xw43DA==", + "license": "MIT", + "peer": true }, "node_modules/json-schema-typed": { "version": "8.0.2", @@ -8073,7 +8724,6 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, "bin": { "json5": "lib/cli.js" }, @@ -8795,8 +9445,7 @@ "node_modules/node-releases": { "version": "2.0.27", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", - "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", - "dev": true + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==" }, "node_modules/normalize-path": { "version": "3.0.0", @@ -9455,10 +10104,21 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", "engines": { "node": ">=6" } }, + "node_modules/qr-scanner": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/qr-scanner/-/qr-scanner-1.4.2.tgz", + "integrity": "sha512-kV1yQUe2FENvn59tMZW6mOVfpq9mGxGf8l6+EGaXUOd4RBOLg7tRC83OrirM5AtDvZRpdjdlXURsHreAOSPOUw==", + "license": "MIT", + "dependencies": { + "@types/offscreencanvas": "^2019.6.4" + } + }, "node_modules/qr.js": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/qr.js/-/qr.js-0.0.0.tgz", @@ -10940,16 +11600,49 @@ } }, "node_modules/rollup": { - "version": "0.25.8", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.25.8.tgz", - "integrity": "sha512-a2S4Bh3bgrdO4BhKr2E4nZkjTvrJ2m2bWjMTzVYtoqSCn0HnuxosXnaJUHrMEziOWr3CzL9GjilQQKcyCQpJoA==", + "version": "4.58.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.58.0.tgz", + "integrity": "sha512-wbT0mBmWbIvvq8NeEYWWvevvxnOyhKChir47S66WCxw1SXqhw7ssIYejnQEVt7XYQpsj2y8F9PM+Cr3SNEa0gw==", + "dev": true, + "license": "MIT", + "peer": true, "dependencies": { - "chalk": "^1.1.1", - "minimist": "^1.2.0", - "source-map-support": "^0.3.2" + "@types/estree": "1.0.8" }, "bin": { - "rollup": "bin/rollup" + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.58.0", + "@rollup/rollup-android-arm64": "4.58.0", + "@rollup/rollup-darwin-arm64": "4.58.0", + "@rollup/rollup-darwin-x64": "4.58.0", + "@rollup/rollup-freebsd-arm64": "4.58.0", + "@rollup/rollup-freebsd-x64": "4.58.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.58.0", + "@rollup/rollup-linux-arm-musleabihf": "4.58.0", + "@rollup/rollup-linux-arm64-gnu": "4.58.0", + "@rollup/rollup-linux-arm64-musl": "4.58.0", + "@rollup/rollup-linux-loong64-gnu": "4.58.0", + "@rollup/rollup-linux-loong64-musl": "4.58.0", + "@rollup/rollup-linux-ppc64-gnu": "4.58.0", + "@rollup/rollup-linux-ppc64-musl": "4.58.0", + "@rollup/rollup-linux-riscv64-gnu": "4.58.0", + "@rollup/rollup-linux-riscv64-musl": "4.58.0", + "@rollup/rollup-linux-s390x-gnu": "4.58.0", + "@rollup/rollup-linux-x64-gnu": "4.58.0", + "@rollup/rollup-linux-x64-musl": "4.58.0", + "@rollup/rollup-openbsd-x64": "4.58.0", + "@rollup/rollup-openharmony-arm64": "4.58.0", + "@rollup/rollup-win32-arm64-msvc": "4.58.0", + "@rollup/rollup-win32-ia32-msvc": "4.58.0", + "@rollup/rollup-win32-x64-gnu": "4.58.0", + "@rollup/rollup-win32-x64-msvc": "4.58.0", + "fsevents": "~2.3.2" } }, "node_modules/rollup-plugin-obfuscator": { @@ -11434,6 +12127,7 @@ "version": "0.3.3", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.3.3.tgz", "integrity": "sha512-9O4+y9n64RewmFoKUZ/5Tx9IHIcXM6Q+RTSw6ehnqybUz4a7iwR3Eaw80uLtqqQ5D0C+5H03D4KKGo9PdP33Gg==", + "license": "MIT", "dependencies": { "source-map": "0.1.32" } @@ -11636,6 +12330,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "license": "MIT", "dependencies": { "ansi-regex": "^2.0.0" }, @@ -11702,6 +12397,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "license": "MIT", "engines": { "node": ">=0.8.0" } @@ -11999,6 +12695,15 @@ "resolved": "https://registry.npmjs.org/trim-canvas/-/trim-canvas-0.1.2.tgz", "integrity": "sha512-nd4Ga3iLFV94mdhW9JFMLpQbHUyCQuhFOD71PEAt1NjtMD5wbZctzhX8c3agHNybMR5zXD1XTGoIEWk995E6pQ==" }, + "node_modules/ts-custom-error": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.3.1.tgz", + "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -12272,7 +12977,6 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", - "dev": true, "funding": [ { "type": "opencollective", @@ -12378,6 +13082,8 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" } diff --git a/package.json b/package.json index 187784c..213d7b5 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "@ant-design/plots": "^1.2.6", "@autocomplete/material-ui": "0.0.17", + "@capacitor-mlkit/barcode-scanning": "^8.0.1", "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@emotion/react": "^11.11.4", @@ -23,6 +24,7 @@ "@tanstack/react-query": "^5.90.11", "@tanstack/react-query-devtools": "^5.91.1", "@tanstack/react-virtual": "^3.13.18", + "@zxing/library": "^0.21.3", "antd": "^5.17.4", "antd-img-crop": "^4.22.0", "aos": "^2.3.4", @@ -52,6 +54,7 @@ "mui-autocomplete": "^2.0.1", "number-to-words": "^1.2.4", "pdf-lib": "^1.17.1", + "qr-scanner": "^1.4.2", "qrcode": "^1.5.3", "qrcode.react": "^4.2.0", "react": "^18.3.1", diff --git a/src/Components/AddProduct/AddProduct.jsx b/src/Components/AddProduct/AddProduct.jsx index 6a1d6af..23bb908 100644 --- a/src/Components/AddProduct/AddProduct.jsx +++ b/src/Components/AddProduct/AddProduct.jsx @@ -53,6 +53,9 @@ export default function AddProduct({ products, setProducts }) { return (
+
+ Add Product +
diff --git a/src/Components/Modal/ProductDetailsModal.jsx b/src/Components/Modal/ProductDetailsModal.jsx index 4f377c0..16754f2 100644 --- a/src/Components/Modal/ProductDetailsModal.jsx +++ b/src/Components/Modal/ProductDetailsModal.jsx @@ -1,9 +1,11 @@ -import React from 'react'; +import React, { lazy } from 'react'; import { DefaultModal } from './DefaultModal'; -import StockReceived from '../../Pages/StockTransfer/StockReceived'; import Buttons from '../Forms/Buttons'; import { BiPlus } from 'react-icons/bi'; import { ArrowRightOutlined } from '@ant-design/icons'; +const StockReceived = lazy( + () => import('../../Pages/StockTransfer/StockReceived.jsx') +); const ProductDetailsModal = ({ open, @@ -11,7 +13,7 @@ const ProductDetailsModal = ({ productDetails, headerData, onDataChange, - onSubmit + onSubmit, }) => { return (
{headerData && ( -
-
Dispatch Id: {headerData.Dispatch_Id}
-
Date & Time: {headerData.dateTime}
-
From Branch: {headerData.fromBranch}
+
+
+ Dispatch Id:{' '} + + {' '} + {headerData.Dispatch_Id}{' '} + {' '} +
+
+ Date & Time:{' '} + {headerData.dateTime} +
+
+ From Branch:{' '} + + {' '} + {headerData.fromBranch}{' '} + {' '} +
{/*
dispatched By {headerData.Created_By}
*/}
)} @@ -43,12 +62,14 @@ const ProductDetailsModal = ({ editable={true} /> -
+
{ const renderCell = (column, row, index) => { if (column.render) { @@ -28,24 +28,32 @@ const ReceivedStocksModal = ({ className={'receive-stocks-modal'} > <> - - {!customTable &&
- - -
} - { - customTable && -
- + {!customTable && ( +
+ +
+ )} + {customTable && ( +
+
{columns.map((column) => ( - ))} @@ -53,9 +61,12 @@ const ReceivedStocksModal = ({ {tableData.map((row, index) => ( - + {columns.map((column) => ( - ))} @@ -64,13 +75,10 @@ const ReceivedStocksModal = ({
+ {column.title?.toUpperCase()}
+ {renderCell(column, row, index)}
- } - - + )} - ); }; -export default ReceivedStocksModal; \ No newline at end of file +export default ReceivedStocksModal; diff --git a/src/Features/BookingScreen/BookingData/BookingData.js b/src/Features/BookingScreen/BookingData/BookingData.js index 8626441..a8530a3 100644 --- a/src/Features/BookingScreen/BookingData/BookingData.js +++ b/src/Features/BookingScreen/BookingData/BookingData.js @@ -149,6 +149,16 @@ export const getConfigType = createAsyncThunk( } } ); +export const getConfigTypeBookingType = createAsyncThunk( + 'BookingData/getConfigTypeBookingType', + async ({ TypeName }) => { + if (TypeName != null && TypeName != undefined) { + return await axiosRetailInstanceData.get( + `/configMaster?TypeName=${TypeName}` + ); + } + } +); export const PostBookingData = createAsyncThunk( 'BookingData/PostBookingdata', async (postData) => { @@ -682,7 +692,6 @@ export const getSelectedFavItems = createAsyncThunk( if (fromDate) params.append('fromDate', fromDate); if (toDate) params.append('toDate', toDate); // let url = `/productCardList?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}&Type=A`; - return await axiosRetailInstanceData.get( `/productCardList?${params.toString()}` ); @@ -858,7 +867,6 @@ export const getCardDataWithoutSubmodule = createAsyncThunk( ? { fromDate: data?.fromDate, toDate: data?.toDate } : {}), }); - return await axiosRetailInstanceData.get( `/productCardList?${params.toString()}` ); @@ -1609,7 +1617,8 @@ const initialState = { salesBillEdit: false, previousOrderPayment: [], previousOrderOfferDetails: [], - getmultipleSearchDatas: [] + getmultipleSearchDatas: [], + AllBookingType: [], }; const BookingData = createSlice({ @@ -1981,6 +1990,13 @@ const BookingData = createSlice({ state.ItemCard = []; } }), + builder.addCase(getConfigTypeBookingType.fulfilled, (state, action) => { + if (action?.payload?.data?.statusCode === 1) { + state.AllBookingType = action?.payload?.data?.data; + } else { + state.AllBookingType = []; + } + }), builder.addCase(getLayoutsearch.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { state.ItemCard = action?.payload?.data?.data; @@ -2113,7 +2129,10 @@ const BookingData = createSlice({ }); builder.addCase(getmultipleSearch.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { - state.getmultipleSearchDatas = action?.payload?.data?.data[0]?.SearchTermDtl?.map((e) => e?.SearchTerm) || []; + state.getmultipleSearchDatas = + action?.payload?.data?.data[0]?.SearchTermDtl?.map( + (e) => e?.SearchTerm + ) || []; } else { state.getmultipleSearchDatas = []; } @@ -2220,7 +2239,7 @@ export const { triggerProductCard, changeBillEditingMode, changePreviousOrderPayment, - changePreviousOrderOfferDetail + changePreviousOrderOfferDetail, } = BookingData.actions; export const GlobalComboRedirectionToDefaultLayoutForParking = (state) => @@ -2389,13 +2408,14 @@ export const GlobalAddBookingDetailsTrigger = (state) => state?.BookingData?.AddBookingDetailsTrigger; export const GlobalCurrentOrderId = (state) => state?.BookingData?.CurrentOrderId; -export const GlobalSalesBillEdit = (state) => - state?.BookingData?.salesBillEdit; +export const GlobalSalesBillEdit = (state) => state?.BookingData?.salesBillEdit; export const GlobalPreviousOrderPayment = (state) => state?.BookingData?.previousOrderPayment; export const GlobalPreviousOrderOfferDetails = (state) => state?.BookingData?.previousOrderOfferDetails; export const GlobalGetmultipleSearchDatas = (state) => state?.BookingData?.getmultipleSearchDatas; +export const GlobalAllBookingType = (state) => + state?.BookingData?.AllBookingType; export default BookingData.reducer; diff --git a/src/Features/Payment/PaymentOptions/PaymentOptions.js b/src/Features/Payment/PaymentOptions/PaymentOptions.js index d73cade..bad66ed 100644 --- a/src/Features/Payment/PaymentOptions/PaymentOptions.js +++ b/src/Features/Payment/PaymentOptions/PaymentOptions.js @@ -77,7 +77,7 @@ export const putPaymentOptions = createAsyncThunk( } ); export const getPaymentUPIDetails = createAsyncThunk( - 'getPaymentGatewayDetails', + 'getPaymentGatewayDetails', async ({ CompId, AppId, BranchId, DetailType }) => { if ( CompId != undefined && diff --git a/src/Features/WholeSale/WholesaleData.js b/src/Features/WholeSale/WholesaleData.js index e2072d3..096b6a6 100644 --- a/src/Features/WholeSale/WholesaleData.js +++ b/src/Features/WholeSale/WholesaleData.js @@ -465,8 +465,8 @@ const WholesaleData = createSlice({ state.WholeSaleEntryList = action?.payload; }, changeWholeSaleSelectedEntryDtl: (state, action) => { - (state.WholeSaleSelectedEntryDtl = action?.payload), - (state.WholeSaleSelectedProdDtl = [action?.payload?.ProdDetails?.[0]]); + ((state.WholeSaleSelectedEntryDtl = action?.payload), + (state.WholeSaleSelectedProdDtl = [action?.payload?.ProdDetails?.[0]])); state.WholeSaleSelectedGradeDtl = [ action?.payload?.ProdDetails?.[0].GradeDetails?.[0], ]; @@ -513,7 +513,7 @@ const WholesaleData = createSlice({ }, }, extraReducers: (builder) => { - builder.addCase(getWholeSaleSupplier.fulfilled, (state, action) => { + (builder.addCase(getWholeSaleSupplier.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode == 1) { state.SupplierDetails = action?.payload?.data?.data; } else { @@ -636,7 +636,7 @@ const WholesaleData = createSlice({ } else { state.WSBookingStatus = []; } - }); + })); }, }); export const { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx index bcc150e..429e834 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall1.jsx @@ -1,11 +1,8 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, lazy, Suspense } from 'react'; import { useSelector } from 'react-redux'; import { Button, Popover } from 'antd'; import { AiOutlineClose } from 'react-icons/ai'; import { IoIosArrowUp } from 'react-icons/io'; -import BSBillingTable1 from '../BSBillingTable1/BSBillingTable1'; -import BST1Payment from '../BSBillingTable1/BST1Payment'; -import BSSummery from '../BSBillingTableSummery/BSSummery'; import { GlobalCustId, GlobalSelOption, @@ -14,13 +11,23 @@ import { GlobalOrderStatus, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBTOverall.scss'; -import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; -import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon'; 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'; +// jsx File +const BSBillingTable1 = lazy( + () => import('../BSBillingTable1/BSBillingTable1.jsx') +); +const BST1Payment = lazy(() => import('../BSBillingTable1/BST1Payment')); +const BSSummery = lazy(() => import('../BSBillingTableSummery/BSSummery')); +const FeaturesFunctionalities = lazy( + () => import('../../BookingFunctionality/FeaturesFunctionalities') +); +const BSCustomerSelect = lazy( + () => import('../../UtillComponents/BSSelectCustomer.jsx') +); export default function BSBTOverall1() { const [open, setOpen] = useState(false); @@ -73,7 +80,7 @@ export default function BSBTOverall1() { containerHeight = isMobile ? ExpDate <= 7 ? '490px' - : '475px' // billing table 1 height in POS + : '475px' // billing table 1 height in POS : ExpDate <= 7 ? '85vh' : ''; @@ -121,126 +128,132 @@ export default function BSBTOverall1() { }, [width]); return ( - <> -
- {width > 768 && } - {(addcustomer || hold) && ( - - )} -
- {width <= 768 && ( -
- {tableData && } -
+ Loading…
}> + <> +
+ {width > 768 && } + {(addcustomer || hold) && ( + )} -
- {summeryopen == true && ( -
- -
- )} - - - - - - - - ) - } - trigger="click" - open={open} - onOpenChange={handleOpenChange} - > - - -
-
- {tableOptions.find( - (item) => item.OptionName === 'AddCustomer' - ) && ( -
- - - - {' '} - - -
- )} -
-
- {tableData && ( +
+ {width <= 768 && (
- {width <= 768 && ( -
- -
- )} + {tableData && }
)} -
-
- +
+ {summeryopen == true && ( +
+ +
+ )} + + + + + + + + ) + } + trigger="click" + open={open} + onOpenChange={handleOpenChange} + > + + +
+
+ {tableOptions.find( + (item) => item.OptionName === 'AddCustomer' + ) && ( +
+ + + + {' '} + + +
+ )} +
+
+ {tableData && ( +
+ {width <= 768 && ( +
+ +
+ )} +
+ )} +
+
+ +
-
- + + ); } diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx index 4b15324..e4e1cbe 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx @@ -6,7 +6,6 @@ import WebFont from 'webfontloader'; import { isMobile } from 'react-device-detect'; import dineInIcon from '../../../../../Images/Dine In.svg'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; -import { settingDataSelector } from '../../../../../Features/PreferenceMaster/PreferenceMaster.js'; import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; import { ChangeTotalAmount, @@ -18,13 +17,10 @@ import { puttinghold, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { - ChangeOfferAppliedProducts, - ChangeFreeProductList, ChangeFullFreeProductList, GlobalFreeProdList, GlobalOfferAppliedProducts, changeFullOfferAppliedProducts, - changeLoyaltyConsumedQuantities, ClearOfferAppliedProducts, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; @@ -76,11 +72,17 @@ import { changePreviousOrderPayment, changePreviousOrderOfferDetail, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; -import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.scss'; import { useUtilsComponent } from '../../../../../Services/utils.js'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; +// Jsx Files +const BSEditTotalAmt = lazy( + () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') +); + +const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); +const CustomerPriceHistory = lazy( + () => import('../../UtillComponents/CustomerPriceHistory.jsx') +); // Scss File +import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.scss'; const BSBillingTable1 = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -142,7 +144,8 @@ const BSBillingTable1 = () => { const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); const tableDataDinein = tableData?.filter( @@ -152,8 +155,8 @@ const BSBillingTable1 = () => { 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 @@ -161,8 +164,8 @@ const BSBillingTable1 = () => { const OldtableDataTakeAway = OrderType != 'Hold' ? tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; const [OpenEditTotalAmt, setOpenEditTotalAmt] = useState(false); const [OpenImeiDetail, setOpenImeiDetail] = useState(false); @@ -320,7 +323,6 @@ const BSBillingTable1 = () => { event.preventDefault(); handleShortcut('weightAmount'); } - }; window.addEventListener('keydown', handleKeyDown); @@ -329,11 +331,6 @@ const BSBillingTable1 = () => { }; }, [preferenceshortcutkey, tableDataTakeAway, tableDataDinein, BillOrderPre]); - - - - - function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; @@ -347,7 +344,7 @@ const BSBillingTable1 = () => { const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; const getstockbadge = async () => { let data = { @@ -1133,9 +1130,9 @@ const BSBillingTable1 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1855,7 +1852,6 @@ const BSBillingTable1 = () => { insideinwardDtlId: false, }); } else { - let data = isCheckFreeProductOutside?.FreeQty - item?.OrderQty; //First i Calculate Another Booking Type Qty let anotherBookingType = tableData?.find( (e) => @@ -1870,21 +1866,6 @@ const BSBillingTable1 = () => { 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 @@ -2042,145 +2023,7 @@ const BSBillingTable1 = () => { } } } - }; - // 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(changeAllProductTokenAvailable(false)); - // 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)); - // } - // await dispatch(ChangeTotalAmount([])); - // 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([])); - // } - // } - // }; const OpenEditTotalAmount = () => { setOpenEditTotalAmt(true); @@ -2190,195 +2033,211 @@ const BSBillingTable1 = () => { }; return ( - <> -
-
- - - - {tableOptions?.map((item) => ( - <> - {item.OptionName == 'Sl.No' && BookingTypeBoth && ( - - )} - {item.OptionName == 'Sl.No' && ( - - )} - {item.OptionName == 'Item' && ( - - )} - {item.OptionName == 'MRP' && ( - - )} - {item.OptionName == 'Discount' && ( - - )} - {item.OptionName == 'Quantity' && ( - - )} - {item.OptionName == 'Rate' && ( - - )} - {item.OptionName == 'Amount' && ( - - )} + Loading…}> + <> +
+
+
- {!isMobile ? ( - {''} - ) : ( -
{''}
- )} -
- {!isMobile ? ( - Sl.No - ) : ( -
Sl.No
- )} -
- {!isMobile ? ( - Item - ) : ( -
Item
- )} -
- {!isMobile ? ( - MRP - ) : ( -
MRP
- )} -
- {!isMobile ? ( - ₹/% - ) : ( -
₹/%
- )} -
{ - if (tableData?.length > 0) { - OpenEditTotalAmount(); - } - }} - // onClick={tableData?.length>0? OpenEditTotalAmount :""} - > - {!isMobile ? ( - Qty - ) : ( -
Qty
- )} -
- {!isMobile ? ( - Rt - ) : ( -
Rt
- )} -
- {!isMobile ? ( - Amt - ) : ( -
Amt
- )} -
+ + + {tableOptions?.map((item) => ( + <> + {item.OptionName == 'Sl.No' && BookingTypeBoth && ( + + )} + {item.OptionName == 'Sl.No' && ( + + )} + {item.OptionName == 'Item' && ( + + )} + {item.OptionName == 'MRP' && ( + + )} + {item.OptionName == 'Discount' && ( + + )} + {item.OptionName == 'Quantity' && ( + + )} + {item.OptionName == 'Rate' && ( + + )} + {item.OptionName == 'Amount' && ( + + )} - {item.OptionName == 'Delete' && ( - - )} - - ))} - - - {OldtableDataTakeAway?.length > 0 && ( - - {OldtableDataTakeAway?.map((item, index) => ( - + )} + + ))} + + + {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)' - : triggerAnimation && + : 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 - ? 'wheat' - : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + 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 && ( + + )} + + )} + {OldtableDataDinein?.length > 0 && ( + + {OldtableDataDinein?.map((item, index) => ( + = PreviousdataLength ? 'wheat' - : 'inherit' - : 'none', - background: - item?.SalesId && OrderType !== 'Hold' + : 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' - : index % 2 === 0 + : (OldtableDataTakeAway?.length + 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 && ( - - )} - - )} - {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' && ( + 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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {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) => ( - removeFromCart(item)} + > + + + )} + + ))} + + ))} + {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 + 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' - : (OldtableDataDinein?.length + + : 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' - : (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 + 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' && ( + 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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {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) => ( - removeFromCart(item)} + > + + + )} + + ))} + + ))} + {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)' - : BookingType === 'Dine In' && - triggerAnimation && + : 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 - ? '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' && ( + !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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - {tableDataDinein?.length > 0 && EditQuantity && ( - - )} - + {tableitem.OptionName == 'Delete' && ( + + )} + + ))} + + ))} + {tableDataDinein?.length > 0 && EditQuantity && ( + + )} + + )} +
+ {!isMobile ? ( + {''} + ) : ( +
{''}
+ )} +
+ {!isMobile ? ( + Sl.No + ) : ( +
Sl.No
+ )} +
+ {!isMobile ? ( + Item + ) : ( +
Item
+ )} +
+ {!isMobile ? ( + MRP + ) : ( +
MRP
+ )} +
+ {!isMobile ? ( + ₹/% + ) : ( +
₹/%
+ )} +
{ + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + }} + // onClick={tableData?.length>0? OpenEditTotalAmount :""} + > + {!isMobile ? ( + Qty + ) : ( +
Qty
+ )} +
+ {!isMobile ? ( + Rt + ) : ( +
Rt
+ )} +
+ {!isMobile ? ( + Amt + ) : ( +
Amt
+ )} +
- {tableData?.length > 0 ? ( - { - Clearall(); - }} - > + {item.OptionName == 'Delete' && ( + + {tableData?.length > 0 ? ( + { + Clearall(); + }} + > +
+ {' '} + {!isMobile ? ( + + {' '} + {' '} + + ) : ( +
+ {' '} + {' '} +
+ )} +
+
+ ) : (
- {' '} {!isMobile ? ( - - {' '} - {' '} + + ) : (
@@ -2387,456 +2246,458 @@ const BSBillingTable1 = () => {
)}
- - ) : ( -
- {!isMobile ? ( - - - - ) : ( -
- {' '} - {' '} -
- )} -
- )} -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {index + 1} + + item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 + ? 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?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${item.OfferPrice}` + : `${item.OfferPrice}%` + : '-'} + { + 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)} + > + +
- - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {index + 1} - - item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 - ? 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?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${item.OfferPrice}` - : `${item.OfferPrice}%` - : '-'} - { - 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)} - > - -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataTakeAway?.length + index + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataTakeAway?.length + index + 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.ProdName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

{ + 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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${item.OfferPrice}` - : `${item.OfferPrice}%` - : '-'} - { - 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 - )} - { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' + ? item.Offer && item.Offer > 0 + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${item.OfferPrice}` + : `${item.OfferPrice}%` + : '-'} + { + 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)} - > - -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index + + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index + - 1} - - item.FullProductIdentifierDtls?.length > 0 || + {tableitem.OptionName == 'Item' && ( + + item.FullProductIdentifierDtls?.length > 0 || item.ProductIdentifierDtls?.length > 0 - ? handleImeiDetails(item) - : editField && handleEditQuantity(item) - } - > - {item?.Type !== 'OS' - ? item.ProdName - : item.ServiceName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

+ {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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${item.OfferPrice}` - : `${item.OfferPrice}%` - : '-'} - { - 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 - )} - { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' + ? item.Offer && item.Offer > 0 + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${item.OfferPrice}` + : `${item.OfferPrice}%` + : '-'} + { + 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)} - > - -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataTakeAway?.length + + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index + + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index + - 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.ProdName} -  {' '} - {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

{ + 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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${item.OfferPrice}` - : `${item.OfferPrice}%` - : '-'} - { - 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 - )} - { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' + ? item.Offer && item.Offer > 0 + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${item.OfferPrice}` + : `${item.OfferPrice}%` + : '-'} + { + 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)} - > - -
removeFromCart(item)} + > + +
+ + {OpenEditTotalAmt && ( + )} - - - {OpenEditTotalAmt && ( - - )} - {OpenImeiDetail && ( - - )} - {(customerPriceHistoryOpen && GetCustId) && - - } + {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} +
-
- + + ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx index d7fba48..ebe8b68 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx @@ -2,10 +2,9 @@ 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, Popover, Modal, Tooltip } from 'antd'; +import { Badge, Modal, Tooltip } from 'antd'; import { Tables } from '../../../../../Components/Tables/Table'; import { DefaultModal } from '../../../../../Components/Modal/DefaultModal.jsx'; -import { UpOutlined } from '@ant-design/icons'; import paygate from '../../../../../Images/paygate.png'; import defaultupi from '../../../../../Images/defaultupi.png'; import paydevice from '../../../../../Images/paydevice.png'; @@ -42,8 +41,6 @@ import { changeReorderHoldDetails, ChangeNavHoldData, GlobalNavHoldData, - changeSummeryQty, - changeSummeryTotalItems, changeSummeryTotalAmount, changeSummeryTotalTaxAmount, changeSummeryTotalWithoutTaxAmount, @@ -126,6 +123,7 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; import { @@ -158,7 +156,6 @@ import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditC import { isMobile } from 'react-device-detect'; import MobilePrint from '../../BookingFunctionality/MobilePrint.jsx'; import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; -import { settingDataSelector } from '../../../../../Features/PreferenceMaster/PreferenceMaster.js'; import CountUp from 'react-countup'; import { GlobalpreOrderOpen } from '../../../../../Features/BookingScreen/PreOrder/PreOrder.js'; import SplitPayment from '../../BookingFunctionality/SplitPayment.jsx'; @@ -197,7 +194,6 @@ import BSOtherServiceClaim from '../../UtillComponents/BSOtherServiceClaim.jsx'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices.js'; import { TfiClipboard } from 'react-icons/tfi'; import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; -import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint.js'; import { PublicQrCodepost } from '../../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; import { ChangeFullFreeProductList, @@ -218,7 +214,6 @@ import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); -const RetailApiurl = import.meta.env.ENV_API_URL; export default function BST1Payment() { const isF4Pressed = useRef(false); @@ -246,7 +241,9 @@ export default function BST1Payment() { const navigate = useNavigate(); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const Discount = useSelector(GlobalOverAllOfferAmt); const defaultBookingType = useSelector(GlobalDefaultBookingType); @@ -281,7 +278,6 @@ export default function BST1Payment() { const GlobEstBooking = useSelector(GlobalEstimateBooking); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); const preOrder = useSelector(GlobalpreOrderOpen); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail, shallowEqual); const prodCat = useSelector(GlobalProductCategorie); const ProdSubCat = useSelector(GlobalProductSubCategorie); const templateData = useSelector(getTemplateData); @@ -292,6 +288,7 @@ export default function BST1Payment() { const SettingDataSelector = useSelector(PreferenceData); const unpaidFlow = useSelector(Globalunpaidflow); const appPreferences = useSelector(ApplicationPreferences); + const AllBookingType = useSelector(GlobalAllBookingType); const bookingTypePreference = appPreferences?.find( (preference) => preference?.PreferredCatName === 'Booking Type' )?.PreferenceCatDetails; @@ -321,8 +318,6 @@ export default function BST1Payment() { const AppId = SessionData?.AppId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; // for customised invoice number const { invoiceDate, clearInvoiceDate } = useDateStore(); const CurrentOrderId = useSelector(GlobalCurrentOrderId); @@ -341,7 +336,7 @@ export default function BST1Payment() { const [refundPaySelectedName, setRefundPaySelectedName] = useState(null); const [currentOrderNetAmount, setCurrentOrderNetAmount] = useState(0); const [previousNetAmount, setPreviousNetAmount] = useState(0); - console.log(currentOrderNetAmount, 'currentOrderNetAmount', previousNetAmount, salesBillEdit); + const [addcustomer, setAddCustomer] = useState(false); const [PrintOrderDetails, setPrintOrderDetails] = useState([]); //Total calculation @@ -365,7 +360,7 @@ export default function BST1Payment() { (item) => item.SettingIdName == 'Estimation' ); const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); - const [ConfigDataList, setConfigDataList] = useState([]); + const [ConfigDataList, setConfigDataList] = useState(AllBookingType); const [OrderStatus, setOrderStatus] = useState(true); const CheckOrderType = OrderCardDetail?.filter( (a) => a?.BookingTypeName !== BookingType @@ -562,14 +557,21 @@ export default function BST1Payment() { const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -578,8 +580,7 @@ export default function BST1Payment() { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; + const previousNetAmount = totalPreviouspayment || 0; // let withdiscTotal = Total - ((OverAllSales || 0) + (OverAllEstimate || 0)); let withdiscTotal = @@ -592,13 +593,26 @@ export default function BST1Payment() { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); - + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); @@ -628,14 +642,17 @@ export default function BST1Payment() { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // alert("hih") + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); //mohan stoped data useEffect(() => { if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); + if (holdCheckedSalesSetup) { + getHolddata(); + } + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -668,7 +685,6 @@ export default function BST1Payment() { }, [salesBillEdit]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -683,8 +699,7 @@ export default function BST1Payment() { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); useEffect(() => { let hasAccess = false; @@ -712,10 +727,7 @@ export default function BST1Payment() { setEmpData(datas?.[0]); }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); - await dispatch( + await dispatch( getAddCustomerDetails({ CompId: CompId, AppId: AppId, @@ -892,7 +904,7 @@ export default function BST1Payment() { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1246,8 +1258,9 @@ export default function BST1Payment() { await Promise.all( PrintOrderDetails?.[0]?.OrderDetails?.map( async (orderDetail, index) => { - const groupedTokens = orderDetail?.productDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.reduce( - (acc, item, idx) => { + const groupedTokens = orderDetail?.productDetails + ?.filter((data) => data?.EditTokenAvailable !== 'N') + ?.reduce((acc, item, idx) => { if (item.TokenAvailable === 'Y') { if (!item.CounterName) { // If CounterName is null or empty @@ -1260,9 +1273,7 @@ export default function BST1Payment() { } } return acc; - }, - {} - ); + }, {}); // Iterate over grouped tokens and print them const tokensToPrint = Object.entries(groupedTokens).map( @@ -1327,7 +1338,11 @@ export default function BST1Payment() { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1523,9 +1538,9 @@ export default function BST1Payment() { setPaybtnselected(PaymentOptionsModeId); }, [PaymentOptions]); - useEffect(() => { - getBookingTypeId(); - }, [BookingType]); + // useEffect(() => { + // getBookingTypeId(); + // }, [BookingType]); const getHolddata = async () => { const data = { CompId: CompId, BranchId: BranchId, AppId: AppId }; @@ -1607,7 +1622,7 @@ export default function BST1Payment() { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -1831,7 +1846,9 @@ export default function BST1Payment() { setUpinotSelected(false); setCurrentOrderNetAmount(0); setPreviousNetAmount(0); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -2008,15 +2025,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', @@ -2106,7 +2123,7 @@ export default function BST1Payment() { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2123,86 +2140,114 @@ export default function BST1Payment() { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) + : (Paybtnnameselected?.toLowerCase() === 'upi' && + 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') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -2270,14 +2315,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]); @@ -2434,14 +2479,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]); @@ -2542,14 +2587,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]); @@ -2724,14 +2769,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]); @@ -2749,7 +2794,7 @@ export default function BST1Payment() { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3300,8 +3345,10 @@ export default function BST1Payment() { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); const Otherserviceprint = async () => { if (OtherServicesPrintDetails?.length > 0) { @@ -3527,30 +3574,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) ? ( + {paybtns?.length > 0 && + currentOrderNetAmount >= previousNetAmount ? ( paybtns?.map((payment) => (
)) - ) : (currentOrderNetAmount < previousNetAmount && salesBillEdit && refundPayBtns.length > 0) ? ( + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( refundPayBtns.map((payment) => (
- - )} - {OtherServicesglobal && OrderCardDetail.length >= 1 && ( - - {' '} -
- + )) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => ( +
+
- + )) + ) : ( +
+ Please Set Payment Options +
)}
- )} -
- -
- - {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} - {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} -
- - - - - {/* - {" "} - - */} - - - } - trigger="click" - // width={1000} - open={open} - onOpenChange={handleOpenChange} - > - - -
-
-
- -
- -
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 -
- )} -
-
- {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 || + + {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 */} - {GetCustId && ( - - {' '} -
{ - 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={{ + ? 'gray' + : 'rgb(18, 146, 238)', fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', }} /> - + + )} + + )} +
+ ) : ( + '' + )} + + {/* Customer Orders */} + {GetCustId && ( + + {' '} +
{ + 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 -
- )} + )} + + + +
+ {UpiOpen && ( + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
- } - handleSubmit={() => { - Upimodel('Submit'); - }} - /> +
+ +
+ +
+

+ {' '} + 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} + + )} +
+ ); + })} +
+ ); + })} +
+
} /> - )} - {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); - }} + open={businessUPI} + handleCancel={() => setShowCancelConfirm(true)} 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 && ( - - )} - - { + 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)} + /> + + } /> - - {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/BSBillingTable3/BSBillingTable3.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx index 5703160..fe58020 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx @@ -10,16 +10,13 @@ import { ChangeTotalAmount, globalExtraTotalAmount, } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; import { changeholddata, gettinghold, puttinghold, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; import { getTemplateData, SelectedGlobalBillingColorDetail, @@ -80,6 +77,10 @@ import { 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'; const BSBillingTable3 = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -123,7 +124,6 @@ const BSBillingTable3 = () => { const UnpaidData = useSelector(GlobalUnpaidData); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); const ReportholdData = useSelector(GlobalReorderHoldDetails); - const salesBillEdit = useSelector(GlobalSalesBillEdit); const prodCat = useSelector(GlobalProductCategorie); const ProdSubCat = useSelector(GlobalProductSubCategorie); const [PreviousdataLength, setPreviousdataLength] = @@ -137,7 +137,8 @@ const BSBillingTable3 = () => { const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); const preferenceshortcutkey = preferenceDatas?.[0]?.[ 'SettingDtlDetails' @@ -154,16 +155,16 @@ const BSBillingTable3 = () => { 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([]); @@ -259,7 +260,6 @@ const BSBillingTable3 = () => { event.preventDefault(); handleShortcut('weightAmount'); } - }; window.addEventListener('keydown', handleKeyDown); @@ -389,7 +389,7 @@ const BSBillingTable3 = () => { const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; @@ -1057,9 +1057,9 @@ const BSBillingTable3 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1983,7 +1983,6 @@ const BSBillingTable3 = () => { } } } - }; // const removeFromCart = async (item) => { @@ -2395,10 +2394,11 @@ const BSBillingTable3 = () => { {OldtableDataTakeAway?.map((item, index) => ( { ? item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength + index === 0 && + !item?.SalesId && + tableDataTakeAway?.length >= PreviousdataLength ? 'wheat' : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + index === 0 && + tableDataTakeAway?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', @@ -2425,9 +2425,9 @@ const BSBillingTable3 = () => { item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : index % 2 === 0 ? 'white' @@ -2483,7 +2483,7 @@ const BSBillingTable3 = () => { style={{ fontFamily: 'Poppins' }} onClick={() => item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 + item.ProductIdentifierDtls?.length > 0 ? handleImeiDetails(item) : editField && handleEditQuantity(item) } @@ -2530,21 +2530,21 @@ const BSBillingTable3 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -2637,8 +2637,8 @@ const BSBillingTable3 = () => { > {allowDecimal ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2) : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} )} @@ -2673,10 +2673,11 @@ const BSBillingTable3 = () => { {OldtableDataDinein?.map((item, index) => ( { ? item?.SalesId ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && triggerAnimation && OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + !item?.SalesId && + tableDataDinein?.length >= 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + index) % 2 === 0 ? 'white' @@ -2807,21 +2808,21 @@ const BSBillingTable3 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -2914,8 +2915,8 @@ const BSBillingTable3 = () => { > {allowDecimal ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2) : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} )} @@ -2955,10 +2956,11 @@ const BSBillingTable3 = () => { OldtableDataTakeAway?.length + index } - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'BSBill-Table3-content-Disabled' - : 'BSBill-Table3-content' - } + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'BSBill-Table3-content-Disabled' + : 'BSBill-Table3-content' + } `} style={{ @@ -2969,38 +2971,38 @@ const BSBillingTable3 = () => { ? 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 + 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 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] : '#d6d6d6' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3009,15 +3011,15 @@ const BSBillingTable3 = () => { BookingType === 'Dine In' && item?.SalesId ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3026,9 +3028,9 @@ const BSBillingTable3 = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && + OldtableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataTakeAway?.length >= PreviousdataLength && !HoldOrderDtl && @@ -3077,7 +3079,7 @@ const BSBillingTable3 = () => { style={{ fontFamily: 'Poppins' }} onClick={() => item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 + item.ProductIdentifierDtls?.length > 0 ? handleImeiDetails(item) : editField && handleEditQuantity(item, index) } @@ -3131,21 +3133,21 @@ const BSBillingTable3 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -3239,8 +3241,8 @@ const BSBillingTable3 = () => { > {allowDecimal ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2) : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} )} @@ -3280,10 +3282,11 @@ const BSBillingTable3 = () => { tableDataTakeAway?.length + index } - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'BSBill-Table3-content-Disabled' - : 'BSBill-Table3-content' - } + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'BSBill-Table3-content-Disabled' + : 'BSBill-Table3-content' + } `} style={{ @@ -3296,44 +3299,44 @@ const BSBillingTable3 = () => { !BookingTypeBoth ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && triggerAnimation && OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && + !item?.SalesId && + tableDataDinein?.length >= 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 + item?.SalesId && + !BookingTypeBoth ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3342,10 +3345,10 @@ const BSBillingTable3 = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataDinein?.length >= PreviousdataLength && !HoldOrderDtl && @@ -3441,21 +3444,21 @@ const BSBillingTable3 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -3548,8 +3551,8 @@ const BSBillingTable3 = () => { > {allowDecimal ? Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2) + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2) : Number(item?.TotalAmt - (item?.Offer || 0) || 0)} )} @@ -3592,7 +3595,7 @@ const BSBillingTable3 = () => { ProductDetail={Modaldata} /> )} - {(customerPriceHistoryOpen && GetCustId) && + {customerPriceHistoryOpen && GetCustId && ( { setCustomerProduct={setCustomerProduct} selectedCustomer={selectedCustomer} /> - } + )} ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx index 116745e..c02f6e7 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3pay.jsx @@ -1,4 +1,11 @@ -import React, { useCallback, useEffect, useState, useRef } from 'react'; +import React, { + useCallback, + useEffect, + useState, + useRef, + lazy, + Suspense, +} from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; @@ -6,17 +13,12 @@ import { BiRightArrowAlt } from 'react-icons/bi'; import { AiOutlineClose } from 'react-icons/ai'; import { Tables } from '../../../../../Components/Tables/Table'; import { DefaultModal } from '../../../../../Components/Modal/DefaultModal.jsx'; -import { - UpCircleOutlined, - DownCircleOutlined, - UpOutlined, -} from '@ant-design/icons'; +import { UpCircleOutlined, DownCircleOutlined } from '@ant-design/icons'; import { Popover, Badge, Modal, Tooltip } from 'antd'; import { printDiv, extractLastNumberOrderId, encryptObject, - decryptToObject, } from '../../../../../Services/Others'; import { Messages } from '../../../../../Components/Notifications/Messages'; import BSBillingTable3 from './BSBillingTable3'; @@ -24,9 +26,9 @@ import paygate from '../../../../../Images/paygate.png'; import defaultupi from '../../../../../Images/defaultupi.png'; import pozologoimg from '../../../../../Images/pozologoimg.png'; import paydevice from '../../../../../Images/paydevice.png'; -import BSSummery1 from '../../BSBillingTables/BSBillingTableSummery/BSSummery'; -import QrComponent from '../../BookingFunctionality/DynamicQr.jsx'; -import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; +const BSSummery1 = lazy( + () => import('../../BSBillingTables/BSBillingTableSummery/BSSummery') +); import { ArrowRightOutlined } from '@ant-design/icons'; import Buttons from '../../../../../Components/Forms/Buttons'; import WpIcon from '../../../../../Images/message.png'; @@ -40,6 +42,15 @@ import { getPrinterMappingDetails, getPrintSelectionComponentData, } from '../../../../../Features/ThemeChange/ThemeChange'; +import { + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + changeLoyaltyConsumedQuantities, + GlobalFreeProdList, + GlobalOfferAppliedProducts, + GlobalOverAllOfferAmt, +} from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; + import { GlobalOrderCardDetails, changeOrderCardDetails, @@ -48,7 +59,6 @@ import { GlobalSelectedTableDetails, GlobalBookingType, changeBookingType, - getConfigType, PutBookingData, GlobalReorderHoldDetails, getUnpaidData, @@ -73,8 +83,6 @@ import { SendPaymentLink, changeSummeryTotalAmount, changeUpiIDprint, - changeSummeryTotalItems, - changeSummeryQty, changeSummeryTotalWithoutTaxAmount, changeSummeryTotalTaxAmount, GlobalEstimateBooking, @@ -113,7 +121,7 @@ import { GlobalOverAllDiscSales, ChangeOverAllDiscSales, ChangeOverAllDiscEstimate, - getAllCustomer, + // getAllCustomer, GlobalBranchFinancialStatus, changeSummeryComboOfferAmount, ChangeComboCarddata, @@ -124,13 +132,11 @@ import { changeOtherServiceTicketClaim, GlobalRetailWSSalesType, GlobalDefaultBookingType, - GlobalComboOfferAmount, GlobalPaymentTrigger, GlobalCurrentOrderId, changeCurrentOrderId, GlobalCombocarddata, getCreditCustomer, - GlobalSummeryTotalItems, GlobalSalesBillEdit, GlobalPreviousOrderPayment, GlobalPreviousOrderOfferDetails, @@ -140,17 +146,19 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import { PrintStyleFunction } from '../../../../paymentpdfPage/PrintStyleFunction.js'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; -import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; +const BSCustomerSelect = lazy( + () => import('../../UtillComponents/BSSelectCustomer.jsx') +); import { ChangeTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; import { gettinghold, globalholddata, changeholddata, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption'; -import PaymentPdfBooking from '../../../../paymentpdfPage/PaymentPdfBooking'; import { globalExtraTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges'; import { getAddCustomerDetails, @@ -160,18 +168,20 @@ import { triggerCustomerRefresh, } from '../../../../../Features/BookingScreen/Customer/addCustomer'; import PozoHoldIcon from '../../UtillComponents/Pozo retail icons/PozoHoldIcon'; -import PozoDineInIcon from '../../UtillComponents/Pozo retail icons/PozoDineIn.jsx'; import PozoUnpaidIcon from '../../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; import PozoBillIcon from '../../UtillComponents/Pozo retail icons/PozoBIllIcon.jsx'; import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; -import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditCustomer.jsx'; -import BSCreditCustomer from '../../UtillComponents/BSCreditCustomer.jsx'; +const BSCreditCustomer = lazy( + () => import('../../UtillComponents/BSCreditCustomer.jsx') +); import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; import { isMobile } from 'react-device-detect'; import MobilePrint from '../../BookingFunctionality/MobilePrint.jsx'; import CountUp from 'react-countup'; -import SplitPayment from '../../BookingFunctionality/SplitPayment.jsx'; import { GlobalpreOrderOpen } from '../../../../../Features/BookingScreen/PreOrder/PreOrder.js'; +const SplitPayment = lazy( + () => import('../../BookingFunctionality/SplitPayment.jsx') +); import TokensinglePrint from '../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx'; import SingleTokenMobilePrint from '../../BookingFunctionality/SingleTokenMobilePrint.jsx'; import IndividualTokenMobilePrint from '../../BookingFunctionality/IndividualTokenMobilePrint.jsx'; @@ -180,7 +190,6 @@ import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; import { Global_OverallOfferAmount } from '../../../../../Features/Offer/Offer.js'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; import { useAuth } from '../../../../../AuthContext.jsx'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTables3/BSBillingTable3.scss'; @@ -189,45 +198,65 @@ import { changeSalesPaymentoption, GlobalSalesPaymentoption, } from '../../../../../Features/Payment/Paymentoptions/Paymentoptions.js'; -import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions.jsx'; import { getPaymentOptionsData } from '../../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; import { getCombolist } from '../../../../../Features/ComboMaster/ComboMaster.js'; -import SMSShare from '../../../../WhatsAppShare/SmsShare.jsx'; -import WhatsAppShare from '../../../../WhatsAppShare/whatsAppShare.jsx'; import { MdSms } from 'react-icons/md'; import { FaWhatsapp, FaPrint, FaCartPlus } from 'react-icons/fa'; -import BSTipAmount from '../../UtillComponents/BSTipAmount.jsx'; import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices.js'; import { TfiClipboard } from 'react-icons/tfi'; -import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; -import BSOtherServiceClaim from '../../UtillComponents/BSOtherServiceClaim.jsx'; -import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint.js'; +const BSOtherServiceClaim = lazy( + () => import('../../UtillComponents/BSOtherServiceClaim.jsx') +); import { PublicQrCodepost } from '../../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; -import { - ChangeFreeProductList, - ChangeFullFreeProductList, - changeFullOfferAppliedProducts, - changeLoyaltyConsumedQuantities, - GlobalFreeProdList, - GlobalOfferAppliedProducts, - GlobalOverAllOfferAmt, -} from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import CardPopover from '../StandardTable/Utils/CardPopover.jsx'; import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; -import PaymentGatewayEmbedded from '../../UtillComponents/PaymentGatewayEmbedded.jsx'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; -import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; +const PaymentGatewayEmbedded = lazy( + () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') +); + +const CustomerOrders = lazy( + () => import('../../BookingFunctionality/CustomerOrders.jsx') +); +// jsx File +const QrComponent = lazy( + () => import('../../BookingFunctionality/DynamicQr.jsx') +); +const QrinScreen = lazy( + () => import('../../BookingFunctionality/DynamicScreenQr.jsx') +); +const PaymentPdfBooking = lazy( + () => import('../../../../paymentpdfPage/PaymentPdfBooking') +); +const PozoDineInIcon = lazy( + () => import('../../UtillComponents/Pozo retail icons/PozoDineIn.jsx') +); +const BsBillingCreditCustomer = lazy( + () => import('../../BookingFunctionality/BSBillingCreditCustomer.jsx') +); +const Paymentoption = lazy( + () => import('../../../../Payment/PaymentOptions/PaymentOptions.jsx') +); +const SMSShare = lazy(() => import('../../../../WhatsAppShare/SmsShare.jsx')); +const WhatsAppShare = lazy( + () => import('../../../../WhatsAppShare/whatsAppShare.jsx') +); +const BSTipAmount = lazy(() => import('../../UtillComponents/BSTipAmount.jsx')); +const OtherServicePrintStyle1 = lazy( + () => + import('../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); -const RetailApiurl = import.meta.env.ENV_API_URL; + const BSBillingTable3Pay = () => { const isF4Pressed = useRef(false); - const applyOffer = useApplyOfferto_CardDetail(); + const AllBookingType = useSelector(GlobalAllBookingType); const { SadminuserAccess } = useAuth(); let SAAccessCommonMaster = SadminuserAccess?.find( (e) => e?.MenuName === 'Sales' @@ -236,7 +265,9 @@ const BSBillingTable3Pay = () => { const navigate = useNavigate(); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const FreeProdList = useSelector(GlobalFreeProdList); const offerAppliedProducts = useSelector( @@ -289,15 +320,10 @@ const BSBillingTable3Pay = () => { const ProdSubCat = useSelector(GlobalProductSubCategorie); const BSLayoutData = useSelector(getTemplateData); const Combodata = useSelector(GlobalCombocarddata, shallowEqual); - const OfferCheckedInSetup = BSLayoutData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - ); + const Custdisable = useSelector(GlobalSelectedCustDisable); const SettingDataSelector = useSelector(PreferenceData); - const preferenceOffer = - SettingDataSelector?.[0]?.['SettingDtlDetails']?.find( - (item) => item.SettingIdName === 'Offer' - )?.SettingValue === 'Y'; + const allowDecimal = SettingDataSelector?.[0]?.SettingDtlDetails?.find( (setting) => setting?.SettingIdName?.toLowerCase() === 'decimal' && @@ -316,10 +342,7 @@ const BSBillingTable3Pay = () => { const preOrder = useSelector(GlobalpreOrderOpen); const OrderType = useSelector(GlobalOrderType); const FailedTotalAmt = useSelector(GlobalFailedTotalAmt); - const OrderOfferDetail = useSelector( - GlobalOfferAppliedProducts, - shallowEqual - ); + const tabledata = useSelector(GlobalUnpaidListData); const GlobalSalesPaymentoptions = useSelector(GlobalSalesPaymentoption); @@ -402,6 +425,10 @@ const BSBillingTable3Pay = () => { const [Splitpayment, setSplitpayment] = useState(false); const [urlData, setUrlData] = useState(); + const holdCheckedSalesSetup = tableOptions?.some( + (item) => item?.OptionName === 'Hold' + ); + const PaymentOptionsModeName = PaymentOptions?.find((e) => e.ModeDefault?.toUpperCase() === 'Y') ?.ModeName || PaymentOptions?.[0]?.ModeName; @@ -589,14 +616,21 @@ const BSBillingTable3Pay = () => { const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -605,8 +639,7 @@ const BSBillingTable3Pay = () => { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; + const previousNetAmount = totalPreviouspayment || 0; let withdiscTotal = Total - @@ -618,12 +651,26 @@ const BSBillingTable3Pay = () => { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); @@ -653,8 +700,8 @@ const BSBillingTable3Pay = () => { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); useEffect(() => { @@ -711,8 +758,11 @@ const BSBillingTable3Pay = () => { }; useEffect(() => { if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); + if (holdCheckedSalesSetup) { + getHolddata(); + } + + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -739,7 +789,6 @@ const BSBillingTable3Pay = () => { }, [salesBillEdit]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -754,8 +803,7 @@ const BSBillingTable3Pay = () => { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); useEffect(() => { if (UserType === 'Employee') { @@ -777,29 +825,6 @@ const BSBillingTable3Pay = () => { setaddnewAccess(!hasAccess); }, [empData, SAAccessCommonMaster, UserType]); - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); - const fetchApi = async () => { let data = { CompId: CompId, @@ -815,9 +840,9 @@ const BSBillingTable3Pay = () => { }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); + // await dispatch( + // getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) + // ); await dispatch( getAddCustomerDetails({ CompId: CompId, @@ -965,7 +990,7 @@ const BSBillingTable3Pay = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1044,8 +1069,10 @@ const BSBillingTable3Pay = () => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); const TokenPrint = async (index) => { try { @@ -1488,7 +1515,11 @@ const BSBillingTable3Pay = () => { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1700,20 +1731,12 @@ const BSBillingTable3Pay = () => { }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); + setConfigDataList(AllBookingType); + let configdata = AllBookingType; + let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - setSelectedBookingType(filterconfigdata?.ConfigId); - } + let filterconfigdata = configdata?.find((a) => a?.ConfigName === checkName); + setSelectedBookingType(filterconfigdata?.ConfigId); }; const gettodaydate = () => { @@ -1776,7 +1799,7 @@ const BSBillingTable3Pay = () => { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -1865,14 +1888,6 @@ const BSBillingTable3Pay = () => { setUpiOptionOpen(false); }; - const handlePopoverVisibleChange = (visible) => { - setUpiOptionOpen(visible); - }; - - const handlePopoverVisibleChangeCard = (visible) => { - setCardOptionOpen(visible); - }; - const ProductSummary = (salesData) => { const productMap = new Map(); @@ -2006,7 +2021,9 @@ const BSBillingTable3Pay = () => { setCurrentOrderNetAmount(0); setPreviousNetAmount(0); setUpinotSelected(false); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -2194,15 +2211,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', @@ -2294,7 +2311,7 @@ const BSBillingTable3Pay = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2311,85 +2328,113 @@ const BSBillingTable3Pay = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) + : (Paybtnnameselected?.toLowerCase() === 'upi' && + 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') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -2459,14 +2504,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]); @@ -2626,14 +2671,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]); @@ -2736,14 +2781,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]); @@ -2920,14 +2965,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]); @@ -2946,7 +2991,7 @@ const BSBillingTable3Pay = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3540,841 +3585,851 @@ const BSBillingTable3Pay = () => { ); }; return ( - <> -
- {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( - - )} -
- )} - -
- + Suspense Loading...
}> + <> +
{screenwidth <= 768 && (
{Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( -
handleResponsiveBill()} - className="Btn-responsiveBill" - style={{ color: responsiveBill ? '#52c41a' : '#1292ee' }} - > - {screenwidth <= 768 && ( -
- {' '} - {' '} -
- )} -
- )} + OrderCardDetail?.length >= 1 && }
)} -
- {(addcustomer || hold) && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- + +
+ + {screenwidth <= 768 && ( +
+ {Array.isArray(OrderCardDetail) && + OrderCardDetail?.length >= 1 && ( +
handleResponsiveBill()} + className="Btn-responsiveBill" + style={{ color: responsiveBill ? '#52c41a' : '#1292ee' }} + > + {screenwidth <= 768 && ( +
+ {' '} + {' '} +
+ )} +
+ )}
)} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( +
+ {(addcustomer || hold) && ( + + )} + {creditCustomerOpen && ( + + )} + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelectedUpiOption && ( +
+ +
+ )} + + {PaymentUpiOptions?.length > 0 && OrderId && (
)} - - {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 || + {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 && ( - - {' '} -
- -
-
- )} -
- )} - {/* Customer Orders */} - {GetCustId && ( - - - {' '} -
{ - 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 && - 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 && - paybtns?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - - HandleholdModelOpen()} - style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - - ) - : ''} - - ))} -
- )} - -
- - - - - - - - } - trigger="click" - open={open} - onOpenChange={handleOpenChange} - > - - -
- - {OtherServicesglobal && OrderCardDetail.length >= 1 && ( - - {' '} -
- -
-
- )} - -
-
-
-
- {tableOptions - .filter((item) => item.OptionName === 'AddCustomer') - .map((filteredItem) => ( - -
- - - - {' '} - - -
-
- ))} -
-
- -
-
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)} - /> - )} -
- )} -
- -
- - - -
-
-
- - - - - - - - - -
-

- Items :  -

-
- {TotalItems} -
-

- Qty :  -

-
- {' '} - {Qty} -
-
- {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} -
- {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - + ) : ( '' )} -
+ {paybtns?.length > 1 && ( +
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + width: '2rem', + }} + > + {!OtherServicesglobal && ( + + {' '} +
+ +
+
+ )} +
+ )} + {/* Customer Orders */} + {GetCustId && ( + + {' '} +
{ + 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 && + 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 && + paybtns?.length > 0 && + OrderCardDetail?.length == 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + {' '} + + HandleholdModelOpen()} + style={{ + fontSize: '28px', + cursor: 'pointer', + color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> + + + ) + : ''} + + ))} +
+ )} + +
- + } trigger="click" - open={open2} - onOpenChange={handleOpenChange2} + open={open} + onOpenChange={handleOpenChange} > - {!isMobile ? ( - - {!open2 ? ( - + +
+ + {OtherServicesglobal && OrderCardDetail.length >= 1 && ( + + {' '} +
+ +
+
+ )} + +
+
+
+
+ {tableOptions + .filter((item) => item.OptionName === 'AddCustomer') + .map((filteredItem) => ( + +
+ + + + {' '} + + +
+
+ ))} +
+
+ +
+
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) => ( +
+ +
+ )) ) : ( -
- {!open2 ? ( - { - handleOpenChange2; - }} - /> - ) : ( - { - handleOpenChange2; - }} - /> - )} +
+ 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)} + /> + )} +
+ )} +
+ +
+ + + +
+
+
+ + + + + + + + + +
+

+ 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 ? ( { /> )} */} -
+ +
-
- -
0 && - paybtnselected && - CheckBookingStatus != 'Close' - ? !OrderStatus ? salesBillEdit && (currentOrderNetAmount < previousNetAmount) ? - 'BSBillingTable3-paybtn' - : 'BSBillingTable3-paybtn' - : '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 - > - {!OrderStatus ? salesBillEdit && (currentOrderNetAmount < previousNetAmount) ?

Refund: ₹{(previousNetAmount || 0) - (currentOrderNetAmount || 0)}

: ( - <> -

- {' '} - {isMobile ? ( - `₹ ${safeRound( - OrderType === 'Failed' - ? FailedTotalAmt - : credit && overAllBal >= 0 - ? Math.max(0, TotalAmount - overAllBal) - : TotalAmount - )}` - ) : ( -

- ₹{' '} - +
0 && + paybtnselected && + CheckBookingStatus != 'Close' + ? !OrderStatus + ? salesBillEdit && + currentOrderNetAmount < previousNetAmount + ? 'BSBillingTable3-paybtn' + : 'BSBillingTable3-paybtn' + : '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 + > + {!OrderStatus ? ( + salesBillEdit && currentOrderNetAmount < previousNetAmount ? ( +

+ Refund: ₹ + {(previousNetAmount || 0) - (currentOrderNetAmount || 0)} +

+ ) : ( + <> +

+ {' '} + {isMobile ? ( + `₹ ${safeRound( OrderType === 'Failed' ? FailedTotalAmt : credit && overAllBal >= 0 ? Math.max(0, TotalAmount - overAllBal) : TotalAmount - )} - /> + )}` + ) : ( +

+ ₹{' '} + = 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + )} + /> +
+ )} +

+ +
+
- )} -

- -
- -
- - ) : ( -
ORDER
- )} -
- - {UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
-
-
- -
- -
-

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

-
-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text -
- )} - + + ) + ) : ( +
ORDER
+ )} +
+ + {UpiOpen && ( + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
- } - handleSubmit={() => { - Upimodel('Submit'); +
+ +
+ +
+

+ {' '} + 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'); - }} + } /> -
- )} + )} + {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 && ( + {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} + /> + )} + { - setUnpaidOpen(false); + dispatch(changeSalesPaymentoption(false)); }} footer={false} children={ -
- +
+
} /> - )} - {UnpaidConfirmation && ( - 0 && ( +
+ +
+ ) + // )) + } + + { + 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}`; + + // 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={ <> -
- 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} - /> - )} - - { - 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)} + } /> - )} - + {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/BSBillingTable4/BSBilling4Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx index 9cee205..67afd93 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx @@ -1,19 +1,28 @@ -import React, { useEffect, useState, useRef } from 'react'; +import React, { useEffect, useState, useRef, lazy, Suspense } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; import { Badge, Modal, Popover, Tooltip } from 'antd'; import { BiRightArrowAlt } from 'react-icons/bi'; import { AiOutlineClose } from 'react-icons/ai'; -import BSSummery from '../BSBillingTableSummery/BSSummery'; import BSBillingTable4 from './BSBillingTable4'; -import { UpCircleOutlined, UpOutlined } from '@ant-design/icons'; -import QrComponent from '../../BookingFunctionality/DynamicQr.jsx'; -import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; +import { UpCircleOutlined } from '@ant-design/icons'; +const BSSummery = lazy(() => import('../BSBillingTableSummery/BSSummery')); + +const QrComponent = lazy( + () => import('../../BookingFunctionality/DynamicQr.jsx') +); + +const QrinScreen = lazy( + () => import('../../BookingFunctionality/DynamicScreenQr.jsx') +); import { ArrowRightOutlined } from '@ant-design/icons'; import Buttons from '../../../../../Components/Forms/Buttons'; import WpIcon from '../../../../../Images/message.png'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.scss'; +import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTables3/BSBillingTable3.scss'; +import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.scss'; + import { GlobalSelectedFont, getTemplateData, @@ -22,11 +31,17 @@ import { GlobalprintDatas, GlobalPrinterMappingDtls, getPrinterMappingDetails, - getPrintSelectionComponentData, + // getPrintSelectionComponentData, } from '../../../../../Features/ThemeChange/ThemeChange'; -import SplitPayment from '../../BookingFunctionality/SplitPayment.jsx'; import { PrintStyleFunction } from '../../../../paymentpdfPage/PrintStyleFunction.js'; -import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; + +const SplitPayment = lazy( + () => import('../../BookingFunctionality/SplitPayment.jsx') +); + +const FeaturesFunctionalities = lazy( + () => import('../../BookingFunctionality/FeaturesFunctionalities') +); import { ChangeNavHoldData, GlobalBookingType, @@ -162,10 +177,18 @@ import PozoHoldIcon from '../../UtillComponents/Pozo retail icons/PozoHoldIcon'; import PozoDineInIcon from '../../UtillComponents/Pozo retail icons/PozoDineIn.jsx'; import PozoUnpaidIcon from '../../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; import PozoBillIcon from '../../UtillComponents/Pozo retail icons/PozoBIllIcon.jsx'; -import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; -import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditCustomer.jsx'; +const PozoAddCustomerIcon = lazy( + () => + import('../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx') +); + +const BsBillingCreditCustomer = lazy( + () => import('../../BookingFunctionality/BSBillingCreditCustomer.jsx') +); import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; -import BSCreditCustomer from '../../UtillComponents/BSCreditCustomer.jsx'; +const BSCreditCustomer = lazy( + () => import('../../UtillComponents/BSCreditCustomer.jsx') +); import { isMobile } from 'react-device-detect'; import MobilePrint from '../../BookingFunctionality/MobilePrint.jsx'; import CountUp from 'react-countup'; @@ -178,13 +201,9 @@ import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, Global_OrderOfferDetail, Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, } from '../../../../../Features/Offer/Offer.js'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; import { useAuth } from '../../../../../AuthContext.jsx'; import { GlobalBookingStatus } from '../../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; @@ -192,24 +211,24 @@ import { changeSalesPaymentoption, GlobalSalesPaymentoption, } from '../../../../../Features/Payment/Paymentoptions/Paymentoptions.js'; -import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions.jsx'; +const Paymentoption = lazy( + () => import('../../../../Payment/PaymentOptions/PaymentOptions.jsx') +); import { getPaymentOptionsData } from '../../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; import { getCombolist } from '../../../../../Features/ComboMaster/ComboMaster.js'; -import WhatsAppShare from '../../../../WhatsAppShare/whatsAppShare.jsx'; -import SMSShare from '../../../../WhatsAppShare/SmsShare.jsx'; +const WhatsAppShare = lazy( + () => import('../../../../WhatsAppShare/whatsAppShare.jsx') +); + +const SMSShare = lazy(() => import('../../../../WhatsAppShare/SmsShare.jsx')); import { MdSms } from 'react-icons/md'; import { FaWhatsapp, FaPrint, FaCartPlus } from 'react-icons/fa'; -import BSTipAmount from '../../UtillComponents/BSTipAmount.jsx'; +const BSTipAmount = lazy(() => import('../../UtillComponents/BSTipAmount.jsx')); import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices.js'; import { TfiClipboard } from 'react-icons/tfi'; -import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; -import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; -import BSOtherServiceClaim from '../../UtillComponents/BSOtherServiceClaim.jsx'; -import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint.js'; import { PublicQrCodepost } from '../../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; import { - ChangeFreeProductList, ChangeFullFreeProductList, changeFullOfferAppliedProducts, changeLoyaltyConsumedQuantities, @@ -220,15 +239,27 @@ import { import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; import CardPopover from '../StandardTable/Utils/CardPopover.jsx'; -import PaymentGatewayEmbedded from '../../UtillComponents/PaymentGatewayEmbedded.jsx'; import pozologoimg from '../../../../../Images/pozologoimg.png'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; -import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; +const PaymentGatewayEmbedded = lazy( + () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') +); +const CustomerOrders = lazy( + () => import('../../BookingFunctionality/CustomerOrders.jsx') +); // jsx File +const BSOtherServiceClaim = lazy( + () => import('../../UtillComponents/BSOtherServiceClaim.jsx') +); +const OtherServiceMobilePrint = lazy( + () => import('../../BookingFunctionality/OtherServiceMobilePrint.jsx') +); +const OtherServicePrintStyle1 = lazy( + () => + import('../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; - const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); const BSBilling4Payment = () => { @@ -241,7 +272,9 @@ const BSBilling4Payment = () => { const navigate = useNavigate(); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const FreeProdList = useSelector(GlobalFreeProdList); const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts); @@ -271,7 +304,6 @@ const BSBilling4Payment = () => { const GlobalExtraCharge = useSelector(globalExtraTotalAmount); const NavHoldData = useSelector(GlobalNavHoldData); const SettingDataSelector = useSelector(PreferenceData); - const BranchFinancialStatus = useSelector(GlobalBranchFinancialStatus); const RetailWSSalesType = useSelector(GlobalRetailWSSalesType); const appPreferences = useSelector(ApplicationPreferences); const bookingTypePreference = appPreferences?.find( @@ -282,10 +314,6 @@ const BSBilling4Payment = () => { type?.PreferredSubCatName?.toLowerCase() === 'dine in' && type?.PreferredStatus === 'Y' ); - const preferenceOffer = - SettingDataSelector?.[0]?.['SettingDtlDetails']?.find( - (item) => item.SettingIdName === 'Offer' - )?.SettingValue === 'Y'; const allowDecimal = SettingDataSelector?.[0]?.SettingDtlDetails?.find( (setting) => setting?.SettingIdName?.toLowerCase() === 'decimal' && @@ -305,9 +333,6 @@ const BSBilling4Payment = () => { const ProdSubCat = useSelector(GlobalProductSubCategorie); const templateData = useSelector(getTemplateData); const [urlData, setUrlData] = useState(); - const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - ); // for customised invoice number const { selectedDate, invoiceDate, clearInvoiceDate } = useDateStore(); @@ -339,8 +364,6 @@ const BSBilling4Payment = () => { const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; const [refundPayBtns, setRefundPayBtns] = useState([]); const [refundPaySelected, setRefundPaySelected] = useState(); const [refundPaySelectedName, setRefundPaySelectedName] = useState(null); @@ -485,8 +508,10 @@ const BSBilling4Payment = () => { ); const PrinterDetails = useSelector(GlobalPrinterMappingDtls); const [showCancelConfirm, setShowCancelConfirm] = useState(false); + const holdCheckedSalesSetup = tableOptions?.some( + (item) => item?.OptionName === 'Hold' + ); - console.log(PrinterDetails, 'PrinterDetailsPrinterDetails'); const filteredSettingNames = SettingDataSelector?.[0]?.['SettingDtlDetails'] ?.filter( (item) => @@ -521,7 +546,7 @@ const BSBilling4Payment = () => { }; dispatch(getPrinterMappingDetails(data)).unwrap(); const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); useEffect(() => { @@ -531,7 +556,6 @@ const BSBilling4Payment = () => { }, [salesBillEdit]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -546,8 +570,7 @@ const BSBilling4Payment = () => { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); useEffect(() => { const fetchCreditCustomer = async () => { @@ -648,14 +671,21 @@ const BSBilling4Payment = () => { const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -664,8 +694,7 @@ const BSBilling4Payment = () => { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; + const previousNetAmount = totalPreviouspayment || 0; let withdiscTotal = Total - @@ -677,12 +706,26 @@ const BSBilling4Payment = () => { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); @@ -1235,8 +1278,10 @@ const BSBilling4Payment = () => { }, [OrderCardDetail]); useEffect(() => { if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); + if (holdCheckedSalesSetup) { + getHolddata(); + } + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -1369,7 +1414,11 @@ const BSBilling4Payment = () => { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1680,7 +1729,7 @@ const BSBilling4Payment = () => { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -1899,7 +1948,9 @@ const BSBilling4Payment = () => { setCurrentOrderNetAmount(0); setPreviousNetAmount(0); setUpinotSelected(false); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -2201,78 +2252,106 @@ const BSBilling4Payment = () => { SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pd') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pd') - ? useOptions?.[0]?.PaymentDetails?.PaymentDevice + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg') || + SelectedUPIPayOption?.toLowerCase() === 'pd') || (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' + SelectedCardOption?.toLowerCase() === 'pd') + ? useOptions?.[0]?.PaymentDetails?.PaymentDevice + : (Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'pg') || + (Paybtnnameselected?.toLowerCase() === 'card' && + SelectedCardOption?.toLowerCase() === 'pg') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'cash' ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -3385,8 +3464,10 @@ const BSBilling4Payment = () => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); const Otherserviceprint = async () => { if (OtherServicesPrintDetails?.length > 0) { @@ -3541,202 +3622,483 @@ const BSBilling4Payment = () => { }; return ( -
-
-
- - {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && ( - - )} -
- )} - {/* {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( + Loading ...}> +
+
+
+ + {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 && ( -
- -
- )} - {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', + fontSize: '25px', color: - OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', + selOption || GetCustId + ? '#52c41a' + : '#1292EE', + cursor: Custdisable ? 'not-allowed' : 'pointer', }} /> - )} +
- )} + ))}
- ) : ( - '' - )} - {paybtns?.length > 1 && ( + + {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 && ( +
+ +
+ )} + {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 && ( + + {' '} +
+ +
+
+ )} + {/*
*/} +
+ )} + + {/* Customer Orders */} + {GetCustId && ( + + {' '} +
{ + 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 && + CheckOrderType?.length === 0 && + OrderType != 'Failed' && + paybtns?.length > 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + {' '} + AddBookingDetails('Hold')} + style={{ + fontSize: '30px', + cursor: 'pointer', + color: '' ? '#52c41a' : '#1292EE', + }} + /> + + ) + : ''} + {unpaidFlow == false + ? item?.OptionName == 'Hold' && + BookingType !== 'Dine In' && + !BookingTypeBoth && + Holddata?.length > 0 && + OrderCardDetail?.length == 0 && + paybtns?.length > 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + {' '} + + HandleholdModelOpen()} + style={{ + fontSize: '28px', + cursor: 'pointer', + color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' + ? 'none' + : 'auto', + }} + /> + + + ) + : ''} + + ))} +
+ )}
+
+ +
{ OrderStatus ? 0.5 : 1, - width: '2rem', }} > - {/* */} - {!OtherServicesglobal && ( - - {' '} -
- -
-
- )} - - {OtherServicesglobal && OrderCardDetail.length >= 1 && ( - - {' '} -
- -
-
- )} - {/*
*/} -
- )} - - {/* Customer Orders */} - {GetCustId && ( - - {' '} -
{ - 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 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - AddBookingDetails('Hold')} - style={{ - fontSize: '30px', - cursor: 'pointer', - color: '' ? '#52c41a' : '#1292EE', - }} - /> - - ) - : ''} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - - HandleholdModelOpen()} - style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - 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 && ( - UPI

} */} + +
+ {payment.ModeName} + {payment?.ModeName?.toLowerCase() === 'card' && ( + + )} + {payment?.ModeName?.toLowerCase() === 'upi' && ( + + )} +
+ +
+ )) + ) : 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)} + /> + )} +
+ )} +
- - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} -
- )} -
- - {/* {(selectCustomerDisplay === true || paymentModeDisplay === true) && ( + {/* {(selectCustomerDisplay === true || paymentModeDisplay === true) && (
)} */} -
-
-
-
- - - - - +
+
+
+
+
- Items: - - {TotalItems} -
+ + + + - - - - -
+ Items: + + {TotalItems} +
- Qty: - - {Qty} -
-
-
- {OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} -
- {' '} - {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} + + + Qty: + + + {Qty} + + +
+
+ {OrderCardDetail?.length > 0 && + ParkingDisplay && + !OtherServicesglobal && ( +
+ +
+ )} +
+ {' '} + {!OtherServicesglobal && unpaidFlow == true ? ( + + {' '} + { + Recipt(); + }} + /> + + ) : ( + '' + )} +
-
- - - - - {/* +
+ + + + + {/* {" "} */} - - - } - trigger="click" - // width={1000} - open={open} - onOpenChange={handleOpenChange} - > - - -
- -
- - - - - {/* - - */} - - - } - trigger="click" - // width={1000} - open={open2} - onOpenChange={handleOpenChange2} - > - + + + } + trigger="click" + // width={1000} + open={open} + onOpenChange={handleOpenChange} + > { color: '' ? '#52c41a' : '#1292EE', }} /> - - + +
+ +
+ + + + + {/* + + */} + + + } + trigger="click" + // width={1000} + open={open2} + onOpenChange={handleOpenChange2} + > + + + + +
-
-
- -
- ) : ( -
ORDER
- )} - - -
- { - Upimodel('Cancel'); - }} - footer={false} - children={ -
- {/*

UPI PAYMENT

*/} - -
-
- -
- -
-

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

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

UPI PAYMENT

*/}
- } - handleSubmit={() => { - Upimodel('Submit'); +
+ +
+ +
+

+ {' '} + 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'); + }} + />
- } - /> - {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} + /> + )} + {Splitpayment && ( + data?.TotalAmt + acc, + 0 + ) - + ((OverAllSales > 0 ? OverAllSales : 0) + + (OverAllEstimate > 0 ? OverAllEstimate : 0) + + (Discount > 0 ? Discount : 0)) + ) + } + failedOrderData={failedOrderData} + /> + )} + { + dispatch(changeSalesPaymentoption(false)); + }} + footer={false} + children={ +
+ +
+ } + /> + + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ) + // )) } - /> - {UnpaidConfirmation && ( - { + 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={ <> -
- 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} - /> - )} - { - 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)} + } /> - )} -
+ {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/BSBillingTable4.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx index 5e70f81..d393c8a 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { lazy, useEffect, useState, Suspense } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { isMobile } from 'react-device-detect'; import { AiFillDelete, AiOutlineClose } from 'react-icons/ai'; @@ -55,7 +55,9 @@ import { ChangeTotalAmount, globalExtraTotalAmount, } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; //Shifayath Date:27/12/2023 -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; +const BSBillingEditQuantity = lazy( + () => import('../BSBillingEditQuantity/BSBillingEditQuantity') +); import dineInIcon from '../../../../../Images/Dine In.svg'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; import WebFont from 'webfontloader'; @@ -66,8 +68,11 @@ import { } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; +const BSEditTotalAmt = lazy( + () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') +); + +const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, @@ -78,8 +83,9 @@ import { import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import { useUtilsComponent } from '../../../../../Services/utils.js'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; - +const CustomerPriceHistory = lazy( + () => import('../../UtillComponents/CustomerPriceHistory.jsx') +); const BSBillingTable4 = () => { const { removeExtraCharge } = useUtilsComponent(); const dispatch = useDispatch(); @@ -117,7 +123,6 @@ const BSBillingTable4 = () => { const UnpaidData = useSelector(GlobalUnpaidData); const tableData = useSelector(GlobalOrderCardDetails); console.log(tableData, 'tableDatatableData'); - const salesBillEdit = useSelector(GlobalSalesBillEdit); const ReportholdData = useSelector(GlobalReorderHoldDetails); const PreviousOrderLength = useSelector(GlobalPreviousOrderLength); const HoldOrderDtl = useSelector(GlobalHoldOrderDtl); @@ -146,7 +151,8 @@ const BSBillingTable4 = () => { const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); const [OpenEditTotalAmt, setOpenEditTotalAmt] = useState(false); const [OpenImeiDetail, setOpenImeiDetail] = useState(false); @@ -183,16 +189,16 @@ const BSBillingTable4 = () => { 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 + ) : []; useEffect(() => { @@ -312,7 +318,6 @@ const BSBillingTable4 = () => { event.preventDefault(); handleShortcut('weightAmount'); } - }; window.addEventListener('keydown', handleKeyDown); @@ -329,142 +334,6 @@ const BSBillingTable4 = () => { const handleImeiDetailClose = () => { setOpenImeiDetail(false); }; - // 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(changeAllProductTokenAvailable(false)); - // 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)); - // } - // 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([])); - // } - // } - // }; const calculateAmounts = ( OrderQty, @@ -1133,9 +1002,9 @@ const BSBillingTable4 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -2083,7 +1952,6 @@ const BSBillingTable4 = () => { } } } - }; const UnblockSlots = async (newCartItem) => { let BlockPostdata = { @@ -2145,7 +2013,7 @@ const BSBillingTable4 = () => { const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; const getstockbadge = async () => { let data = { @@ -2154,9 +2022,9 @@ const BSBillingTable4 = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -2168,9 +2036,9 @@ const BSBillingTable4 = () => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -2181,9 +2049,9 @@ const BSBillingTable4 = () => { prodCat: prodCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -2306,184 +2174,200 @@ const BSBillingTable4 = () => { }; return ( -
- - - - {tableOptions?.map((item) => ( - <> - {item.OptionName == 'Sl.No' && BookingTypeBoth && ( - - )} - {item.OptionName == 'Sl.No' && ( - - )} - {item.OptionName == 'Item' && ( - - )} - {item.OptionName == 'MRP' && ( - - )} - {item.OptionName == 'Discount' && ( - - )} - {item.OptionName == 'Quantity' && ( - - )} - {item.OptionName == 'Rate' && ( - - )} - {item.OptionName == 'Amount' && ( - - )} + Loading...}> +
+
- {!isMobile ? ( - {''} - ) : ( -
{''}
- )} -
- {!isMobile ? ( - Sl.No - ) : ( -
Sl.No
- )} -
- {!isMobile ? ( - Item - ) : ( -
Item
- )} -
- {!isMobile ? ( - MRP - ) : ( -
MRP
- )} -
- {!isMobile ? ( - ₹/% - ) : ( -
₹/%
- )} -
{ - if (tableData?.length > 0) { - OpenEditTotalAmount(); - } - }} - // onClick={tableData?.length>0? OpenEditTotalAmount :""} - > - {!isMobile ? ( - Qty - ) : ( -
Qty
- )} -
- {!isMobile ? ( - Rt - ) : ( -
Rt
- )} -
- {!isMobile ? ( - Amt - ) : ( -
Amt
- )} -
+ + + {tableOptions?.map((item) => ( + <> + {item.OptionName == 'Sl.No' && BookingTypeBoth && ( + + )} + {item.OptionName == 'Sl.No' && ( + + )} + {item.OptionName == 'Item' && ( + + )} + {item.OptionName == 'MRP' && ( + + )} + {item.OptionName == 'Discount' && ( + + )} + {item.OptionName == 'Quantity' && ( + + )} + {item.OptionName == 'Rate' && ( + + )} + {item.OptionName == 'Amount' && ( + + )} - {item.OptionName == 'Delete' && ( - - )} - - ))} - - + )} + + )} + + ))} + + - {OldtableDataTakeAway?.length > 0 && ( - - {OldtableDataTakeAway?.map((item, index) => ( - 0 && ( + + {OldtableDataTakeAway?.map((item, index) => ( + = PreviousdataLength + ? 'wheat' + : BookingType !== 'Dine In' && + triggerAnimation && + index === 0 && + tableDataTakeAway?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ? 'wheat' + : 'inherit' + : 'none', + background: + item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' - : BookingType === 'Dine In' && - triggerAnimation && + : 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 - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + 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 && ( + + )} + + )} + {OldtableDataDinein?.length > 0 && ( + + {OldtableDataDinein?.map((item, index) => ( + = PreviousdataLength ? 'wheat' - : 'inherit' - : 'none', - background: - item?.SalesId && OrderType !== 'Hold' + : 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' - : index % 2 === 0 + : (OldtableDataTakeAway?.length + 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 && ( - - )} - - )} - {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' && ( + 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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} + {tableitem.OptionName == 'Delete' && ( + + )} + + ))} + + ))} - {OldtableDataDinein?.length > 0 && EditQuantity && ( - - )} - - )} - {tableDataTakeAway?.length > 0 && ( - - {tableDataTakeAway?.map((item, index) => ( - 0 && EditQuantity && ( + + )} + + )} + {tableDataTakeAway?.length > 0 && ( + + {tableDataTakeAway?.map((item, index) => ( + = PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + style={{ + fontFamily: SelectedFont ? SelectedFont : '', + 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' - : (OldtableDataDinein?.length + + : 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' - : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'] - ? SelectedBillColor?.['OverallBackgroundColor'] - : '#d6d6d6', - //change - 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 + 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' && ( + //change + 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 == 'Sl.No' && ( - - )} - {tableitem?.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} + {tableitem.OptionName == 'Delete' && ( + + )} + + ))} + + ))} - {tableDataTakeAway?.length > 0 && EditQuantity && ( - - )} - - )} - {tableDataDinein?.length > 0 && ( - - {tableDataDinein?.map((item, index) => ( - 0 && EditQuantity && ( + + )} + + )} + {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)' - : BookingType === 'Dine In' && - triggerAnimation && + : 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 - ? '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' && ( + !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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} + {tableitem.OptionName == 'Delete' && ( + + )} + + ))} + + ))} - {tableDataDinein?.length > 0 && EditQuantity && ( - - )} - + {tableDataDinein?.length > 0 && EditQuantity && ( + + )} + + )} +
+ {!isMobile ? ( + {''} + ) : ( +
{''}
+ )} +
+ {!isMobile ? ( + Sl.No + ) : ( +
Sl.No
+ )} +
+ {!isMobile ? ( + Item + ) : ( +
Item
+ )} +
+ {!isMobile ? ( + MRP + ) : ( +
MRP
+ )} +
+ {!isMobile ? ( + ₹/% + ) : ( +
₹/%
+ )} +
{ + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + }} + // onClick={tableData?.length>0? OpenEditTotalAmount :""} + > + {!isMobile ? ( + Qty + ) : ( +
Qty
+ )} +
+ {!isMobile ? ( + Rt + ) : ( +
Rt
+ )} +
+ {!isMobile ? ( + Amt + ) : ( +
Amt
+ )} +
- {tableData?.length > 0 ? ( - { - Clearall(); - }} - > + {item.OptionName == 'Delete' && ( + + {tableData?.length > 0 ? ( + { + Clearall(); + }} + > +
+ {' '} + {!isMobile ? ( + + {' '} + {' '} + + ) : ( +
+ {' '} + {' '} +
+ )}{' '} +
+
+ ) : (
{' '} {!isMobile ? ( - - {' '} - {' '} + + ) : (
@@ -2492,449 +2376,439 @@ const BSBillingTable4 = () => {
)}{' '}
- - ) : ( -
- {' '} - {!isMobile ? ( - - - - ) : ( -
- {' '} - {' '} -
- )}{' '} -
- )} -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {index + 1} + + item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 + ? handleImeiDetails(item) + : editField && handleEditQuantity(item) + } + > + {item.ProdName} +  {' '} + {item?.BrandName !== null ? item?.BrandName : ''} + {item?.Type != 'C' && ( + <> +

+ ( + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } + {AvailableDate ? ( + <> + {' '} + ( + {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} + )   + {item?.SinglePc == 'Y' && 'Single'} + + ) : ( + <> + {item?.Size} + {item?.SinglePc == 'Y' + ? 'Single' + : 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?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.OrderQty} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {Number( + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2)} + + removeFromCart(item)} + style={{ color: '#FF4D4F', cursor: 'pointer' }} + /> +
- - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {index + 1} - - item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 - ? handleImeiDetails(item) - : editField && handleEditQuantity(item) - } - > - {item.ProdName} -   {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {AvailableDate ? ( - <> - {' '} - ( - {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} - )   - {item?.SinglePc == 'Y' && 'Single'} - - ) : ( - <> - {item?.Size} - {item?.SinglePc == 'Y' - ? 'Single' - : 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?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2)} - - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataTakeAway?.length + index + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataTakeAway?.length + index + 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.ProdName} -   {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

{ + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.ProdName} +  {' '} + {item?.BrandName !== null ? item?.BrandName : ''} + {item?.Type != 'C' && ( + <> +

+ ( + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } + {AvailableDate ? ( + <> + {' '} + ( + {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} + )   + {item?.SinglePc == 'Y' && 'Single'} + + ) : ( + <> + {item?.Size} + {item?.SinglePc == 'Y' + ? 'Single' + : item?.UomName} + + )} + ) +

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

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

+ )} + + )} + {item?.Type === 'C' && ( +
- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {AvailableDate ? ( - <> - {' '} - ( - {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} - )   - {item?.SinglePc == 'Y' && 'Single'} - - ) : ( - <> - {item?.Size} - {item?.SinglePc == 'Y' - ? 'Single' - : item?.UomName} - - )} - ) -

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

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} + {item.ProdDetail?.map((prod, index) => ( +

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

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

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

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

- {/* ( + ? handleImeiDetails(item) + : editField && handleEditQuantity(item, index) + } + > + {item?.Type !== 'OS' + ? item.ProdName + : item.ServiceName} +  {' '} + {item?.BrandName !== null ? item?.BrandName : ''} + {item?.Type != 'C' && ( + <> +

+ {/* ( {!item?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && {item?.ProdVariantName} } {item?.Size} {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) */} - {item?.Type !== 'OS' && ( - <> - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } + {item?.Type !== 'OS' && ( + <> + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } - {AvailableDate ? ( - <> - {' '} - ( - {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} - )   - {item?.SinglePc == 'Y' && 'Single'} - - ) : ( - <> - {item?.Size} - {item?.SinglePc == 'Y' - ? 'Single' - : 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} + {AvailableDate ? ( + <> + {' '} + ( + {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} + )   + {item?.SinglePc == 'Y' && 'Single'} + + ) : ( + <> + {item?.Size} + {item?.SinglePc == 'Y' + ? 'Single' + : item?.UomName} + + )} + + )}

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

{ + if (editField) { + handleEditQuantity(item, index); + } + }} + > + {item.ProdName} +  {' '} + {item?.BrandName !== null ? item?.BrandName : ''} + {item?.Type != 'C' && ( + <> +

+ ( + {!item?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && {item?.ProdVariantName} } + {AvailableDate ? ( + <> + {' '} + ( + {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} + )   + {item?.SinglePc == 'Y' && 'Single'} + + ) : ( + <> + {item?.Size} + {item?.SinglePc == 'Y' + ? 'Single' + : item?.UomName} + + )} + ) +

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

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

+ )} + + )} + {item?.Type === 'C' && ( +
- ( - {!item?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {AvailableDate ? ( - <> - {' '} - ( - {`${to12Hour(item?.VariantAvailableFrom)} - ${to12Hour(item?.VariantAvailableTo)}`} - )   - {item?.SinglePc == 'Y' && 'Single'} - - ) : ( - <> - {item?.Size} - {item?.SinglePc == 'Y' - ? 'Single' - : item?.UomName} - - )} - ) -

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

- {item.OfferMessage?.split('>')?.[0] + - `> ${item?.OrderQty} Eligible Free`} + {item.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.Type != 'C' - ? item.Offer && item.Offer > 0 - ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item.OrderQty} - { - if (editField) { - handleEditQuantity(item, index); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {Number( - item?.TotalAmt - (item?.Offer || 0) || 0 - ).toFixed(2)} - { + if (editField) { + handleEditQuantity(item, index); + } + }} + > + {item?.MRP} + { + if (editField) { + handleEditQuantity(item, index); + } + }} + > + {item?.Type != 'C' + ? item.Offer && item.Offer > 0 + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + { + if (editField) { + handleEditQuantity(item, index); + } + }} + > + {item.OrderQty} + { + if (editField) { + handleEditQuantity(item, index); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {Number( + item?.TotalAmt - (item?.Offer || 0) || 0 + ).toFixed(2)} + - removeFromCart(item)} - style={{ color: '#FF4D4F', cursor: 'pointer' }} - /> -
+ removeFromCart(item)} + style={{ color: '#FF4D4F', cursor: 'pointer' }} + /> +
+ {OpenEditTotalAmt && ( + )} - - {OpenEditTotalAmt && ( - - )} - {OpenImeiDetail && ( - - )} - {(customerPriceHistoryOpen && GetCustId) && - - } -
+ {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} +
+ ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx index c4ee9cb..e99b170 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable5.jsx @@ -1,10 +1,9 @@ -import React, { useEffect, useState, useRef } from 'react'; +import React, { useEffect, useState, useRef, lazy, Suspense } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; import { Popover, Badge, Modal, Tooltip } from 'antd'; import { useNavigate } from 'react-router-dom'; import { - UpOutlined, ArrowRightOutlined, UpCircleOutlined, DownCircleOutlined, @@ -15,7 +14,6 @@ import defaultupi from '../../../../../Images/defaultupi.png'; import pozologoimg from '../../../../../Images/pozologoimg.png'; import paydevice from '../../../../../Images/paydevice.png'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable5/BSBillingTable15.scss'; -import BsBill from './BsBill'; import { isMobile } from 'react-device-detect'; import { GlobalSelectedFont, @@ -29,7 +27,9 @@ import { } from '../../../../../Features/ThemeChange/ThemeChange'; import { PrintStyleFunction } from '../../../../paymentpdfPage/PrintStyleFunction.js'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; -import BSSummery1 from '../../BSBillingTables/BSBillingTableSummery/BSSummery'; +const BSSummery1 = lazy( + () => import('../../BSBillingTables/BSBillingTableSummery/BSSummery') +); import { Messages } from '../../../../../Components/Notifications/Messages'; import { GlobalOrderCardDetails, @@ -105,7 +105,6 @@ import { GlobalOverAllDiscSales, ChangeOverAllDiscSales, ChangeOverAllDiscEstimate, - getAllCustomer, GlobalBranchFinancialStatus, changeSummeryComboOfferAmount, ChangeComboCarddata, @@ -130,6 +129,7 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import { ChangeTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; //Shifayth Date:27/12/2023 import { @@ -137,7 +137,6 @@ import { globalholddata, changeholddata, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption'; -import PaymentPdfBooking from '../../../../paymentpdfPage/PaymentPdfBooking'; import { globalExtraTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges'; import { encryptObject, @@ -154,34 +153,21 @@ import { triggerCustomerRefresh, } from '../../../../../Features/BookingScreen/Customer/addCustomer'; import BSCustomerSelect from '../../UtillComponents/BSSelectCustomer.jsx'; -import PozoDineInIcon from '../../UtillComponents/Pozo retail icons/PozoDineIn.jsx'; import PozoUnpaidIcon from '../../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; import PozoBillIcon from '../../UtillComponents/Pozo retail icons/PozoBIllIcon.jsx'; import PozoAddCustomerIcon from '../../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; -import QrComponent from '../../BookingFunctionality/DynamicQr.jsx'; -import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; import Buttons from '../../../../../Components/Forms/Buttons'; import WpIcon from '../../../../../Images/message.png'; -import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditCustomer.jsx'; -import BSCreditCustomer from '../../UtillComponents/BSCreditCustomer.jsx'; import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; -import MobilePrint from '../../BookingFunctionality/MobilePrint.jsx'; import CountUp from 'react-countup'; import { GlobalpreOrderOpen } from '../../../../../Features/BookingScreen/PreOrder/PreOrder.js'; -import SplitPayment from '../../BookingFunctionality/SplitPayment.jsx'; -import TokensinglePrint from '../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx'; -import SingleTokenMobilePrint from '../../BookingFunctionality/SingleTokenMobilePrint.jsx'; -import IndividualTokenMobilePrint from '../../BookingFunctionality/IndividualTokenMobilePrint.jsx'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, Global_OrderOfferDetail, Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, } from '../../../../../Features/Offer/Offer.js'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; @@ -191,21 +177,13 @@ import { changeSalesPaymentoption, GlobalSalesPaymentoption, } from '../../../../../Features/Payment/Paymentoptions/Paymentoptions.js'; -import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions.jsx'; import { getPaymentOptionsData } from '../../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; import { getCombolist } from '../../../../../Features/ComboMaster/ComboMaster.js'; -import WhatsAppShare from '../../../../WhatsAppShare/whatsAppShare.jsx'; -import SMSShare from '../../../../WhatsAppShare/SmsShare.jsx'; import { MdSms } from 'react-icons/md'; import { FaWhatsapp, FaPrint, FaCartPlus } from 'react-icons/fa'; -import BSTipAmount from '../../UtillComponents/BSTipAmount.jsx'; import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices.js'; import { TfiClipboard } from 'react-icons/tfi'; -import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; -import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; -import BSOtherServiceClaim from '../../UtillComponents/BSOtherServiceClaim.jsx'; -import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint.js'; import { PublicQrCodepost } from '../../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; import { ChangeFullFreeProductList, @@ -217,14 +195,75 @@ import { } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import CardPopover from '../StandardTable/Utils/CardPopover.jsx'; import UpiPopover from '../StandardTable/Utils/UpiPopOver.jsx'; -import PaymentGatewayEmbedded from '../../UtillComponents/PaymentGatewayEmbedded.jsx'; -import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; -import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; +// Jsx Files +const OtherServicePrintStyle1 = lazy( + () => + import('../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx') +); +const OtherServiceMobilePrint = lazy( + () => import('../../BookingFunctionality/OtherServiceMobilePrint.jsx') +); +const BSOtherServiceClaim = lazy( + () => import('../../UtillComponents/BSOtherServiceClaim.jsx') +); +const WhatsAppShare = lazy( + () => import('../../../../WhatsAppShare/whatsAppShare.jsx') +); +const BsBill = lazy(() => import('./BsBill')); + +const SMSShare = lazy(() => import('../../../../WhatsAppShare/SmsShare.jsx')); + +const PaymentPdfBooking = lazy( + () => import('../../../../paymentpdfPage/PaymentPdfBooking') +); +const PozoDineInIcon = lazy( + () => import('../../UtillComponents/Pozo retail icons/PozoDineIn.jsx') +); +const QrComponent = lazy( + () => import('../../BookingFunctionality/DynamicQr.jsx') +); +const QrinScreen = lazy( + () => import('../../BookingFunctionality/DynamicScreenQr.jsx') +); +const BsBillingCreditCustomer = lazy( + () => import('../../BookingFunctionality/BSBillingCreditCustomer.jsx') +); +const BSCreditCustomer = lazy( + () => import('../../UtillComponents/BSCreditCustomer.jsx') +); +const MobilePrint = lazy( + () => import('../../BookingFunctionality/MobilePrint.jsx') +); +const SplitPayment = lazy( + () => import('../../BookingFunctionality/SplitPayment.jsx') +); +const TokensinglePrint = lazy( + () => + import('../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx') +); +const SingleTokenMobilePrint = lazy( + () => import('../../BookingFunctionality/SingleTokenMobilePrint.jsx') +); +const IndividualTokenMobilePrint = lazy( + () => import('../../BookingFunctionality/IndividualTokenMobilePrint.jsx') +); +const MobileMultiPdfPrintTrigger = lazy( + () => import('../../UtillComponents/MobileMultiPdfPrintTrigger.jsx') +); +const CustomerOrders = lazy( + () => import('../../BookingFunctionality/CustomerOrders.jsx') +); +const Paymentoption = lazy( + () => import('../../../../Payment/PaymentOptions/PaymentOptions.jsx') +); +const BSTipAmount = lazy(() => import('../../UtillComponents/BSTipAmount.jsx')); +const PaymentGatewayEmbedded = lazy( + () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -244,11 +283,12 @@ const BSBillingTable5 = () => { const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; + const AllBookingType = useSelector(GlobalAllBookingType); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const Discount = useSelector(GlobalOverAllOfferAmt); const FreeProdList = useSelector(GlobalFreeProdList); @@ -485,6 +525,10 @@ const BSBillingTable5 = () => { // for customised invoice number const { invoiceDate, clearInvoiceDate } = useDateStore(); const CurrentOrderId = useSelector(GlobalCurrentOrderId); + const holdCheckedSalesSetup = tableOptions?.some( + (item) => item?.OptionName === 'Hold' + ); + useEffect(() => { if (salesBillEdit) { dispatch(getPaymentOptions()).unwrap(); @@ -492,7 +536,6 @@ const BSBillingTable5 = () => { }, [salesBillEdit]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -507,8 +550,7 @@ const BSBillingTable5 = () => { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); useEffect(() => { if ( @@ -529,8 +571,8 @@ const BSBillingTable5 = () => { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); useEffect(() => { if (selOption) { @@ -634,17 +676,23 @@ const BSBillingTable5 = () => { ); } - const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -653,8 +701,7 @@ const BSBillingTable5 = () => { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; + const previousNetAmount = totalPreviouspayment || 0; let withdiscTotal = Total - @@ -666,12 +713,26 @@ const BSBillingTable5 = () => { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); @@ -696,8 +757,9 @@ const BSBillingTable5 = () => { useEffect(() => { if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); + if (holdCheckedSalesSetup) { + getHolddata(); + } getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -728,28 +790,6 @@ const BSBillingTable5 = () => { setaddnewAccess(!hasAccess); }, [empData, SAAccessCommonMaster, UserType]); - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); const formatAmount = (value) => { return allowDecimal ? parseFloat(value || 0).toFixed(2) @@ -769,9 +809,6 @@ const BSBillingTable5 = () => { setEmpData(datas?.[0]); }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); await dispatch( getAddCustomerDetails({ CompId: CompId, @@ -908,7 +945,11 @@ const BSBillingTable5 = () => { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1124,7 +1165,7 @@ const BSBillingTable5 = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1554,20 +1595,12 @@ const BSBillingTable5 = () => { }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); + setConfigDataList(AllBookingType); + let configdata = AllBookingType; + let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - setSelectedBookingType(filterconfigdata?.ConfigId); - } + let filterconfigdata = configdata?.find((a) => a?.ConfigName === checkName); + setSelectedBookingType(filterconfigdata?.ConfigId); }; const TotalItemsCalculation = async () => { let tempTotalitems = OrderCardDetail?.length; @@ -1751,7 +1784,7 @@ const BSBillingTable5 = () => { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -1814,12 +1847,7 @@ const BSBillingTable5 = () => { const hideDefault = () => { setUpiOptionOpen(false); }; - const handlePopoverVisibleChange = (visible) => { - setUpiOptionOpen(visible); - }; - const handlePopoverVisibleChangeCard = (visible) => { - setCardOptionOpen(visible); - }; + const getHolddata = async () => { const data = { CompId: CompId, BranchId: BranchId, AppId: AppId }; let response = await dispatch(gettinghold(data)).unwrap(); @@ -1915,7 +1943,9 @@ const BSBillingTable5 = () => { setUpinotSelected(false); setCurrentOrderNetAmount(0); setPreviousNetAmount(0); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -2091,15 +2121,15 @@ const BSBillingTable5 = () => { 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', @@ -2190,7 +2220,7 @@ const BSBillingTable5 = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2207,85 +2237,113 @@ const BSBillingTable5 = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) + : (Paybtnnameselected?.toLowerCase() === 'upi' && + 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') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -2352,14 +2410,14 @@ const BSBillingTable5 = () => { 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]); @@ -2518,14 +2576,14 @@ const BSBillingTable5 = () => { 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]); @@ -2632,14 +2690,14 @@ const BSBillingTable5 = () => { } 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]); @@ -2815,14 +2873,14 @@ const BSBillingTable5 = () => { setMessageType('success'); setMessageData( bookingpaymentupdate?.data?.response + - ' ' + - (bookingpaymentupdate?.data?.OrderDetails?.length > 0 - ? bookingpaymentupdate?.data?.OrderId && - extractLastNumberOrderId( - bookingpaymentupdate?.data?.OrderId, - rbookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus - ) - : '') + ' ' + + (bookingpaymentupdate?.data?.OrderDetails?.length > 0 + ? bookingpaymentupdate?.data?.OrderId && + extractLastNumberOrderId( + bookingpaymentupdate?.data?.OrderId, + rbookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus + ) + : '') ); bookingpaymentupdate?.data?.OrderDetails?.length > 0 && setPrintOrderDetails([bookingpaymentupdate?.data]); @@ -2841,7 +2899,7 @@ const BSBillingTable5 = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3389,8 +3447,10 @@ const BSBillingTable5 = () => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); const Otherserviceprint = async () => { if (OtherServicesPrintDetails?.length > 0) { @@ -3545,995 +3605,1035 @@ const BSBillingTable5 = () => { }; return ( <> -
- {(addcustomer || hold) && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- -
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( + Loading…
}> +
+ {(addcustomer || hold) && ( + + )} + {creditCustomerOpen && ( + + )} + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelectedUpiOption && ( +
+ +
+ )} + + {PaymentUpiOptions?.length > 0 && OrderId && (
)} - {PaymentUpiOptions?.length > 0 && OrderId && ( -
- -
- )} - - {screenwidth > 768 && ( -
- -
- )} - - {/* bill table */} - -
- {screenwidth <= 768 && ( + {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 && ( +
+ {screenwidth <= 768 && (
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - width: '2rem', + transition: 'max-height 0.3s ease-in-out', + overflow: 'scroll', + maxHeight: responsiveBill ? '190px' : '0px', }} > - {!OtherServicesglobal && ( - - {' '} + {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 && (
- +
- - )} -
- )} -
- - {/* 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 */} - {GetCustId && ( - - {' '} -
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(OrderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); + {!OtherServicesglobal && unpaidFlow == true ? ( + + {' '} + { + Recipt(); + }} + /> + + ) : ( + '' + )} +
+ + + + + + + } - }} - 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', - }} - > - + trigger="click" + open={open2} + onOpenChange={handleOpenChange2} + > + + {!open2 ? ( + + ) : ( + + )} + +
- - )} - {tabledata?.length > 0 && dinePreference && ( -
+
+
+
+
{tableOptions - .filter((item) => item.OptionName === 'UnpaidBill') + .filter((item) => item.OptionName === 'AddCustomer') .map((filteredItem) => ( - {!OtherServicesglobal && ( +
+ + {' '} - { - (setUnpaidOpen(true), getUnpaiddatas()); + fontSize: '25px', + color: + selOption || GetCustId ? '#52c41a' : '#1292EE', + cursor: Custdisable ? 'not-allowed' : 'pointer', }} /> - )} +
))}
- )} - {OtherServicesglobal && OrderCardDetail.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', }} > - -
-
- )} - {dinePreference && ( -
- {(BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - SelectedTableDetails?.length !== 0 && ( - <> - - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - /> - - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } - + {!OtherServicesglobal && ( + + {' '} +
+ +
+
)} -
- )} - {!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 && ( - - - +
+ )} +
+ + {/* 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' + ) ) - : ''} - {unpaidFlow === false && - item?.OptionName === 'Hold' && - !BookingTypeBoth && - BookingType !== 'Dine In' && - Holddata?.length > 0 && - OrderCardDetail?.length === 0 && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - - - + ) && + !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 */} + {GetCustId && ( + + {' '} +
{ + 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 - {/* */} -
+ )}` + ) : ( +
+ ₹{' '} + = 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + )} + /> +
+ )} + + + ) + ) : ( +
ORDER
)} + + +
+ { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+ {/*

UPI PAYMENT

*/}
- } - handleSubmit={() => { - Upimodel('Submit'); +
+ +
+ +
+

+ {' '} + 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 && ( - + } + /> + {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('Print') || - !MobileNoWhatsApp || - !MobileNoWhatsApp.value) && ( + {(filteredSettingNames?.includes('Print') || + !MobileNoWhatsApp || + !MobileNoWhatsApp.value) && ( { /> )} - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} -
- )} - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- + {filteredSettingNames?.includes('SMS') && isMobile && ( + + )} + {/* WhatsAppShare modal/component */} + {showWhatsAppShare && ( + closePrintOption(false)} + /> + )} + {showSMSShare && isMobile && ( + closePrintOption(false)} + /> + )}
- ) - // )) - } - { - 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} - - )} -
- ); - })} -
- ); - })} -
- + )} + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+
-
+ ) + // )) } - /> - { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
- } - /> - 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)} + className={'paymentoptionsModal'} + open={OtherServicesModal} + title="Vehicle No" + handleCancel={() => { + setOtherServicesModal(false); + }} + // handleSubmit={Handlevehiclenumbers} footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} + 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} + + )} +
+ ); + })} +
+ ); + })} +
+ +
+
+ } + /> + { + dispatch(changeSalesPaymentoption(false)); + }} + footer={false} + children={ +
+ +
+ } + /> + setShowCancelConfirm(true)} + footer={false} + width={500} 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)} + /> + + } + /> + )} +
+ ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx index 9ccb2fb..b8f4595 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { Suspense, useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { Popconfirm, Tooltip } from 'antd'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.scss'; @@ -60,7 +60,9 @@ import { GlobalOfferAppliedProducts, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { AiOutlineClose, AiFillDelete } from 'react-icons/ai'; -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; +const BSBillingEditQuantity = lazy( + () => import('../BSBillingEditQuantity/BSBillingEditQuantity') +); import { isMobile } from 'react-device-detect'; import WebFont from 'webfontloader'; import dineInIcon from '../../../../../Images/Dine In.svg'; @@ -71,11 +73,17 @@ import { puttinghold, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import { useUtilsComponent } from '../../../../../Services/utils.js'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; +const BSEditTotalAmt = lazy( + () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') +); + +const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); + +const CustomerPriceHistory = lazy( + () => import('../../UtillComponents/CustomerPriceHistory.jsx') +); const BSBillingTable6 = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -134,7 +142,8 @@ const BSBillingTable6 = () => { const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); const [OpenImeiDetail, setOpenImeiDetail] = useState(false); const [shortKeyMethod, setshortKeyMethod] = useState(null); @@ -157,16 +166,16 @@ const BSBillingTable6 = () => { 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 [OpenEditTotalAmt, setOpenEditTotalAmt] = useState(false); useEffect(() => { @@ -221,9 +230,6 @@ const BSBillingTable6 = () => { } }, [tableData]); - // useEffect(() => { - // setPreviousdataLength(PreviousOrderLength) - // }, [PreviousOrderLength]) useEffect(() => { if (tableOptions?.length > 0) { let editFieldValue = tableOptions?.filter( @@ -285,7 +291,6 @@ const BSBillingTable6 = () => { event.preventDefault(); handleShortcut('weightAmount'); } - }; window.addEventListener('keydown', handleKeyDown); @@ -1055,9 +1060,9 @@ const BSBillingTable6 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1715,7 +1720,6 @@ const BSBillingTable6 = () => { OfferId: FreeProd?.OfferId, CompleteRemove: true, }); - // await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true) await ChangeOfferAppliedProdsFn({ inwardDtlId: item?.InwardDtlId, OfferAmount: isPaidproduct?.OrderRate * isPaidproduct?.OrderQty, @@ -1725,8 +1729,6 @@ const BSBillingTable6 = () => { }); } } else { - //have to find if thereis two Booking Type is there - //Convert That Free Product To Paid Product let ischeckBothBookingType = tableData?.find( (e) => e?.InwardDtlId == inward && @@ -1741,12 +1743,6 @@ const BSBillingTable6 = () => { e?.BookingTypeName == item?.BookingTypeName ); if (ischeckBothBookingType) { - //Convert That Free Product To Paid Product - - //merge that paid product with same booking type - //decrease free prod list qty - //change offer applied product qty - // await ChangeOrderCardDetailsFn(item?.BookingTypeName, null, ischeckBothBookingType?.OrderQty + FreeProductSameBookingType?.OrderQty, false, ischeckBothBookingType?.InwardDtlId, item?.InwardDtlId, item?.Offer, true) if (FreeProductSameBookingType?.OrderQty >= item?.OrderQty) { await ChangeFreeprodlistFn({ OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty, @@ -1779,7 +1775,6 @@ const BSBillingTable6 = () => { }); } else { let data = isCheckFreeProductOutside?.FreeQty - item?.OrderQty; - //First i Calculate Another Booking Type Qty let anotherBookingType = tableData?.find( (e) => e?.InwardDtlId == item?.InwardDtlId && @@ -1796,24 +1791,10 @@ const BSBillingTable6 = () => { 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 ) { - //paidproduct ischeckBothBookingType?.OrderQty-anotherBookingType?.OrderQty - //PaidProdcut Current BookingType FreeProductSameBookingType?.OrderQty let paidproductAnotherType = ischeckBothBookingType?.OrderQty - anotherBookingType?.OrderQty; @@ -1965,144 +1946,7 @@ const BSBillingTable6 = () => { } } } - }; - // 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(changeAllProductTokenAvailable(false)); - // 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)); - // } - // 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([])); - // } - // } - // }; function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; @@ -2118,7 +1962,7 @@ const BSBillingTable6 = () => { const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; const OpenEditTotalAmount = () => { setOpenEditTotalAmt(true); @@ -2142,612 +1986,616 @@ const BSBillingTable6 = () => { }; return ( -
- - - - {tableOptions?.map((item) => ( - <> - {item.OptionName == 'Sl.No' && BookingTypeBoth && ( - - )} - {item.OptionName == 'Sl.No' && ( - - )} - {item.OptionName == 'Item' && ( - - )} - {item.OptionName == 'MRP' && ( - - )} - {item.OptionName == 'Discount' && ( - - )} - {item.OptionName == 'Quantity' && ( - - )} - {item.OptionName == 'Rate' && ( - - )} - {item.OptionName == 'Amount' && ( - - )} + Loading...}> +
+
- {!isMobile ? ( - {''} - ) : ( -
{''}
- )} -
- {!isMobile ? ( - Sl.No - ) : ( -
Sl.No
- )} -
- {!isMobile ? ( - Item - ) : ( -
Item
- )} -
- {!isMobile ? ( - MRP - ) : ( -
MRP
- )} -
- {!isMobile ? ( - ₹/% - ) : ( -
₹/%
- )} -
0 ? OpenEditTotalAmount : ""} - onClick={() => { - if (tableData?.length > 0) { - OpenEditTotalAmount(); - } - }} - > - {!isMobile ? ( - Qty - ) : ( -
Qty
- )} -
- {!isMobile ? ( - Rt - ) : ( -
Rt
- )} -
- {!isMobile ? ( - Amt - ) : ( -
Amt
- )} -
+ + + {tableOptions?.map((item) => ( + <> + {item.OptionName == 'Sl.No' && BookingTypeBoth && ( + + )} + {item.OptionName == 'Sl.No' && ( + + )} + {item.OptionName == 'Item' && ( + + )} + {item.OptionName == 'MRP' && ( + + )} + {item.OptionName == 'Discount' && ( + + )} + {item.OptionName == 'Quantity' && ( + + )} + {item.OptionName == 'Rate' && ( + + )} + {item.OptionName == 'Amount' && ( + + )} - {item.OptionName == 'Delete' && ( - - )} - - ))} - - - {/* For Reorder TakeWay */} - {OldtableDataTakeAway?.length > 0 && ( - - {OldtableDataTakeAway?.map((item, index) => ( - + )} + + ))} + + + {/* 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)' - : triggerAnimation && + : 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 - ? 'wheat' - : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + 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' - : 'inherit' - : 'none', - background: - item?.SalesId && OrderType !== 'Hold' + : 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' - : index % 2 === 0 + : (OldtableDataTakeAway?.length + 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' && ( + 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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - {OldtableDataDinein?.length > 0 && EditQuantity && ( - - )} - - )} - {/* TakeWay */} - {tableDataTakeAway?.length > 0 && ( - - {tableDataTakeAway?.map((item, index) => ( - removeFromCart(item)} + > + + + )} + + ))} + + ))} + {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 + 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' - : (OldtableDataDinein?.length + + : 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' - : (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 + 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' && ( + 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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {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) => ( - 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {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)' - : BookingType === 'Dine In' && - triggerAnimation && + : 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 - ? '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' && ( + !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 == 'Sl.No' && ( - - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} - {tableitem.OptionName == 'Delete' && ( - - )} - - ))} - - ))} - {tableDataDinein?.length > 0 && EditQuantity && ( - - )} - + {tableitem.OptionName == 'Delete' && ( + + )} + + ))} + + ))} + {tableDataDinein?.length > 0 && EditQuantity && ( + + )} + + )} +
+ {!isMobile ? ( + {''} + ) : ( +
{''}
+ )} +
+ {!isMobile ? ( + Sl.No + ) : ( +
Sl.No
+ )} +
+ {!isMobile ? ( + Item + ) : ( +
Item
+ )} +
+ {!isMobile ? ( + MRP + ) : ( +
MRP
+ )} +
+ {!isMobile ? ( + ₹/% + ) : ( +
₹/%
+ )} +
0 ? OpenEditTotalAmount : ""} + onClick={() => { + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + }} + > + {!isMobile ? ( + Qty + ) : ( +
Qty
+ )} +
+ {!isMobile ? ( + Rt + ) : ( +
Rt
+ )} +
+ {!isMobile ? ( + Amt + ) : ( +
Amt
+ )} +
- {tableData?.length > 0 ? ( - { - Clearall(); - }} - > + {item.OptionName == 'Delete' && ( + + {tableData?.length > 0 ? ( + { + Clearall(); + }} + > +
+ {' '} + {!isMobile ? ( + + {' '} + {' '} + + ) : ( +
+ {' '} + {' '} +
+ )}{' '} +
+
+ ) : (
- {' '} {!isMobile ? ( - - {' '} - {' '} + + ) : (
{' '} {' '}
- )}{' '} + )}
- - ) : ( -
- {!isMobile ? ( - - - - ) : ( -
- {' '} - {' '} -
- )} -
- )} -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {index + 1} + + item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 + ? 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 + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.OrderQty} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {item.TotalAmt} + removeFromCart(item)} + > + +
- - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {index + 1} - - item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 - ? 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 - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {item.TotalAmt} - removeFromCart(item)} - > - -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataTakeAway?.length + index + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataTakeAway?.length + index + 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.ProdName} -   {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

{ + 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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {item.TotalAmt} - { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.OrderQty} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {item.TotalAmt} + removeFromCart(item)} - > - -
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index + + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index + - 1} - - item.FullProductIdentifierDtls?.length > 0 || + {tableitem.OptionName == 'Item' && ( + + item.FullProductIdentifierDtls?.length > 0 || item.ProductIdentifierDtls?.length > 0 - ? handleImeiDetails(item) - : editField && handleEditQuantity(item) - } - > - {item.ProdName} -   {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

+ {item.ProdName} +  {' '} + {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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {item.TotalAmt} - removeFromCart(item)} - > - -
{ + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderQty} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {item.TotalAmt} + removeFromCart(item)} + > + +
+ + { + if (editField) { + handleEditQuantity(item); + } + }} > - + {OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index + + 1} { - if (editField) { - handleEditQuantity(item); - } - }} - > - {OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index + - 1} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.ProdName} -   {item?.BrandName !== null ? item?.BrandName : ''} - {item?.Type != 'C' && ( - <> -

{ + 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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
{ - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.MRP} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.Type != 'C' - ? item.Offer + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.MRP} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item.OrderQty} - { - if (editField) { - handleEditQuantity(item); - } - }} - > - {item?.OrderRate} - { - // if (editField) { - // handleEditQuantity(item); - // } - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - > - {item.TotalAmt} - { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item.OrderQty} + { + if (editField) { + handleEditQuantity(item); + } + }} + > + {item?.OrderRate} + { + // if (editField) { + // handleEditQuantity(item); + // } + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + > + {item.TotalAmt} + removeFromCart(item)} - > - -
removeFromCart(item)} + > + +
+ {OpenEditTotalAmt && ( + )} - - {OpenEditTotalAmt && ( - - )} - {OpenImeiDetail && ( - - )} - {(customerPriceHistoryOpen && GetCustId) && - - } -
+ {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} +
+ ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx index 9a02c94..7c5658e 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BST6Payment.jsx @@ -1,11 +1,11 @@ -import React, { useEffect, useState, useRef } from 'react'; +import React, { useEffect, useState, useRef, lazy } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; import { AiOutlineClose, AiOutlineArrowRight } from 'react-icons/ai'; import { Tables } from '../../../../../Components/Tables/Table'; import { DefaultModal } from '../../../../../Components/Modal/DefaultModal.jsx'; -import { UpCircleOutlined, UpOutlined } from '@ant-design/icons'; +import { UpCircleOutlined } from '@ant-design/icons'; import { Popover, Badge, Modal, Tooltip } from 'antd'; import { printDiv, @@ -38,7 +38,6 @@ import { GlobalSelectedTableDetails, GlobalBookingType, changeBookingType, - getConfigType, PutBookingData, GlobalReorderHoldDetails, getUnpaidData, @@ -61,7 +60,6 @@ import { changeCustomerID, changeSelectedCustId, GlobalSelOption, - changefocusStatusBalrec, changeUnpaidData, ChangeSelectedCustDisable, getSalesDetailData, @@ -104,7 +102,6 @@ import { ChangeOverAllDiscEstimate, GlobalScreenSize, GlobalUnpaidListData, - getAllCustomer, GlobalBranchFinancialStatus, changeSummeryComboOfferAmount, ChangeComboCarddata, @@ -129,6 +126,7 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; import { @@ -159,7 +157,6 @@ import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; import { ArrowRightOutlined } from '@ant-design/icons'; import Buttons from '../../../../../Components/Forms/Buttons'; import WpIcon from '../../../../../Images/message.png'; -import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditCustomer.jsx'; import BSCreditCustomer from '../../UtillComponents/BSCreditCustomer.jsx'; import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; import { isMobile } from 'react-device-detect'; @@ -174,17 +171,10 @@ import { getCustomerDisplayWindow } from '../../../../../Features/customerDispla import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; -import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, - Global_OrderOfferDetail, - Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, -} from '../../../../../Features/Offer/Offer.js'; +import { Global_OverallOfferAmount } from '../../../../../Features/Offer/Offer.js'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; import { useAuth } from '../../../../../AuthContext.jsx'; -import PaymentInput from '../BSBillingTable1/BalanceAndReceived.jsx'; import { GlobalBookingStatus } from '../../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; import { changeSalesPaymentoption, @@ -193,15 +183,11 @@ import { import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions.jsx'; import { getPaymentOptionsData } from '../../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; import { getCombolist } from '../../../../../Features/ComboMaster/ComboMaster.js'; -import WhatsAppShare from '../../../../WhatsAppShare/whatsAppShare.jsx'; -import SMSShare from '../../../../WhatsAppShare/SmsShare.jsx'; import { MdSms } from 'react-icons/md'; import { FaWhatsapp, FaPrint, FaCartPlus } from 'react-icons/fa'; -import BSTipAmount from '../../UtillComponents/BSTipAmount.jsx'; import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { TfiClipboard } from 'react-icons/tfi'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices.js'; -import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; import BSOtherServiceClaim from '../../UtillComponents/BSOtherServiceClaim.jsx'; import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint.js'; @@ -221,10 +207,24 @@ 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'; - +// jsx Files +const BsBillingCreditCustomer = lazy( + () => import('../../BookingFunctionality/BSBillingCreditCustomer.jsx') +); +const PaymentInput = lazy( + () => import('../BSBillingTable1/BalanceAndReceived.jsx') +); +const WhatsAppShare = lazy( + () => import('../../../../WhatsAppShare/whatsAppShare.jsx') +); +const SMSShare = lazy(() => import('../../../../WhatsAppShare/SmsShare.jsx')); +const BSTipAmount = lazy(() => import('../../UtillComponents/BSTipAmount.jsx')); +const OtherServicePrintStyle1 = lazy( + () => + import('../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -239,6 +239,7 @@ const BST6Payment = () => { const navigate = useNavigate(); const FreeProdList = useSelector(GlobalFreeProdList); const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts); + const AllBookingType = useSelector(GlobalAllBookingType); const defaultBookingType = useSelector(GlobalDefaultBookingType); const appPreferences = useSelector(ApplicationPreferences); const bookingTypePreference = appPreferences?.find( @@ -251,7 +252,9 @@ const BST6Payment = () => { ); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const screenwidth = useSelector(GlobalScreenSize); const printerTemplateStyle = useSelector(SelectedPrintTemplate); @@ -298,7 +301,9 @@ const BST6Payment = () => { const prodCat = useSelector(GlobalProductCategorie); const ProdSubCat = useSelector(GlobalProductSubCategorie); const templateData = useSelector(getTemplateData); - const BranchFinancialStatus = useSelector(GlobalBranchFinancialStatus); + const holdCheckedSalesSetup = tableOptions?.some( + (item) => item?.OptionName === 'Hold' + ); const tableOptions = templateData?.BookingBilling?.[1]; const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( (item) => item?.OptionName == 'Offer' @@ -484,7 +489,6 @@ const BST6Payment = () => { }, [salesBillEdit]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -499,8 +503,7 @@ const BST6Payment = () => { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); console.log(PrintOrderDetails, 'PrintOrderDetails'); useEffect(() => { if (selOption) { @@ -552,7 +555,7 @@ const BST6Payment = () => { if (!preOrder) { const totalSum = OrderCardDetail?.reduce( // (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), - (acc, card) => acc + parseFloat(card.TotalAmt || 0), + (acc, card) => acc + parseFloat(card.TotalAmt || 0), 0 ); @@ -608,14 +611,21 @@ const BST6Payment = () => { const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -624,8 +634,7 @@ const BST6Payment = () => { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; + const previousNetAmount = totalPreviouspayment || 0; let withdiscTotal = Total - @@ -637,12 +646,26 @@ const BST6Payment = () => { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); @@ -672,8 +695,8 @@ const BST6Payment = () => { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); //mohan stoped data useEffect(() => { @@ -734,7 +757,7 @@ const BST6Payment = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -919,27 +942,6 @@ const BST6Payment = () => { } }; - // useEffect(() => { - // if ( - // PrintOrderDetails?.length > 0 && - // (!filteredSettingNames || - // filteredSettingNames?.includes('Print') || - // filteredSettingNames?.length === 0) && - // ( - // (!filteredSettingNames?.includes('whatsapp') && - // (!isMobile || !filteredSettingNames?.includes('SMS'))) || - // ( - // (filteredSettingNames?.includes('whatsapp') || - // (isMobile && filteredSettingNames?.includes('SMS'))) && - // (!MobileNoWhatsApp || Object.keys(MobileNoWhatsApp).length === 0) - // ) - // ) - // ) { - - // handlePrintOrToken(); - // } - // }, [PrintOrderDetails]); - useEffect(() => { if (!PrintOrderDetails?.length) return; @@ -1047,8 +1049,10 @@ const BST6Payment = () => { }; useEffect(() => { if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); + if (holdCheckedSalesSetup) { + getHolddata(); + } + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -1136,9 +1140,6 @@ const BST6Payment = () => { setEmpData(datas?.[0]); }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); await dispatch( getAddCustomerDetails({ CompId: CompId, @@ -1235,7 +1236,11 @@ const BST6Payment = () => { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1564,28 +1569,7 @@ const BST6Payment = () => { setPaybtnnameselected(PaymentOptionsModeName); setPaybtnselected(PaymentOptionsModeId); }, [PaymentOptions]); - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); + useEffect(() => { getBookingTypeId(); }, [BookingType, BookingTypeBoth]); @@ -1610,20 +1594,12 @@ const BST6Payment = () => { }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); + setConfigDataList(AllBookingType); + let configdata = AllBookingType; + let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - setSelectedBookingType(filterconfigdata?.ConfigId); - } + let filterconfigdata = configdata?.find((a) => a?.ConfigName === checkName); + setSelectedBookingType(filterconfigdata?.ConfigId); }; const gettodaydate = () => { const currentDate = new Date(); @@ -1702,7 +1678,7 @@ const BST6Payment = () => { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -1957,7 +1933,9 @@ const BST6Payment = () => { setUpinotSelected(false); setCurrentOrderNetAmount(0); setPreviousNetAmount(0); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -2132,15 +2110,15 @@ const BST6Payment = () => { 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', @@ -2230,7 +2208,7 @@ const BST6Payment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2247,85 +2225,113 @@ const BST6Payment = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) + : (Paybtnnameselected?.toLowerCase() === 'upi' && + 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') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -2394,14 +2400,14 @@ const BST6Payment = () => { 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]); @@ -2562,14 +2568,14 @@ const BST6Payment = () => { 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]); @@ -2676,14 +2682,14 @@ const BST6Payment = () => { } 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]); @@ -2859,14 +2865,14 @@ const BST6Payment = () => { 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]); @@ -2885,7 +2891,7 @@ const BST6Payment = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3323,8 +3329,10 @@ const BST6Payment = () => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); const Otherserviceprint = async () => { if (OtherServicesPrintDetails?.length > 0) { @@ -3478,1326 +3486,1360 @@ const BST6Payment = () => { ); }; return ( - <> - {(addcustomer || hold) && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- -
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( + Suspense Loading...
}> + <> + {(addcustomer || hold) && ( + + )} + {creditCustomerOpen && ( + + )} + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelectedUpiOption && ( +
+ +
+ )} + + {PaymentUpiOptions?.length > 0 && OrderId && (
)} - {PaymentUpiOptions?.length > 0 && OrderId && ( -
- -
- )} - -
- {screenwidth <= 768 && ( -
- {Array.isArray(OrderCardDetail) && - OrderCardDetail?.length >= 1 && - (isMobile || screenwidth <= 768) && ( - - )} -
- )} -
-
-
- {tableOptions - ?.filter((item) => item.OptionName === 'AddCustomer') - .map((filteredItem) => ( - -
- - - {' '} - - -
-
- ))} -
-
- {!OtherServicesglobal && ( +
+ {screenwidth <= 768 && (
- {tableOptions?.map((item) => ( - <> - {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')} - style={{ - fontSize: '30px', - cursor: 'pointer', - color: '' ? '#52c41a' : '#1292EE', - }} - /> - - ) - : ''} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && - paybtns?.length > 0 && - !OtherServicesglobal && ( - - {' '} - = 1 && + (isMobile || screenwidth <= 768) && ( + + )} +
+ )} +
+
+
+ {tableOptions + ?.filter((item) => item.OptionName === 'AddCustomer') + .map((filteredItem) => ( + +
+ + - HandleholdModelOpen()} + onClick={handleAddCustomer} style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', + fontSize: '25px', + color: + selOption || GetCustId ? '#52c41a' : '#1292EE', + cursor: Custdisable ? 'not-allowed' : 'pointer', }} /> - + +
+
+ ))} +
+
+ {!OtherServicesglobal && ( +
+ {tableOptions?.map((item) => ( + <> + {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')} + style={{ + fontSize: '30px', + cursor: 'pointer', + color: '' ? '#52c41a' : '#1292EE', + }} + /> + + ) + : ''} + {unpaidFlow == false + ? item?.OptionName == 'Hold' && + BookingType !== 'Dine In' && + !BookingTypeBoth && + Holddata?.length > 0 && + OrderCardDetail?.length == 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && + paybtns?.length > 0 && + !OtherServicesglobal && ( + + {' '} + + HandleholdModelOpen()} + style={{ + fontSize: '28px', + cursor: 'pointer', + color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> + + + ) + : ''} + + ))} + {paybtns?.length > 1 && ( +
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + width: '2rem', + }} + > + {!OtherServicesglobal && ( + + {' '} +
+ +
- ) - : ''} - - ))} - {paybtns?.length > 1 && ( + )} +
+ )} +
+ )} + {Array.isArray(OrderCardDetail) && OrderCardDetail?.length >= 1 && ( +
+ {responsiveBill ? ( +
+ {' '} + {' '} +
+ ) : ( +
+ {' '} + {' '} +
+ )} +
+ )} +
+
+ + +
+
0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 'none' : 'auto', opacity: (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 0.5 : 1, - width: '2rem', }} > - {!OtherServicesglobal && ( - - {' '} -
- + {paybtns?.length > 0 && + currentOrderNetAmount >= previousNetAmount ? ( + paybtns?.map((payment) => ( +
+
- + )) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => ( +
+ +
+ )) + ) : ( +
+ Please Set Payment Options +
)}
- )} +
- )} - {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 -
- )} -
-
-
- -
- - + +
+ + - ) : ( -
ORDER
- )} - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail, index) => ( -
- -
- ) - )} -
- - -
+ } + title=" " + trigger="click" + open={open2} + onOpenChange={handleOpenChange2} + overlayStyle={{ + // width: "100%", + height: '300', + }} + > + + +
+ + + } title=" " trigger="click" - open={open2} - onOpenChange={handleOpenChange2} + open={open} + onOpenChange={handleOpenChange} overlayStyle={{ - // width: "100%", + width: '100%', height: '300', }} >
- - - - - - - } - title=" " - trigger="click" - open={open} - onOpenChange={handleOpenChange} - overlayStyle={{ - width: '100%', - height: '300', - }} - > - - -
-
- -
-
- {paybtnselected == - paybtns?.filter( - (item) => item?.ModeName?.toLowerCase() === 'cash' - )?.[0]?.ModeId ? ( - - ) : ( - '' - )}
-
- {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 */} - {GetCustId && ( - - {' '} -
{ - 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 && - OrderCardDetail?.length > 0 && - ParkingDisplay && - !OtherServicesglobal && ( -
- -
- )} - {!OtherServicesglobal && unpaidFlow == true ? ( - - {' '} - { - Recipt(); - }} - /> - - ) : ( - '' - )} -
- {!OtherServicesglobal && CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); - }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - /> -
- )} -
- { - 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'); - }} - /> -
-
-
- } - /> - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ) - // )) - } - { - 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} - /> - )} - {!OtherServicesglobal && 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 && ( - + {paybtnselected == + paybtns?.filter( + (item) => item?.ModeName?.toLowerCase() === 'cash' + )?.[0]?.ModeId ? ( + + ) : ( + '' )} +
- - - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> +
+ {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 */} + {GetCustId && ( + + {' '} +
{ + 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 && + OrderCardDetail?.length > 0 && + ParkingDisplay && + !OtherServicesglobal && ( +
+ +
+ )} + {!OtherServicesglobal && unpaidFlow == true ? ( + + {' '} + { + Recipt(); + }} + /> + + ) : ( + '' + )} +
+ {!OtherServicesglobal && CreditCustomer && ( +
+ { + handleCreditCustomer('Cancel'); + }} + handleOk={() => { + handleCreditCustomer('Submit'); + }} + /> +
)}
- )} - { - 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}`; + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+ {/*

UPI PAYMENT

*/} - // 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} - - )} -
- ); - })} -
- ); - })} -
- +
+ +
+ +
+

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

+
+
+ +
+ {(selOption || SelCustId) && ( +
+ Sent Payment Link + Your Alt Text + {/* */} +
+ )} + +
+ } + handleSubmit={() => { + Upimodel('Submit'); + }} + /> +
+
-
+ } + /> + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ) + // )) } - /> - 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? - - )} - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ) - // )) - } - {customerPreviesOrders && ( setCustomerPreviesOrders(false)} + open={unpaidopen} + title="UNPAID BILL'S" + width={1000} + handleCancel={() => { + setUnpaidOpen(false); + }} footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} + 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} + /> + )} + {!OtherServicesglobal && 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={ +
+ +
+ } + /> + { + 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={ <> - setCustomerPreviesOrders(false)} + } /> - )} - { - setOtherServicesModal(false); - }} - handleSubmit={Handlevehiclenumbers} - footer={true} - children={ -
{ + setBusinessUPI(false); + setShowCancelConfirm(false); + ClearAllGlobalStateDatas(); + CustomerDisplay(); + }} + onCancel={() => setShowCancelConfirm(false)} + okText="Yes" + cancelText="No" > - {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 - ) - } - style={{ - width: '100%', - padding: 8, - borderRadius: 4, - border: error - ? '1px solid red' - : '1px solid #ccc', - }} - /> - {error && ( - - {error} - - )} -
- ); - })} -
- ); - })} -
+ Do you want to cancel the payment? +
+ )} + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ) + // )) } - /> -
- + {customerPreviesOrders && ( + setCustomerPreviesOrders(false)} + footer={false} + width={700} + className={'ModalPaymentGatewayEmbedded'} + children={ + <> + setCustomerPreviesOrders(false)} + /> + + } + /> + )} + { + setOtherServicesModal(false); + }} + handleSubmit={Handlevehiclenumbers} + footer={true} + 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 + ) + } + style={{ + width: '100%', + padding: 8, + borderRadius: 4, + border: error + ? '1px solid red' + : '1px solid #ccc', + }} + /> + {error && ( + + {error} + + )} +
+ ); + })} +
+ ); + })} +
+ } + /> +
+ + ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx index f8400af..e44bf95 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBilling7Payment.jsx @@ -7,7 +7,7 @@ import { BiRightArrowAlt } from 'react-icons/bi'; import { AiOutlineClose } from 'react-icons/ai'; import BSSummery from '../BSBillingTableSummery/BSSummery.jsx'; import BSBillingTable7 from './BSBillingTable7'; -import { UpCircleOutlined, UpOutlined } from '@ant-design/icons'; +import { UpCircleOutlined } from '@ant-design/icons'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.scss'; import { GlobalSelectedFont, @@ -17,7 +17,7 @@ import { GlobalprintDatas, GlobalPrinterMappingDtls, getPrinterMappingDetails, - getPrintSelectionComponentData, + // getPrintSelectionComponentData, } from '../../../../../Features/ThemeChange/ThemeChange.js'; import { PrintStyleFunction } from '../../../../paymentpdfPage/PrintStyleFunction.js'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities.jsx'; @@ -94,7 +94,7 @@ import { GlobalOverAllDiscSales, ChangeOverAllDiscSales, ChangeOverAllDiscEstimate, - getAllCustomer, + GlobalBranchFinancialStatus, changeSummeryComboOfferAmount, ChangeComboCarddata, @@ -119,6 +119,7 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData.js'; import { globalExtraTotalAmount, @@ -174,11 +175,8 @@ import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoCartIcon from '../../../../../Pages/BookingScreen/Components/UtillComponents/PozoCartIcon.jsx'; import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, Global_OrderOfferDetail, - Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, + Global_OverallOfferAmount } from '../../../../../Features/Offer/Offer.js'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip'; @@ -242,6 +240,7 @@ const BSBilling7Payment = () => { const screenwidth = useSelector(GlobalScreenSize); const defaultBookingType = useSelector(GlobalDefaultBookingType); const printerTemplateStyle = useSelector(SelectedPrintTemplate); + const AllBookingType=useSelector(GlobalAllBookingType) const FontFamily = useSelector(GlobalSelectedFont); const OrderCardDetail = useSelector(GlobalOrderCardDetails); const GetCustId = useSelector(GlobalCustId); @@ -269,6 +268,9 @@ const BSBilling7Payment = () => { const templateData = useSelector(getTemplateData); const appPreferences = useSelector(ApplicationPreferences); const Combodata = useSelector(GlobalCombocarddata, shallowEqual); + const holdCheckedSalesSetup = tableOptions?.some( + (item) => item?.OptionName === 'Hold' + ); const bookingTypePreference = appPreferences?.find( (preference) => preference?.PreferredCatName === 'Booking Type' )?.PreferenceCatDetails; @@ -306,11 +308,9 @@ const BSBilling7Payment = () => { const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts); const GlobEstBooking = useSelector(GlobalEstimateBooking); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); - const BranchFinancialStatus = useSelector(GlobalBranchFinancialStatus); const preOrder = useSelector(GlobalpreOrderOpen); const OrderType = useSelector(GlobalOrderType); const FailedTotalAmt = useSelector(GlobalFailedTotalAmt); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail, shallowEqual); const defaultPaymentTrigger = useSelector(GlobalPaymentTrigger); const [defaultPaymentMode, setDefaultPaymentMode] = useState([]); const [defaultEnabled, setDefaultEnabled] = useState(false); @@ -324,8 +324,6 @@ const BSBilling7Payment = () => { const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; const [FirstPaymentclick, setFirstPaymentclick] = useState(false); const [open, setOpen] = useState(false); const [unpaidopen, setUnpaidOpen] = useState(false); @@ -692,13 +690,16 @@ const BSBilling7Payment = () => { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); useEffect(() => { if (CompId && BranchId && AppId) { + if(holdCheckedSalesSetup) + { getHolddata(); - getUnpaiddatas(); + } + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -814,9 +815,7 @@ const BSBilling7Payment = () => { : parseInt(value || 0); }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); + await dispatch( getAddCustomerDetails({ CompId: CompId, @@ -1627,20 +1626,14 @@ const BSBilling7Payment = () => { }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); - - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; + setConfigDataList(AllBookingType); + let configdata = AllBookingType; let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; let filterconfigdata = configdata?.find( (a) => a?.ConfigName === checkName ); setSelectedBookingType(filterconfigdata?.ConfigId); - } }; const gettodaydate = () => { const currentDate = new Date(); @@ -1932,7 +1925,10 @@ const BSBilling7Payment = () => { setCurrentOrderNetAmount(0); setPreviousNetAmount(0); setUpinotSelected(false); + if(holdCheckedSalesSetup) + { getHolddata(); + } if (defaultBookingType === 'Both') { await dispatch(changeBookingType('TakeAway')); } @@ -3331,8 +3327,10 @@ const BSBilling7Payment = () => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if(salesBillEdit){ + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger,salesBillEdit]); const Otherserviceprint = async () => { if (OtherServicesPrintDetails?.length > 0) { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx index 34ded16..82755a3 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { lazy, Suspense, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.scss'; import { @@ -14,7 +14,6 @@ import { GlobalPreviousOrderLength, GlobalUnpaidData, changeOrderCardDetails, - ChangeSelectedCustDisable, changeReorderHoldDetails, changeBookingType, changeSelectedOption, @@ -50,7 +49,9 @@ import { GlobalOfferAppliedProducts, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; +const BSBillingEditQuantity = lazy( + () => import('../BSBillingEditQuantity/BSBillingEditQuantity') +); import { ChangeTotalAmount, globalExtraTotalAmount, @@ -61,11 +62,14 @@ import dineInIcon from '../../../../../Images/Dine In.svg'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; -import { getSession } from '../../../../../Services/Others.js'; +const BSEditTotalAmt = lazy( + () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') +); +const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); +const CustomerPriceHistory = lazy( + () => import('../../UtillComponents/CustomerPriceHistory.jsx') +); import { useUtilsComponent } from '../../../../../Services/utils.js'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; const BSBillingTable7 = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -99,7 +103,8 @@ const BSBillingTable7 = () => { const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); const [EditQuantity, setEditQuantity] = useState(false); const [Modaldata, setModaldata] = useState([]); @@ -133,16 +138,16 @@ const BSBillingTable7 = () => { 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 productBasedExtraCharges = GlobalExtraCharge.filter( (obj) => 'ProdName' in obj @@ -276,7 +281,6 @@ const BSBillingTable7 = () => { event.preventDefault(); handleShortcut('weightAmount'); } - }; window.addEventListener('keydown', handleKeyDown); @@ -936,9 +940,9 @@ const BSBillingTable7 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1309,9 +1313,6 @@ const BSBillingTable7 = () => { }); } } - //Change Remove OrderCartDetail - //Remove FreeprodList - //ChangeOfferApplied Products } } else { ///remove item wise offer @@ -1605,8 +1606,6 @@ const BSBillingTable7 = () => { }); } } else { - //have to find if thereis two Booking Type is there - //Convert That Free Product To Paid Product let ischeckBothBookingType = tableData?.find( (e) => e?.InwardDtlId == inward && @@ -1621,12 +1620,6 @@ const BSBillingTable7 = () => { e?.BookingTypeName == item?.BookingTypeName ); if (ischeckBothBookingType) { - //Convert That Free Product To Paid Product - - //merge that paid product with same booking type - //decrease free prod list qty - //change offer applied product qty - // await ChangeOrderCardDetailsFn(item?.BookingTypeName, null, ischeckBothBookingType?.OrderQty + FreeProductSameBookingType?.OrderQty, false, ischeckBothBookingType?.InwardDtlId, item?.InwardDtlId, item?.Offer, true) if (FreeProductSameBookingType?.OrderQty >= item?.OrderQty) { await ChangeFreeprodlistFn({ OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty, @@ -1676,24 +1669,10 @@ const BSBillingTable7 = () => { 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 ) { - //paidproduct ischeckBothBookingType?.OrderQty-anotherBookingType?.OrderQty - //PaidProdcut Current BookingType FreeProductSameBookingType?.OrderQty let paidproductAnotherType = ischeckBothBookingType?.OrderQty - anotherBookingType?.OrderQty; @@ -1845,146 +1824,7 @@ const BSBillingTable7 = () => { } } } - }; - // 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(changeReorderHoldDetails([])); - // 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' && 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(changeReorderHoldDetails([])); - // 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(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(ChangeOverAllDiscSales(null)); - // await dispatch(ChangeOverAllDiscEstimate(null)); - // await dispatch(changeSelProdWiseEst([])); - // await dispatch(ChangeTotalAmount([])); - // } - // } - // }; function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; @@ -1997,11 +1837,10 @@ const BSBillingTable7 = () => { return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } - const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; const handlechange33 = () => { if (editdelete === 'Edit') { @@ -2055,592 +1894,603 @@ const BSBillingTable7 = () => { }; return ( - <> -
-
- {editField && ( -
- - -
- )} - {deleteField && ( -
- - -
- )} -
+ Loading...
}> + <> +
+
+ {editField && ( +
+ + +
+ )} + {deleteField && ( +
+ + +
+ )} +
-
- - - - {tableOptions?.map((item) => ( - <> - {item.OptionName == 'Sl.No' && BookingTypeBoth && ( - - )} - {item.OptionName == 'Sl.No' && ( - - )} +
+
- {!isMobile ? ( - {''} - ) : ( -
{''}
- )} -
- {!isMobile ? ( - Sl.No - ) : ( -
Sl.No
- )} -
+ + + {tableOptions?.map((item) => ( + <> + {item.OptionName == 'Sl.No' && BookingTypeBoth && ( + + )} + {item.OptionName == 'Sl.No' && ( + + )} - {item.OptionName == 'Item' && ( - - )} - {item.OptionName == 'MRP' && ( - - )} - {item.OptionName == 'Discount' && ( - - )} - {item.OptionName == 'Quantity' && ( - - )} - {item.OptionName == 'Rate' && ( - - )} - {item.OptionName == 'Amount' && ( - - )} - - ))} - - - {/* For Reorder TakeWay */} - {OldtableDataTakeAway?.length > 0 && ( - - {OldtableDataTakeAway?.map((item, index) => ( - + {!isMobile ? ( + Item + ) : ( +
Item
+ )} + + )} + {item.OptionName == 'MRP' && ( + + )} + {item.OptionName == 'Discount' && ( + + )} + {item.OptionName == 'Quantity' && ( + + )} + {item.OptionName == 'Rate' && ( + + )} + {item.OptionName == 'Amount' && ( + + )} + + ))} + + + {/* 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)' - : triggerAnimation && + : 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 - ? 'wheat' - : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData - ? 'wheat' - : 'inherit' - : 'none', - background: + tableDataTakeAway?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ? 'splashAnimation 0.5s ease-in-out' + : 'none' + : 'none', + }} + key={index} + onClick={ + editdelete === 'Edit' + ? () => handleEditQuantity(item) + : editdelete === 'Delete' + ? () => removeFromCart(item) + : () => {} + } + // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} + + className={`${ item?.SalesId && OrderType !== 'Hold' + ? 'BSBill-Table7-content-disabled' + : 'BSBill-Table7-content' + } + + `} + > + {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' && ( + + )} + + ))} + + ))} + + )} + {/* 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' - : index % 2 === 0 + : (OldtableDataTakeAway?.length + 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', - }} - key={index} - onClick={ - editdelete === 'Edit' - ? () => handleEditQuantity(item) - : editdelete === 'Delete' - ? () => removeFromCart(item) - : () => { } - } - // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - - className={`${item?.SalesId && OrderType !== 'Hold' - ? 'BSBill-Table7-content-disabled' - : 'BSBill-Table7-content' - } - - `} - > - {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' && ( - - )} - - ))} - - ))} - - )} - {/* 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', - }} - key={OldtableDataTakeAway?.length + index} - onClick={ - editdelete === 'Edit' - ? () => handleEditQuantity(item) - : editdelete === 'Delete' - ? () => removeFromCart(item) - : () => { } - } - // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} + tableDataDinein?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ? 'splashAnimation 0.5s ease-in-out' + : 'none' + : 'none', + }} + key={OldtableDataTakeAway?.length + index} + onClick={ + editdelete === 'Edit' + ? () => handleEditQuantity(item) + : editdelete === 'Delete' + ? () => removeFromCart(item) + : () => {} + } + // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${item?.SalesId - ? 'BSBill-Table7-content-disabled' - : 'BSBill-Table7-content' + className={`${ + item?.SalesId + ? 'BSBill-Table7-content-disabled' + : 'BSBill-Table7-content' } `} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( + > + {tableOptions?.map((tableitem) => ( + <> + {BookingTypeBoth && + index == 0 && + tableitem.OptionName == 'Sl.No' && ( + + )} + + {tableitem.OptionName == 'Sl.No' && ( )} + {tableitem.OptionName == 'Item' && ( + - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - ))} - - ))} - - )} - {/* TakeWay */} - {tableDataTakeAway?.length > 0 && ( - - {tableDataTakeAway?.map((item, index) => ( - 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} + + ))} + + ))} + + )} + {/* 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 + 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' - : (OldtableDataDinein?.length + + : 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' - : (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 + 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', - }} - key={ - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index - } - onClick={ - editdelete === 'Edit' - ? () => - item.Type == 'P' || item.Type == 'C' - ? handleEditQuantity(item) - : item.ServiceType == 'G' - ? handleEditQuantity(item) - : '' - : editdelete === 'Delete' - ? () => removeFromCart(item) - : () => { } - } - // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} + 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', + }} + key={ + OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index + } + onClick={ + editdelete === 'Edit' + ? () => + item.Type == 'P' || item.Type == 'C' + ? handleEditQuantity(item) + : item.ServiceType == 'G' + ? handleEditQuantity(item) + : '' + : editdelete === 'Delete' + ? () => removeFromCart(item) + : () => {} + } + // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'BSBill-Table7-content-disabled' - : 'BSBill-Table7-content' + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'BSBill-Table7-content-disabled' + : 'BSBill-Table7-content' } `} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( + > + {tableOptions?.map((tableitem) => ( + <> + {BookingTypeBoth && + index == 0 && + tableitem.OptionName == 'Sl.No' && ( + + )} + + {tableitem.OptionName == 'Sl.No' && ( )} + {tableitem.OptionName == 'Item' && ( + - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - ))} - - ))} - - )} - {/* DineIn */} - {tableDataDinein?.length > 0 && ( - - {tableDataDinein?.map((item, index) => ( - 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} + + ))} + + ))} + + )} + {/* 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)' - : BookingType === 'Dine In' && - triggerAnimation && + : 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 - ? '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', - }} - key={ - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index - } - onClick={ - editdelete === 'Edit' - ? () => handleEditQuantity(item) - : editdelete === 'Delete' - ? () => removeFromCart(item) - : () => { } - } - // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} + !item?.SalesId && + tableDataDinein?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData + ? 'splashAnimation 0.5s ease-in-out' + : 'none' + : 'none', + }} + key={ + OldtableDataTakeAway?.length + + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index + } + onClick={ + editdelete === 'Edit' + ? () => handleEditQuantity(item) + : editdelete === 'Delete' + ? () => removeFromCart(item) + : () => {} + } + // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'BSBill-Table7-content-disabled' - : 'BSBill-Table7-content' + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'BSBill-Table7-content-disabled' + : 'BSBill-Table7-content' } `} - > - {tableOptions?.map((tableitem) => ( - <> - {BookingTypeBoth && - index == 0 && - tableitem.OptionName == 'Sl.No' && ( + > + {tableOptions?.map((tableitem) => ( + <> + {BookingTypeBoth && + index == 0 && + tableitem.OptionName == 'Sl.No' && ( + + )} + + {tableitem.OptionName == 'Sl.No' && ( )} + {tableitem.OptionName == 'Item' && ( + - )} - {tableitem.OptionName == 'Item' && ( - - )} - {tableitem.OptionName == 'MRP' && ( - - )} - {tableitem.OptionName == 'Discount' && ( - + )} + {tableitem.OptionName == 'MRP' && ( + + )} + {tableitem.OptionName == 'Discount' && ( + - )} - {tableitem.OptionName == 'Quantity' && ( - - )} - {tableitem.OptionName == 'Rate' && ( - - )} - {tableitem.OptionName == 'Amount' && ( - - )} - - ))} - - ))} - + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + )} + {tableitem.OptionName == 'Quantity' && ( + + )} + {tableitem.OptionName == 'Rate' && ( + + )} + {tableitem.OptionName == 'Amount' && ( + + )} + + ))} + + ))} + + )} +
+ {!isMobile ? ( + {''} + ) : ( +
{''}
+ )} +
+ {!isMobile ? ( + Sl.No + ) : ( +
Sl.No
+ )} +
- {!isMobile ? ( - Item - ) : ( -
Item
- )} -
- {!isMobile ? ( - MRP - ) : ( -
MRP
- )} -
- {!isMobile ? ( - ₹/% - ) : ( -
₹/%
- )} -
0? OpenEditTotalAmount :""} - onClick={() => { - if (tableData?.length > 0) { - OpenEditTotalAmount(); - } - }} - > - {!isMobile ? ( - Qty - ) : ( -
Qty
- )} -
- {!isMobile ? ( - Rt - ) : ( -
Rt
- )} -
- {!isMobile ? ( - Amt - ) : ( -
Amt
- )} -
+ {!isMobile ? ( + MRP + ) : ( +
MRP
+ )} +
+ {!isMobile ? ( + ₹/% + ) : ( +
₹/%
+ )} +
0? OpenEditTotalAmount :""} + onClick={() => { + if (tableData?.length > 0) { + OpenEditTotalAmount(); + } + }} + > + {!isMobile ? ( + Qty + ) : ( +
Qty
+ )} +
+ {!isMobile ? ( + Rt + ) : ( +
Rt
+ )} +
+ {!isMobile ? ( + Amt + ) : ( +
Amt
+ )} +
+ + + {index + 1} + + (item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0) && + handleImeiDetails(item) + } + > + {item?.ProdName} + {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 + } +
+ )} +
+ {item?.MRP} + + {item?.Type != 'C' + ? item.Offer + ? item.Offer + : '-' + : item?.OfferPrice && item?.OfferPrice > 0 + ? item?.OfferType === 'F' + ? `₹${safeRound(item.OfferPrice)}` + : `${item.OfferPrice}%` + : '-'} + + {item?.OrderQty} + + {item?.OrderRate} + { + e.stopPropagation(); + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + style={{ fontFamily: 'Poppins' }} + > + {safeRound(item?.TotalAmt)} +
- - - {index + 1} - - (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0) && - handleImeiDetails(item) - } - > - {item?.ProdName} - {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 - } -
- )} -
- {item?.MRP} - - {item?.Type != 'C' - ? item.Offer - ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - - {item?.OrderQty} - - {item?.OrderRate} - { - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - style={{ fontFamily: 'Poppins' }}> - {safeRound(item?.TotalAmt)} -
+ + - + {OldtableDataTakeAway?.length + index + 1} + {item?.ProdName} - {tableitem.OptionName == 'Sl.No' && ( - - {OldtableDataTakeAway?.length + index + 1} - - {item?.ProdName} - - {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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
- {item?.MRP} - - {item?.Type != 'C' - ? item.Offer + + {item?.MRP} + + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - - {item?.OrderQty} - - {item?.OrderRate} - { - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} style={{ fontFamily: 'Poppins' }}> - {safeRound(item?.TotalAmt)} -
+ {item?.OrderQty} + + {item?.OrderRate} + { + e.stopPropagation(); + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + style={{ fontFamily: 'Poppins' }} + > + {safeRound(item?.TotalAmt)} +
+ + - + {OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index + + 1} + (item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0) && + handleImeiDetails(item) + } + > + {item?.Type !== 'OS' + ? item.ProdName + : item.ServiceName} - {tableitem.OptionName == 'Sl.No' && ( - - {OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index + - 1} - - (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0) && - handleImeiDetails(item) - } - > - {item?.Type !== 'OS' - ? item.ProdName - : item.ServiceName} - - {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?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {item?.ProdVariantName} } - {item?.Size} - {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}) */} - {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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
- {item?.MRP} - - {item?.Type != 'C' - ? item.Offer + + {item?.MRP} + + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - - {item?.OrderQty} - - {safeRound(item?.OrderRate)} - { - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} style={{ fontFamily: 'Poppins' }}> - {item?.TotalAmt} -
+ {item?.OrderQty} + + {safeRound(item?.OrderRate)} + { + e.stopPropagation(); + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + style={{ fontFamily: 'Poppins' }} + > + {item?.TotalAmt} +
+ + - + {OldtableDataTakeAway?.length + + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index + + 1} + {item?.ProdName} - {tableitem.OptionName == 'Sl.No' && ( - - {OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index + - 1} - - {item?.ProdName} - - {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?.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.ProdDetail?.map((prod, index) => ( +

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

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

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

- ))} -
- )} - {productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - ) !== undefined && ( + ))} +
+ )} + {productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + ) !== undefined && (
{ }
)} -
- {item?.MRP} - - {item?.Type != 'C' - ? item.Offer + + {item?.MRP} + + {item?.Type != 'C' ? item.Offer - : '-' - : item?.OfferPrice && item?.OfferPrice > 0 - ? item?.OfferType === 'F' - ? `₹${safeRound(item.OfferPrice)}` - : `${item.OfferPrice}%` - : '-'} - - {item?.OrderQty} - - {item?.OrderRate} - { - e.stopPropagation(); - if (GetCustId) { - handleCustomerProductPriceHistory(item); - } - }} - style={{ fontFamily: 'Poppins' }}> - {safeRound(item?.TotalAmt)} -
+ {item?.OrderQty} + + {item?.OrderRate} + { + e.stopPropagation(); + if (GetCustId) { + handleCustomerProductPriceHistory(item); + } + }} + style={{ fontFamily: 'Poppins' }} + > + {safeRound(item?.TotalAmt)} +
+ {OpenEditTotalAmt && ( + )} - - {OpenEditTotalAmt && ( - + {EditQuantity && ( + )} -
- {EditQuantity && ( - - )} - {OpenImeiDetail && ( - - )} - {(customerPriceHistoryOpen && GetCustId) && - - } - + {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} + + ); }; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQty.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQty.jsx index 64af609..7da9ce1 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQty.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQty.jsx @@ -1,7 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; -import { DefaultModal } from '../../../../../Components/Modal/DefaultModal'; -import FormHeader from '../../../../PageComponents/FormHeader.jsx'; import { Form } from 'antd'; import { GlobalOrderCardDetails, @@ -11,38 +9,29 @@ import { GlobalOrderType, GlobalReorderProductDetails, PreferenceData, - getConfigType, + GlobalAllBookingType, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; -import { ArrowRightOutlined } from '@ant-design/icons'; import { Messages } from '../../../../../Components/Notifications/Messages'; import '../../../../../Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss'; -import { settingDataSelector } from '../../../../../Features/PreferenceMaster/PreferenceMaster.js'; -import { RadioGrpButton } from '../../../../../Components/Forms/RadioGroup.jsx'; -import Buttons from '../../../../../Components/Forms/Buttons.jsx'; -import { InputField } from '../../../../../Components/Forms/InputField.jsx'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import { getTemplateData, StoredSessionData, } from '../../../../../Features/ThemeChange/ThemeChange.js'; -import { validateSafeInput } from '../../../../../Services/Others.js'; import { GlobalEmpAccessDetail } from '../../../../../Features/AppPage/CenterPage.js'; import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, ChangeOfferAppliedProducts, - changeOfferAppliedProductsForLoyalty, GlobalFreeProdList, GlobalOfferAppliedProducts, RemoveOfferAppliedProduct, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx'; import { v4 as uuidv4 } from 'uuid'; -import "./ComboBillTableEdit.scss" +import './ComboBillTableEdit.scss'; const ComboEditQty = (props) => { const dispatch = useDispatch(); - const formRef = useRef(null); const quantityInputRef = useRef(null); const priceChangeInputRef = useRef(null); const reductionInputRef = useRef(null); @@ -54,7 +43,7 @@ const ComboEditQty = (props) => { // const CompId = SessionData?.CompId; // const BranchId = SessionData?.BranchId; const UserType = SessionData?.UserType; - const applyOffer = useApplyOfferto_CardDetail(); + const AllBookingType = useSelector(GlobalAllBookingType); const preferenceDatas = useSelector(PreferenceData); const EmpAccessDetail = useSelector(GlobalEmpAccessDetail); const OverAllproductBasedOfferDatas = useSelector( @@ -75,7 +64,7 @@ const ComboEditQty = (props) => { console.log(preferenceshortcutkey, 'preferenceshortcutkey'); const [PriceChangeaccess, setPriceChangeaccess] = useState(true); - const [ConfigDataList, setConfigDataList] = useState([]); + const [ConfigDataList, setConfigDataList] = useState(AllBookingType); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); const [EditOpen, setEditOpen] = useState(props?.BSBillingEditQuantity); @@ -104,7 +93,7 @@ const ComboEditQty = (props) => { ? 'Price' : 'Parcel' ); - const [PercentageSelection, setPercentageSelection] = useState('Fixed'); + const [RadioDetails, setRadioDetails] = useState(false); const [editedPrice, setEditedPrice] = useState(0); const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find( @@ -265,11 +254,7 @@ const ComboEditQty = (props) => { setEditedPrice(0); }; - // const AddQuantityonly = () => { - // setMessageType('success'); - // setMessageData('Quantity Added'); - // }; - + const createUpdatedCartItem = (cartItem, quantity, newPrice) => { const qty = parseInt(quantity); const rate = parseFloat(newPrice); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx index 83107da..4d274fc 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx @@ -29,16 +29,18 @@ import { } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx'; import { v4 as uuidv4 } from 'uuid'; -import "./ComboBillTableEdit.scss" +import './ComboBillTableEdit.scss'; const ComboEditQtyAndRate = (props) => { const dispatch = useDispatch(); const formRef = useRef(null); const quantityInputRef = useRef(null); const priceChangeInputRef = useRef(null); - const modalRef = useRef(null); - const { setIndex = () => {}, setEditQtyCombo = () => {}, setEditRateCombo = () => {} } = props; - + const { + setIndex = () => {}, + setEditQtyCombo = () => {}, + setEditRateCombo = () => {}, + } = props; const [disableSubmitButton, setDisableSubmitButton] = useState(false); const SessionData = useSelector(StoredSessionData); @@ -70,7 +72,9 @@ const ComboEditQtyAndRate = (props) => { const [ConfigDataList, setConfigDataList] = useState([]); const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); - const [EditOpen, setEditOpen] = useState(props?.BSBillingEditQuantity || props?.BSBillingEditRate); + const [EditOpen, setEditOpen] = useState( + props?.BSBillingEditQuantity || props?.BSBillingEditRate + ); const [ItemData, setItemData] = useState(props?.Productdata); const [Quantity, setQuantity] = useState(''); const ReorderProductData = useSelector(GlobalReorderProductDetails); @@ -123,7 +127,7 @@ const ComboEditQtyAndRate = (props) => { setEditOpen(props.BSBillingEditQuantity || props.BSBillingEditRate); setItemData(props.Productdata); setQuantity(''); - setEditedPrice(''); + setEditedPrice(''); }, [props.BSBillingEditQuantity], [props.Productdata], @@ -141,21 +145,26 @@ const ComboEditQtyAndRate = (props) => { }, [RadioBtnSelection, props.BSBillingEditQuantity, props.BSBillingEditRate]); useEffect(() => { -const handleKeyDown = (event) => { - const navigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; - if (event.key === 'Escape' || navigationKeys.includes(event.key)) { - event.preventDefault(); - if (props.BSBillingEditQuantity) { - props.handleEditQuantityCancel?.(); - setEditQtyCombo(false); - } - if (props.BSBillingEditRate) { - props.handleEditRateComboCancel?.(); - setEditRateCombo(false); - } - return; - } -}; + const handleKeyDown = (event) => { + const navigationKeys = [ + 'ArrowLeft', + 'ArrowRight', + 'ArrowUp', + 'ArrowDown', + ]; + if (event.key === 'Escape' || navigationKeys.includes(event.key)) { + event.preventDefault(); + if (props.BSBillingEditQuantity) { + props.handleEditQuantityCancel?.(); + setEditQtyCombo(false); + } + if (props.BSBillingEditRate) { + props.handleEditRateComboCancel?.(); + setEditRateCombo(false); + } + return; + } + }; if (EditOpen) { document.addEventListener('keydown', handleKeyDown); @@ -173,8 +182,6 @@ const handleKeyDown = (event) => { props.BSBillingEditRate, ]); - - useEffect(() => { const BillOrder = SettingDataSelector?.[0]?.SettingDtlDetails?.find( (item) => item.SettingIdName === 'BillItemsOrder' @@ -198,7 +205,11 @@ const handleKeyDown = (event) => { } else if (props?.BSBillingEditQuantity) { setRadioBtnSelection('Quantity'); } - }, [props?.BSBillingEditRate, props?.BSBillingEditQuantity, props.Productdata?.OrderRate]); + }, [ + props?.BSBillingEditRate, + props?.BSBillingEditQuantity, + props.Productdata?.OrderRate, + ]); const getBookingTypeId = async () => { let tempconfigdata = await dispatch( getConfigType({ TypeName: 'Booking Type' }) @@ -209,7 +220,6 @@ const handleKeyDown = (event) => { } }; - const calculateOverAllQty = (item, filterItems) => { if (!item) return 0; @@ -256,25 +266,25 @@ const handleKeyDown = (event) => { setMessageData('Product not found in cart'); return; } - + const editedProduct = CartOrderDetails[editedProductIndex]; const existingQty = editedProduct.OrderQty; - + // Validate rate value if (!newPrice || newPrice <= 0) { setMessageType('error'); setMessageData('Please enter a valid rate'); return; } - + // Update ONLY the rate, use existing quantity await handleNormalEditQuantity( editedProduct, editedProductIndex, - existingQty, + existingQty, newPrice ); - + // Reset and close setClearQuantity(false); setIndex(null); @@ -3216,14 +3226,13 @@ const handleKeyDown = (event) => { ref={quantityInputRef} type="number" value={Quantity} - min="0" + min="0" onChange={(e) => setQuantity(e.target.value)} onBlur={() => { if (Quantity && Quantity.trim() !== '') { AddProductQuantity(); } }} - min={0} className="EditQTYcomboInput" placeholder="Enter Qty" /> @@ -3239,7 +3248,11 @@ const handleKeyDown = (event) => { autoComplete="off" onChange={SellingPriceChange} onBlur={() => { - if (editedPrice && editedPrice !== '' && disableSubmitButton) { + if ( + editedPrice && + editedPrice !== '' && + disableSubmitButton + ) { AddProductQuantity(); } }} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx index 0a453ef..0630d60 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx @@ -1,5 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react'; -import './ComboSalesBillTable.scss'; +import React, { lazy, useEffect, useRef, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { Popconfirm, Tooltip } from 'antd'; import WebFont from 'webfontloader'; @@ -9,16 +8,12 @@ import { ChangeTotalAmount, globalExtraTotalAmount, } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; import { changeholddata, gettinghold, puttinghold, } from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; import { getTemplateData, SelectedGlobalBillingColorDetail, @@ -66,8 +61,6 @@ import { GlobalSalesBillEdit, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import { - ChangeOfferAppliedProducts, - ChangeFreeProductList, ChangeFullFreeProductList, GlobalFreeProdList, GlobalOfferAppliedProducts, @@ -75,11 +68,24 @@ import { changeLoyaltyConsumedQuantities, ClearOfferAppliedProducts, } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; -import { useRemoveProducts } from '../BSBillingTable3/RemoveCartWithOffer.jsx'; import { useUtilsComponent } from '../../../../../Services/utils.js'; -import ComboEditRate from '../ComboBillTableEdit/ComboEditRate.jsx'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; -import ComboEditQtyAndRate from '../ComboBillTableEdit/ComboEditQtyAndRate.jsx'; +import { useRemoveProducts } from '../BSBillingTable3/RemoveCartWithOffer.jsx'; +import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; +// jsx files +const CustomerPriceHistory = lazy( + () => import('../../UtillComponents/CustomerPriceHistory.jsx') +); +const ComboEditQtyAndRate = lazy( + () => import('../ComboBillTableEdit/ComboEditQtyAndRate.jsx') +); +const BSEditTotalAmt = lazy( + () => import('../BSEditTotalAmount/BSEditTotalAmt.jsx') +); +const BSImeiDetails = lazy(() => import('../BSImeiDetails/BSImeiDetails.jsx')); +const BSBillingEditQuantity = lazy( + () => import('../BSBillingEditQuantity/BSBillingEditQuantity.jsx') +); // Scss Files +import './ComboSalesBillTable.scss'; const ComboSalesBillTable = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -152,13 +158,13 @@ const ComboSalesBillTable = () => { OrderType === 'Hold' ? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway') : tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId - ); + (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId + ); const OldtableDataTakeAway = OrderType != 'Hold' ? tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; const [EditQuantity, setEditQuantity] = useState(false); @@ -267,7 +273,9 @@ const ComboSalesBillTable = () => { ...sameItems[0], OrderQty: totalQty, TotalAmt: totalQty * item.OrderRate, - TaxAmt: ((totalQty * item.OrderRate * item.TaxPercentage) / (100 + item.TaxPercentage)), + TaxAmt: + (totalQty * item.OrderRate * item.TaxPercentage) / + (100 + item.TaxPercentage), }; mergedData.push(mergedItem); } else { @@ -313,13 +321,7 @@ const ComboSalesBillTable = () => { }; }, [GetCustId, tableData]); - // useEffect(() => { - // const BillOrder = preferenceDatas?.[0]?.SettingDtlDetails?.find( - // (item) => item.SettingIdName === 'BillItemsOrder' - // ); - // setBillOrderPre(BillOrder?.SettingValue); - // }, [preferenceDatas]); - useEffect(() => { + useEffect(() => { const getSelectedItem = () => { const getItem = (data = []) => { if (!data.length) return null; @@ -463,6 +465,7 @@ const ComboSalesBillTable = () => { BranchId: BranchId, AppId: AppId, }; + await dispatch(getSelectedFavItems(data)).unwrap(); let data1 = { @@ -1229,9 +1232,9 @@ const ComboSalesBillTable = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -2136,7 +2139,6 @@ const ComboSalesBillTable = () => { } } } - }; useEffect(() => { @@ -2468,24 +2470,25 @@ const ComboSalesBillTable = () => { tableDataDinein?.length >= PreviousdataLength ? 'wheat' : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + triggerAnimation && + OldtableDataTakeAway?.length + index === 0 && + tableDataDinein?.length >= PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', - background: row?.SalesId && OrderType !== 'Hold' - ? 'rgb(243, 248, 213)' - : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - row?.InwardDtlId + ' ' + row?.BookingTypeName - ) - ? '#b2d1f7' - : (OldtableDataTakeAway?.length + index) % 2 === 0 - ? 'white' - : SelectedBillColor?.['OverallBackgroundColor'], + background: + row?.SalesId && OrderType !== 'Hold' + ? 'rgb(243, 248, 213)' + : GlobEstBooking === 'ParEst' && + GlobProdwisedata?.includes( + row?.InwardDtlId + ' ' + row?.BookingTypeName + ) + ? '#b2d1f7' + : (OldtableDataTakeAway?.length + index) % 2 === 0 + ? 'white' + : SelectedBillColor?.['OverallBackgroundColor'], animation: BillOrderPre === 'Y' && !BookingTypeBoth @@ -2524,44 +2527,44 @@ const ComboSalesBillTable = () => { {/* Product Name / Item */} {(item.OptionName === 'Item' || item.OptionName === 'Product Name') && ( - - row.FullProductIdentifierDtls?.length > 0 || - row.ProductIdentifierDtls?.length > 0 - ? handleImeiDetails(row) - : editField && handleEditQuantity(row) - } - > - {row?.Type !== 'OS' ? row.ProdName : row.ServiceName} - {row?.BrandName ? ` ${row.BrandName}` : ''} - {row?.Type !== 'C' && ( -

- {/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */} - ( - {!row?.ProdVariantName?.toLowerCase()?.includes( - 'variant' - ) && {row?.ProdVariantName} } - {row?.Size} - {row?.SinglePc == 'Y' ? 'PCS' : row?.UomName}) + + row.FullProductIdentifierDtls?.length > 0 || + row.ProductIdentifierDtls?.length > 0 + ? handleImeiDetails(row) + : editField && handleEditQuantity(row) + } + > + {row?.Type !== 'OS' ? row.ProdName : row.ServiceName} + {row?.BrandName ? ` ${row.BrandName}` : ''} + {row?.Type !== 'C' && ( +

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

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

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

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

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

- ))} - - )} + ))} + + )} {/* Barcode */} {item.OptionName === 'Barcode' && ( @@ -2588,10 +2591,11 @@ const ComboSalesBillTable = () => { }} key={`qty-${index}`} tabIndex={0} - className={`${EditQtyCombo && row?.localId === Index - ? 'EditQTYcomboTD' - : 'qtyTd' - } ${isActiveCell ? 'active-cell' : ''}`} + className={`${ + EditQtyCombo && row?.localId === Index + ? 'EditQTYcomboTD' + : 'qtyTd' + } ${isActiveCell ? 'active-cell' : ''}`} onClick={() => editField && handleEditQuantityCombo(row) } @@ -2654,9 +2658,9 @@ const ComboSalesBillTable = () => { > {row?.Offer > 0 ? `${( - (row.Offer / (row?.OrderQty * row?.OrderRate)) * - 100 - ).toFixed(2)}%` + (row.Offer / (row?.OrderQty * row?.OrderRate)) * + 100 + ).toFixed(2)}%` : '-'} )} @@ -2688,8 +2692,8 @@ const ComboSalesBillTable = () => { > {allowDecimal ? Number(row.TotalAmt - (row?.Offer || 0)).toFixed( - 2 - ) + 2 + ) : Number(row.TotalAmt - (row?.Offer || 0))} )} @@ -2732,7 +2736,7 @@ const ComboSalesBillTable = () => { removeFromCart(row)} diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx index c3ec00f..37fdb39 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx @@ -1,25 +1,27 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useState, lazy, Suspense } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Popconfirm, Tooltip } from 'antd'; import WebFont from 'webfontloader'; -import { isMobile } from 'react-device-detect'; import { AiOutlineClose, AiFillDelete } from 'react-icons/ai'; import TakeAwayIcon from '../../../../../Images/Take away.svg'; import dineInIcon from '../../../../../Images/Dine In.svg'; -import { - ChangeTotalAmount, - globalExtraTotalAmount, -} from '../../../../../Features/ExteraCharges/ExtraCharges.js'; -import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity'; -import { - changeholddata, - gettinghold, - puttinghold, -} from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; + import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; +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') +); import { getTemplateData, SelectedGlobalBillingColorDetail, @@ -70,9 +72,17 @@ import { GlobalSelOption, GlobalSalesBillEdit, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; +import { + ChangeTotalAmount, + globalExtraTotalAmount, +} from '../../../../../Features/ExteraCharges/ExtraCharges.js'; +import { + changeholddata, + gettinghold, + puttinghold, +} from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import './StandardTable.scss'; -import { IoClose } from 'react-icons/io5'; -import StandardTablePayment from './StandardTablePayment.jsx'; + import { FaAngleDown, FaAngleUp } from 'react-icons/fa'; import { ChangeFullFreeProductList, @@ -82,10 +92,7 @@ import { } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin.js'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; -import { CiShop } from 'react-icons/ci'; -import BranchName from '../../../Template/BranchName.jsx'; import { useUtilsComponent } from '../../../../../Services/utils.js'; -import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; const StandardTable = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -139,18 +146,12 @@ const StandardTable = () => { const OrderType = useSelector(GlobalOrderType); const GlobalExtraCharge = useSelector(globalExtraTotalAmount); const OtherServicesglobal = useSelector(GlobalOtherSevices); - const totalItems = useSelector(GlobalSummeryTotalItems); const GetCustId = useSelector(GlobalCustId); const selectedCustomer = useSelector(GlobalSelOption); - const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = useState(false); + const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] = + useState(false); const [customerProduct, setCustomerProduct] = useState(null); - const [tableCollapse, setTableCollapse] = useState(false); const [shortKeyMethod, setshortKeyMethod] = useState(null); - - // Add state for toggle functionality - const [isExpanded, setIsExpanded] = useState(false); - - // Add state for mobile table show/hide const [mobileTableVisible, setMobileTableVisible] = useState(true); const tableDataDinein = OrderCardDetail?.filter( @@ -160,8 +161,8 @@ const StandardTable = () => { OrderType === 'Hold' ? OrderCardDetail?.filter((a, b) => a.BookingTypeName === 'TakeAway') : OrderCardDetail?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId - ); + (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId + ); console.log('HoldOrderDtl', OrderCardDetail); const OldtableDataDinein = OrderCardDetail?.filter( (a, b) => a.BookingTypeName === 'Dine In' && a?.SalesId @@ -169,8 +170,8 @@ const StandardTable = () => { const OldtableDataTakeAway = OrderType != 'Hold' ? OrderCardDetail?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; const [EditQuantity, setEditQuantity] = useState(false); @@ -274,16 +275,7 @@ const StandardTable = () => { } return; } - // 👉 CTRL shortcuts if (!event.ctrlKey) return; - // if (key === 'q') { - // event.preventDefault(); - // handleShortcut('qty'); - // } - // if (key === 'e') { - // event.preventDefault(); - // handleShortcut('price'); - // } if (key === 'q') { event.preventDefault(); handleShortcut('qty'); @@ -305,36 +297,6 @@ const StandardTable = () => { }; }, [preferenceshortcutkey, tableDataTakeAway, tableDataDinein, BillOrderPre]); - // useEffect(() => { - // const handleKeyDown = (event) => { - // // Ctrl + Q - // if (event.ctrlKey && event.key.toLowerCase() === "q") { - // event.preventDefault(); - - // const getItem = (data = []) => { - // if (!data.length) return null; - // return BillOrderPre === "Y" - // ? data[0] - // : data[data.length - 1]; - // }; - - // let item = null; - // if (tableDataTakeAway?.length > 0) { - // item = getItem(tableDataTakeAway); - // } else if (tableDataDinein?.length > 0) { - // item = getItem(tableDataDinein); - // } - // if (item) { - // handleEditQuantity(item); - // } - // } - // }; - // window.addEventListener("keydown", handleKeyDown); - - // return () => { - // window.removeEventListener("keydown", handleKeyDown); - // }; - // }, [tableDataTakeAway, tableDataDinein, BillOrderPre]); const getstockbadge = async () => { let data = { CompId: CompId, @@ -342,9 +304,9 @@ const StandardTable = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -356,9 +318,9 @@ const StandardTable = () => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -369,9 +331,9 @@ const StandardTable = () => { prodCat: prodCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -576,7 +538,6 @@ const StandardTable = () => { CompleteRemoveAndPaidToFreeOtherTypeWithoutMerge = false, RemoveAndUpdateOtherBookingType = false, BookingTypeName, - TotalAmt, localid, }) => { let ModifiedOrderCardDetail = JSON.parse(JSON.stringify(OrderCardDetail)); @@ -687,14 +648,7 @@ const StandardTable = () => { } if (CompleteRemove) { const data = ModifiedOrderCardDetail?.filter( - (e) => - !( - (e.localId === localid) - // e?.InwardDtlId === InwardDtlId && - // e?.Offer === Offer && - // e?.BookingTypeName === BookingTypeName && - // e?.TotalAmt === TotalAmt - ) + (e) => !(e.localId === localid) ); return dispatch(changeOrderCardDetails(data)); } @@ -1188,9 +1142,9 @@ const StandardTable = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -1915,7 +1869,6 @@ const StandardTable = () => { insideinwardDtlId: false, }); } else { - let data = isCheckFreeProductOutside?.FreeQty - item?.OrderQty; //First i Calculate Another Booking Type Qty let anotherBookingType = OrderCardDetail?.find( (e) => @@ -1930,27 +1883,10 @@ const StandardTable = () => { 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 ) { - //paidproduct ischeckBothBookingType?.OrderQty-anotherBookingType?.OrderQty - //PaidProdcut Current BookingType FreeProductSameBookingType?.OrderQty let paidproductAnotherType = ischeckBothBookingType?.OrderQty - anotherBookingType?.OrderQty; @@ -2102,146 +2038,7 @@ const StandardTable = () => { } } } - }; - // const removeFromCart = async (item) => { - // setPreviousdataLength(OrderCardDetail?.length); - // if (item?.BookingTypeName !== 'Dine In' && OrderType !== 'Hold') { - // const UpdatedData = OrderCardDetail?.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 (OrderCardDetail?.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 = OrderCardDetail?.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 (OrderCardDetail?.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 = OrderCardDetail?.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 (OrderCardDetail?.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); @@ -2296,16 +2093,12 @@ const StandardTable = () => { const handleCustomerProductPriceHistory = (item) => { setCustomerPriceHistoryOpen(true); setCustomerProduct(item?.ProdId); - } + }; const handleEditQuantityCancel = () => { setEditQuantity(false); }; - const handleToggle = () => { - setIsExpanded(!isExpanded); - }; - const handleTableCart = () => { if (window.innerWidth <= 768) { setMobileTableVisible((prev) => !prev); @@ -2594,10 +2387,11 @@ const StandardTable = () => { {OldtableDataTakeAway?.map((item, index) => ( { ? item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength + index === 0 && + !item?.SalesId && + tableDataTakeAway?.length >= PreviousdataLength ? 'wheat' : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + index === 0 && + tableDataTakeAway?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', @@ -2624,9 +2418,9 @@ const StandardTable = () => { item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : index % 2 === 0 ? 'white' @@ -2652,7 +2446,7 @@ const StandardTable = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -2689,7 +2483,7 @@ const StandardTable = () => { }} onClick={() => item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 + item.ProductIdentifierDtls?.length > 0 ? handleImeiDetails(item) : editField && handleEditQuantity(item) } @@ -2758,21 +2552,21 @@ const StandardTable = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -2870,7 +2664,9 @@ const StandardTable = () => { } }} > - {safeRound(item?.TotalAmt - (item?.Offer || 0) || 0)} + {safeRound( + item?.TotalAmt - (item?.Offer || 0) || 0 + )} )} {tableitem.OptionName == 'Delete' && ( @@ -2914,10 +2710,11 @@ const StandardTable = () => { {OldtableDataDinein?.map((item, index) => ( { ? item?.SalesId ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && triggerAnimation && OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + !item?.SalesId && + tableDataDinein?.length >= 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 - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + index) % 2 === 0 ? 'white' @@ -2975,7 +2772,7 @@ const StandardTable = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -3076,21 +2873,21 @@ const StandardTable = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -3187,7 +2984,9 @@ const StandardTable = () => { } }} > - {safeRound(item?.TotalAmt - (item?.Offer || 0) || 0)} + {safeRound( + item?.TotalAmt - (item?.Offer || 0) || 0 + )} )} @@ -3236,10 +3035,11 @@ const StandardTable = () => { OldtableDataTakeAway?.length + index } - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'booking-billing-table-row-disabled' - : 'booking-billing-table-row' - } + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'booking-billing-table-row-disabled' + : 'booking-billing-table-row' + } `} style={{ @@ -3248,43 +3048,43 @@ const StandardTable = () => { ? 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 + 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 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.[ - 'OverallBackgroundColor' - ] + 'OverallBackgroundColor' + ] ? SelectedBillColor?.[ - 'OverallBackgroundColor' - ] + 'OverallBackgroundColor' + ] : '#d6d6d6' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3293,15 +3093,15 @@ const StandardTable = () => { BookingType === 'Dine In' && item?.SalesId ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3310,9 +3110,9 @@ const StandardTable = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && + OldtableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataTakeAway?.length >= PreviousdataLength && !HoldOrderDtl && @@ -3328,7 +3128,7 @@ const StandardTable = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -3365,7 +3165,7 @@ const StandardTable = () => { }} onClick={() => item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 + item.ProductIdentifierDtls?.length > 0 ? handleImeiDetails(item) : editField && handleEditQuantity(item) } @@ -3389,8 +3189,8 @@ const StandardTable = () => { {!item?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - {item?.ProdVariantName} - )} + {item?.ProdVariantName} + )} {AvailableDate ? ( <> {' '} @@ -3440,21 +3240,21 @@ const StandardTable = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -3552,7 +3352,9 @@ const StandardTable = () => { } }} > - {safeRound(item?.TotalAmt - (item?.Offer || 0) || 0)} + {safeRound( + item?.TotalAmt - (item?.Offer || 0) || 0 + )} )} @@ -3601,10 +3403,11 @@ const StandardTable = () => { tableDataTakeAway?.length + index } - className={`${BookingType === 'Dine In' && item?.SalesId - ? 'booking-billing-table-row-disabled' - : 'booking-billing-table-row' - } + className={`${ + BookingType === 'Dine In' && item?.SalesId + ? 'booking-billing-table-row-disabled' + : 'booking-billing-table-row' + } `} style={{ @@ -3615,45 +3418,45 @@ const StandardTable = () => { !BookingTypeBoth ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength - ? 'wheat' - : BookingType !== 'Dine In' && triggerAnimation && OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - tableDataDinein?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && + !item?.SalesId && + tableDataDinein?.length >= 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 + item?.SalesId && + !BookingTypeBoth ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -3662,10 +3465,10 @@ const StandardTable = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataDinein?.length >= PreviousdataLength && !HoldOrderDtl && @@ -3681,7 +3484,7 @@ const StandardTable = () => { index == 0 && tableitem.OptionName == 'Sl.No' && ( @@ -3787,21 +3590,21 @@ const StandardTable = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} @@ -3898,7 +3701,9 @@ const StandardTable = () => { } }} > - {safeRound(item?.TotalAmt - (item?.Offer || 0) || 0)} + {safeRound( + item?.TotalAmt - (item?.Offer || 0) || 0 + )} )} @@ -3929,33 +3734,37 @@ const StandardTable = () => { )} - {OpenEditTotalAmt && ( - - )} - {OpenImeiDetail && ( - - )} - {(customerPriceHistoryOpen && GetCustId) && - - } + Loading...
}> + {OpenEditTotalAmt && ( + + )} + {OpenImeiDetail && ( + + )} + {customerPriceHistoryOpen && GetCustId && ( + + )} +
- + Loading...
}> + +
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx index ce83b53..503a1a1 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTablePayment.jsx @@ -1,5 +1,12 @@ +import React, { + useCallback, + useEffect, + useRef, + useState, + lazy, + Suspense, +} from 'react'; import { - FaAngleDown, FaCartPlus, FaMoneyBillWave, FaPrint, @@ -8,8 +15,13 @@ import { import { IoClose } from 'react-icons/io5'; import { FaMobileScreenButton } from 'react-icons/fa6'; import moment from 'moment'; -import Credit from '../../UtillComponents/Pozo retail icons/credit.svg'; -import { FaCreditCard } from 'react-icons/fa6'; +import { Tables } from '../../../../../Components/Tables/Table.jsx'; +import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip.jsx'; +import UpiPopover from './Utils/UpiPopOver'; +import { isMobile } from 'react-device-detect'; +import { useDispatch } from 'react-redux'; + +// Js Files import { changeAddBookingDetailsTrigger, changeBillEditingMode, @@ -58,6 +70,7 @@ import { getSelectedFavItems, getUnpaidData, GlobalAddBookingDetailsTrigger, + GlobalAllBookingType, GlobalBookingType, GlobalBookingTypeBoth, GlobalCombocarddata, @@ -89,7 +102,6 @@ import { GlobalSelectedTableDetails, GlobalSelOption, GlobalSelProdWiseEst, - GlobalSummeryTotalItems, GlobalSummeryTotalTaxAmount, GlobaltipAmount, Globalunpaidflow, @@ -104,16 +116,10 @@ import { putSalesBillEdit, putSplitpaymentStatus, SendPaymentLink, -} from '../../../../../Features/BookingScreen/BookingData/BookingData'; +} from '../../../../../Features/BookingScreen/BookingData/BookingData.js'; import { shallowEqual, useSelector } from 'react-redux'; +import { Global_OverallOfferAmount } from '../../../../../Features/Offer/Offer'; import { - Global_OrderOfferDetail, - Global_OverallOfferAmount, -} from '../../../../../Features/Offer/Offer'; -import React, { useCallback, useEffect, useRef, useState } from 'react'; -import { - getPrinterMappingDetails, - getPrintSelectionComponentData, getTemplateData, GlobalprintDatas, GlobalPrinterMappingDtls, @@ -130,13 +136,11 @@ import { encryptObject, extractLastNumberOrderId, } from '../../../../../Services/Others'; -import { useDispatch } from 'react-redux'; import { getPaymentOptionsData } from '../../../../../Features/BookingScreen/BookingData/KioskBookingData'; import { PostOtherServices } from '../../../../../Features/OtherServices/OtherServices'; import paygate from '../../../../../Images/paygate.png'; import defaultupi from '../../../../../Images/defaultupi.png'; import paydevice from '../../../../../Images/paydevice.png'; -import QrinScreen from '../../BookingFunctionality/DynamicScreenQr.jsx'; import { changeholddata, gettinghold, @@ -147,33 +151,22 @@ import { changeSalesPaymentoption, GlobalSalesPaymentoption, } from '../../../../../Features/Payment/Paymentoptions/Paymentoptions'; -import UpiPopover from './Utils/UpiPopOver'; -import { isMobile } from 'react-device-detect'; -import { MobilePdfPrint } from '../../BookingFunctionality/MobilePdfPrint'; import IndividualTokenMobilePrint from '../../BookingFunctionality/IndividualTokenMobilePrint'; import SingleTokenMobilePrint from '../../BookingFunctionality/SingleTokenMobilePrint'; import MobilePrint from '../../BookingFunctionality/MobilePrint'; import { PrintStyleFunction } from '../../../../paymentpdfPage/PrintStyleFunction'; import { printDiv } from '../../../../../Services/WSOthers'; -import { MdSms } from 'react-icons/md'; -import WhatsAppShare from '../../../../WhatsAppShare/whatsAppShare'; -import SMSShare from '../../../../WhatsAppShare/SmsShare'; import { GlobalBookingStatus } from '../../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail'; import { useAuth } from '../../../../../AuthContext'; import CountUp from 'react-countup'; -import { BiRightArrowAlt } from 'react-icons/bi'; import { GlobalpreOrderOpen } from '../../../../../Features/BookingScreen/PreOrder/PreOrder'; import BsBillingCreditCustomer from '../../BookingFunctionality/BSBillingCreditCustomer'; -import TokensinglePrint from '../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint'; import PaymentPdfBooking from '../../../../paymentpdfPage/PaymentPdfBooking'; import { DefaultModal } from '../../../../../Components/Modal/DefaultModal'; import Buttons from '../../../../../Components/Forms/Buttons'; -import { ArrowRightOutlined } from '@ant-design/icons'; -import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions'; -import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon'; + import SplitPayment from '../../BookingFunctionality/SplitPayment'; import BSCreditCustomer from '../../UtillComponents/BSCreditCustomer'; -import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon'; import { getDefaultPaymentOptions, GlobalAddCustomerDetails, @@ -182,12 +175,8 @@ import { } from '../../../../../Features/BookingScreen/Customer/addCustomer'; import { useNavigate } from 'react-router-dom'; import { ApplicationPreferences } from '../../../../../Features/BrachLogin/BranchLogin'; -import PozoDineInIcon from '../../UtillComponents/Pozo retail icons/PozoDineIn'; import { Messages } from '../../../../../Components/Notifications/Messages'; -import WpIcon from '../../../../../Images/message.png'; import { FaAngleUp } from 'react-icons/fa'; -import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import CardPopover from './Utils/CardPopover.jsx'; import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, @@ -197,24 +186,57 @@ import { } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; import { PublicQrCodepost } from '../../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; -import TooltipWrapper from '../../../../../Components/Tooltip/Tooltip.jsx'; -import PozoUnpaidIcon from '../../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; -import { Tables } from '../../../../../Components/Tables/Table.jsx'; -import pozologoimg from '../../../../../Images/pozologoimg.png'; -import PaymentGatewayEmbedded from '../../UtillComponents/PaymentGatewayEmbedded.jsx'; -import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; -import OtherServicePrintStyle1 from '../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx'; -import OtherServiceMobilePrint from '../../BookingFunctionality/OtherServiceMobilePrint.jsx'; import { getExpireProductsList, getLowStockAlertProductsList, } from '../../../../../Features/ProductPage/ProductPage.js'; -import { PostBlockSlots } from '../../../../../Features/Kiosk/kiosk.js'; -import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; -import { getEmpAccess } from '../../../../../Features/AppPage/CenterPage.js'; + +// Jsx Files +const CustomerOrders = lazy( + () => import('../../BookingFunctionality/CustomerOrders.jsx') +); +const PaymentGatewayEmbedded = lazy( + () => import('../../UtillComponents/PaymentGatewayEmbedded.jsx') +); +const MobileMultiPdfPrintTrigger = lazy( + () => import('../../UtillComponents/MobileMultiPdfPrintTrigger.jsx') +); +const OtherServicePrintStyle1 = lazy( + () => + import('../../../PrintTemplates/ThermalPrinter/OtherServicePrintStyle1.jsx') +); +const OtherServiceMobilePrint = lazy( + () => import('../../BookingFunctionality/OtherServiceMobilePrint.jsx') +); +const QrinScreen = lazy( + () => import('../../BookingFunctionality/DynamicScreenQr.jsx') +); +const CardPopover = lazy(() => import('./Utils/CardPopover.jsx')); +const SMSShare = lazy(() => import('../../../../WhatsAppShare/SmsShare')); +const WhatsAppShare = lazy( + () => import('../../../../WhatsAppShare/whatsAppShare') +); +const TokensinglePrint = lazy( + () => import('../../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint') +); +import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; + +// Icons File +import WpIcon from '../../../../../Images/message.png'; +import pozologoimg from '../../../../../Images/pozologoimg.png'; +import PozoUnpaidIcon from '../../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; +import PozoDineInIcon from '../../UtillComponents/Pozo retail icons/PozoDineIn'; +import Credit from '../../UtillComponents/Pozo retail icons/credit.svg'; +import Paymentoption from '../../../../Payment/PaymentOptions/PaymentOptions'; +import PozoSplitPaymentIcon from '../../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon'; +import { ArrowRightOutlined } from '@ant-design/icons'; +import { BiRightArrowAlt } from 'react-icons/bi'; +import PozoAdvanceIcon from '../../UtillComponents/Pozo retail icons/PozoAdvanceIcon'; +import { MdSms } from 'react-icons/md'; + +// const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); const StandardTablePayment = () => { @@ -231,11 +253,10 @@ const StandardTablePayment = () => { const CompId = SessionData?.CompId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; const applyOffer = useApplyOfferto_CardDetail(); const defaultPaymentTrigger = useSelector(GlobalPaymentTrigger); const defaultBookingType = useSelector(GlobalDefaultBookingType); + const AllBookingType = useSelector(GlobalAllBookingType); const Holddata = useSelector(globalholddata); const FontFamily = useSelector(GlobalSelectedFont); const prodCat = useSelector(GlobalProductCategorie); @@ -273,13 +294,14 @@ const StandardTablePayment = () => { const [SelectedBookingType, setSelectedBookingType] = useState(null); const GlobaluseOptions = useSelector(GlobalCommonPaymentOptions); const SelCustId = useSelector(GlobalSelCustId); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail, shallowEqual); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); const GlobEstBooking = useSelector(GlobalEstimateBooking); const OtherServicesglobal = useSelector(GlobalOtherSevices); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const OrderType = useSelector(GlobalOrderType); const unpaidFlow = useSelector(Globalunpaidflow); @@ -323,7 +345,6 @@ const StandardTablePayment = () => { preference?.PreferredSubCatName === 'SportsApp' && preference?.PreferredStatus == 'Y' ); - console.log(selectedDate, 'selectedDateselectedDate'); const PrinterDetails = useSelector(GlobalPrinterMappingDtls); const UpiQRPreference = preferenceDetails?.find( (setting) => @@ -336,7 +357,6 @@ const StandardTablePayment = () => { const [blink, setBlink] = useState(false); const [showWhatsAppShare, setShowWhatsAppShare] = useState(false); const [showSMSShare, setSMSShare] = useState(false); - const [formattedDate, setFormattedDate] = useState(''); const [OrderStatus, setOrderStatus] = useState(true); const [OtherServicesPrintDetails, setOtherServicesPrintDetails] = useState( [] @@ -598,10 +618,10 @@ const StandardTablePayment = () => { }, }, ]; - useEffect(() => { - let data = { compId: CompId, branchId: BranchId }; - dispatch(getCurrentOrderid(data)).unwrap(); - }, []); + // useEffect(() => { + // let data = { compId: CompId, branchId: BranchId }; + // dispatch(getCurrentOrderid(data)).unwrap(); + // }, []); const TableData = []; tabledata?.map((item) => TableData.push({ @@ -639,19 +659,6 @@ const StandardTablePayment = () => { } }, [AddBookingDetailsTrigger]); - // useEffect(() => { - // let data = { - // CompId: CompId, - // BranchId: BranchId, - // AppId: AppId, - // UserId: UserId, - // }; - - // dispatch(getPrinterMappingDetails(data)).unwrap(); - // const Data1 = { AppId, CompId, BranchId }; - // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); - // }, []); - useEffect(() => { if (isMobile) { OtherServiceMobilePrint( @@ -735,29 +742,6 @@ const StandardTablePayment = () => { unpaidFlow, ]); - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); - useEffect(() => { // setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); // setPaybtnselected(PaymentOptions?.[0]?.ModeId); @@ -900,14 +884,21 @@ const StandardTablePayment = () => { const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = - filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; + filteredPayments.length > 0 + ? filteredPayments + : previousOrderPayment || []; const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); @@ -916,9 +907,7 @@ const StandardTablePayment = () => { 0 ); - const previousNetAmount = - (totalPreviouspayment) || 0; - + const previousNetAmount = totalPreviouspayment || 0; let withdiscTotal = Total - @@ -930,22 +919,35 @@ const StandardTablePayment = () => { withdiscTotal >= 0 ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ) - console.log(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount, "totalPreviouspayment") + ); + console.log( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount, + 'totalPreviouspayment' + ); - setTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount); + setTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ); setCurrentOrderNetAmount(currentOrderNetAmount); setPreviousNetAmount(previousNetAmount); - dispatch(changeSummeryTotalAmount(salesBillEdit ? (currentOrderNetAmount > previousNetAmount) ? (currentOrderNetAmount - previousNetAmount) : 0 : currentOrderNetAmount)); - // dispatch( - // changeSummeryTotalAmount(withdiscTotal > 0 ? withdiscTotal : Number(Total)) - // ); + dispatch( + changeSummeryTotalAmount( + salesBillEdit + ? currentOrderNetAmount > previousNetAmount + ? currentOrderNetAmount - previousNetAmount + : 0 + : currentOrderNetAmount + ) + ); dispatch(changeSummeryComboOfferAmount(withComboSum)); - - // if (withdiscTotal <= 0) { - // dispatch(ChangeOverAllDiscSales(0)); - // dispatch(ChangeOverAllDiscEstimate(0)); - // } } else { setTotalAmount(0); dispatch(changeSummeryTotalAmount(0)); @@ -971,22 +973,6 @@ const StandardTablePayment = () => { } }, [orderCardDetail]); - // useEffect(() => { - // if ( - // PrintOrderDetails?.length > 0 && - // (!filteredSettingNames || - // filteredSettingNames?.includes('Print') || - // filteredSettingNames?.length === 0) && - // ((!filteredSettingNames?.includes('whatsapp') && - // (!isMobile || !filteredSettingNames?.includes('SMS'))) || - // ((filteredSettingNames?.includes('whatsapp') || - // (isMobile && filteredSettingNames?.includes('SMS'))) && - // (!MobileNoWhatsApp || Object.keys(MobileNoWhatsApp).length === 0))) - // ) { - // handlePrintOrToken(); - // } - // }, [PrintOrderDetails]); - useEffect(() => { if (!PrintOrderDetails?.length) return; @@ -1065,7 +1051,6 @@ const StandardTablePayment = () => { }, [PaymentUpiOptions, PaymentOptions, SelCustId]); useEffect(() => { - if (salesBillEdit) { if (SelCustId) { setRefundPayBtns(AllPaymentOptions); @@ -1080,8 +1065,7 @@ const StandardTablePayment = () => { setRefundPayBtns(withoutCustomer); } } - - }, [AllPaymentOptions, SelCustId, salesBillEdit]) + }, [AllPaymentOptions, SelCustId, salesBillEdit]); useEffect(() => { if ( @@ -1179,7 +1163,11 @@ const StandardTablePayment = () => { const handleButtonClick = () => { if (qrCode && SelectedUPIPayOption === 'Default' && UpiQRPreference) { UpiPayment(); - } else if (salesBillEdit && currentOrderNetAmount < previousNetAmount && !refundPaySelected) { + } else if ( + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + !refundPaySelected + ) { setMessageType('warning'); setMessageData('Please Select Refund Payment Method'); return; @@ -1433,15 +1421,15 @@ const StandardTablePayment = () => { 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', @@ -1537,7 +1525,7 @@ const StandardTablePayment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -1554,86 +1542,114 @@ const StandardTablePayment = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ { - PaymentType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? refundPaySelected : - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), - MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' - ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId - : null, - PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption?.toLowerCase() === 'business' - ? 'BU' - : SelectedUPIPayOption - : null, - ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : SelectedUPIPayOption?.toLowerCase() === 'business' + PaymentType: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? refundPaySelected + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'pd' + ? PaymentDeviceUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'pg' + ? PaymentgatewayUPI?.[0]?.ModeId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.ModeId + : paybtnselected + : paybtnselected + ? paybtnselected + : null, + Amount: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? previousNetAmount - currentOrderNetAmount + : Math.round(TotalAmount), + MerchantId: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantId : null, - AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && + PaymentOptionType: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'credit' + ? 'PC' + : Paybtnnameselected?.toLowerCase() === 'card' + ? SelectedCardOption + : Paybtnnameselected?.toLowerCase() === 'upi' + ? SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'PC' + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? 'BU' + : SelectedUPIPayOption + : null, + ModeOfPayment: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? null + : SelectedUPIPayOption?.toLowerCase() === 'default' + ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) + ?.UPIDetailId + : SelectedUPIPayOption?.toLowerCase() === 'business' + ? BusinessPayOption?.find( + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId + : null, + AccountDtl: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? [] + : Paybtnnameselected?.toLowerCase() === 'upi' && SelectedUPIPayOption?.toLowerCase() === 'default' + ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( + (upipay) => upipay?.UPIId === UpiId + ) + : (Paybtnnameselected?.toLowerCase() === 'upi' && + 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') + ? useOptions?.[0]?.PaymentDetails?.PaymentGateway + : [], + PaymentStatus: + salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'cash' + ? 'S' + : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' - : 'P', - Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, - Credit: salesBillEdit ? (currentOrderNetAmount > previousNetAmount && Paybtnnameselected?.toLowerCase() === 'credit') ? Math.round(TotalAmount) : 0 : - Paybtnnameselected?.toLowerCase() === 'credit' + : Paybtnnameselected?.toLowerCase() === 'upi' && + SelectedUPIPayOption?.toLowerCase() === 'default' + ? 'S' + : 'P', + Debit: + salesBillEdit && + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' + ? Math.round(previousNetAmount - currentOrderNetAmount) + : 0, + Credit: salesBillEdit + ? currentOrderNetAmount > previousNetAmount && + Paybtnnameselected?.toLowerCase() === 'credit' + ? Math.round(TotalAmount) + : 0 + : Paybtnnameselected?.toLowerCase() === 'credit' ? Math.round(TotalAmount) : 0, }, @@ -1727,14 +1743,14 @@ const StandardTablePayment = () => { 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]); @@ -1893,14 +1909,14 @@ const StandardTablePayment = () => { 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]); @@ -2005,14 +2021,14 @@ const StandardTablePayment = () => { } 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]); @@ -2039,8 +2055,8 @@ const StandardTablePayment = () => { }; const handleSalesBillEdit = async (putdatas, value, pay) => { - console.log(putdatas, value, pay, "handleSalesBillEdit") - } + console.log(putdatas, value, pay, 'handleSalesBillEdit'); + }; const OtherServicePostBooking = async (PostData, value) => { console.log(PostData, value, 'PostData, value'); @@ -2086,11 +2102,12 @@ const StandardTablePayment = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; + await dispatch(getSelectedFavItems(data)).unwrap(); let data1 = { @@ -2100,9 +2117,9 @@ const StandardTablePayment = () => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -2113,9 +2130,9 @@ const StandardTablePayment = () => { prodCat: prodCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -2295,14 +2312,14 @@ const StandardTablePayment = () => { 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]); @@ -2320,7 +2337,7 @@ const StandardTablePayment = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -2435,27 +2452,11 @@ const StandardTablePayment = () => { setMessageData('Payment Failed'); await dispatch(changePaymentloader(false)); setFirstPaymentclick(false); - // setPaybtnselected(PaymentOptions?.[0]?.ModeId); - // setPaybtnnameselected(PaymentOptions?.[0]?.ModeName); setPaybtnnameselected(PaymentOptionsModeName); setPaybtnselected(PaymentOptionsModeId); clearInterval(intervalId); // Stop the loop when payment fails CustomerDisplayRemovedData(); ClearAllGlobalStateDatas(value); - // const customerDisplayWindow = getCustomerDisplayWindow(); - // if (customerDisplayWindow && !customerDisplayWindow.closed) { - // const updatedData = { - // userData: orderCardDetail, - // ExtraCharges: GlobalExtraCharge, - // upi: GlobalUpiID, - // customer: selOption != null ? selOption : GetCustId, - // paymentMethod: Paybtnnameselected, - // Paymentgateway: false, - // OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount - - // }; - // customerDisplayWindow.postMessage(updatedData, '*'); - // } } } } catch (error) { @@ -2666,13 +2667,6 @@ const StandardTablePayment = () => { 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); setunpaidselectedindex(event); } else { @@ -2789,7 +2783,7 @@ const StandardTablePayment = () => { const handleRefundPaymentMode = (id, name) => { setRefundPaySelected(id); setRefundPaySelectedName(name); - } + }; const addUpiOption = async (id, name, UPIId) => { await dispatch(changeUpiIDprint(UPIId)); @@ -2842,7 +2836,9 @@ const StandardTablePayment = () => { setPaybtnselected(PaymentOptionsModeId); setQrCode(false); setUpinotSelected(false); - getHolddata(); + if (holdCheckedSalesSetup) { + getHolddata(); + } setCurrentOrderNetAmount(0); setPreviousNetAmount(0); if (defaultBookingType === 'Both') { @@ -2977,7 +2973,7 @@ const StandardTablePayment = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -2986,8 +2982,9 @@ const StandardTablePayment = () => { async (orderDetail, index) => { await printDiv(`${selectedStyle}-${index}`, style); // Use unique IDs for each print if (orderDetail?.BookingTypeName !== 'Dine In') { - const groupedTokens = orderDetail?.productDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.reduce( - (acc, item, idx) => { + const groupedTokens = orderDetail?.productDetails + ?.filter((data) => data?.EditTokenAvailable !== 'N') + ?.reduce((acc, item, idx) => { if (item.TokenAvailable === 'Y') { if (!item.CounterName) { // If CounterName is null or empty @@ -3000,9 +2997,7 @@ const StandardTablePayment = () => { } } return acc; - }, - {} - ); + }, {}); // Iterate over grouped tokens and print them const tokensToPrint = Object.entries(groupedTokens).map( @@ -3031,8 +3026,9 @@ const StandardTablePayment = () => { await Promise.all( PrintOrderDetails?.[0]?.OrderDetails?.map( async (orderDetail, index) => { - const groupedTokens = orderDetail?.productDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.reduce( - (acc, item, idx) => { + const groupedTokens = orderDetail?.productDetails + ?.filter((data) => data?.EditTokenAvailable !== 'N') + ?.reduce((acc, item, idx) => { if (item.TokenAvailable === 'Y') { if (!item.CounterName) { // If CounterName is null or empty @@ -3045,9 +3041,7 @@ const StandardTablePayment = () => { } } return acc; - }, - {} - ); + }, {}); // Iterate over grouped tokens and print them const tokensToPrint = Object.entries(groupedTokens).map( @@ -3067,11 +3061,11 @@ const StandardTablePayment = () => { ); } else { await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.map( - async (orderDetail, index) => { - await TokenPrint(`${index}-${orderDetail?.OrderId}`); - } - ) + PrintOrderDetails?.[0]?.OrderDetails?.filter( + (data) => data?.EditTokenAvailable !== 'N' + )?.map(async (orderDetail, index) => { + await TokenPrint(`${index}-${orderDetail?.OrderId}`); + }) ); setPrintOrderDetails([]); closePrintOption(); @@ -3395,218 +3389,223 @@ const StandardTablePayment = () => { } return ( -
- - {summary && ( -
-
-
Items :
-

{orderCardDetail?.length || 0}

-
-
-
Total Qty :
-

- {orderCardDetail?.reduce((acc, item) => { - const isWeightScale = item?.ScaleType === 'weight'; - - if (isWeightScale) { - return ( - acc + - (Weightasquantity - ? Math.round(Number(item?.OrderQty || 0)) - : 1) - ); - } - - return acc + Math.round(Number(item?.OrderQty || 0)); - }, 0)} -

-
-
-
MRP Total :
-

- ₹ - {orderCardDetail?.reduce( - (acc, data) => parseFloat(data?.TotalAmt || 0) + acc, - 0 - )} -

-
- {TotalTaxAmount > 0 && ( + Suspense Loading...
}> +
+ + {summary && ( +
-
Tax Amount :
-

{safeRound(TotalTaxAmount)}

+
Items :
+

{orderCardDetail?.length || 0}

- )} - {parseInt(extra) > 0 && (
-
Extra Charges :
-

{safeRound(extra)}

+
Total Qty :
+

+ {orderCardDetail?.reduce((acc, item) => { + const isWeightScale = item?.ScaleType === 'weight'; + + if (isWeightScale) { + return ( + acc + + (Weightasquantity + ? Math.round(Number(item?.OrderQty || 0)) + : 1) + ); + } + + return acc + Math.round(Number(item?.OrderQty || 0)); + }, 0)} +

+
+
+
MRP Total :
+

+ ₹ + {orderCardDetail?.reduce( + (acc, data) => parseFloat(data?.TotalAmt || 0) + acc, + 0 + )} +

+
+ {TotalTaxAmount > 0 && ( +
+
Tax Amount :
+

{safeRound(TotalTaxAmount)}

+
+ )} + {parseInt(extra) > 0 && ( +
+
Extra Charges :
+

{safeRound(extra)}

+
+ )} +
+
Discount :
+

+ -₹ + {(OverAllSales > 0 ? OverAllSales : 0) + + (OverAllEstimate > 0 ? OverAllEstimate : 0) + + (Discount > 0 ? Discount : 0)} +

+
+
+
Total :
+

+ ₹ + {safeRound( + credit && overAllBal >= 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + )} +

- )} -
-
Discount :
-

- -₹ - {(OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)} -

-
-
Total :
-

- ₹ - {safeRound(credit && overAllBal >= 0 - ? Math.max(0, TotalAmount - overAllBal) - : TotalAmount)} -

-
-
- )} -
-
- -
- {' '} - 0 && 'not-allowed', - color: - orderCardDetail?.length > 0 || + )} +
+
+ +
+ {' '} + 0 && 'not-allowed', + color: + orderCardDetail?.length > 0 || (selOption?.value === undefined && GlobalAddCustomerDetails1?.length === 0 && GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '28px', - }} - />{' '} -
-
- - {!OtherServicesglobal && ( - - {' '} -
- + ? 'gray' + : 'rgb(18, 146, 238)', + fontSize: '28px', + }} + />{' '}
- )} - {/* Customer Orders */} - {GetCustId && ( - - - {' '} -
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(orderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); + {!OtherServicesglobal && ( + + {' '} +
0 && 'not-allowed', - color: - orderCardDetail?.length > 0 || + style={{ + width: '1.5rem', + cursor: + orderCardDetail?.length === 0 || + CheckBookingStatus == 'Close' || + addnewAccess + ? 'not-allowed' + : 'pointer', + color: + orderCardDetail?.length === 0 || + CheckBookingStatus == 'Close' || + addnewAccess + ? 'gray' + : 'rgb(18, 146, 238)', + display: 'flex', + alignItems: 'center', + height: '2.46rem', + }} + > + +
+
+ )} + + {/* Customer Orders */} + {GetCustId && ( + + {' '} +
{ + 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', + ? '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()); + }} + /> + + )} + + ))} +
+ )} + {/* share */} + {PrintOrderDetails?.length > 0 && ( +
- -
- - )} - - {tabledata?.length > 0 && dinePreference && ( -
- {tableOptions - ?.filter((item) => item.OptionName === 'UnpaidBill') - .map((filteredItem) => ( - - {!OtherServicesglobal && ( - - {' '} - { - (setUnpaidOpen(true), getUnpaiddatas()); - }} - /> - - )} - - ))} -
- )} - {/* share */} - {PrintOrderDetails?.length > 0 && ( -
- {filteredSettingNames?.includes('whatsapp') && - MobileNoWhatsApp?.value && ( - - )} - {/* + )} + {/* { title="Print" /> */} - {(filteredSettingNames?.includes('Print') || - !MobileNoWhatsApp || - !MobileNoWhatsApp.value) && ( + {(filteredSettingNames?.includes('Print') || + !MobileNoWhatsApp || + !MobileNoWhatsApp.value) && ( { /> )} - {filteredSettingNames?.includes('SMS') && isMobile && ( - - )} - {/* WhatsAppShare modal/component */} - {showWhatsAppShare && ( - closePrintOption(false)} - /> - )} - {showSMSShare && isMobile && ( - closePrintOption(false)} - /> - )} -
- )} - - {dinePreference && - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - SelectedTableDetails?.length !== 0 && ( -
- - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } + {filteredSettingNames?.includes('SMS') && isMobile && ( + - + )} + {/* WhatsAppShare modal/component */} + {showWhatsAppShare && ( + closePrintOption(false)} + /> + )} + {showSMSShare && isMobile && ( + closePrintOption(false)} + /> + )}
)} -
- -
- -
- {payBtns?.length > 0 && (currentOrderNetAmount >= previousNetAmount) ? ( - payBtns.map((payment) => { - const mode = payment?.ModeName?.toLowerCase(); - const isSelected = paybtnselected === payment?.ModeId; - const buttonClass = isSelected - ? 'paybutton-selected' - : 'paybutton'; - const handleClick = - mode === 'upi' - ? () => - handleUPIButtonClick(payment?.ModeId, payment?.ModeName) - : () => handlePaymentMode(payment?.ModeId, payment?.ModeName); - - return ( -
- + {dinePreference && + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + SelectedTableDetails?.length !== 0 && ( +
+ + {' '} + + FirstPaymentclick === false && !addnewAccess + ? changeOrderStatus() + : '' + } + /> +
- ); - }) - ) : (currentOrderNetAmount < previousNetAmount && salesBillEdit && refundPayBtns.length > 0) ? ( - refundPayBtns.map((payment) => { - const mode = payment?.ConfigName?.toLowerCase(); - const isSelected = refundPaySelected === payment?.ConfigId; - const buttonClass = isSelected - ? 'paybutton-selected' - : 'paybutton'; - - return ( -
- -
- ); - }) - ) : ( -
- Please Set Payment Options -
- )} + )} +
+
-
+ +
+ {payBtns?.length > 0 && + currentOrderNetAmount >= previousNetAmount ? ( + payBtns.map((payment) => { + const mode = payment?.ModeName?.toLowerCase(); + const isSelected = paybtnselected === payment?.ModeId; + const buttonClass = isSelected + ? 'paybutton-selected' + : 'paybutton'; - -
0 && - paybtnselected && - CheckBookingStatus !== 'Close' - ? !OrderStatus ? salesBillEdit && (currentOrderNetAmount < previousNetAmount) ? - 'standard-pay-btn-refund' - : 'standard-pay-btn' - : 'standard-pay-btn order-complete' - : 'standard-pay-btn-disabled' - } - onClick={handleButtonClick} - > - {!OrderStatus ? salesBillEdit && (currentOrderNetAmount < previousNetAmount) ?

Refund: ₹{(previousNetAmount || 0) - (currentOrderNetAmount || 0)}

: ( - <> -

+ handleUPIButtonClick(payment?.ModeId, payment?.ModeName) + : () => + handlePaymentMode(payment?.ModeId, payment?.ModeName); + + return ( +

+ +
+ ); + }) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => { + const mode = payment?.ConfigName?.toLowerCase(); + const isSelected = refundPaySelected === payment?.ConfigId; + const buttonClass = isSelected + ? 'paybutton-selected' + : 'paybutton'; + + return ( +
+ +
+ ); + }) + ) : ( +
- {isMobile ? ( - `₹ ${safeRound( - OrderType === 'Failed' - ? FailedTotalAmt - : credit && overAllBal >= 0 - ? Math.max(0, TotalAmount - overAllBal) - : TotalAmount - )}` - ) : ( -
- ₹{' '} - + )} +
+ + + +
0 && + paybtnselected && + CheckBookingStatus !== 'Close' + ? !OrderStatus + ? salesBillEdit && currentOrderNetAmount < previousNetAmount + ? 'standard-pay-btn-refund' + : 'standard-pay-btn' + : 'standard-pay-btn order-complete' + : 'standard-pay-btn-disabled' + } + onClick={handleButtonClick} + > + {!OrderStatus ? ( + salesBillEdit && currentOrderNetAmount < previousNetAmount ? ( +

+ Refund: ₹ + {(previousNetAmount || 0) - (currentOrderNetAmount || 0)} +

+ ) : ( + <> +

+ {isMobile ? ( + `₹ ${safeRound( OrderType === 'Failed' ? FailedTotalAmt : credit && overAllBal >= 0 ? Math.max(0, TotalAmount - overAllBal) : TotalAmount - )} - /> + )}` + ) : ( +

+ ₹{' '} + = 0 + ? Math.max(0, TotalAmount - overAllBal) + : TotalAmount + )} + /> +
+ )} +

+ +
+
- )} -

- -
- -
- - ) : ( -
ORDER
- )} -
-
- - { - setUnpaidOpen(false); - }} - footer={false} - children={ -
- + + ) + ) : ( +
ORDER
+ )}
- } - /> - {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} - /> - )} + - {UpiOpen && ( { - Upimodel('Cancel'); + setUnpaidOpen(false); }} 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'); - }} + {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} /> -
- )} + )} - {creditCustomerOpen && ( - - )} - {Splitpayment && ( - data?.TotalAmt + acc, 0) - - ((OverAllSales > 0 ? OverAllSales : 0) + - (OverAllEstimate > 0 ? OverAllEstimate : 0) + - (Discount > 0 ? Discount : 0)) - )} - // failedOrderData={failedOrderData} - /> - )} + {UpiOpen && ( + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+
+
+ +
- { - dispatch(changeSalesPaymentoption(false)); - }} - footer={false} - children={ -
- -
- } - /> - setShowCancelConfirm(true)} - footer={false} - width={600} - className={'ModalPaymentGatewayEmbedded'} - 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'); + }} /> - - } - /> - {showCancelConfirm && ( - { - paymentGatewayRef.current?.clearPolling(); - setBusinessUPI(false); - setShowCancelConfirm(false); - ClearAllGlobalStateDatas(); - CustomerDisplay(); - }} - onCancel={() => setShowCancelConfirm(false)} - okText="Yes" - cancelText="No" - > - Do you want to cancel the payment? - - )} - {customerPreviesOrders && ( +
+ )} + + {creditCustomerOpen && ( + + )} + {Splitpayment && ( + data?.TotalAmt + acc, 0) - + ((OverAllSales > 0 ? OverAllSales : 0) + + (OverAllEstimate > 0 ? OverAllEstimate : 0) + + (Discount > 0 ? Discount : 0)) + )} + // failedOrderData={failedOrderData} + /> + )} + setCustomerPreviesOrders(false)} + className={'paymentoptionsModal'} + open={GlobalSalesPaymentoptions} + width={500} + height={1000} + handleCancel={() => { + dispatch(changeSalesPaymentoption(false)); + }} footer={false} - width={700} + children={ +
+ +
+ } + /> + setShowCancelConfirm(true)} + footer={false} + width={600} className={'ModalPaymentGatewayEmbedded'} children={ <> - setCustomerPreviesOrders(false)} + } /> - )} - { - OtherServicesPrintDetails?.length > 0 && ( - // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ) - // )) - } -
+ {showCancelConfirm && ( + { + paymentGatewayRef.current?.clearPolling(); + 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)} + /> + + } + /> + )} + { + OtherServicesPrintDetails?.length > 0 && ( + // PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ) + // )) + } +
+ ); }; diff --git a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx index 1a53a03..17c6ce2 100644 --- a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx +++ b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryHorizontal.jsx @@ -524,36 +524,6 @@ function BSCategoryHorizontal(props) { await dispatch(changeProductSubCategorieProdCatfun()); } }; - // const handleClick = async (e, ProdCat, index) => { - // let data1 = { - // compId: CompId, - // branchId: BranchId, - // appId: AppId, - // prodCat: ProdCat, - // }; - // let data = false; - // setaccessToCard(false); - // await dispatch(changeCombosearch(false)); - // dispatch(ChangeisFavClicked(false)); - // setAccessOther(false); - // setIsModalOpen(false); - // setIndexVal(index); - - // await dispatch(changeProductCategorie(ProdCat)); - // // await dispatch(changeProductSubCategorie(ProdCat)); - // await dispatch(changeAccessForOthers(data)); - // await dispatch(ChangeFocusCatCard(!FocusStatus)); - // let tempSubCat = templateData?.BookingLayout?.[1]?.filter( - // (a, b) => a?.OptionName === 'SubCategory' - // ); - // if (tempSubCat.length === 0) { - // await dispatch(changeProductSubCategorieProdCatfun()); - // } - // if (templateData?.BookingLayout?.[0] === 'Layout2') { - // setSubCat(true); - // } - - // }; useEffect(() => { if (productCardTrigger && FavSelected) { @@ -584,27 +554,15 @@ function BSCategoryHorizontal(props) { } : {}), }; - await dispatch(getSelectedFavItems(data1)); + + // await dispatch(getSelectedFavItems(data1)); await dispatch(ChangeFocusCatCard(!FocusStatus)); }; const handleClickOtherItems = async () => { dispatch(ChangedraggingComponent(null)); dispatch(Changedragging(false)); - let data = false; setIndexVal(Infinity); - // setaccessToCard(true); - // dispatch(ChangeisFavClicked(true)); - // setAccessOther(false); setIsModalOpen(true); - // // await dispatch(ChangeSubcategoryData(null)); - // await dispatch(changeAccessForOthers(data)); - // let data1 = { - // CompId: CompId, - // BranchId: BranchId, - // AppId: AppId, - // }; - // await dispatch(getSelectedFavItems(data1)); - // await dispatch(ChangeFocusCatCard(!FocusStatus)); }; const handleClick2 = async () => { @@ -690,8 +648,10 @@ function BSCategoryHorizontal(props) { }; useEffect(() => { - holdnamedrop(); - }, [AppId, CompId, BranchId]); + if (isModalOpen) { + holdnamedrop(); + } + }, [isModalOpen]); const holdnamedrop = async () => { let data = { @@ -896,16 +856,16 @@ function BSCategoryHorizontal(props) { formRef?.current?.resetFields(); resetForm(); - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdType: 'O', - }; - const respons = await dispatch(othernamedrop(data)).unwrap(); - if (respons?.data?.statusCode == 1) { - setTabledropname(respons?.data?.data); - } + // let data = { + // CompId: CompId, + // BranchId: BranchId, + // AppId: AppId, + // ProdType: 'O', + // }; + // const respons = await dispatch(othernamedrop(data)).unwrap(); + // if (respons?.data?.statusCode == 1) { + // setTabledropname(respons?.data?.data); + // } }; const handleValuesChange = (values) => { @@ -1702,7 +1662,7 @@ function BSCategoryHorizontal(props) { }))} className="field-DropDown" // placeholder="ConfigType" - label={} + label={} // optionsNames={{ value: "TaxPercentage", label: "TaxIdName" }} onChangeFunction={(selectedValue) => onChangeFunction(selectedValue) @@ -1773,7 +1733,7 @@ function BSCategoryHorizontal(props) { // }} className="size-input" label={ - + } autocomplete="off" onChange={(e) => @@ -1885,7 +1845,7 @@ function BSCategoryHorizontal(props) { ]} > Quantity} + label={} valueData={defaultQuantity} autocomplete="off" onChange={(e) => @@ -1953,7 +1913,9 @@ function BSCategoryHorizontal(props) { > Amount / Per Item + } autocomplete="off" onChange={(e) => diff --git a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryVertical.jsx b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryVertical.jsx index 70555cd..eb6a953 100644 --- a/src/Pages/BookingScreen/Components/BSCategories/BSCategoryVertical.jsx +++ b/src/Pages/BookingScreen/Components/BSCategories/BSCategoryVertical.jsx @@ -510,8 +510,10 @@ function BSCategoryVertical(props) { }; useEffect(() => { - holdnamedrop(); - }, [AppId, CompId, BranchId]); + if (isModalOpen) { + holdnamedrop(); + } + }, [isModalOpen]); const holdnamedrop = async () => { let data = { @@ -708,16 +710,16 @@ function BSCategoryVertical(props) { formRef?.current?.resetFields(); resetForm(); - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdType: 'O', - }; - const respons = await dispatch(othernamedrop(data)).unwrap(); - if (respons?.data?.statusCode == 1) { - setTabledropname(respons?.data?.data); - } + // let data = { + // CompId: CompId, + // BranchId: BranchId, + // AppId: AppId, + // ProdType: 'O', + // }; + // const respons = await dispatch(othernamedrop(data)).unwrap(); + // if (respons?.data?.statusCode == 1) { + // setTabledropname(respons?.data?.data); + // } }; const handleValuesChange = (values) => { @@ -1422,7 +1424,7 @@ function BSCategoryVertical(props) {

{ + let Filterdata1 = ComboCardata?.filter( + (item) => item?.ServiceCategory === ProdCat + ); + let Filterdata2 = ComboCardata?.filter( + (item) => item?.ServiceCategory === ProdCat + ); -let Filterdata1 = ComboCardata?.filter((item) => item?.ServiceCategory === ProdCat) -let Filterdata2 = ComboCardata?.filter((item) => item?.ServiceCategory === ProdCat) - - -let Filterdata = ComboCardata?.filter((item) => item?.ServiceCategory === ProdCat)?.[0]?.ServiceDetails; -let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdCat)?.[0]?.ServiceDetails; - + let Filterdata = ComboCardata?.filter( + (item) => item?.ServiceCategory === ProdCat + )?.[0]?.ServiceDetails; + let Filterdatas = ComboCardata?.filter( + (item) => item?.ServiceCategory === ProdCat + )?.[0]?.ServiceDetails; let data1 = { compId: CompId, @@ -430,7 +437,6 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC }; const handleClick2 = async () => { - getTaxname(); getUom(); setIndexVal(-1); @@ -511,8 +517,10 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC }; useEffect(() => { - holdnamedrop(); - }, [AppId, CompId, BranchId]); + if (isModalOpen) { + holdnamedrop(); + } + }, [isModalOpen]); const holdnamedrop = async () => { let data = { @@ -526,13 +534,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC const response = await dispatch(getUomData()).unwrap(); - // setTableuomname(response?.data?.data); - // let UomId = response?.data?.data?.filter( - // (item) => item.ConfigName?.toLowerCase() === 'pcs' - // )?.[0]?.['ConfigId']; - // formRef.current?.setFieldsValue({ UOM: UomId }); - // setselectedUom(UomId); - + const UomTypePreference = ApplicationPreferenceData?.find( (preference) => preference?.PreferredCatName === 'Product Uom' )?.PreferenceCatDetails; @@ -718,17 +720,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC handleCancel(); formRef?.current?.resetFields(); - resetForm(); - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdType: 'O', - }; - const respons = await dispatch(othernamedrop(data)).unwrap(); - if (respons?.data?.statusCode == 1) { - setTabledropname(respons?.data?.data); - } + resetForm(); }; const handleValuesChange = (values) => { @@ -860,20 +852,19 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC }; useEffect(() => { - if (typeof searchData === 'string' && categoryData?.length > 0) { - const searchTerm = searchData?.trim()?.toLowerCase(); - const foundIndex = categoryData.findIndex( - (cat) => - typeof cat.ProdCatName === 'string' && - cat.ProdCatName?.trim()?.toLowerCase() === searchTerm - ); - if (foundIndex !== -1) { - setIndexVal(foundIndex); + if (typeof searchData === 'string' && categoryData?.length > 0) { + const searchTerm = searchData?.trim()?.toLowerCase(); + const foundIndex = categoryData.findIndex( + (cat) => + typeof cat.ProdCatName === 'string' && + cat.ProdCatName?.trim()?.toLowerCase() === searchTerm + ); + if (foundIndex !== -1) { + setIndexVal(foundIndex); + } + } else if (categoryData?.length > 0) { + setIndexVal(0); } - } else if (categoryData?.length > 0) { - setIndexVal(0); - } - }, [searchData, categoryData]); useEffect(() => { @@ -893,14 +884,13 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC let Data = response?.data?.data; setCombocardata(Data?.ServiceCategories); - } }; return ( <> - -

@@ -1026,7 +1016,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC option, selectedTaxPercentage === option.TaxId ), - // label: option.TaxIdName + ' - ' + option.TaxPercentage + ' % ', + // label: option.NameTaxIdName + ' - ' + option.TaxPercentage + ' % ', }))} className="field-DropDown" // placeholder="ConfigType" @@ -1099,13 +1089,11 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC } // inputMode="numeric" // onInput={(e) => { - // e.target.value = e.target.value.replace(/\D/g, ""); + // e.target.Namevalue = e.target.value.replace(/\D/g, ""); // }} className="size-input" label={ - + } autocomplete="off" onChange={(e) => @@ -1147,32 +1135,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC />
-
- {/* - ({ - value: option.ConfigId, - label: option.ConfigName, - }))} - placeholder="ConfigType" - label={} - optionsNames={{ value: "TypeId", label: "TypeName" }} - className="field-DropDown" - onChangeFunction={(selectedValues) => - onChangeuomFunction(selectedValues) - } - valueData={selectedUom} - disabled={add || !EditState ? false : true} - /> - */} +
item?.ServiceCategory === ProdC index={indexval} onClick={() => handleClick1()} > */} - {/*
@@ -1438,7 +1401,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC Favourites

*/} - {/*
*/} + {/*
*/} {/* )} */} {(!Isdragging || draggingComponent !== 'category') && @@ -1469,7 +1432,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC borderColor: index === indexval - ? '#000000' + ? '#000000' : SelectedCatgColor?.['BackgroundColor'], }} // key={} @@ -1569,7 +1532,9 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC minWidth: 'max-content', // set a width if needed }} className="sampleCard" - onClick={(e) => handleClick(e, item.ServiceCategory, index)} + onClick={(e) => + handleClick(e, item.ServiceCategory, index) + } >
item?.ServiceCategory === ProdC index={indexval} onClick={() => handleClick2()} > */} - {/*
@@ -1703,9 +1668,7 @@ let Filterdatas = ComboCardata?.filter((item) => item?.ServiceCategory === ProdC
)}
-
- ); } diff --git a/src/Pages/BookingScreen/Components/BSCategories/BSOtherServicesVerticalcat.jsx b/src/Pages/BookingScreen/Components/BSCategories/BSOtherServicesVerticalcat.jsx index 546c240..f7e29d4 100644 --- a/src/Pages/BookingScreen/Components/BSCategories/BSOtherServicesVerticalcat.jsx +++ b/src/Pages/BookingScreen/Components/BSCategories/BSOtherServicesVerticalcat.jsx @@ -58,7 +58,10 @@ import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd'; import { BsSortAlphaDown } from 'react-icons/bs'; import { BsSortAlphaDownAlt } from 'react-icons/bs'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; -import { changeothersdatas, OtherServicesCardlistdata } from '../../../../Features/OtherServices/OtherServices.js'; +import { + changeothersdatas, + OtherServicesCardlistdata, +} from '../../../../Features/OtherServices/OtherServices.js'; function BSOtherServicesVerticalcat(props) { const formRef = useRef(null); @@ -105,7 +108,7 @@ function BSOtherServicesVerticalcat(props) { const [add, setAdd] = useState(false); const [defaultQuantity, setdefaultQuantity] = useState(1); const [isSortClicked, setIsSortClicked] = useState(false); - const [otherServiceCategoryData,setOtherServiceCategoryData] = useState([]) + const [otherServiceCategoryData, setOtherServiceCategoryData] = useState([]); const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; @@ -147,7 +150,7 @@ function BSOtherServicesVerticalcat(props) { ); } }; - OtherServicesCategoryList() + OtherServicesCategoryList(); const container = scrollContainerRef?.current; if (container) { container.addEventListener('scroll', handleScroll); @@ -299,7 +302,9 @@ function BSOtherServicesVerticalcat(props) { }; const handleClick = async (e, ProdCat, index) => { - const selectedOtherServiceCategory = otherServiceCategoryData?.filter(({ServiceCategory}) => ServiceCategory === ProdCat) + const selectedOtherServiceCategory = otherServiceCategoryData?.filter( + ({ ServiceCategory }) => ServiceCategory === ProdCat + ); let data = false; setaccessToCard(false); setAccessOther(false); @@ -416,8 +421,10 @@ function BSOtherServicesVerticalcat(props) { }; useEffect(() => { - holdnamedrop(); - }, [AppId, CompId, BranchId]); + if (isModalOpen) { + holdnamedrop(); + } + }, [isModalOpen]); const holdnamedrop = async () => { let data = { @@ -614,16 +621,16 @@ function BSOtherServicesVerticalcat(props) { formRef?.current?.resetFields(); resetForm(); - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - ProdType: 'O', - }; - const respons = await dispatch(othernamedrop(data)).unwrap(); - if (respons?.data?.statusCode == 1) { - setTabledropname(respons?.data?.data); - } + // let data = { + // CompId: CompId, + // BranchId: BranchId, + // AppId: AppId, + // ProdType: 'O', + // }; + // const respons = await dispatch(othernamedrop(data)).unwrap(); + // if (respons?.data?.statusCode == 1) { + // setTabledropname(respons?.data?.data); + // } }; const handleValuesChange = (values) => { @@ -778,31 +785,32 @@ function BSOtherServicesVerticalcat(props) { }; useEffect(() => { - if (typeof searchData === 'string' && categoryData?.length > 0) { - const searchTerm = searchData?.trim()?.toLowerCase(); - const foundIndex = categoryData.findIndex( - (cat) => - typeof cat.ProdCatName === 'string' && - cat.ProdCatName?.trim()?.toLowerCase() === searchTerm - ); - if (foundIndex !== -1) { - setIndexVal(foundIndex); - } - } else if (categoryData?.length > 0) { - setIndexVal(0); + if (typeof searchData === 'string' && categoryData?.length > 0) { + const searchTerm = searchData?.trim()?.toLowerCase(); + const foundIndex = categoryData.findIndex( + (cat) => + typeof cat.ProdCatName === 'string' && + cat.ProdCatName?.trim()?.toLowerCase() === searchTerm + ); + if (foundIndex !== -1) { + setIndexVal(foundIndex); } - + } else if (categoryData?.length > 0) { + setIndexVal(0); + } }, [searchData, categoryData]); - const OtherServicesCategoryList = async () => { - let response = await dispatch(OtherServicesCardlistdata({CompId,BranchId,AppId})).unwrap(); - if (response?.data?.statusCode === 1) { - setOtherServiceCategoryData(response?.data?.data?.ServiceCategories); - }else{ - setMessageType("error") - setMessageData(response?.data?.response) - } - }; + const OtherServicesCategoryList = async () => { + let response = await dispatch( + OtherServicesCardlistdata({ CompId, BranchId, AppId }) + ).unwrap(); + if (response?.data?.statusCode === 1) { + setOtherServiceCategoryData(response?.data?.data?.ServiceCategories); + } else { + setMessageType('error'); + setMessageData(response?.data?.response); + } + }; return (
@@ -919,7 +927,7 @@ function BSOtherServicesVerticalcat(props) { ), // label: // option.TaxIdName + - // " - " + + // " - " +Name // option.TaxPercentage + // " % ", }))} @@ -951,7 +959,7 @@ function BSOtherServicesVerticalcat(props) { ); } - return Promise.resolve(); + return Promise.Nameresolve(); }, }, ]} @@ -1099,6 +1107,7 @@ function BSOtherServicesVerticalcat(props) { return Promise.resolve(); }, + Name, }, ]} > @@ -1210,51 +1219,7 @@ function BSOtherServicesVerticalcat(props) { pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', }} > - {/* {globalAllItemdata?.length > 0 && ( -
handleClick1()} - > -
- {categoryFunction?.Image && } -

- Favourites -

-
-
- )} */} - + {(!Isdragging || draggingComponent !== 'category') && otherServiceCategoryData?.map((item, index) => (
)} - {/* {globalAllItemdata?.length === 0 && ( -
handleClick1()} - > -
- {categoryFunction?.Image && } -

- Favourites -

-
-
- )} */} - - {/*
handleClick2()} - > -
- {categoryFunction?.Image && } -

- Others -

-
-
*/} -
+
); } diff --git a/src/Pages/BookingScreen/Components/BSCombo/BSC1NavBar.jsx b/src/Pages/BookingScreen/Components/BSCombo/BSC1NavBar.jsx index 4379a9c..35dd3c0 100644 --- a/src/Pages/BookingScreen/Components/BSCombo/BSC1NavBar.jsx +++ b/src/Pages/BookingScreen/Components/BSCombo/BSC1NavBar.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, { lazy, Suspense, useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import { TiLocation } from 'react-icons/ti'; @@ -24,30 +24,31 @@ import BSPrinterSetting from '../UtillComponents/BSPrinterSetting.jsx'; import { isMobile } from 'react-device-detect'; import { FaDisplay } from 'react-icons/fa6'; import { - FeatureAddon, GlobalFeatAddOnData, PreferenceData, } from '../../../../Features/BookingScreen/BookingData/BookingData.js'; -import { - setCustomerDisplayWindow, - closeCustomerDisplayWindow, -} from '../../../../Features/customerDisplayWindow/customerDisplayWindow'; +import { setCustomerDisplayWindow } from '../../../../Features/customerDisplayWindow/customerDisplayWindow'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip'; -import { - getUserProfile, - userDataByUserId, -} from '../../../../Features/UserAccount/userData.js'; -import UserRelieveManager from '../../Template/RealivingUser.jsx'; -import BSNavBarUserInfo from '../BSNavbar/BSNavBarUserInfo.jsx'; -import BSScanTemplate from '../UtillComponents/BSScanTemplate.jsx'; +import { userDataByUserId } from '../../../../Features/UserAccount/userData.js'; import { RiFullscreenExitFill, RiFullscreenFill } from 'react-icons/ri'; import { Popconfirm, Tooltip } from 'antd'; import { FaCaretDown } from 'react-icons/fa'; +const UserRelieveManager = lazy( + () => import('../../Template/RealivingUser.jsx') +); +const BSNavBarUserInfo = lazy(() => import('../BSNavbar/BSNavBarUserInfo.jsx')); + +const BSScanTemplate = lazy( + () => import('../UtillComponents/BSScanTemplate.jsx') +); + +const BSPrinterSetting = lazy( + () => import('../UtillComponents/BSPrinterSetting.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const commonUrl = import.meta.env.ENV_COMMON_BASE_URL; const BSC1NavBar = (props) => { - const BSComboData = props?.hasOwnProperty('data') ? props['data'] : null; const divRef = useRef(null); const navigate = useNavigate(); @@ -109,16 +110,7 @@ const BSC1NavBar = (props) => { ).unwrap(); } }; - // const getFeatureAddonData = async () => { - // let featureAddon = await dispatch( - // FeatureAddon({ AppId: AppId, UserId: UserId }) - // ).unwrap(); - // if (featureAddon?.data?.statusCode === 1) { - // setFeatureAddonData(featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]); - // } else { - // setFeatureAddonData([]); - // } - // }; + const UserAcc = () => { setAccIsOpen(!isAccOpen); }; @@ -197,25 +189,6 @@ const BSC1NavBar = (props) => { console.error('Customer display window failed to open.'); } }; - // const openNewTab = async () => { - - // const initialData = { - // Paymentgateway: false, - // }; - - // const customerDisplayWindow = window.open(`${subDirectory}customer-display`, 'CustomerDisplayWindow', 'width=2000,height=5000,scrollbars=yes,resizable=yes'); - // if (customerDisplayWindow && !customerDisplayWindow.closed) { - // setCustomerDisplayWindow(customerDisplayWindow); - - // customerDisplayWindow.onload = () => { - // setTimeout(() => { - // customerDisplayWindow.postMessage(initialData, '*'); // Or use targetOrigin for CORS - // }, 500); // Slight delay to ensure window is ready - // }; - // } else { - // console.error("Customer display window failed to open."); - // } - // }; const handleEditProfile = async () => { navigate(`${subDirectory}app-page/redirect-userprofile`); }; @@ -240,161 +213,167 @@ const BSC1NavBar = (props) => { }; return ( - <> -
-
-
- - - {' '} -
-
- - - - - - - - - - - - - - - -
-
-
- -
- {/* */} - - {branchName}{' '} - - {BranchCity && ( - - {' '} - - - {BranchCity} - {' '} - - )} -
- -
- {ScanLayoutScreen?.SettingValue === 'Y' && ( - - - - )} -
- -
-
-
-
- {/* {formattedDate} */} - - - -
- - -
- {isFullscreen ? : } -
-
- - {FeatureAddonData?.FeatureDtls?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customer display' - ) && ( - -
Loading...
}> + <> +
+
+
+ - -
- - )} + + {' '} +
+
+ + + - {!isMobile && ( -
- + + + + + + + + + + + +
+
- )} -
- -
- - -
-
+
+ {/* */} + + + {branchName} + {' '} + + {BranchCity && ( + + {' '} + + + {BranchCity} + {' '} + + )} +
+ +
+ {ScanLayoutScreen?.SettingValue === 'Y' && ( + + + + )} +
+ +
+
+
+
+ {/* {formattedDate} */} + + + +
+ + +
+ {isFullscreen ? : } +
+
+ + {FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'customer display' + ) && ( + +
+ +
+
+ )} + + {!isMobile && ( +
+ +
+ )} + +
+ +
+ + +
+
+
+ {isAccOpen && ( + } + Logout={Logout} + /> + )}
- {isAccOpen && ( - } - Logout={Logout} - /> - )}
-
- + + ); }; diff --git a/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx b/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx index 477d529..d4b72fe 100644 --- a/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSCombo/BSC1Payment.jsx @@ -1,33 +1,34 @@ -import React, { useEffect, useState, useRef } from 'react'; +import React, { useEffect, useState, useRef, lazy, Suspense } from 'react'; import { FaWhatsapp, FaPrint, FaParking } from 'react-icons/fa'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import moment from 'moment'; import { Badge, Popover, Modal, Tooltip } from 'antd'; import { AiOutlineClose, AiOutlineArrowRight } from 'react-icons/ai'; -import { GiBasket } from 'react-icons/gi'; -import { - UpCircleOutlined, - UpOutlined, - TransactionOutlined, -} from '@ant-design/icons'; +import { UpCircleOutlined } from '@ant-design/icons'; import { printDiv, extractLastNumberOrderId, encryptObject, } from '../../../../Services/Others'; -import PaymentPdfBooking from '../../../paymentpdfPage/PaymentPdfBooking'; +const PaymentPdfBooking = lazy( + () => import('../../../paymentpdfPage/PaymentPdfBooking') +); import { Messages } from '../../../../Components/Notifications/Messages'; -import { MdMoneyOff } from 'react-icons/md'; import paygate from '../../../../Images/paygate.png'; import defaultupi from '../../../../Images/defaultupi.png'; import paydevice from '../../../../Images/paydevice.png'; -import paymentFailure from '../../../../Images/payment-failure2.png'; -import BSSummery1 from '../BSBillingTables/BSBillingTableSummery/BSSummery'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal.jsx'; import { Tables } from '../../../../Components/Tables/Table'; -import QrComponent from '../BookingFunctionality/DynamicQr.jsx'; -import QrinScreen from '../BookingFunctionality/DynamicScreenQr.jsx'; +const BSSummery1 = lazy( + () => import('../BSBillingTables/BSBillingTableSummery/BSSummery') +); + +const QrComponent = lazy(() => import('../BookingFunctionality/DynamicQr.jsx')); + +const QrinScreen = lazy( + () => import('../BookingFunctionality/DynamicScreenQr.jsx') +); import { ArrowRightOutlined } from '@ant-design/icons'; import Buttons from '../../../../Components/Forms/Buttons'; import WpIcon from '../../../../Images/message.png'; @@ -51,7 +52,6 @@ import { GlobalReprintModal, changeSelectedTableDetails, GlobalNavHoldData, - getPreferenceData, changeSelectedCustId, GlobalSelCustId, changeSelectedOption, @@ -64,8 +64,6 @@ import { changeCreditFocus, changeUpiIDprint, GlobalSelectedCustDisable, - changeSummeryTotalItems, - changeSummeryQty, changeSummeryTotalWithoutTaxAmount, changeSummeryTotalTaxAmount, GlobalEstimateBooking, @@ -80,16 +78,13 @@ import { changeSelectChair, GlobalOrderType, changeReorderProductDetails, - FeatureAddon, GlobalCommonPaymentOptions, PostPaymentdevice, changeUpiIDName, changeUpiIDoptionId, GetPaymentdeviceResponse, PutBookingPaymentStatusChange, - changeCombosearch, GlobalCombosearch, - Comboget, GlobalPayementloader, changePaymentloader, PaymentGatewayGetdetail, @@ -108,7 +103,6 @@ import { ChangeOverAllDiscEstimate, GlobalUnpaidListData, changeUnpaidData, - getAllCustomer, GlobalBranchFinancialStatus, changeSummeryComboOfferAmount, changeTipAmount, @@ -116,7 +110,6 @@ import { GlobalFeatAddOnData, GlobalOtherServiceTicketClaim, changeOtherServiceTicketClaim, - GlobalOtherSevices, changeOtherServices, changeComboRedirectionToDefaultLayoutForParking, GlobalRetailWSSalesType, @@ -149,7 +142,7 @@ import { GlobalprintDatas, GlobalPrinterMappingDtls, getPrinterMappingDetails, - getPrintSelectionComponentData, + // getPrintSelectionComponentData, } from '../../../../Features/ThemeChange/ThemeChange'; import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; import { @@ -163,7 +156,6 @@ import { ReprintDetails, triggerCustomerRefresh, } from '../../../../Features/BookingScreen/Customer/addCustomer'; -import BSCustomerSelect from '../UtillComponents/BSSelectCustomer.jsx'; import PozoHoldIcon from '../UtillComponents/Pozo retail icons/PozoHoldIcon'; import PozoDineInIcon from '../UtillComponents/Pozo retail icons/PozoDineIn.jsx'; import PozoUnpaidIcon from '../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; @@ -173,16 +165,32 @@ import PozoQuickAddIcon from '../UtillComponents/Pozo retail icons/PozoQuickAddI import PozoReprintIcon from '../UtillComponents/Pozo retail icons/PozoReprintIcon'; import PozoExtraChargesIcon from '../UtillComponents/Pozo retail icons/PozoExtraChargesIcon.jsx'; import PozoAddCustomerIcon from '../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; -import BsBillingCreditCustomer from '../BookingFunctionality/BSBillingCreditCustomer.jsx'; +const BSCustomerSelect = lazy( + () => import('../UtillComponents/BSSelectCustomer.jsx') +); + +const BsBillingCreditCustomer = lazy( + () => import('../BookingFunctionality/BSBillingCreditCustomer.jsx') +); import { TfiMoreAlt } from 'react-icons/tfi'; -import BSCreditCustomer from '../UtillComponents/BSCreditCustomer.jsx'; +const BSCreditCustomer = lazy( + () => import('../UtillComponents/BSCreditCustomer.jsx') +); import PozoAdvanceIcon from '../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; import { isMobile } from 'react-device-detect'; import MobilePrint from '../BookingFunctionality/MobilePrint.jsx'; -import SplitPayment from '../BookingFunctionality/SplitPayment.jsx'; -import BSNavBarEstimate from '../UtillComponents/BSNavBarEst.jsx'; import CountUp from 'react-countup'; -import BSNavBarPreOrder from '../UtillComponents/BSComboNavBarPreOrder.jsx'; +const SplitPayment = lazy( + () => import('../BookingFunctionality/SplitPayment.jsx') +); + +const BSNavBarEstimate = lazy( + () => import('../UtillComponents/BSNavBarEst.jsx') +); + +const BSNavBarPreOrder = lazy( + () => import('../UtillComponents/BSComboNavBarPreOrder.jsx') +); import { GlobalpreOrderOpen } from '../../../../Features/BookingScreen/PreOrder/PreOrder.js'; import TokensinglePrint from '../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx'; import SingleTokenMobilePrint from '../BookingFunctionality/SingleTokenMobilePrint.jsx'; @@ -207,38 +215,48 @@ import { changePreOrderDistrict, changePreOrderState, } from '../../../../Features/BookingScreen/PreOrder/PreOrder.js'; -import PaymentFailedSales from '../../../Payment/PaymentFailedDetails/PaymentFailedSales.jsx'; +const PaymentFailedSales = lazy( + () => import('../../../Payment/PaymentFailedDetails/PaymentFailedSales.jsx') +); import PozoSplitPaymentIcon from '../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; import PozoFailedPaymentsIcon from '../UtillComponents/Pozo retail icons/PozoFailedPaymentsIcon.jsx'; import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, Global_OrderOfferDetail, Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, } from '../../../../Features/Offer/Offer.js'; import { useApplyOfferto_CardDetail } from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import TooltipWrapper from '../../../../Components/Tooltip/Tooltip'; -import BSNavBarOffer from '../UtillComponents/BSNavBarOffer/BSNavBarOffer.jsx'; import { getEmpAccess } from '../../../../Features/AppPage/CenterPage.js'; import { useAuth } from '../../../../AuthContext.jsx'; import { GlobalBookingStatus } from '../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; -import WhatsAppShare from '../../../WhatsAppShare/whatsAppShare.jsx'; -import CryptoJS from 'crypto-js'; -import SMSShare from '../../../WhatsAppShare/SmsShare.jsx'; +const BSNavBarOffer = lazy( + () => import('../UtillComponents/BSNavBarOffer/BSNavBarOffer.jsx') +); + +const WhatsAppShare = lazy( + () => import('../../../WhatsAppShare/whatsAppShare.jsx') +); + +const SMSShare = lazy(() => import('../../../WhatsAppShare/SmsShare.jsx')); import { MdSms } from 'react-icons/md'; import { changeSalesPaymentoption, GlobalSalesPaymentoption, } from '../../../../Features/Payment/Paymentoptions/Paymentoptions.js'; -import Paymentoption from '../../../Payment/PaymentOptions/PaymentOptions.jsx'; -import BSTipAmount from '../UtillComponents/BSTipAmount.jsx'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; -import BSOtherServiceClaim from '../UtillComponents/BSOtherServiceClaim.jsx'; +const Paymentoption = lazy( + () => import('../../../Payment/PaymentOptions/PaymentOptions.jsx') +); + +const BSTipAmount = lazy(() => import('../UtillComponents/BSTipAmount.jsx')); + +const BSOtherServiceClaim = lazy( + () => import('../UtillComponents/BSOtherServiceClaim.jsx') +); + +const BSMembership = lazy(() => import('../UtillComponents/BSMembership.jsx')); import { OtherServicesCardlistdata } from '../../../../Features/OtherServices/OtherServices.js'; -import { MobilePdfPrint } from '../BookingFunctionality/MobilePdfPrint.js'; import { PublicQrCodepost } from '../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; -import BSMembership from '../UtillComponents/BSMembership.jsx'; import CardPopover from '../BSBillingTables/StandardTable/Utils/CardPopover.jsx'; import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx'; import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; @@ -248,13 +266,12 @@ import { GlobalOfferAppliedProducts, GlobalOverAllOfferAmt, } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; -import BSNavBarTable from '../UtillComponents/BSNavBarTable.jsx'; import pozologoimg from '../../../../Images/pozologoimg.png'; -import PaymentGatewayEmbedded from '../UtillComponents/PaymentGatewayEmbedded.jsx'; - +const PaymentGatewayEmbedded = lazy( + () => import('../UtillComponents/PaymentGatewayEmbedded.jsx') +); const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); @@ -275,7 +292,7 @@ const BSC1Payment = (props) => { ); const AllPaymentOptions = useSelector(GlobalpaymentOptionData); const SessionData = useSelector(StoredSessionData); - const BranchFinancialStatus = useSelector(GlobalBranchFinancialStatus); + const globalTipAmount = useSelector(GlobaltipAmount); const OtherServiceTicketClaim = useSelector(GlobalOtherServiceTicketClaim); const RetailWSSalesType = useSelector(GlobalRetailWSSalesType); @@ -285,8 +302,7 @@ const BSC1Payment = (props) => { const CompId = SessionData?.CompId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; + const [open, setOpen] = useState(false); const printerTemplateStyle = useSelector(SelectedPrintTemplate); const SelectedTableDetails = useSelector(GlobalSelectedTableDetails); @@ -327,9 +343,7 @@ const BSC1Payment = (props) => { const GlobEstBooking = useSelector(GlobalEstimateBooking); const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); const preOrder = useSelector(GlobalpreOrderOpen); - const Comboglobal = useSelector(GlobalCombosearch); const FailedTotalAmt = useSelector(GlobalFailedTotalAmt); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail); const [SelectedUpiOption, setSelectedUpiOption] = useState(); const [credit, setCredit] = useState(false); const [overAllBal, setOverAllBal] = useState(0); @@ -359,11 +373,7 @@ const BSC1Payment = (props) => { preference?.PreferredSubCatName === 'SportsApp' && preference?.PreferredStatus == 'Y' ); - console.log( - sportsAppPreference, - commonModulePreference, - 'sportsAppPreference' - ); + const bookingTypePreference = appPreferences?.find( (preference) => preference?.PreferredCatName === 'Booking Type' )?.PreferenceCatDetails; @@ -620,8 +630,10 @@ const BSC1Payment = (props) => { setDefaultPaymentMode([]); } }; - setDefaultPaymentOption(); - }, [defaultPaymentTrigger]); + if (salesBillEdit) { + setDefaultPaymentOption(); + } + }, [defaultPaymentTrigger, salesBillEdit]); useEffect(() => { const getPrintData = async () => { @@ -846,11 +858,6 @@ const BSC1Payment = (props) => { ); dispatch(changeSummeryComboOfferAmount(withComboSum)); - - // if (withdiscTotal <= 0) { - // dispatch(ChangeOverAllDiscSales(0)); - // dispatch(ChangeOverAllDiscEstimate(0)); - // } } else { setTotalAmount(0); dispatch(changeSummeryTotalAmount(0)); @@ -873,8 +880,8 @@ const BSC1Payment = (props) => { UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); handleOtherData(); }, []); useEffect(() => { @@ -960,28 +967,6 @@ const BSC1Payment = (props) => { const paymentFailedStatusFun = async () => { SetOpenFailData(!OpenFailData); }; - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); const handleOtherData = async () => { let data = { @@ -1011,7 +996,7 @@ const BSC1Payment = (props) => { useEffect(() => { if (CompId && BranchId && AppId) { getHolddata(); - getUnpaiddatas(); + // getUnpaiddatas(); getCustomerData(); } }, [CompId, BranchId, AppId]); @@ -1134,21 +1119,6 @@ const BSC1Payment = (props) => { setPaybtnnameselected(PaymentOptionsModeName); setPaybtnselected(PaymentOptionsModeId); }, [PaymentOptions]); - // useEffect(() => { - // if ( - // PrintOrderDetails?.length > 0 && - // (!filteredSettingNames || - // filteredSettingNames?.includes('Print') || - // filteredSettingNames?.length === 0) && - // ((!filteredSettingNames?.includes('whatsapp') && - // (!isMobile || !filteredSettingNames?.includes('SMS'))) || - // ((filteredSettingNames?.includes('whatsapp') || - // (isMobile && filteredSettingNames?.includes('SMS'))) && - // (!MobileNoWhatsApp || Object.keys(MobileNoWhatsApp).length === 0))) - // ) { - // handlePrintOrToken(); - // } - // }, [PrintOrderDetails]); useEffect(() => { if (!PrintOrderDetails?.length) return; @@ -1342,9 +1312,6 @@ const BSC1Payment = (props) => { setEmpData(datas?.[0]); }; const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); await dispatch( getAddCustomerDetails({ CompId: CompId, @@ -2944,8 +2911,6 @@ const BSC1Payment = (props) => { } console.error('Transaction not approved within 1 minute.'); - // Send an error message or handle the timeout - // You can dispatch an action, show a notification, etc. break; } @@ -3029,20 +2994,6 @@ const BSC1Payment = (props) => { clearInterval(intervalId); // Stop the loop when payment fails CustomerDisplayRemovedData(); ClearAllGlobalStateDatas(value); - // const customerDisplayWindow = getCustomerDisplayWindow(); - // if (customerDisplayWindow && !customerDisplayWindow.closed) { - // const updatedData = { - // userData: OrderCardDetail, - // ExtraCharges: GlobalExtraCharge, - // upi: GlobalUpiID, - // customer: selOption != null ? selOption : GetCustId, - // paymentMethod: Paybtnnameselected, - // Paymentgateway: false, - // OrderTotalAmount:PaymentGatewayfilter?.[0]?.Amount - - // }; - // customerDisplayWindow.postMessage(updatedData, '*'); - // } } } } catch (error) { @@ -3212,13 +3163,6 @@ const BSC1Payment = (props) => { } else { dispatch(changeOrderCardDetails([])); } - // 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); setunpaidselectedindex(event); } else { @@ -3435,28 +3379,6 @@ const BSC1Payment = (props) => { ); } }; - // const handleClick = async () => { - // if (Comboglobal == false) { - // await dispatch(changeCombosearch(true)); - // } else { - // await dispatch(changeCombosearch(false)); - // } - // }; - - // const Combodata = async () => { - // let data = { - // AppId: AppId, - // CompId: CompId, - // BranchId: BranchId, - // ActiveStatus: 'A', - // }; - - // let Response = await dispatch(Comboget(data)).unwrap(); - // if (Response?.data?.statusCode == 1) { - // setComboDropDown(Response?.data?.data); - // } - // }; - const openPreOrder = async () => { setPreOrderOpen((prevState) => !prevState); if (preOrderOpen) { @@ -3555,631 +3477,642 @@ const BSC1Payment = (props) => { }; return ( - <> -
- -
-
- {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'QuickAdd' && ( - - + Loading...
}> + <> +
+ +
+
+ {BSComboNavbar?.[1]?.map((item) => ( + <> + {item?.OptionName == 'QuickAdd' && ( + + +
+ +
+ Quick Add + {!isAltPressed && ( + + (Alt + N) + + )} +
+
+
+
+ )} + {item?.OptionName == 'DineIn' && + DineInPreference?.SettingValue === 'Y' && + dinePreference && ( + +
+ + DINE IN +
+
+ )} + {item?.OptionName == 'TakeAway' && takeAwayPreference && ( +
+ BookingType !== 'TakeAway' && ChangeTakeAway() + } style={{ pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', }} > - + + {/* TAKE AWAY */} + Take Away +
+
+ )} + + ))} + + {OtherServiceStatus && ( +
+ +
+ + Other Services +
+
+
+ )} +
+ +
+ {BSComboNavbar?.[1]?.map((item) => ( + <> + {item?.OptionName == 'Offer' && ( +
+ +
+ )} + {item?.OptionName == 'ExtraCharge' && ( + +
- Quick Add +
+ + {/* EXTRA CHARGE */} + Extra Charge +
+ {!isAltPressed && ( - - (Alt + N) - + (Alt + A) +
)}
-
- - - )} - {item?.OptionName == 'DineIn' && - DineInPreference?.SettingValue === 'Y' && - dinePreference && ( - -
- - DINE IN -
-
+ + )} - {item?.OptionName == 'TakeAway' && takeAwayPreference && ( - -
- BookingType !== 'TakeAway' && ChangeTakeAway() - } - style={{ - pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', - }} + {item?.OptionName == 'RePrint' && ( + - - {/* TAKE AWAY */} - Take Away -
-
- )} - - ))} - - {OtherServiceStatus && ( -
- -
- - Other Services -
-
-
- )} -
- -
- {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'Offer' && ( -
- -
- )} - {item?.OptionName == 'ExtraCharge' && ( - - -
-
- - {/* EXTRA CHARGE */} - Extra Charge -
- - {!isAltPressed && ( -
- (Alt + A) -
- )} -
-
-
- )} - {item?.OptionName == 'RePrint' && ( - - -
+
- - Re-Print - {!isAltPressed && ( - - (Alt + R) - - )} +
+ + Re-Print + {!isAltPressed && ( + + (Alt + R) + + )} +
-
-
-
- )} - - ))} - {/* {reprint1 && ( + + + )} + + ))} + {/* {reprint1 && ( )} */} - {extraCharges && ( - - )} - {QuickAdd && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- -
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( + {extraCharges && ( + + )} + {QuickAdd && ( + + )} + {creditCustomerOpen && ( + + )} + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelectedUpiOption && ( +
+ +
+ )} + + {PaymentUpiOptions?.length > 0 && OrderId && (
)} +
+
- {PaymentUpiOptions?.length > 0 && OrderId && ( -
- +
+
setIsFloatMenuOpen(!isFloatMenuOpen)} + > +
- )} -
-
-
-
-
setIsFloatMenuOpen(!isFloatMenuOpen)} - > - + {isFloatMenuOpen && ( +
+ {!OtherServiceStatus && ( +
+ +
+ +

Parking

+
+
+
+ )} + {BSComboNavbar?.[1]?.map((item) => ( + <> + {item?.OptionName == 'QuickAdd' && ( +
+ +
+ +

+ Quick Add
(Alt +N) +

+
+
+
+ )} + {item?.OptionName == 'DineIn' && + DineInPreference?.SettingValue === 'Y' && ( + <> +
+ +
+ +

Dine In

+
+
+
+ {FirstPaymentclick === false && + !addnewAccess && + !OrderStatus && ( +
+ +
+ )} + + )} + {item?.OptionName == 'TakeAway' && ( +
+ +
+ +

Take Away

+
+
+
+ )} + {item?.OptionName == 'Offer' && ( +
+ +
+ )} + {item?.OptionName == 'ExtraCharge' && ( +
+ +
+ +

Extra Charge

+
+
+
+ )} + {item?.OptionName == 'RePrint' && ( +
+ +
+ +

Re Print

+
+
+
+ )} + + ))} +
+ )}
- - {isFloatMenuOpen && ( -
- {!OtherServiceStatus && ( -
- -
- -

Parking

-
-
-
- )} - {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'QuickAdd' && ( -
- -
- -

- Quick Add
(Alt +N) -

-
-
-
- )} - {item?.OptionName == 'DineIn' && - DineInPreference?.SettingValue === 'Y' && ( - <> -
- -
- -

Dine In

-
-
-
- {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && ( -
- -
- )} - - )} - {item?.OptionName == 'TakeAway' && ( -
- -
- -

Take Away

-
-
-
- )} - {item?.OptionName == 'Offer' && ( -
- -
- )} - {item?.OptionName == 'ExtraCharge' && ( -
- -
- -

Extra Charge

-
-
-
- )} - {item?.OptionName == 'RePrint' && ( -
- -
- -

Re Print

-
-
-
- )} - - ))} -
- )}
-
-
- -
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 -
- )} - - {paybtns?.length > 1 && ( -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - }} - > - - {' '} -
-
- - Split Pay -
+
+ {payment.ModeName} + {payment?.ModeName?.toLowerCase() === 'card' && ( + + )} + {payment?.ModeName?.toLowerCase() === 'upi' && ( + + )} +
+
-
-
- )} -
-
+ )) + ) : currentOrderNetAmount < previousNetAmount && + salesBillEdit && + refundPayBtns.length > 0 ? ( + refundPayBtns.map((payment) => ( +
+ +
+ )) + ) : ( +
+ Please Set Payment Options +
+ )} + + {paybtns?.length > 1 && ( +
0) && + !unpaidFlow && + OrderStatus + ? 'none' + : 'auto', + opacity: + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && + OrderStatus + ? 0.5 + : 1, + }} + > + + {' '} +
+
+ + Split Pay +
+
+
+
+ )} +
+ + + {/*
*/} -
+
-
-
-
+
+
-
Items
-
:
-
- {' '} - {TotalItems}{' '} +
+
Items
+
:
+
+ {' '} + {TotalItems}{' '} +
-
-
-
Qty
-
:
-
{Qty}
-
-
-
Dis
-
:
-
- {' '} - {Discount}{' '} +
+
Qty
+
:
+
+ {' '} + {Qty}{' '} +
+
+
+
Dis
+
:
+
+ {' '} + {Discount}{' '} +
-
-
+
-
- {(addcustomer || hold) && ( - setHold(false)} - /> - )} -
- {Estimation?.SettingValue == 'Y' && - BookingType !== 'Dine In' && - !BookingTypeBoth && ( -
- -
- )} - {BSComboData?.BookingBilling?.[1]?.map((item) => ( - <> - {/* {item?.OptionName=="Hold" && */} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length != 0 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - +
+ {(addcustomer || hold) && ( + setHold(false)} + /> + )} +
+ {Estimation?.SettingValue == 'Y' && + BookingType !== 'Dine In' && + !BookingTypeBoth && ( +
+ +
+ )} + {BSComboData?.BookingBilling?.[1]?.map((item) => ( + <> + {/* {item?.OptionName=="Hold" && */} + {unpaidFlow == false + ? item?.OptionName == 'Hold' && + BookingType !== 'Dine In' && + !BookingTypeBoth && + OrderCardDetail?.length != 0 && + CheckOrderType?.length === 0 && + OrderType != 'Failed' && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + + {' '} +
+ AddBookingDetails('Hold')} + style={{ + cursor: 'pointer', + // color: '' ? '#52c41a' : '#1292EE', + }} + />{' '} + {/*

Hold

*/} +
+
+
+ ) + : ''} + + {unpaidFlow == false + ? item?.OptionName == 'Hold' && + BookingType !== 'Dine In' && + !BookingTypeBoth && + Holddata?.length > 0 && + OrderCardDetail?.length == 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + {' '} + +
+ HandleholdModelOpen()} + style={{ + cursor: 'pointer', + // color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> +
+
+
+ ) + : ''} + {tabledata?.length > 0 && dinePreference && ( + <> + {item?.OptionName == 'UnpaidBill' && ( + {' '}
- AddBookingDetails('Hold')} style={{ + fontSize: '27px', cursor: 'pointer', - // color: '' ? '#52c41a' : '#1292EE', - }} - />{' '} - {/*

Hold

*/} -
-
- - ) - : ''} - - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - -
- HandleholdModelOpen()} - style={{ - cursor: 'pointer', - // color: Holddata ? '#52c41a' : 'default', pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', + height: '45px', + width: '45px', + borderRadius: '6px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + padding: '4px 6px 4px 6px', + }} + onClick={() => { + (setUnpaidOpen(true), getUnpaiddatas()); }} />
-
-
- ) - : ''} - {tabledata?.length > 0 && dinePreference && ( - <> - {item?.OptionName == 'UnpaidBill' && ( - - {' '} -
+ )} + + )} + + ))} + {BSComboData?.BookingBilling?.[1]?.filter( + (item) => item.OptionName === 'AddCustomer' + ).length === 1 ? ( + <> + {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' + ) + ) + ) && ( + + - 0 || + (selOption?.value === undefined && + GlobalAddCustomerDetails1?.length === 0 && + GetCustId?.CustMobile === undefined) + ? 'gray' + : '#1292eeff', + color: '#fff', + height: '40px', width: '45px', borderRadius: '6px', display: 'flex', alignItems: 'center', justifyContent: 'center', - padding: '4px 6px 4px 6px', + padding: '8px 8px 12px 8px', }} + className="AsAmtCombo" + > + {' '} + 0 && 'not-allowed', + fontSize: '28px', + }} + />{' '} +

Adv Amt

+
+
+ + )} + + ) : ( + '' + )} + {FeatureAddonData?.FeatureDtls?.find( + (item) => item?.FeatureAddonName?.toLowerCase() === 'preorder' + ) && ( + <> + { +
0 || OrderType === 'Failed' + ? 'none' + : 'auto', + opacity: OrderCardDetail?.length > 0 ? 0.5 : 1, + }} + > + + + { - (setUnpaidOpen(true), getUnpaiddatas()); + openPreOrder(); + }} + /> + + +
+ } + + )} + {preOrderOpen && } + {sportsAppPreference && } + {dinePreference && + (BookingType === 'Dine In' || + BookingTypeBoth || + CheckOrderType?.length > 0) && + !unpaidFlow && ( + <> + + {' '} + + FirstPaymentclick === false && !addnewAccess + ? changeOrderStatus() + : '' + } + style={{ + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> + + {FirstPaymentclick === false && + !addnewAccess && + !OrderStatus && } + + )} + {OrderCardDetail?.length > 0 && ParkingDisplay && ( +
+ +
+ )} + {unpaidFlow == true ? ( + + { + Recipt(); + }} + /> + + ) : ( + '' + )} + {paymentfeataddon && ( + +
{ + paymentFailedStatusFun(); + }} + style={{ + width: '27px', + cursor: 'pointer', + fontWeight: '600', + color: 'rgb(18, 146, 238)', + }} + > + +
+
+ )} + {OpenFailData && ( + + )} +
+
+
+ {BSComboData?.BookingBilling?.[1]?.map((item) => ( + <> + {item?.OptionName == 'AddCustomer' && !preOrderOpen && ( + +
+ + +
+
- )} - +
+
)} ))} - {BSComboData?.BookingBilling?.[1]?.filter( - (item) => item.OptionName === 'AddCustomer' - ).length === 1 ? ( - <> - {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' - ) - ) - ) && ( - - -
0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : '#1292eeff', - color: '#fff', - height: '40px', - width: '45px', - borderRadius: '6px', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - padding: '8px 8px 12px 8px', - }} - className="AsAmtCombo" - > - {' '} - 0 && 'not-allowed', - // color: - // OrderCardDetail?.length > 0 || - // (selOption?.value === undefined && - // GlobalAddCustomerDetails1?.length === 0 && - // GetCustId?.CustMobile === undefined) - // ? 'gray' - // : '#1292eeff', - fontSize: '28px', - }} - />{' '} -

Adv Amt

-
-
-
- )} - - ) : ( - '' - )} - {FeatureAddonData?.FeatureDtls?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'preorder' - ) && ( - <> - { -
0 || OrderType === 'Failed' - ? 'none' - : 'auto', - opacity: OrderCardDetail?.length > 0 ? 0.5 : 1, - }} - > - - - { - openPreOrder(); - }} - /> - - -
- } - - )} - {preOrderOpen && } - {sportsAppPreference && } - {dinePreference && - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && ( - <> - - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - style={{ - pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } - - )} - {OrderCardDetail?.length > 0 && ParkingDisplay && ( -
+ - -
- )} - {unpaidFlow == true ? ( - - { - Recipt(); - }} - /> - - ) : ( - '' - )} - {/*
+ + + + - - + content={ + <> + + + + + } trigger="click" open={open} onOpenChange={handleOpenChange} > - - -
*/} - {/* {ComboDropDown?.length >= 1 && ( -
- - + -
- )} */} - {paymentfeataddon && ( - -
{ - paymentFailedStatusFun(); - }} - style={{ - width: '27px', - cursor: 'pointer', - fontWeight: '600', - color: 'rgb(18, 146, 238)', - }} - > - -
-
- )} - {OpenFailData && ( - - )} + +
-
-
- {BSComboData?.BookingBilling?.[1]?.map((item) => ( - <> - {item?.OptionName == 'AddCustomer' && !preOrderOpen && ( - -
- - -
- -
-
-
-
- )} - - ))} - -
- - - - - - - - - - - - } - trigger="click" - open={open} - onOpenChange={handleOpenChange} - > - - - - -
-
- {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'); - }} - /> -
- )} -
- {UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
- {/*

UPI PAYMENT

*/} - -
-
- -
- -
-

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

-
- -
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text - {/* */} -
- )} + ))} + {PrintOrderDetails?.length > 0 && + (TokenOnly?.SettingValue === 'Y' || + IndividualToken?.SettingValue === 'Y') && + PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ))} + {CreditCustomer && ( +
+ { + handleCreditCustomer('Cancel'); + }} + handleOk={() => { + handleCreditCustomer('Submit'); + }} + /> +
+ )} +
+ {UpiOpen && ( + { + Upimodel('Cancel'); + }} + footer={false} + children={ +
+ {/*

UPI PAYMENT

*/}
- } - handleSubmit={() => { - Upimodel('Submit'); +
+ +
+ +
+

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

+
+
+ +
+ {(selOption || SelCustId) && ( +
+ Sent Payment Link + Your Alt Text + {/* */} +
+ )} + +
+ > + } + handleSubmit={() => { + Upimodel('Submit'); + }} + /> +
-
- } - /> - )} - {unpaidopen && ( - { - setUnpaidOpen(false); - }} - footer={false} - children={ -
- -
- } - /> - )} - {/* + } + /> + )} + {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={ +
+ +
+ } + /> + setShowCancelConfirm(true)} + footer={false} width={500} children={ <> -
- 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={ -
{ + setBusinessUPI(false); + setShowCancelConfirm(false); + ClearAllGlobalStateDatas(); + CustomerDisplay(); + }} + onCancel={() => setShowCancelConfirm(false)} + okText="Yes" + cancelText="No" > - -
- } - /> - 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? - - )} - + Do you want to cancel the payment? +
+ )} + + ); }; diff --git a/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx b/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx index a567aa5..a29016f 100644 --- a/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx +++ b/src/Pages/BookingScreen/Components/BSCombo/BSC1Search.jsx @@ -1,4 +1,11 @@ -import { useEffect, useRef, useState, useCallback } from 'react'; +import { + useEffect, + useRef, + useState, + useCallback, + Suspense, + lazy, +} from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; import { BiBarcodeReader } from 'react-icons/bi'; @@ -54,7 +61,9 @@ import { Messages } from '../../../../Components/Notifications/Messages'; import FormHeader from '../../../PageComponents/FormHeader'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; import { Tables } from '../../../../Components/Tables/Table'; -import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; +const FeaturesFunctionalities = lazy( + () => import('../BookingFunctionality/FeaturesFunctionalities') +); import { isMobile } from 'react-device-detect'; import BarcodeScanner from '../UtillComponents/BarcodeScanner.jsx'; import { @@ -80,11 +89,20 @@ import { import { Global_PromoCodeOffers } from '../../../../Features/Offer/Offer.js'; import { validateOffers } from '../BSItemCards/ValidateOffer.jsx'; import { useSaleswiseOfferWatcher } from '../BSItemCards/SalesWiseOffer.jsx'; -import ExpireConfirmModal from '../BookingFunctionality/ExpireConfirmModal.jsx'; -import BarCodeScan from '../../../../Services/BarCodeScan.jsx'; +const ExpireConfirmModal = lazy( + () => import('../BookingFunctionality/ExpireConfirmModal.jsx') +); + +const BarcodeScanner = lazy( + () => import('../UtillComponents/BarcodeScanner.jsx') +); + +const BSNavBarWeightScale = lazy( + () => import('../UtillComponents/BSNavBarWeightScale.jsx') +); export default function BSC1Search(props) { - const dispatch = useDispatch(); + const dispatch = useDispatch(); const searchPromiseRef = useRef(null); const debounceTimerRef = useRef(null); const SessionData = useSelector(StoredSessionData); @@ -4499,335 +4517,349 @@ export default function BSC1Search(props) { const widthBasedOnProdVariantDetails = getMaxBrandWidth(); return ( - <> -
- + Loading...
}> + <>
OnfocusTrue()} + className="BSC1Search-container" + ref={containerRef} + onFocus={handleFocus} > -
- - ({ - value: option.ProdName, - label: ( -
-
{ - setOnePeiceFlow(false); - }} - > - {option.ProdName} -
-
- {option.ProductDetail?.filter( - (item) => item.OnePcsAvailable == 'Y' - ).length !== 0 && ( - { - setOnePeiceFlow(true); - }} - /> - )} -
-
- ), - })) - } - className="Search-auto-field" - ref={inputRef} - onChange={ProductNameOnChange} - onSelect={ProductOnSelect} - placeholder="Product Name (SHIFT + S)" - allowClear={{ - clearIcon: , - }} - autoFocus={autoCompleteVisible} - onFocus={handleFocus} - /> -
-
- {isMobile && screenWidth <= 768 && ( - // handleQrcode()} - // // onClick={() => OnfocusTrue()} - // /> - { - ProductNameOnChange(value, true); - }} - /> - )} - - OnfocusTrue()} + -
- {ProductSearch?.length > 5 && - QuickAdd && - GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode') && ( -
- OnfocusTrue()} + > +
+ + ({ + value: option.ProdName, + label: ( +
+
{ + setOnePeiceFlow(false); + }} + > + {option.ProdName} +
+
+ {option.ProductDetail?.filter( + (item) => item.OnePcsAvailable == 'Y' + ).length !== 0 && ( + { + setOnePeiceFlow(true); + }} + /> + )} +
+
+ ), + })) + } + className="Search-auto-field" + ref={inputRef} + onChange={ProductNameOnChange} + onSelect={ProductOnSelect} + placeholder="Product Name (SHIFT + S)" + allowClear={{ + clearIcon: , + }} + autoFocus={autoCompleteVisible} + onFocus={handleFocus} + /> +
+
+ {isMobile && screenWidth <= 768 && ( + // handleQrcode()} + // // onClick={() => OnfocusTrue()} + // /> + { + ProductNameOnChange(value, true); + }} /> -
- )} - {BSComboData == 'Combo1' && - FeatureAddonData?.FeatureDtls?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'weight scale' - ) && } -
- {expireModal?.open && ( - { - expireModal.onOk?.(); - closeExpireModal(); - }} - onCancel={() => { - expireModal.onCancel?.(); - closeExpireModal(); - }} - /> - )} + )} - - + OnfocusTrue()} + />
- } - open={modelQty} - width={widthBasedOnProdVariantDetails} - footer={null} - handleCancel={CloseModal} - > -
-
-
-

Item Name:

+ {ProductSearch?.length > 5 && + QuickAdd && + GetmultipleSearchDatas.some( + (e) => e.toLowerCase() === 'qrcode' + ) && ( +
+ +
+ )} + {BSComboData == 'Combo1' && + FeatureAddonData?.FeatureDtls?.find( + (item) => item?.FeatureAddonName?.toLowerCase() === 'weight scale' + ) && } +
+ {expireModal?.open && ( + { + expireModal.onOk?.(); + closeExpireModal(); + }} + onCancel={() => { + expireModal.onCancel?.(); + closeExpireModal(); + }} + /> + )} + + + +
+ } + open={modelQty} + width={widthBasedOnProdVariantDetails} + footer={null} + handleCancel={CloseModal} + > +
+
+
+

Item Name:

+
+
+

{qtydata?.ProdName}

+
-

{qtydata?.ProdName}

-
-
-
- {Object.keys(brandMapping)?.map((brandId) => ( -
-
-

- {' '} - {brandId !== 'null' && brandId !== 'undefined' - ? brandId - : ''} -

-
+ {Object.keys(brandMapping)?.map((brandId) => ( +
+
+

+ {' '} + {brandId !== 'null' && brandId !== 'undefined' + ? brandId + : ''} +

+
-
- {brandMapping[brandId]?.map((item, index) => ( -
-
- 0 || item?.StockAvailable !== 'Y' - ? 'ItemQtyCard' - : 'ItemQtyCard-disabled' - } - onClick={() => VarientFun(item)} - > -
- {`Product -
- -
-

- {item?.Size + ' ' + item?.UomName} -

- {returnQtyCount( - item?.ProdId, - item, - CartOrderDetails - ) > 0 || item?.StockAvailable !== 'Y' ? ( -

- -   - { - item?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.SellPrice +

+ {brandMapping[brandId]?.map((item, index) => ( +
+
0 || item?.StockAvailable !== 'Y' + ? 'ItemQtyCard' + : 'ItemQtyCard-disabled' + } + onClick={() => VarientFun(item)} + > +
+ {`Product +
+ +
+

+ {item?.Size + ' ' + item?.UomName}

- ) : ( - '' - )} + {returnQtyCount( + item?.ProdId, + item, + CartOrderDetails + ) > 0 || item?.StockAvailable !== 'Y' ? ( +

+ +   + { + item?.ProdVariantDetails?.[0] + ?.StockDetails?.[0]?.SellPrice + } +

+ ) : ( + '' + )} +
-
- ))} + ))} +
+ {brandId !== 'null' && brandId !== 'undefined' ? ( +
+ ) : ( + '' + )}
- {brandId !== 'null' && brandId !== 'undefined' ?
: ''} -
- ))} + ))} - {Object.keys(brandMapping).length === 0 && ( -

No product details available

- )} -
-
- - - -
- } - open={modelstock} - // width={500} - footer={null} - handleCancel={CloseModal1} - > -
-
-
-
-

Item Name:

-
-
-

{qtydata?.ProdName}

-
-
-
-
-

Item Quantity:

-
-
-

- {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} - {onePeiceFlow - ? 'PCS' - : qtydata?.ProductDetail?.[QtyIndex]?.UomName} -

-
+ {Object.keys(brandMapping).length === 0 && ( +

No product details available

+ )}
-
- -
-
- - - -
- } - open={ModalVarient} - width={500} - footer={null} - handleCancel={CloseVarientModal} - > -
-
-
-
-

Item Name:

+ + + +
+ } + open={modelstock} + // width={500} + footer={null} + handleCancel={CloseModal1} + > +
+
+
+
+

Item Name:

+
+
+

+ {qtydata?.ProdName} +

+
-
-

{qtydata?.ProdName}

+
+
+

Item Quantity:

+
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

+
-
-
-

Item Quantity:

-
-
-

- {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} - {onePeiceFlow - ? 'PCS' - : qtydata?.ProductDetail?.[QtyIndex]?.UomName} -

-
+
+
-
- + + + +
+ } + open={ModalVarient} + width={500} + footer={null} + handleCancel={CloseVarientModal} + > +
+
+
+
+

Item Name:

+
+
+

+ {qtydata?.ProdName} +

+
+
+
+
+

Item Quantity:

+
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

+
+
+
+
+ +
-
- - {/* {isMobile && screenWidth <= 768 && ( + + {/* {isMobile && screenWidth <= 768 && ( )} */} - + + ); } diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx index c71de64..b120a6c 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx @@ -6098,7 +6098,7 @@ const BSItemCard = (props) => { style={{ position: 'relative', overflow: 'hidden', - scrollbarWidth:"none" + scrollbarWidth: 'none', }} className={ (item?.OverAllQty !== undefined && diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx index b2b0f12..8c0d2cc 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BSOtherServiceItemCard.jsx @@ -75,9 +75,7 @@ import WebFont from 'webfontloader'; import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; import { isMobile } from 'react-device-detect'; import { Global_OfferStatus } from '../../../../Features/Offer/Offer'; -import { - useApplyOfferto_CardDetail -} from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; +import { useApplyOfferto_CardDetail } from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import { GlobalAddCustomerDetails } from '../../../../Features/BookingScreen/Customer/addCustomer.js'; import { DndContext, @@ -94,8 +92,10 @@ import { import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { getCombolist } from '../../../../Features/ComboMaster/ComboMaster.js'; -import { GlobalOtherServicesdata, OtherServicesCardlistdata } from '../../../../Features/OtherServices/OtherServices.js'; - +import { + GlobalOtherServicesdata, + OtherServicesCardlistdata, +} from '../../../../Features/OtherServices/OtherServices.js'; export function SortableCard({ id, children, item }) { const { @@ -185,10 +185,13 @@ const BSOtherServiceItemCard = (props) => { SelectedGlobalCardColorDetail, shallowEqual ); - const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) + const GetmultipleSearchDatas = useSelector( + GlobalGetmultipleSearchDatas, + shallowEqual + ); const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual); const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual); - console.log(CartOrderDetails, "CartOrderDetailsOTHERSERVICESITEMCARD"); + console.log(CartOrderDetails, 'CartOrderDetailsOTHERSERVICESITEMCARD'); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); const otherscarddata = useSelector(Globalothersdata, shallowEqual); const WSProductdata = useSelector(GlobalWSProduct, shallowEqual); @@ -209,7 +212,6 @@ const BSOtherServiceItemCard = (props) => { const SessionData = useSelector(StoredSessionData, shallowEqual); const GlobalOtherServicescarddatas = useSelector(GlobalOtherServicesdata); - const [messageType, setMessageType] = useState(null); const [messageData, setMessageData] = useState(null); const [repeatedModel, setRepeatedModel] = useState(false); @@ -224,7 +226,7 @@ const BSOtherServiceItemCard = (props) => { const [ComboCardata, setCombocardata] = useState([]); - const [ExpiredProduct, setExpiredProduct] = useState() + const [ExpiredProduct, setExpiredProduct] = useState(); const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; @@ -250,7 +252,7 @@ const BSOtherServiceItemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -272,7 +274,7 @@ const BSOtherServiceItemCard = (props) => { useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); - GetmultipleSearchData() + GetmultipleSearchData(); } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission @@ -285,10 +287,9 @@ const BSOtherServiceItemCard = (props) => { }; try { - const response = await dispatch(getmultipleSearch(data)) - + const response = await dispatch(getmultipleSearch(data)); } catch (error) { - console.error("Get Search Terms Error:", error); + console.error('Get Search Terms Error:', error); } }; useEffect(() => { @@ -307,12 +308,12 @@ const BSOtherServiceItemCard = (props) => { if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( - e => e.toLowerCase() === "qrcode" - )) { + if ( + ProductSearch?.length > 5 && + GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode') + ) { setQuickAdd(true); } - }, [ProductSearch, GetmultipleSearchDatas]); useEffect(() => { @@ -418,95 +419,94 @@ const BSOtherServiceItemCard = (props) => { let Data = response?.data?.data; setCombocardata(Data); - } }; let Otherservicedata = [ { - "CompId": 1, - "BranchId": 101, - "AppId": 2025, - "ConfigTypeId": 10, - "ConfigTypeIdName": "Other Services", - "ServiceCategories": [ + CompId: 1, + BranchId: 101, + AppId: 2025, + ConfigTypeId: 10, + ConfigTypeIdName: 'Other Services', + ServiceCategories: [ { - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceDetails": [ + ServiceCategory: 1, + ServiceCategoryName: 'Parking', + ServiceDetails: [ { - "ServiceId": "PK2W", - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceName": "2-Wheeler Parking", - "ServiceShortName": "2W", - "TaxId": "T1", - "TaxName": "GST 5%", - "TaxAmt": 1.50, - "Rate": 30.00, - "TotalAmt": 31.50, - "ActiveStatus": "Active" + ServiceId: 'PK2W', + ServiceCategory: 1, + ServiceCategoryName: 'Parking', + ServiceName: '2-Wheeler Parking', + ServiceShortName: '2W', + TaxId: 'T1', + TaxName: 'GST 5%', + TaxAmt: 1.5, + Rate: 30.0, + TotalAmt: 31.5, + ActiveStatus: 'Active', }, { - "ServiceId": "PK4W", - "ServiceCategory": 1, - "ServiceCategoryName": "Parking", - "ServiceName": "4-Wheeler Parking", - "ServiceShortName": "4W", - "TaxId": "T1", - "TaxName": "GST 5%", - "TaxAmt": 2.50, - "Rate": 50.00, - "TotalAmt": 52.50, - "ActiveStatus": "Active" - } - ] + ServiceId: 'PK4W', + ServiceCategory: 1, + ServiceCategoryName: 'Parking', + ServiceName: '4-Wheeler Parking', + ServiceShortName: '4W', + TaxId: 'T1', + TaxName: 'GST 5%', + TaxAmt: 2.5, + Rate: 50.0, + TotalAmt: 52.5, + ActiveStatus: 'Active', + }, + ], }, { - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceDetails": [ + ServiceCategory: 2, + ServiceCategoryName: 'Entrance', + ServiceDetails: [ { - "ServiceId": "ENAD", - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceName": "Adult Entry", - "ServiceShortName": "Adult", - "TaxId": "T2", - "TaxName": "GST 12%", - "TaxAmt": 6.00, - "Rate": 50.00, - "TotalAmt": 56.00, - "ActiveStatus": "Active" + ServiceId: 'ENAD', + ServiceCategory: 2, + ServiceCategoryName: 'Entrance', + ServiceName: 'Adult Entry', + ServiceShortName: 'Adult', + TaxId: 'T2', + TaxName: 'GST 12%', + TaxAmt: 6.0, + Rate: 50.0, + TotalAmt: 56.0, + ActiveStatus: 'Active', }, { - "ServiceId": "ENCH", - "ServiceCategory": 2, - "ServiceCategoryName": "Entrance", - "ServiceName": "Child Entry", - "ServiceShortName": "Child", - "TaxId": "T2", - "TaxName": "GST 12%", - "TaxAmt": 3.00, - "Rate": 25.00, - "TotalAmt": 28.00, - "ActiveStatus": "Active" - } - ] - } - ] - } - ] - + ServiceId: 'ENCH', + ServiceCategory: 2, + ServiceCategoryName: 'Entrance', + ServiceName: 'Child Entry', + ServiceShortName: 'Child', + TaxId: 'T2', + TaxName: 'GST 12%', + TaxAmt: 3.0, + Rate: 25.0, + TotalAmt: 28.0, + ActiveStatus: 'Active', + }, + ], + }, + ], + }, + ]; const processGlobalComboData = () => { - const serviceCategories = GlobalOtherServicescarddatas?.[0]?.ServiceDetails; if (!Array.isArray(serviceCategories)) return []; // Flatten all ServiceDetails into a single array - const allServiceDetails = serviceCategories.map((category) => category.ServiceDetails || []); + const allServiceDetails = serviceCategories.map( + (category) => category.ServiceDetails || [] + ); const comboList = serviceCategories.map((item, index) => ({ ...item, @@ -520,7 +520,6 @@ const BSOtherServiceItemCard = (props) => { const comboList = processGlobalComboData() || []; - useEffect(() => { DispatchData(); }, [SelectedProdNames]); @@ -536,7 +535,6 @@ const BSOtherServiceItemCard = (props) => { }, [WSProductdata]); useEffect(() => { - if (ItemCard?.[0]?.QrBasedSearch === 'Y') { if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) { setexpModel(true); @@ -632,10 +630,11 @@ const BSOtherServiceItemCard = (props) => { ); setBillOrderPre(BillOrder?.SettingValue); - const expiredDate = PreferenceStckDtl?.find( - (item) => item.SettingIdName === 'ExpiredSelection' - )?.SettingValue === 'Y'; - setExpiredProduct(expiredDate) + const expiredDate = + PreferenceStckDtl?.find( + (item) => item.SettingIdName === 'ExpiredSelection' + )?.SettingValue === 'Y'; + setExpiredProduct(expiredDate); }; const CloseModal = () => { @@ -681,13 +680,13 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -696,9 +695,9 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -740,11 +739,11 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -753,9 +752,9 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -808,7 +807,7 @@ const BSOtherServiceItemCard = (props) => { if ( overallExpStatus === 'N' || // (overallExpStatus === 'Y' && prodexpir) - (overallExpStatus === 'Y') + overallExpStatus === 'Y' ) { setModalVarient(false); setModelstock(true); @@ -829,13 +828,13 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -843,11 +842,11 @@ const BSOtherServiceItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -896,32 +895,28 @@ const BSOtherServiceItemCard = (props) => { } } } else { - - if ( - overallExpStatus === 'N' || - (overallExpStatus === 'Y' && prodexpir) - ) { + if (overallExpStatus === 'N' || (overallExpStatus === 'Y' && prodexpir)) { setModalVarient(false); setModelstock(true); setVarItem(index.key); if (overallExpStatus === 'Y' && prodexpir) { setRepeatedModel(true); } - return + return; } else if (overallExpStatus === 'Y' && ExpiredProduct) { setVarItem(index.key); setexpVarModel(true); - return + return; } let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); if (onePeiceFlow) { @@ -929,9 +924,9 @@ const BSOtherServiceItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1026,15 +1021,15 @@ const BSOtherServiceItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1042,11 +1037,11 @@ const BSOtherServiceItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1124,15 +1119,15 @@ const BSOtherServiceItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1140,11 +1135,11 @@ const BSOtherServiceItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1575,7 +1570,7 @@ const BSOtherServiceItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1605,7 +1600,7 @@ const BSOtherServiceItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1635,7 +1630,7 @@ const BSOtherServiceItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1679,17 +1674,17 @@ const BSOtherServiceItemCard = (props) => { qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable === 'Y' ? onePeiceFlow ? returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.ProdVariantName + ) : returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllQty, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) : 'Stock Not Maintained', }); }); @@ -1698,7 +1693,7 @@ const BSOtherServiceItemCard = (props) => { if (WeightScalePort === true) { if ( a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - 'KGS'?.toLowerCase() && + 'KGS'?.toLowerCase() && a?.ProductDetail?.[QtyIndex]?.Size == '1' ) { if (WeightScaleWeight > 0 && WeightScaleWeight !== null) { @@ -1706,13 +1701,13 @@ const BSOtherServiceItemCard = (props) => { parseFloat( onePcs ? (a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[stockIndex]?.OnePcsPrice / - 1000) * - (parseFloat(WeightScaleWeight) * 1000) + VarientIndex + ]?.StockDetails?.[stockIndex]?.OnePcsPrice / + 1000) * + (parseFloat(WeightScaleWeight) * 1000) : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[stockIndex]?.SellPrice / 1000 + VarientIndex + ]?.StockDetails?.[stockIndex]?.SellPrice / 1000 ) * (parseFloat(WeightScaleWeight) * 1000); let data = { @@ -1775,9 +1770,9 @@ const BSOtherServiceItemCard = (props) => { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: parseFloat(TotalOrderRate).toFixed(2), SellingPrice: parseFloat(TotalOrderRate).toFixed(2), SuppId: @@ -1801,7 +1796,7 @@ const BSOtherServiceItemCard = (props) => { setQtyIndex(0); setVarientIndex(0); setVarItem(0); - setItem(), setStockItem(); + (setItem(), setStockItem()); dispatch(changeSearchedData('')); AddOrderDetails(data); dispatch(changeWeightScaleWeight(null)); @@ -1889,19 +1884,19 @@ const BSOtherServiceItemCard = (props) => { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SellingPrice: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -1923,7 +1918,7 @@ const BSOtherServiceItemCard = (props) => { setQtyIndex(0); setVarientIndex(0); setVarItem(0); - setItem(), setStockItem(); + (setItem(), setStockItem()); dispatch(changeSearchedData('')); AddOrderDetails(data); setOnePeiceFlow(false); @@ -1938,7 +1933,7 @@ const BSOtherServiceItemCard = (props) => { setQtyIndex(0); setVarientIndex(0); setVarItem(0); - setItem(), setStockItem(); + (setItem(), setStockItem()); dispatch(changeSearchedData('')); setOnePeiceFlow(false); } @@ -2903,12 +2898,9 @@ const BSOtherServiceItemCard = (props) => { }; const onAutocompleteChange = async (selectedOption) => { - - - console.log(selectedOption, "selectedOptionselectedOption"); + console.log(selectedOption, 'selectedOptionselectedOption'); let data = { - Type: 'OS', ActiveStatus: selectedOption?.ActiveStatus, @@ -2927,7 +2919,6 @@ const BSOtherServiceItemCard = (props) => { ProdLogo: selectedOption?.ImageUrl, - OrderRate: selectedOption?.TotalAmt, TotalAmt: selectedOption?.TotalAmt, TotalSellPrice: selectedOption?.TotalAmt, @@ -2963,7 +2954,7 @@ const BSOtherServiceItemCard = (props) => { }; const AddOrderDetails = async (item) => { - console.log("AddOrderDetails item", item) + console.log('AddOrderDetails item', item); if (preOrder) { let Response = await dispatch( getConfigType({ TypeName: 'Booking Type' }) @@ -2983,8 +2974,7 @@ const BSOtherServiceItemCard = (props) => { if (Condition !== undefined && Condition === true) { setMessageData('Dublicate Data'); setMessageType('error'); - } - else { + } else { let OfferPri = item?.OfferType === 'F' ? item?.OfferPrice @@ -3050,9 +3040,7 @@ const BSOtherServiceItemCard = (props) => { dispatch(changepreOrderList(Data)); } } - } - else { - + } else { dispatch(changeHoldOrderDtl(false)); dispatch(changePreviousOrderLength(CartOrderDetails?.length)); const OtherOrderDatas = CartOrderDetails?.filter( @@ -3121,56 +3109,7 @@ const BSOtherServiceItemCard = (props) => { 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?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), - OfferValue: - item?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, - - 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), - }; - - dispatch( - changeOrderCardDetails([ - UpdatedCartItem, - ...OtherorderDataforNormal, - ]) - ); - } - else { - - const isGroupService = isItemInCart?.ServiceType == 'G'; - if (isGroupService) { - const UpdatedCartItem = // if the item is already in the cart, increase the quantity of the item { ...isItemInCart, @@ -3178,21 +3117,19 @@ const BSOtherServiceItemCard = (props) => { TotalAmt: isItemInCart?.OfferPrice > 0 ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) + (isItemInCart?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), OfferValue: item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100, - // TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate), + : isItemInCart?.OfferPrice, + TaxAmt: ( ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate * @@ -3209,6 +3146,55 @@ const BSOtherServiceItemCard = (props) => { ).toFixed(2), }; + dispatch( + changeOrderCardDetails([ + UpdatedCartItem, + ...OtherorderDataforNormal, + ]) + ); + } else { + const isGroupService = isItemInCart?.ServiceType == 'G'; + if (isGroupService) { + const UpdatedCartItem = + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * + isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + OfferValue: + item?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100, + // 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), + }; + dispatch( changeOrderCardDetails([ ...OtherorderDataforNormal, @@ -3218,50 +3204,51 @@ const BSOtherServiceItemCard = (props) => { } else { // ❌ Not a group service setMessageType('error'); - setMessageData("Service Already Exist") + setMessageData('Service Already Exist'); } - } - } - else if (isItemInCart && BookingTypeProd === 'Dine In' && OrderType != 'Hold') { - + } 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?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + OfferValue: + item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - OfferValue: - item?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : isItemInCart?.OfferPrice, - // 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 - - ( + // 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), + }; dispatch( changeOrderCardDetails([ @@ -3269,44 +3256,43 @@ const BSOtherServiceItemCard = (props) => { ...OtherorderDataforNormal, ]) ); - } - else { + } else { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty + 1, - TotalAmt: - isItemInCart?.OfferPrice > 0 - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - - (isItemInCart?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty + 1, + TotalAmt: + isItemInCart?.OfferPrice > 0 + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate - + (isItemInCart?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCart?.OrderQty + 1) * + isItemInCart?.OrderRate * + isItemInCart?.OfferPrice) / + 100) + : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, + OfferValue: + item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCart?.OrderQty + 1) * - isItemInCart?.OrderRate * - isItemInCart?.OfferPrice) / - 100) - : (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate, - OfferValue: - item?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : isItemInCart?.OfferPrice, - // 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 - - ( + // 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), + }; dispatch( changeOrderCardDetails([ @@ -3315,48 +3301,46 @@ const BSOtherServiceItemCard = (props) => { ]) ); } - } - else if (isItemInCartHold && OrderType === 'Hold') { - + } 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?.OfferPrice > 0 - ? (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate - - (isItemInCartHold?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + isItemInCartHold?.OfferPrice > 0 + ? (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate - + (isItemInCartHold?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.OfferPrice) / + 100) + : (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate, + OfferValue: + item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.OfferPrice) / - 100) - : (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate, - OfferValue: - item?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : isItemInCart?.OfferPrice, - // 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 - - ( + // 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), + }; dispatch( changeOrderCardDetails([ @@ -3364,46 +3348,45 @@ const BSOtherServiceItemCard = (props) => { ...OtherorderDataforNormalWithoutSalesId, ]) ); - } - else { + } else { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCartHold, - OrderQty: isItemInCartHold?.OrderQty + 1, - TotalAmt: - isItemInCartHold?.OfferPrice > 0 - ? (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate - - (isItemInCartHold?.OfferType === 'F' + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCartHold, + OrderQty: isItemInCartHold?.OrderQty + 1, + TotalAmt: + isItemInCartHold?.OfferPrice > 0 + ? (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate - + (isItemInCartHold?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate * + isItemInCartHold?.OfferPrice) / + 100) + : (isItemInCartHold?.OrderQty + 1) * + isItemInCartHold?.OrderRate, + OfferValue: + item?.OfferType === 'F' ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate * - isItemInCartHold?.OfferPrice) / - 100) - : (isItemInCartHold?.OrderQty + 1) * - isItemInCartHold?.OrderRate, - OfferValue: - item?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : isItemInCart?.OfferPrice, + : isItemInCart?.OfferPrice, - // 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 - - ( + // 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), + }; dispatch( changeOrderCardDetails([ @@ -3412,9 +3395,11 @@ const BSOtherServiceItemCard = (props) => { ]) ); } - } - else if (isItemNotInDine && BookingTypeProd == 'Dine In' && OrderType != 'Hold') { - + } else if ( + isItemNotInDine && + BookingTypeProd == 'Dine In' && + OrderType != 'Hold' + ) { if (BillOrderPre === 'Y') { const UpdatedCartItem = { ...isItemNotInDine, @@ -3422,12 +3407,12 @@ const BSOtherServiceItemCard = (props) => { TotalAmt: isItemNotInDine?.OfferPrice > 0 ? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - (isItemNotInDine?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.OfferPrice) / - 100) + (isItemNotInDine?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.OfferPrice) / + 100) : (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, OfferValue: item?.OfferType === 'F' @@ -3458,20 +3443,19 @@ const BSOtherServiceItemCard = (props) => { ...OtherOrderDatawithsales, ]) ); - } - else { + } else { const UpdatedCartItem = { ...isItemNotInDine, OrderQty: isItemNotInDine?.OrderQty + 1, TotalAmt: isItemNotInDine?.OfferPrice > 0 ? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate - - (isItemNotInDine?.OfferType === 'F' - ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice - : ((isItemNotInDine?.OrderQty + 1) * - isItemNotInDine?.OrderRate * - isItemNotInDine?.OfferPrice) / - 100) + (isItemNotInDine?.OfferType === 'F' + ? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice + : ((isItemNotInDine?.OrderQty + 1) * + isItemNotInDine?.OrderRate * + isItemNotInDine?.OfferPrice) / + 100) : (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate, OfferValue: item?.OfferType === 'F' @@ -3503,51 +3487,49 @@ const BSOtherServiceItemCard = (props) => { ]) ); } - } - - else { + } else { if (item?.OtherProduct === 'Others') { BillOrderPre === 'Y' ? dispatch( - changeOrderCardDetails([ - { - ...item, - // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), + changeOrderCardDetails([ + { + ...item, + // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), - TotalAmt: item?.OrderQty * item?.OrderRate, - TaxAmt: ( - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderQty * item?.OrderRate - - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - }, - ...CartOrderDetails, - ]) - ) // if the item is not in the cart, add the item to the cart + TotalAmt: item?.OrderQty * item?.OrderRate, + TaxAmt: ( + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: ( + item?.OrderQty * item?.OrderRate - + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + }, + ...CartOrderDetails, + ]) + ) // if the item is not in the cart, add the item to the cart : dispatch( - changeOrderCardDetails([ - ...CartOrderDetails, - { - ...item, - TotalAmt: item?.OrderQty * item?.OrderRate, + changeOrderCardDetails([ + ...CartOrderDetails, + { + ...item, + TotalAmt: item?.OrderQty * item?.OrderRate, - // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), - TaxAmt: ( - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - WithoutTaxRate: ( - item?.OrderQty * item?.OrderRate - - (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) - ).toFixed(2), - }, - ]) - ); + // TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)), + TaxAmt: ( + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: ( + item?.OrderQty * item?.OrderRate - + (item?.OrderQty * item?.OrderRate * item?.TaxPercentage) / + (100 + item?.TaxPercentage) + ).toFixed(2), + }, + ]) + ); } // else { @@ -3593,7 +3575,6 @@ const BSOtherServiceItemCard = (props) => { // ])); // } // } - else { const baseItem = { ...item, @@ -3602,9 +3583,9 @@ const BSOtherServiceItemCard = (props) => { TotalAmt: item?.OfferPrice > 0 ? item?.OrderRate - - (item?.OfferType === 'F' - ? item?.OfferPrice - : (item?.OrderRate * item?.OfferPrice) / 100) + (item?.OfferType === 'F' + ? item?.OfferPrice + : (item?.OrderRate * item?.OfferPrice) / 100) : item?.OrderRate, TaxAmt: ( (item?.OrderRate * item?.TaxPercentage) / @@ -3613,34 +3594,35 @@ const BSOtherServiceItemCard = (props) => { WithoutTaxRate: ( item?.OrderRate - (item?.OrderRate * item?.TaxPercentage) / - (100 + item?.TaxPercentage) + (100 + item?.TaxPercentage) ).toFixed(2), }; if (item?.ServiceType === 'I') { - // Add the item and include a __index to track vehicle number uniquely - const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ - ...itm, - __index: idx, // Temporary index used for vehicle number assignment - })); + const updatedCart = [...CartOrderDetails, baseItem].map( + (itm, idx) => ({ + ...itm, + __index: idx, // Temporary index used for vehicle number assignment + }) + ); dispatch(changeOrderCardDetails(updatedCart)); } else { - // Use existing flow with optional BillOrderPre control // const updatedCart = // BillOrderPre === 'Y' // ? [baseItem, ...CartOrderDetails] // : [...CartOrderDetails, baseItem]; - const updatedCart = [...CartOrderDetails, baseItem].map((itm, idx) => ({ - ...itm, - __index: idx, // Temporary index used for vehicle number assignment - })); + const updatedCart = [...CartOrderDetails, baseItem].map( + (itm, idx) => ({ + ...itm, + __index: idx, // Temporary index used for vehicle number assignment + }) + ); dispatch(changeOrderCardDetails(updatedCart)); } } - } dispatch(changeothersdata({})); @@ -3767,8 +3749,8 @@ const BSOtherServiceItemCard = (props) => { Cartdata?.[0]?.OfferType === 'F' ? Cartdata?.[0]?.OfferPrice : (qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice * - Cartdata?.[0]?.OfferPrice) / - 100, + Cartdata?.[0]?.OfferPrice) / + 100, OfferPrice: Cartdata?.[0]?.OfferPrice, SinglePc: 'N', }; @@ -3810,9 +3792,9 @@ const BSOtherServiceItemCard = (props) => { return DropDown && Array.isArray(DropDown) ? DropDown.map((item) => ({ - label: `${item.ComboName}`, // Display the combo name - value: `${item.ComboId}`, // Use combo ID as the value - })) + label: `${item.ComboName}`, // Display the combo name + value: `${item.ComboId}`, // Use combo ID as the value + })) : []; // }); }; @@ -3839,7 +3821,6 @@ const BSOtherServiceItemCard = (props) => { function encrypt(code, key) { let encrypted = ( <> -
{ height: containerHeight, }} > - {messageType && messageData && ( { >
0) || - // item?.StockAvailable !== 'Y' - // ? 'BkPrdCardActive' - // : 'BkPrdCardDeActive' - // } + // className={ + // (item?.OverallQuantity !== undefined && + // returnCount( + // item?.ComboName, + // item?.OverallQuantity, + // CartOrderDetails, + // item?.OverAllPcs + // ) > 0) || + // item?.StockAvailable !== 'Y' + // ? 'BkPrdCardActive' + // : 'BkPrdCardDeActive' + // } > {!isMobile ? ( @@ -3939,38 +3919,38 @@ const BSOtherServiceItemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -4010,31 +3990,35 @@ const BSOtherServiceItemCard = (props) => { > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + cardFunction?.ImageLeft || + cardFunction?.ImageUp || + cardFunction?.ImageDown + ? '3rem' + : cardFunction?.BigImage && '7rem' + : '5rem', + }} + className={ + cardFunction?.SmallImage + ? 'BSItemCard-image-smallimage' + : 'BSItemCard-image' + } + src={ + item?.ImageUrl === null + ? defaultimage + : item?.ImageUrl + ? item?.ImageUrl + : defaultimage + } + alt="" + /> + )}
{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -4092,9 +4076,9 @@ const BSOtherServiceItemCard = (props) => { width: !cardFunction?.SmallImage ? cardFunction?.BigImage && '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -4142,27 +4126,20 @@ const BSOtherServiceItemCard = (props) => {

- ₹{' '} - { - item?.TotalAmt - } + ₹ {item?.TotalAmt}   {/* {item?.TotalAmt}  */} {/* {ItemSellingPrice(item)} */} @@ -4170,8 +4147,7 @@ const BSOtherServiceItemCard = (props) => { {'(1 Combo Pack)'} */}

- ) - } + )}
{cardFunction?.StockCount && @@ -4206,213 +4182,211 @@ const BSOtherServiceItemCard = (props) => { )}
- ) : + ) : ( + <> + {globaldata && ( + pickData(e, item)} + style={{ + position: 'absolute', + zIndex: 1, + transform: 'scale(1.5)', + cursor: 'pointer', + }} + checked={( + globalAllItemdata || EditfavItems + )?.some( + // (a) => a?.ProdName === item?.ProdName + (a) => + a?.ProdName === item?.ProdName && + a?.ProdCat === item?.ProdCat + )} + /> + )} - ( - <> - {globaldata && ( - pickData(e, item)} +
{ + // if ( + // !( + // item?.OverallQuantity !== undefined && + // returnCount( + // item?.ComboName, + // item?.OverallQuantity, + // CartOrderDetails + // ) > 0 + // ) + // ) { + // e.stopPropagation(); + // } else { + CardOnclick(item); + // } + }} + // data-aos="zoom-in" data-aos-duration="600" + > + {(cardFunction?.BigImage || + cardFunction?.SmallImage) && ( + a?.ProdName === item?.ProdName - (a) => - a?.ProdName === item?.ProdName && - a?.ProdCat === item?.ProdCat - )} + className={ + cardFunction?.SmallImage + ? 'BSItemCard-image-smallimage' + : 'BSItemCard-image' + } + src={ + item?.ProductDetail?.[0]?.ProdLogo === + '' + ? defaultimage + : item?.ProductDetail?.[0]?.ProdLogo + ? item?.ProductDetail?.[0] + ?.ProdLogo + : defaultimage + } + alt="" /> )} -
{ - // if ( - // !( - // item?.OverallQuantity !== undefined && - // returnCount( - // item?.ComboName, - // item?.OverallQuantity, - // CartOrderDetails - // ) > 0 - // ) - // ) { - // e.stopPropagation(); - // } else { - CardOnclick(item); - // } - }} - // data-aos="zoom-in" data-aos-duration="600" - > - {(cardFunction?.BigImage || - cardFunction?.SmallImage) && ( - - )} -
-

+

- {item?.ProdName}{' '} - {/* {(item?.OverallQuantity !== undefined && + // Width: cardFunction?.BigImage && "70px", + fontSize: + !cardFunction?.BigImage && + !cardFunction?.SmallImage && + '12px', //naresh27 + whiteSpace: + !cardFunction?.BigImage && + 'pre-wrap', + margin: 'auto', + fontFamily: SelectedCardFont + ? SelectedCardFont + : '', + color: SelectedCardColor + ? SelectedCardColor?.['FontColor'] + : '', + textOverflow: 'ellipsis', + }} + className="BSItemCard-itemName" + > + {item?.ProdName}{' '} + {/* {(item?.OverallQuantity !== undefined && returnCount( item?.ComboName, item?.OverallQuantity, @@ -4432,80 +4406,79 @@ const BSOtherServiceItemCard = (props) => { No Stock

)} */} -

- {cardFunction?.Price && - ((item?.OverallQuantity !== undefined && - item?.OverallQuantity !== 0 && - item?.OverallQuantity !== null) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - )) && ( -

- ₹ {ItemSellingPrice(item)}  - {/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice}  */} - {/* {ItemSellingPrice(item)} */} - - ({ItemSize(item)} - {ItemUomName(item)}) - -

- )} -
- - {cardFunction?.StockCount && - item?.OverallQuantity !== undefined && - item?.OverallQuantity !== 0 && ( -
+ {cardFunction?.Price && + ((item?.OverallQuantity !== undefined && + item?.OverallQuantity !== 0 && + item?.OverallQuantity !== null) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + )) && ( +

- {item?.OverallQuantity !== null && ( - - )} -

+ ₹ {ItemSellingPrice(item)}  + {/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice}  */} + {/* {ItemSellingPrice(item)} */} + + ({ItemSize(item)} + {ItemUomName(item)}) + +

)}
- - ) - } + + {cardFunction?.StockCount && + item?.OverallQuantity !== undefined && + item?.OverallQuantity !== 0 && ( +
+ {item?.OverallQuantity !== null && ( + + )} +
+ )} +
+ + )}
))} @@ -4513,9 +4486,10 @@ const BSOtherServiceItemCard = (props) => { - ) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( - e => e.toLowerCase() === "qrcode" - ) && + ) : ProductSearch?.length > 5 && + GetmultipleSearchDatas.some( + (e) => e.toLowerCase() === 'qrcode' + ) && (cardData?.length == 0 || cardData == undefined) ? (
{/* cardData mohan 18-04-2025 */} @@ -4535,19 +4509,19 @@ const BSOtherServiceItemCard = (props) => { display: globalAccessForOthers && 'none', }} > -
-
-
-
 
+
+
+
+
 
-
-
 
+
+
 
-
-
 
+
+
 
-
-
 
+
+
 
@@ -4556,19 +4530,19 @@ const BSOtherServiceItemCard = (props) => { )} {paymentloader === true && ( -
-
-
-
 
+
+
+
+
 
-
-
 
+
+
 
-
-
 
+
+
 
-
-
 
+
+
 

{' '} @@ -4582,10 +4556,8 @@ const BSOtherServiceItemCard = (props) => {

)} -
-
{expModel && ( @@ -4629,9 +4601,9 @@ const BSOtherServiceItemCard = (props) => { open={expQtyModel} onOk={() => expQtyFun(qtyExpData)} onCancel={() => { - setRepeatedModel(false), + (setRepeatedModel(false), setProdexpir(false), - setExpQtyModel(false); + setExpQtyModel(false)); }} okText="Submit" cancelText="Don't Submit" @@ -4655,9 +4627,9 @@ const BSOtherServiceItemCard = (props) => { open={expVarModel} onOk={() => expVerFun(VarItem)} onCancel={() => { - setexpVarModel(false), + (setexpVarModel(false), setRepeatedModel(false), - setProdexpir(false); + setProdexpir(false)); }} okText="Submit" cancelText="Don't Submit" @@ -4681,9 +4653,9 @@ const BSOtherServiceItemCard = (props) => { open={expStockModel} onOk={() => expStockFun(StockItem)} onCancel={() => { - setexpStockModel(false), + (setexpStockModel(false), setRepeatedModel(false), - setProdexpir(false); + setProdexpir(false)); }} okText="Submit" cancelText="Don't Submit" @@ -4843,16 +4815,16 @@ const BSOtherServiceItemCard = (props) => { ]?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - - ( - { - qtydata?.ProductDetail?.[QtyIndex] - ?.ProdVariantDetails?.[VarientIndex] - ?.ProdVariantName - } - ){' '} - - )} + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )}

@@ -4943,7 +4915,6 @@ const BSOtherServiceItemCard = (props) => { } /> )} - ); @@ -4974,5 +4945,4 @@ const BSOtherServiceItemCard = (props) => { return <>{encrypt()}; }; - -export default BSOtherServiceItemCard \ No newline at end of file +export default BSOtherServiceItemCard; diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx index 2755054..1285b7f 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BsBookingitemCard.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; -import { Badge, DatePicker, Modal, Tooltip, message } from 'antd'; +import { Badge, DatePicker, Modal, Tooltip, message } from 'antd'; import { ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons'; import defaultimage from '../../../../Images/defaultItemImg.png'; import FormHeader from '../../../PageComponents/FormHeader'; @@ -67,6 +67,7 @@ import { GlobalAddBookingDetailsTrigger, GlobalGetmultipleSearchDatas, getmultipleSearch, + GlobalAllBookingType, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import { GlobalPreOrderAdditem, @@ -108,7 +109,7 @@ import { ExtractDateFormate } from '../../../../Services/Others.js'; import { changeFullOfferAppliedProducts, changeOfferAppliedProductsForMembership, - GlobalOfferAppliedProducts + GlobalOfferAppliedProducts, } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; import { useSaleswiseOfferWatcher } from './SalesWiseOffer.jsx'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; @@ -164,6 +165,8 @@ const BsBookingitemCard = (props) => { const voiceTriggerRef = useRef(null); const unsubscribeRef = useRef(null); + const AllBookingType = useSelector(GlobalAllBookingType); + const { removeFromCart, clearAllItems, decline } = useRemoveFromCart(); const handleRemoveFromCart = async (item) => { await removeFromCart(item, setPreviousdataLength); @@ -172,9 +175,6 @@ const BsBookingitemCard = (props) => { await decline(item, setPreviousdataLength); }; - - - const cardFunction = props?.cardFunctionality; // const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData, shallowEqual); @@ -194,7 +194,10 @@ const BsBookingitemCard = (props) => { shallowEqual ); // const SelectedCust = useSelector(GlobalSelOption, shallowEqual); - const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual) + const GetmultipleSearchDatas = useSelector( + GlobalGetmultipleSearchDatas, + shallowEqual + ); const RetailWSSalesType = useSelector(GlobalRetailWSSalesType, shallowEqual); // const CustDetails = SelectedCust ? SelectedCust : AddCustomerDetails?.[0]; const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); @@ -425,9 +428,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -660,9 +663,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -754,9 +757,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -1001,7 +1004,7 @@ const BsBookingitemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -1069,7 +1072,7 @@ const BsBookingitemCard = (props) => { useEffect(() => { if (AppId && CompId && BranchId) { fetchedit(); - GetmultipleSearchData() + GetmultipleSearchData(); } // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission @@ -1082,10 +1085,9 @@ const BsBookingitemCard = (props) => { }; try { - const response = await dispatch(getmultipleSearch(data)) - + const response = await dispatch(getmultipleSearch(data)); } catch (error) { - console.error("Get Search Terms Error:", error); + console.error('Get Search Terms Error:', error); } }; useEffect(() => { @@ -1106,9 +1108,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; dispatch(getSelectedFavItems(data)).unwrap(); @@ -1120,9 +1122,10 @@ const BsBookingitemCard = (props) => { if (noSubcatCardData) { setNoSubcatCardData(); } - if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some( - e => e.toLowerCase() === "qrcode" - )) { + if ( + ProductSearch?.length > 5 && + GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode') + ) { setQuickAdd(true); } }, [ProductSearch, GetmultipleSearchDatas]); @@ -1169,9 +1172,9 @@ const BsBookingitemCard = (props) => { ProdSubCat: currentProdSubCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; //mohan @@ -1192,9 +1195,9 @@ const BsBookingitemCard = (props) => { prodCat: currentProdCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; @@ -1218,9 +1221,9 @@ const BsBookingitemCard = (props) => { prodCat: currentProdCat, ...(AvailableDate && currentDateRef ? { - fromDate: currentDateRef?.[0], - toDate: currentDateRef?.[1], - } + fromDate: currentDateRef?.[0], + toDate: currentDateRef?.[1], + } : {}), }; @@ -1233,20 +1236,12 @@ const BsBookingitemCard = (props) => { }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); + setConfigDataList(AllBookingType); + let configdata = AllBookingType; + let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - // setSelectedBookingType(filterconfigdata?.ConfigId); - } + let filterconfigdata = configdata?.find((a) => a?.ConfigName === checkName); + // setSelectedBookingType(filterconfigdata?.ConfigId); }; function getCurrentMembership(memberships) { @@ -1276,9 +1271,9 @@ const BsBookingitemCard = (props) => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; let res = await dispatch(getEditFavItems(data)).unwrap(); @@ -1484,13 +1479,13 @@ const BsBookingitemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1498,11 +1493,11 @@ const BsBookingitemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1595,13 +1590,13 @@ const BsBookingitemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1610,9 +1605,9 @@ const BsBookingitemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1760,15 +1755,15 @@ const BsBookingitemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1776,11 +1771,11 @@ const BsBookingitemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1859,15 +1854,15 @@ const BsBookingitemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1875,11 +1870,11 @@ const BsBookingitemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2314,7 +2309,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdName === ProdName ); @@ -2515,7 +2510,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -2551,7 +2546,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -2637,7 +2632,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -2676,7 +2671,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -2768,7 +2763,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -2811,7 +2806,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -2895,7 +2890,7 @@ const BsBookingitemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) { } + } catch (_) {} let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -2942,7 +2937,7 @@ const BsBookingitemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) { } + } catch (_) {} let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -2981,7 +2976,7 @@ const BsBookingitemCard = (props) => { const same = item?.InwardDtlId === data?.InwardDtlId && item?.ProdVariantName?.toLowerCase() === - data?.VarientName?.toLowerCase() && + data?.VarientName?.toLowerCase() && item?.VariantAvailableFrom === data?.VariantAvailableFrom && item?.VariantAvailableTo === data?.VariantAvailableTo && item?.BookedDate && @@ -3006,7 +3001,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3036,7 +3031,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3066,7 +3061,7 @@ const BsBookingitemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -3320,20 +3315,20 @@ const BsBookingitemCard = (props) => { 'Batch No': item?.BatchRef, StockCount: onePeiceFlow ? returnCountStock( - item?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.InwardDtlId, - 'Y' - ) + item?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.InwardDtlId, + 'Y' + ) : returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId, - 'N', - item?.OverAllPcs - ), + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId, + 'N', + item?.OverAllPcs + ), 'Stock Date': ExtractDateFormate(item?.InwardDate), Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, ExpDate: @@ -3637,9 +3632,9 @@ const BsBookingitemCard = (props) => { AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3671,9 +3666,9 @@ const BsBookingitemCard = (props) => { prodCat: ProdCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -4499,9 +4494,9 @@ const BsBookingitemCard = (props) => { allProducts.forEach((product) => { const brandName = product.BrandName && - product.BrandName !== 'null' && - product.BrandName !== 'undefined' && - product.BrandName.trim() !== '' + product.BrandName !== 'null' && + product.BrandName !== 'undefined' && + product.BrandName.trim() !== '' ? product.BrandName : 'Others'; @@ -4535,13 +4530,13 @@ const BsBookingitemCard = (props) => { const result = prodname ? (cardData || [])?.filter( - (item) => - normalize(item.ProdName).includes(normalize(prodname)) || - normalize(item.ProdCatName).includes(normalize(prodname)) || - item.ProductDetail?.some((detail) => - normalize(detail.ProdName).includes(normalize(prodname)) - ) - ) + (item) => + normalize(item.ProdName).includes(normalize(prodname)) || + normalize(item.ProdCatName).includes(normalize(prodname)) || + item.ProductDetail?.some((detail) => + normalize(detail.ProdName).includes(normalize(prodname)) + ) + ) : cardData; const getDatePickerValue = (selectedDate) => { @@ -4598,8 +4593,8 @@ const BsBookingitemCard = (props) => { zIndex: '12', top: templateData?.BookingLayout?.[0] === 'Layout5' || - templateData?.BookingLayout?.[0] === 'Layout4' || - templateData?.BookingLayout?.[0] === 'Layout6' + templateData?.BookingLayout?.[0] === 'Layout4' || + templateData?.BookingLayout?.[0] === 'Layout6' ? '2.5rem' : '', }} @@ -4711,39 +4706,39 @@ const BsBookingitemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -4765,39 +4760,39 @@ const BsBookingitemCard = (props) => { > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + ? item?.ProductDetail?.[0] + ?.ProdLogo + : defaultimage + } + alt="" + /> + )}
{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -4831,7 +4826,7 @@ const BsBookingitemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '5.5rem', + '5.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -4854,11 +4849,11 @@ const BsBookingitemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -4879,7 +4874,7 @@ const BsBookingitemCard = (props) => { className="BSItemCard-itemName" > {item?.ProdName} - { } + {}

{cardFunction?.Price && (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -4897,8 +4892,8 @@ const BsBookingitemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -4984,39 +4979,39 @@ const BsBookingitemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -5033,43 +5028,43 @@ const BsBookingitemCard = (props) => { onClick={(e) => { CardOnclick(item, index); }} - // data-aos="zoom-in" data-aos-duration="600" + // data-aos="zoom-in" data-aos-duration="600" > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + ? item?.ProductDetail?.[0] + ?.ProdLogo + : defaultimage + } + alt="" + /> + )}

{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -5103,7 +5098,7 @@ const BsBookingitemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '4.5rem', + '4.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -5123,11 +5118,11 @@ const BsBookingitemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -5163,7 +5158,7 @@ const BsBookingitemCard = (props) => { fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -5172,8 +5167,8 @@ const BsBookingitemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -5272,7 +5267,7 @@ const BsBookingitemCard = (props) => { height={60} src={ item?.ProductDetail?.[0]?.ProdLogo === - '' + '' ? defaultimage : item?.ProductDetail?.[0]?.ProdLogo ? item?.ProductDetail?.[0]?.ProdLogo @@ -5289,15 +5284,15 @@ const BsBookingitemCard = (props) => {
{item?.ProductDetail?.[0]?.ProdVariantDetails ?.length > 0 && ( -
-
- ₹ {ItemSellingPrice(item)} -
-
- {ItemSize(item)} {ItemUomName(item)} -
+
+
+ ₹ {ItemSellingPrice(item)}
- )} +
+ {ItemSize(item)} {ItemUomName(item)} +
+
+ )}
{/* Stock Count Badge */} @@ -5336,9 +5331,10 @@ const BsBookingitemCard = (props) => { - ) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some( - e => e.toLowerCase() === "qrcode" - ) && + ) : ProductSearch?.length > 5 && + GetmultipleSearchDatas.some( + (e) => e.toLowerCase() === 'qrcode' + ) && (cardData?.length == 0 || cardData == undefined) ? (
{/* cardData mohan 18-04-2025 */} @@ -5358,39 +5354,46 @@ const BsBookingitemCard = (props) => { display: globalAccessForOthers && 'none', }} > -
-
-
-
 
+ Name +
+
+
+
 
-
-
 
+ Name +
+
 
-
-
 
+ Name +
+
 
-
-
 
+ Name +
+
 
)} - {paymentloader === true && ( -
-
-
-
 
+ {paymentloadNameer === true && ( +
+
+
+
 
-
-
 
+ Name +
+
 
-
-
 
+ Name +
+
 
-
-
 
+ Name +
+
 

{' '} @@ -5989,30 +5992,30 @@ const BsBookingitemCard = (props) => { {slots.map((timeSlot, idx) => { const isBooked = timeSlot?.SlotStatus?.toLowerCase() == - 'booked' || false; + 'booked' || false; const isBlocked = timeSlot?.SlotStatus?.toLowerCase() == - 'blocked' || false; + 'blocked' || false; const isPartiallyBooked = timeSlot?.SlotStatus?.toLowerCase() === - 'partially booked' || false; + 'partially booked' || false; const isPartiallyBlocked = timeSlot?.SlotStatus?.toLowerCase() === - 'partially blocked' || false; + 'partially blocked' || false; const isSelected = CartOrderDetails?.some( (selected) => selected.ProdId === - timeSlot?.ProdId && + timeSlot?.ProdId && selected.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && selected.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && selected.BookedDate === - timeSlot?.BookedDate + timeSlot?.BookedDate ); const isAlreadyAdded = @@ -6020,25 +6023,25 @@ const BsBookingitemCard = (props) => { const itemDate = item?.BookedDate ? new Date( - item?.BookedDate - ).toLocaleDateString() + item?.BookedDate + ).toLocaleDateString() : null; return ( item?.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && item?.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && item?.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && item?.ProdVariantName?.toLowerCase() === - timeSlot?.VarientName?.toLowerCase() && + timeSlot?.VarientName?.toLowerCase() && itemDate === dataDate && (item?.SinglePc === 'Y' ? returnVariantStock( - data, - CartOrderDetails - ) === 0 + data, + CartOrderDetails + ) === 0 : true) ); }); @@ -6051,13 +6054,13 @@ const BsBookingitemCard = (props) => { selectedSlots?.some( (selected) => selected.InwardDtlId === - timeSlot?.InwardDtlId && + timeSlot?.InwardDtlId && selected.VariantAvailableFrom === - timeSlot?.VariantAvailableFrom && + timeSlot?.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot?.VariantAvailableTo && + timeSlot?.VariantAvailableTo && selected.TempDate === - timeSlot?.BookedDate + timeSlot?.BookedDate ); const isDisabled = isBooked || @@ -6070,25 +6073,26 @@ const BsBookingitemCard = (props) => { return (

{ @@ -6107,7 +6111,7 @@ const BsBookingitemCard = (props) => { timeSlot, product, onePeiceFlow || - isPartiallyBooked, + isPartiallyBooked, !slotEnded ); } @@ -6125,7 +6129,7 @@ const BsBookingitemCard = (props) => {
₹ {onePeiceFlow || - isPartiallyBooked + isPartiallyBooked ? timeSlot?.OnePcsPrice : timeSlot?.SellPrice || 0}
@@ -6151,15 +6155,15 @@ const BsBookingitemCard = (props) => { !CartOrderDetails?.some( (selected) => selected.ProdId === - timeSlot.ProdId && + timeSlot.ProdId && selected.InwardDtlId === - timeSlot.InwardDtlId && + timeSlot.InwardDtlId && selected.VariantAvailableFrom === - timeSlot.VariantAvailableFrom && + timeSlot.VariantAvailableFrom && selected.VariantAvailableTo === - timeSlot.VariantAvailableTo && + timeSlot.VariantAvailableTo && selected.BookedDate === - timeSlot.BookedDate + timeSlot.BookedDate ) } icon={ @@ -6220,30 +6224,29 @@ const BsBookingitemCard = (props) => { /> )} - { - (timeSlot?.SlotStatus === - 'Partially Booked' || - timeSlot?.SlotStatus === + {(timeSlot?.SlotStatus === + 'Partially Booked' || + timeSlot?.SlotStatus === 'Booked') && ( -
{ - e.stopPropagation(); - handleBookedDetails({ - ...timeSlot, - ProdName: - product - ?.ProductDetail?.[0] - ?.ProdName, - ProdSubCatName: - product?.ProdSubCatName, - }); - }} - > - - {timeSlot?.SlotStatus} - -
- )} +
{ + e.stopPropagation(); + handleBookedDetails({ + ...timeSlot, + ProdName: + product + ?.ProductDetail?.[0] + ?.ProdName, + ProdSubCatName: + product?.ProdSubCatName, + }); + }} + > + + {timeSlot?.SlotStatus} + +
+ )}
); })} @@ -6410,7 +6413,7 @@ const BsBookingitemCard = (props) => { {customer.CustMobile || 'N/A'} {customer?.CustBookDetails?.length > - 1 ? ( + 1 ? ( ) : customer?.CustBookDetails - ?.length === 1 ? ( + ?.length === 1 ? ( <> @@ -2723,7 +2718,7 @@ const FeaturesFunctionalities = (props) => { : selectedSearchValue == 'CustName' ? 'Please Enter Valid Name' : selectedSearchValue == 'CustId' && - 'Please EnterCustomer Id', + 'Please EnterCustomer Id', }, ]} > @@ -2812,7 +2807,7 @@ const FeaturesFunctionalities = (props) => { : selectedSearchValue == 'CustName' ? 'Enter Name' : selectedSearchValue == 'CustId' && - 'Enter Customer Id' + 'Enter Customer Id' : ' Mobile Number'} } @@ -2994,7 +2989,7 @@ const FeaturesFunctionalities = (props) => { autocomplete="off" isOnChange={ formRef.current?.getFieldsValue()?.CustName || - inputValue + inputValue ? true : false } @@ -3060,9 +3055,9 @@ const FeaturesFunctionalities = (props) => {

Upload Profile

- // formType === 'edit' ? editstate?.EmpPhotoLink : e - // } + // getValueFromEvent={(e) => + // formType === 'edit' ? editstate?.EmpPhotoLink : e + // } > { handleRemoveAddress(idx)} + onConfirm={() => + handleRemoveAddress(idx) + } okText="Yes, Remove" cancelText="Cancel" okType="danger" @@ -3492,7 +3489,7 @@ const FeaturesFunctionalities = (props) => { { style={ offerType == 'P' ? { - opacity: '1', - boxShadow: - 'rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px', - margin: '3px', - padding: '5px', - backgroundColor: '#fff', - } + opacity: '1', + boxShadow: + 'rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px', + margin: '3px', + padding: '5px', + backgroundColor: '#fff', + } : { opacity: '0.6', boxShadow: 'none' } } onClick={() => { @@ -3557,13 +3554,13 @@ const FeaturesFunctionalities = (props) => { style={ offerType == 'F' ? { - opacity: '1', - boxShadow: - 'rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px', - margin: '3px', - padding: '5px', - backgroundColor: '#fff', - } + opacity: '1', + boxShadow: + 'rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px', + margin: '3px', + padding: '5px', + backgroundColor: '#fff', + } : { opacity: '0.6', boxShadow: 'none' } } onClick={() => { @@ -3660,7 +3657,7 @@ const FeaturesFunctionalities = (props) => { } isOnChange={ formRef.current?.getFieldsValue()?.CustEmail || - inputValue + inputValue ? true : false } @@ -3688,7 +3685,7 @@ const FeaturesFunctionalities = (props) => { autocomplete="off" isOnChange={ formRef.current?.getFieldsValue()?.CreditLimit || - inputValue + inputValue ? true : false } @@ -3921,7 +3918,7 @@ const FeaturesFunctionalities = (props) => { onChange={setActiveTab} items={[ { key: 'quickAdd', label: 'Quick Add' }, - { key: 'directSale', label: 'Direct Sale' } + { key: 'directSale', label: 'Direct Sale' }, ]} /> { buttonText="SAVE" color="901D77" icon={} - // handleSubmit={() => { globalamount1() }} + // handleSubmit={() => { globalamount1() }} />
@@ -4059,7 +4056,7 @@ const FeaturesFunctionalities = (props) => { bordered dataSource={TableName} width={'120px'} - //pagination={column2?.length < "11" ? false : true} + //pagination={column2?.length < "11" ? false : true} >
)} diff --git a/src/Pages/BookingScreen/Components/BookingFunctionality/SplitPayment.jsx b/src/Pages/BookingScreen/Components/BookingFunctionality/SplitPayment.jsx index a99cd9a..7ce5902 100644 --- a/src/Pages/BookingScreen/Components/BookingFunctionality/SplitPayment.jsx +++ b/src/Pages/BookingScreen/Components/BookingFunctionality/SplitPayment.jsx @@ -1,6 +1,28 @@ -import { useEffect, useRef, useState, useCallback } from 'react'; +import { + useEffect, + useRef, + useState, + useCallback, + lazy, + Suspense, +} from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; +import { Form, Radio } from 'antd'; +import { + ArrowRightOutlined, + CheckCircleOutlined, + CloseCircleOutlined, + PlusOutlined, +} from '@ant-design/icons'; +import { InputField } from '../../../../Components/Forms/InputField'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal.jsx'; +import { DropDowns } from '../../../../Components/Forms/DropDown.jsx'; +import Buttons from '../../../../Components/Forms/Buttons'; +import { Messages } from '../../../../Components/Notifications/Messages'; +import { isMobile } from 'react-device-detect'; + +// Js files import { getConfigType, GlobalCommonPaymentOptions, @@ -58,54 +80,61 @@ import { putSalesBillEdit, changeBillEditingMode, changePreviousOrderPayment, - changePreviousOrderOfferDetail + changePreviousOrderOfferDetail, + GlobalAllBookingType, } from '../../../../Features/BookingScreen/BookingData/BookingData'; -import { Form, Radio } from 'antd'; -import { - ArrowRightOutlined, - CheckCircleOutlined, - CloseCircleOutlined, - PlusOutlined, -} from '@ant-design/icons'; -import { InputField } from '../../../../Components/Forms/InputField'; -import { DefaultModal } from '../../../../Components/Modal/DefaultModal.jsx'; -import { DropDowns } from '../../../../Components/Forms/DropDown.jsx'; -import Buttons from '../../../../Components/Forms/Buttons'; -import QrComponent from '../BookingFunctionality/DynamicQr.jsx'; -import { Messages } from '../../../../Components/Notifications/Messages'; import { extractLastNumberOrderId, getSession, printDiv, validateSafeInput, } from '../../../../Services/Others.js'; -import WpIcon from '../../../../Images/message.png'; import { ChangeTotalAmount, globalExtraTotalAmount, } from '../../../../Features/ExteraCharges/ExtraCharges.js'; -import QrinScreen from '../BookingFunctionality/DynamicScreenQr.jsx'; -import PaymentPdfBooking from '../../../paymentpdfPage/PaymentPdfBooking.jsx'; -import { isMobile } from 'react-device-detect'; import { PrintStyleFunction } from '../../../paymentpdfPage/PrintStyleFunction.js'; import { getTemplateData, GlobalprintDatas, SelectedPrintTemplate, } from '../../../../Features/ThemeChange/ThemeChange.js'; -import '../../../../Styles/BookingScreen/Components/BookingFunctionality/SplitPayment.scss'; -import BsBillingCreditCustomer from '../BookingFunctionality/BSBillingCreditCustomer.jsx'; -import MobilePrint from '../BookingFunctionality/MobilePrint.jsx'; -import FeaturesFunctionalities from './FeaturesFunctionalities.jsx'; -import TokensinglePrint from '../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx'; -import TokenOnlyMobilePrint from './TokenOnlyMobilePrint.jsx'; -import AllProductTokenMobilePrint from './AllProductTokenMobilePrint.jsx'; import { getCustomerDisplayWindow } from '../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; import { gettinghold } from '../../../../Features/BookingScreen/HoldOption/HoldOption.js'; import { Global_OrderOfferDetail } from '../../../../Features/Offer/Offer.js'; -import { useApplyOfferto_CardDetail } from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; -import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, GlobalOfferAppliedProducts } from '../../../../Features/Offer/Offernew/BookingOffernew.js'; +import { + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + GlobalOfferAppliedProducts, +} from '../../../../Features/Offer/Offernew/BookingOffernew.js'; + +// jsx +const QrinScreen = lazy( + () => import('../BookingFunctionality/DynamicScreenQr.jsx') +); +const MobilePrint = lazy( + () => import('../BookingFunctionality/MobilePrint.jsx') +); +const FeaturesFunctionalities = lazy( + () => import('./FeaturesFunctionalities.jsx') +); +const PaymentPdfBooking = lazy( + () => import('../../../paymentpdfPage/PaymentPdfBooking.jsx') +); +const BsBillingCreditCustomer = lazy( + () => import('../BookingFunctionality/BSBillingCreditCustomer.jsx') +); +const TokensinglePrint = lazy( + () => import('../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx') +); +const QrComponent = lazy(() => import('../BookingFunctionality/DynamicQr.jsx')); + +import { useApplyOfferto_CardDetail } from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; + +// Style and Icon +import '../../../../Styles/BookingScreen/Components/BookingFunctionality/SplitPayment.scss'; +import WpIcon from '../../../../Images/message.png'; const subDirectory = import.meta.env.BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; @@ -119,12 +148,13 @@ const SplitPayment = (props) => { const AppId = getSession('AppId'); const UserId = getSession('UserId'); const appPreferences = useSelector(ApplicationPreferences); + const AllBookingType = useSelector(GlobalAllBookingType); const applyOffer = useApplyOfferto_CardDetail(); const globalTipAmount = useSelector(GlobaltipAmount); - const TotalNetAmount = (props.hasOwnProperty('TotalNetAmount') + const TotalNetAmount = props.hasOwnProperty('TotalNetAmount') ? props['TotalNetAmount'] - : null); + : null; const TableOrderId = props.hasOwnProperty('TableBookingOrderId') ? props['TableBookingOrderId'] : null; @@ -138,10 +168,16 @@ const SplitPayment = (props) => { const SelCustId = useSelector(GlobalSelCustId); const salesBillEdit = useSelector(GlobalSalesBillEdit); const previousOrderPayment = useSelector(GlobalPreviousOrderPayment); - const previousOrderOfferDetails = useSelector(GlobalPreviousOrderOfferDetails); + const previousOrderOfferDetails = useSelector( + GlobalPreviousOrderOfferDetails + ); const filteredPayments = previousOrderPayment?.filter( - p => p?.LastOrderTran === 'Y' && p?.AfterAdjustment != null && p?.AfterAdjustment !== '' && p?.AfterAdjustment + (p) => + p?.LastOrderTran === 'Y' && + p?.AfterAdjustment != null && + p?.AfterAdjustment !== '' && + p?.AfterAdjustment ) || []; const paymentsToUse = filteredPayments.length > 0 ? filteredPayments : previousOrderPayment || []; @@ -150,7 +186,8 @@ const SplitPayment = (props) => { 0 ); const totalPreviouspayment = paymentsToUse?.reduce( - (acc, payment) => acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), + (acc, payment) => + acc + parseFloat(payment.AfterAdjustment || payment.Amount || 0), 0 ); const [paybtns, setpaybtns] = useState([]); @@ -193,7 +230,11 @@ const SplitPayment = (props) => { const OverAllSales = useSelector(GlobalOverAllDiscSales); const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate); const printDatas = useSelector(GlobalprintDatas); - const allowDecimal = SettingDataSelector?.[0]?.SettingDtlDetails?.find((setting) => setting?.SettingIdName?.toLowerCase() === "decimal" && setting?.SettingValue === 'Y'); + const allowDecimal = SettingDataSelector?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'decimal' && + setting?.SettingValue === 'Y' + ); const UomPrint = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'PrintUom' )?.[0]; @@ -223,7 +264,7 @@ const SplitPayment = (props) => { (item) => item?.OptionName == 'Offer' ); const [TotalAmount, setTotalAmount] = useState(0); - console.log(TotalAmount, "TotalSplitAmount", TotalSplitAmount) + console.log(TotalAmount, 'TotalSplitAmount', TotalSplitAmount); const preferenceOffer = SettingDataSelector?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' @@ -237,9 +278,8 @@ const SplitPayment = (props) => { }, []); useEffect(() => { - if (salesBillEdit) { - const previousNetAmount = (totalPreviouspayment || 0); + const previousNetAmount = totalPreviouspayment || 0; if (TotalNetAmount > previousNetAmount) { setTotalAmount(TotalNetAmount - previousNetAmount); } else { @@ -248,8 +288,7 @@ const SplitPayment = (props) => { } else { setTotalAmount(TotalNetAmount); } - - }, [totalPreviousOfferAmount, totalPreviouspayment, TotalNetAmount]) + }, [totalPreviousOfferAmount, totalPreviouspayment, TotalNetAmount]); useEffect(() => { if (SelCustId) { @@ -272,7 +311,7 @@ const SplitPayment = (props) => { }, [Splitpayment]); useEffect(() => { const totalPayAmount = Object.keys(SplitSelPayMode) - .filter(key => key.startsWith('PayAmount-')) + .filter((key) => key.startsWith('PayAmount-')) .reduce((sum, key) => { const value = parseInt(SplitSelPayMode[key], 10); return sum + (isNaN(value) ? 0 : value); @@ -360,20 +399,12 @@ const SplitPayment = (props) => { setUpiPayOption(options); }; const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); + setConfigDataList(AllBookingType); + let configdata = AllBookingType; + let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - setSelectedBookingType(filterconfigdata?.ConfigId); - } + let filterconfigdata = configdata?.find((a) => a?.ConfigName === checkName); + setSelectedBookingType(filterconfigdata?.ConfigId); }; const gettodaydate = () => { const currentDate = new Date(); @@ -547,7 +578,8 @@ const SplitPayment = (props) => { SingleTokenMobilePrint(PrintOrderDetails, SelUpiId, 'Booking'); } } else { - MobilePrint(appPreferences, + MobilePrint( + appPreferences, PrintOrderDetails, SelUpiId, 'Booking', @@ -570,8 +602,9 @@ const SplitPayment = (props) => { await Promise.all( PrintOrderDetails?.[0]?.OrderDetails?.map( async (orderDetail, index) => { - const groupedTokens = orderDetail?.productDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.reduce( - (acc, item, idx) => { + const groupedTokens = orderDetail?.productDetails + ?.filter((data) => data?.EditTokenAvailable !== 'N') + ?.reduce((acc, item, idx) => { if (item.TokenAvailable === 'Y') { if (!item.CounterName) { // If CounterName is null or empty @@ -584,9 +617,7 @@ const SplitPayment = (props) => { } } return acc; - }, - {} - ); + }, {}); // Iterate over grouped tokens and print them const tokensToPrint = Object.entries(groupedTokens).map( @@ -605,11 +636,11 @@ const SplitPayment = (props) => { ); } else { await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.map( - async (orderDetail, index) => { - await TokenPrint(`${index}-${orderDetail?.OrderId}`); - } - ) + PrintOrderDetails?.[0]?.OrderDetails?.filter( + (data) => data?.EditTokenAvailable !== 'N' + )?.map(async (orderDetail, index) => { + await TokenPrint(`${index}-${orderDetail?.OrderId}`); + }) ); setPrintOrderDetails([]); } @@ -641,7 +672,7 @@ const SplitPayment = (props) => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -650,8 +681,9 @@ const SplitPayment = (props) => { async (orderDetail, index) => { await printDiv(`${selectedStyle}-${index}`, style); // Use unique IDs for each print if (orderDetail?.BookingTypeName !== 'Dine In') { - const groupedTokens = orderDetail?.productDetails?.filter(data => data?.EditTokenAvailable !== 'N')?.reduce( - (acc, item, idx) => { + const groupedTokens = orderDetail?.productDetails + ?.filter((data) => data?.EditTokenAvailable !== 'N') + ?.reduce((acc, item, idx) => { if (item.TokenAvailable === 'Y') { if (!item.CounterName) { // If CounterName is null or empty @@ -664,9 +696,7 @@ const SplitPayment = (props) => { } } return acc; - }, - {} - ); + }, {}); // Iterate over grouped tokens and print them const tokensToPrint = Object.entries(groupedTokens).map( @@ -1033,11 +1063,11 @@ const SplitPayment = (props) => { @@ -1365,8 +1395,8 @@ const SplitPayment = (props) => { ? 'E' : GlobEstBooking === 'ParEst' ? GlobProdwisedata?.includes( - a.InwardDtlId + ' ' + a?.BookingTypeName - ) + a.InwardDtlId + ' ' + a?.BookingTypeName + ) ? 'E' : 'S' : 'S', @@ -1448,7 +1478,14 @@ const SplitPayment = (props) => { // SalesTableLinkDetails: // SelectedTableDetails?.length > 0 ? SelectedTableDetails : null, SalesTableLinkDetails: - SelectedTableDetails?.length > 0 ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map(item => ({ ...item, "TipsAmount": globalTipAmount })) : null, + SelectedTableDetails?.length > 0 + ? globalTipAmount === 0 + ? SelectedTableDetails + : SelectedTableDetails?.map((item) => ({ + ...item, + TipsAmount: globalTipAmount, + })) + : null, // "Credit": TotalAmount, // "Debit": 0, @@ -1472,37 +1509,37 @@ const SplitPayment = (props) => { : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'card' ? SplitSelPayMode[`CardSelection-${i}`] : SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'default' + 'default' ? 'PC' : SplitSelPayMode[`UPISelection-${i}`], ModeOfPayment: SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' ? PaymentUpiOptions?.find( - (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] - )?.UPIDetailId + (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] + )?.UPIDetailId : null, AccountDtl: SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] - ) + (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] + ) : (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'pd') || - (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === - 'card' && - SplitSelPayMode[`CardSelection-${i}`]?.toLowerCase() === - 'pd') - ? useOptions?.[0]?.PaymentDetails?.PaymentDevice - : (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === - 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'pg') || + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === + 'pd') || (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'card' && SplitSelPayMode[`CardSelection-${i}`]?.toLowerCase() === - 'pg') + 'pd') + ? useOptions?.[0]?.PaymentDetails?.PaymentDevice + : (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === + 'upi' && + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === + 'pg') || + (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === + 'card' && + SplitSelPayMode[`CardSelection-${i}`]?.toLowerCase() === + 'pg') ? useOptions?.[0]?.PaymentDetails?.PaymentGateway : [], PaymentStatus: @@ -1511,9 +1548,9 @@ const SplitPayment = (props) => { : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'credit' ? 'S' : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === - 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'default' + 'upi' && + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === + 'default' ? 'S' : 'P', Debit: 0, @@ -1527,7 +1564,7 @@ const SplitPayment = (props) => { }; let PostData = temppostdata; (i === 0 && SplitSelPayMode[`PaymentStatus-${i}`] === 'F') || - (i === 0 && props.hasOwnProperty('TableBookingOrderId')) + (i === 0 && props.hasOwnProperty('TableBookingOrderId')) ? PutSplitPayment(i) : i === 0 ? Object.keys(ReportholdData)?.length > 0 @@ -1576,14 +1613,14 @@ const SplitPayment = (props) => { } setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); if (response?.data?.OrderDetails?.length > 0) { setPrintOrderDetails([response?.data]); @@ -1635,10 +1672,16 @@ const SplitPayment = (props) => { if (response?.data?.statusCode == 1) { setSalesOrderId(response?.data?.OrderId); - const salesEditAmount = response?.data?.PaymentOrderDtl?.find(payment => - payment?.LastOrderTran === 'Y' && payment?.AdjustmentType && - payment?.AdjustmentType != null && payment?.AfterAdjustment && payment?.BeforeAdjustment && payment?.AfterAdjustment != null && payment?.BeforeAdjustment != null - ) + const salesEditAmount = response?.data?.PaymentOrderDtl?.find( + (payment) => + payment?.LastOrderTran === 'Y' && + payment?.AdjustmentType && + payment?.AdjustmentType != null && + payment?.AfterAdjustment && + payment?.BeforeAdjustment && + payment?.AfterAdjustment != null && + payment?.BeforeAdjustment != null + ); setBeforeAdjAmount(salesEditAmount?.BeforeAdjustment || null); setAfterAdjAmount(salesEditAmount?.AfterAdjustment || null); setAdjustmentType(salesEditAmount?.AdjustmentType || null); @@ -1677,14 +1720,14 @@ const SplitPayment = (props) => { } setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); if (response?.data?.OrderDetails?.length > 0) { setPrintOrderDetails([response?.data]); @@ -1722,7 +1765,13 @@ const SplitPayment = (props) => { OrderId: props.hasOwnProperty('TableBookingOrderId') ? TableOrderId : SalesOrderId, - ...(i === 0 ? { SalesId: props.hasOwnProperty('TableBookingSalesId') ? TableSalesId : SalesOrderId } : {}), + ...(i === 0 + ? { + SalesId: props.hasOwnProperty('TableBookingSalesId') + ? TableSalesId + : SalesOrderId, + } + : {}), PaymentType: SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' ? SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pd' @@ -1743,32 +1792,32 @@ const SplitPayment = (props) => { : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'card' ? SplitSelPayMode[`CardSelection-${i}`] : SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'default' + 'default' ? 'PC' : SplitSelPayMode[`UPISelection-${i}`], ModeOfPayment: SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' ? PaymentUpiOptions?.find( - (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] - )?.UPIDetailId + (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] + )?.UPIDetailId : null, AccountDtl: SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'default' ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] - ) + (upipay) => upipay?.Mode === SplitSelPayMode[`UPIMode-${i}`] + ) : (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pd') || - (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'card' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pd') + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pd') || + (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'card' && + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pd') ? useOptions?.[0]?.PaymentDetails?.PaymentDevice : (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'pg') || - (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === - 'card' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pg') + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === + 'pg') || + (SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === + 'card' && + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === 'pg') ? useOptions?.[0]?.PaymentDetails?.PaymentGateway : [], PaymentStatus: @@ -1777,8 +1826,8 @@ const SplitPayment = (props) => { : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'credit' ? 'S' : SplitSelPayMode[`PaymentMode-${i}`]?.toLowerCase() === 'upi' && - SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === - 'default' + SplitSelPayMode[`UPISelection-${i}`]?.toLowerCase() === + 'default' ? 'S' : 'P', Debit: 0, @@ -1789,7 +1838,6 @@ const SplitPayment = (props) => { BeforeAdjAmount: beforeAdjAmount || null, AfterAdjAmount: afterAdjAmount || null, AdjustmentType: adjustmentType || null, - }; let response = await dispatch( @@ -1836,14 +1884,14 @@ const SplitPayment = (props) => { } setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); if (response?.data?.OrderDetails?.length > 0) { setPrintOrderDetails([response?.data]); @@ -1945,14 +1993,14 @@ const SplitPayment = (props) => { }); setMessageData( bookingpaymentupdate?.data?.response + - ' ' + - (bookingpaymentupdate?.data?.OrderDetails?.length > 0 - ? bookingpaymentupdate?.data?.OrderId && - extractLastNumberOrderId( - bookingpaymentupdate?.data?.OrderId, - bookingpaymentupdate?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (bookingpaymentupdate?.data?.OrderDetails?.length > 0 + ? bookingpaymentupdate?.data?.OrderId && + extractLastNumberOrderId( + bookingpaymentupdate?.data?.OrderId, + bookingpaymentupdate?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); if (bookingpaymentupdate?.data?.OrderDetails?.length > 0) { setPrintOrderDetails([bookingpaymentupdate?.data]); @@ -1970,7 +2018,7 @@ const SplitPayment = (props) => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -2125,195 +2173,200 @@ const SplitPayment = (props) => { } return ( - <> - -
- { - SplitSelPayMode[`PaymentStatus-0`] !== 'S' && HandleModalClose(); - }} - footer={false} - width={1000} - className={'splitpaymentModal'} - children={ -
-

Total Amount : {safeRound(TotalAmount)}

-

- Remaining Balance : {TotalAmount - (isNaN(TotalSplitAmount) ? 0 : TotalSplitAmount)}

+ Loading...
}> + <> + +
+ { + SplitSelPayMode[`PaymentStatus-0`] !== 'S' && HandleModalClose(); + }} + footer={false} + width={1000} + className={'splitpaymentModal'} + children={ +
+

Total Amount : {safeRound(TotalAmount)}

+

+ Remaining Balance :{' '} + {TotalAmount - + (isNaN(TotalSplitAmount) ? 0 : TotalSplitAmount)}{' '} +

- <>{calculateField()} - {TotalAmount > TotalSplitAmount && - SplitSelPayMode[`PaymentStatus-${count}`] === 'S' && ( - -
- {calculateField()} + {TotalAmount > TotalSplitAmount && + SplitSelPayMode[`PaymentStatus-${count}`] === 'S' && ( + +
setCount(count + 1)} - /> -
-
- )} -
- } - /> -
- {TotalAmount == 0 && Success && ( -
- + > + setCount(count + 1)} + /> +
+ + )} +
+ } + />
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelUpiId && ( + {TotalAmount == 0 && Success && ( +
+ +
+ )} + {TotalAmount > 0 && + qrCode && + PaymentUpiOptions?.length > 0 && + SelUpiId && ( +
+ +
+ )} + + {PaymentUpiOptions?.length > 0 && OrderId && (
)} - - {PaymentUpiOptions?.length > 0 && OrderId && ( -
- -
- )} - {PrintOrderDetails?.length > 0 && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( + {PrintOrderDetails?.length > 0 && + PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ))} + {CreditCustomer && (
- { + handleCreditCustomer('Cancel'); + }} + handleOk={() => { + handleCreditCustomer('Submit'); + }} + SplitPayAmount={SplitSelPayMode[`PayAmount-${count}`]} />
- ))} - {CreditCustomer && ( -
- { - handleCreditCustomer('Cancel'); + )} + {PrintOrderDetails?.length > 0 && + (TokenOnly?.SettingValue === 'Y' || + IndividualToken?.SettingValue === 'Y') && + PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( +
+ +
+ ))} + {UpiOpen && ( + { + Upimodel('Cancel'); }} - handleOk={() => { - handleCreditCustomer('Submit'); - }} - SplitPayAmount={SplitSelPayMode[`PayAmount-${count}`]} - /> -
- )} - {PrintOrderDetails?.length > 0 && - (TokenOnly?.SettingValue === 'Y' || - IndividualToken?.SettingValue === 'Y') && - PrintOrderDetails?.[0]?.OrderDetails?.map((orderDetail, index) => ( -
- -
- ))} - {UpiOpen && ( - { - Upimodel('Cancel'); - }} - footer={false} - children={ -
-
-
- -
- -
-

RS :{CurrentPayAmount}

-
-
-
- {(selOption || SelCustId) && ( -
- Sent Payment Link - Your Alt Text -
- )} + footer={false} + children={ +
- } - handleSubmit={() => { - Upimodel('Submit'); +
+ +
+ +
+

RS :{CurrentPayAmount}

+
+
+
+ {(selOption || SelCustId) && ( +
+ Sent Payment Link + Your Alt Text +
+ )} +
+ > + } + handleSubmit={() => { + Upimodel('Submit'); + }} + /> +
-
- } - /> - )} - {addcustomer && ( - - )} - + } + /> + )} + {addcustomer && ( + + )} + + ); }; export default SplitPayment; diff --git a/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx b/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx index 29dc690..376df17 100644 --- a/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx +++ b/src/Pages/BookingScreen/Components/MainPage/SelectionComponent.jsx @@ -1,14 +1,17 @@ -import React, { useEffect, useRef, useState, useCallback, forwardRef, useImperativeHandle } from 'react'; +import React, { + useEffect, + useRef, + useState, + useCallback, + forwardRef, + useImperativeHandle, +} from 'react'; import { useSelector, useDispatch } from 'react-redux'; import WebFont from 'webfontloader'; import { SwatchesPicker } from 'react-color'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; import { RadioGrpButton } from '../../../../Components/Forms/RadioGroup.jsx'; -import { - - CloseOutlined, - ArrowRightOutlined, -} from '@ant-design/icons'; +import { CloseOutlined, ArrowRightOutlined } from '@ant-design/icons'; import { BiSkipPrevious } from 'react-icons/bi'; import { BiSkipNext } from 'react-icons/bi'; import { Modal, Form } from 'antd'; @@ -113,12 +116,15 @@ import { import { getPreferenceData } from '../../../../Features/BookingScreen/BookingData/BookingData.js'; import { useAuth } from '../../../../AuthContext.jsx'; import { HiOutlineSquares2X2, HiSquaresPlus } from 'react-icons/hi2'; -import { ApplicationPreferences, getCommonAppPreference } from '../../../../Features/BrachLogin/BranchLogin.js'; +import { + ApplicationPreferences, + getCommonAppPreference, +} from '../../../../Features/BrachLogin/BranchLogin.js'; import { TbLayoutNavbar } from 'react-icons/tb'; import { HiMenuAlt1 } from 'react-icons/hi'; -import { IoMdAdd } from "react-icons/io"; -import { LuCreditCard } from "react-icons/lu"; -import { IoReceiptOutline } from "react-icons/io5"; +import { IoMdAdd } from 'react-icons/io'; +import { LuCreditCard } from 'react-icons/lu'; +import { IoReceiptOutline } from 'react-icons/io5'; const subDirectory = import.meta.env.BASE_URL; const SelectionComponent = forwardRef((props, ref) => { @@ -175,12 +181,22 @@ const SelectionComponent = forwardRef((props, ref) => { SelectedGlobalSubCatgColorDetail ); const DefaultThemes = useSelector(GlobalDefaultTheme); - const SelectedTheme = useSelector(GlobalSelectedTheme) + const SelectedTheme = useSelector(GlobalSelectedTheme); const activeTheme = useSelector(GlobalActiveTheme); const appPreferences = useSelector(ApplicationPreferences); - const bookingTypePreference = appPreferences?.find((preference) => preference?.PreferredCatName === 'Booking Type')?.PreferenceCatDetails - const dinePreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "dine in" && type?.PreferredStatus === 'Y') - const takeAwayPreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "take away" && type?.PreferredStatus === 'Y') + const bookingTypePreference = appPreferences?.find( + (preference) => preference?.PreferredCatName === 'Booking Type' + )?.PreferenceCatDetails; + const dinePreference = bookingTypePreference?.find( + (type) => + type?.PreferredSubCatName?.toLowerCase() === 'dine in' && + type?.PreferredStatus === 'Y' + ); + const takeAwayPreference = bookingTypePreference?.find( + (type) => + type?.PreferredSubCatName?.toLowerCase() === 'take away' && + type?.PreferredStatus === 'Y' + ); const AppId = getSession('AppId'); const UserId = getSession('UserId'); const CompId = getSession('CompId'); @@ -230,7 +246,6 @@ const SelectionComponent = forwardRef((props, ref) => { const [SelectedBillingTableId, setSelectedBillingTableId] = useState(null); const [ShowDropDownData, SetShowDropDownData] = useState([]); - //navbarcheck boxes const [NavBarCheckList, setNavBarCheckList] = useState([]); const [SelectedNavCheckValues, setSelectedNavCheckValues] = useState([]); @@ -399,9 +414,19 @@ const SelectionComponent = forwardRef((props, ref) => { useEffect(() => { if (activeTheme == 'default') { if (Object.keys(DefaultThemes)?.length > 0) { - dispatch(changeSelectedTheme({ ThemeId: DefaultThemes?.[0]?.TemplatePreferenceId, ThemeName: DefaultThemes?.[0]?.ThemeName })); + dispatch( + changeSelectedTheme({ + ThemeId: DefaultThemes?.[0]?.TemplatePreferenceId, + ThemeName: DefaultThemes?.[0]?.ThemeName, + }) + ); settemplateData(DefaultThemes?.[0]); - dispatch(changeThemeCreation({ formtype: 'edit', editdata: DefaultThemes?.[0] })); + dispatch( + changeThemeCreation({ + formtype: 'edit', + editdata: DefaultThemes?.[0], + }) + ); } else { dispatch(changeSelectedTheme({})); settemplateData({}); @@ -438,7 +463,7 @@ const SelectionComponent = forwardRef((props, ref) => { ).unwrap(); if (tempdetail?.data?.statusCode == 1) { - dispatch(changeActiveTheme("customised")); + dispatch(changeActiveTheme('customised')); } else { setTemptemplatedata(true); } @@ -459,7 +484,7 @@ const SelectionComponent = forwardRef((props, ref) => { }; const getThemesData = async () => { - // let themeresponse = + // let themeresponse = await dispatch(getThemes()).unwrap(); // if (themeresponse.data?.statusCode === 1) { // let themedatalist = themeresponse.data?.data?.filter( @@ -496,7 +521,6 @@ const SelectionComponent = forwardRef((props, ref) => { }, [templateData1, selthemeData, activeTheme]); useEffect(() => { if (Object.keys(templateData)?.length > 0) { - setEditTemplateData(); } else { ClearAllComponentStates(); @@ -764,7 +788,7 @@ const SelectionComponent = forwardRef((props, ref) => { useEffect(() => { if (templateData && BillingTableData?.length > 0) { - console.log(BillingTableData?.length, "BillingTableData?.length") + console.log(BillingTableData?.length, 'BillingTableData?.length'); const editCardVal = BillingTableData?.filter( (item) => item.ComponentName == templateData?.['BookingBilling']?.[0] ); @@ -1062,16 +1086,22 @@ const SelectionComponent = forwardRef((props, ref) => { const GetNavbarFun = async () => { const gettingNavbarData = await dispatch(getNavbar()).unwrap(); if (gettingNavbarData?.data?.statusCode === 1) { - setNavbarData(gettingNavbarData.data?.data?.map((navbar) => { - return { - ...navbar, - ComponentOptionsDetails: navbar?.ComponentOptionsDetails - ?.filter((component) => - !((component?.OptionName === 'DineIn' && dinePreference === undefined) || - (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined)) - ) - } - })); + setNavbarData( + gettingNavbarData.data?.data?.map((navbar) => { + return { + ...navbar, + ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter( + (component) => + !( + (component?.OptionName === 'DineIn' && + dinePreference === undefined) || + (component?.OptionName === 'TakeAway' && + takeAwayPreference === undefined) + ) + ), + }; + }) + ); } }; const GetCategoryFun = async () => { @@ -1122,31 +1152,43 @@ const SelectionComponent = forwardRef((props, ref) => { const GetCombo1Navbar = async () => { const gettingCombo1NavbarData = await dispatch(getCombo1Navbar()).unwrap(); if (gettingCombo1NavbarData?.data?.statusCode === 1) { - setNavbarData(gettingCombo1NavbarData?.data?.data?.map((navbar) => { - return { - ...navbar, - ComponentOptionsDetails: navbar?.ComponentOptionsDetails - ?.filter((component) => - !((component?.OptionName === 'DineIn' && dinePreference === undefined) || - (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined)) - ) - } - })); + setNavbarData( + gettingCombo1NavbarData?.data?.data?.map((navbar) => { + return { + ...navbar, + ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter( + (component) => + !( + (component?.OptionName === 'DineIn' && + dinePreference === undefined) || + (component?.OptionName === 'TakeAway' && + takeAwayPreference === undefined) + ) + ), + }; + }) + ); } }; const GetCombo2Navbar = async () => { const gettingCombo2NavbarData = await dispatch(getCombo2Navbar()).unwrap(); if (gettingCombo2NavbarData?.data?.statusCode === 1) { - setNavbarData(gettingCombo2NavbarData?.data?.data?.map((navbar) => { - return { - ...navbar, - ComponentOptionsDetails: navbar?.ComponentOptionsDetails - ?.filter((component) => - !((component?.OptionName === 'DineIn' && dinePreference === undefined) || - (component?.OptionName === 'TakeAway' && takeAwayPreference === undefined)) - ) - } - })); + setNavbarData( + gettingCombo2NavbarData?.data?.data?.map((navbar) => { + return { + ...navbar, + ComponentOptionsDetails: navbar?.ComponentOptionsDetails?.filter( + (component) => + !( + (component?.OptionName === 'DineIn' && + dinePreference === undefined) || + (component?.OptionName === 'TakeAway' && + takeAwayPreference === undefined) + ) + ), + }; + }) + ); } }; @@ -1318,15 +1360,20 @@ const SelectionComponent = forwardRef((props, ref) => { ], }) ); - setBillTableCheckList(BillTableItems?.map((billItem) => { - return { - ...billItem, - ComponentOptionsDetails: billItem?.ComponentOptionsDetails - ?.filter((component) => - !(component?.OptionName === 'UnpaidBill' && dinePreference === undefined) - ) - } - })); + setBillTableCheckList( + BillTableItems?.map((billItem) => { + return { + ...billItem, + ComponentOptionsDetails: billItem?.ComponentOptionsDetails?.filter( + (component) => + !( + component?.OptionName === 'UnpaidBill' && + dinePreference === undefined + ) + ), + }; + }) + ); const itemOption = BillTableItems[0]?.ComponentOptionsDetails?.find( (option) => option.OptionName === 'Item' @@ -2278,7 +2325,7 @@ const SelectionComponent = forwardRef((props, ref) => { }); }; const validateFontsTable = async (values) => { - console.log(values,"table font") + console.log(values, 'table font'); const apiUrl = `https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDP1HqNkLI53iIAH-SB9_mt_24QdkUZ_24`; fetch(apiUrl) .then((response) => response.json()) @@ -2674,7 +2721,7 @@ const SelectionComponent = forwardRef((props, ref) => { // onfinish function const onfinish = async (values) => { - console.log(values, "valuesvalues") + console.log(values, 'valuesvalues'); setFirstOnClick(true); let colorOriginalArray = [ values.CatColor, @@ -2734,12 +2781,12 @@ const SelectionComponent = forwardRef((props, ref) => { ShowDropDownData?.find((a) => a.OptionName === 'SubCategory') ? tempData.push({ - ComponentId: SelectedSubCategoryId, - ComponentDetails: - SelectedSubCategoryCheckList != undefined - ? SelectedSubCategoryCheckList - : [], - }) + ComponentId: SelectedSubCategoryId, + ComponentDetails: + SelectedSubCategoryCheckList != undefined + ? SelectedSubCategoryCheckList + : [], + }) : ''; // Shifayath Date:27/12/2023 tempData.push({ @@ -2793,8 +2840,10 @@ const SelectionComponent = forwardRef((props, ref) => { setMessageData('Template Details Added Successfully'); setFirstOnClick(false); } - dispatch(changeScanTemplate({})) - + dispatch(changeScanTemplate({})); + await dispatch( + getTemplate({ CompId: CompId, BranchId: BranchId, AppId: AppId }) + ); } else { setMessageType('error'); setMessageData(response?.data?.response); @@ -2963,7 +3012,12 @@ const SelectionComponent = forwardRef((props, ref) => { onComplete={onComplete} />
-
+ {/*
{ Layout and Feature Settings
- {!( - Object.keys(templateData)?.length == 0 - ) && ( -
-

Layout

+ {!(Object.keys(templateData)?.length == 0) && ( +
+

Layout

- - - ({ - value: option.ComponentId, - label: option.ComponentName, - }))} - label="Layout" - onChangeFunction={selectLayout} - className="field-DropDown-Selection" - isOnchanges={SelectedLayoutId ? true : false} - valueData={SelectedLayoutId} - /> - -
- )} + + ({ + value: option.ComponentId, + label: option.ComponentName, + }))} + label="Layout" + onChangeFunction={selectLayout} + className="field-DropDown-Selection" + isOnchanges={SelectedLayoutId ? true : false} + valueData={SelectedLayoutId} + /> + +
+ )} {
-
-
- - {selectOverallSelected == true && ( -
-
- - ({ - value: option.ColorId, - label: ( -
-
- -     - -
-
{option.ThemeName}
-
- ), - }) - )} - labelChange={true} - label={ -

- Overall Background -

- } - className="field-DropDown-Selection" - onChangeFunction={selectLayoutOverallColor} - isOnchanges={ - dropdownLayoutOverallColor ? true : false - } - valueData={dropdownLayoutOverallColor} - /> -
-
-
- Add - +
- )} -
+
+ + + +
+ +
+ + {selectOverallSelected == true && ( +
+
+ + ({ + value: option.ColorId, + label: ( +
+
+ +     + +
+
{option.ThemeName}
+
+ ), + }) + )} + labelChange={true} + label={ +

+ Overall Background +

+ } + className="field-DropDown-Selection" + onChangeFunction={selectLayoutOverallColor} + isOnchanges={ + dropdownLayoutOverallColor ? true : false + } + valueData={dropdownLayoutOverallColor} + /> +
+
+
+ Add + +
+
+ )}
- )} +
+ )}
{NavBarCheckList?.length > 0 && @@ -3527,7 +3584,7 @@ const SelectionComponent = forwardRef((props, ref) => { Selected NavBar : - {NavBarCheckList[0]?.ComponentName} + {NavBarCheckList[0]?.ComponentName}
@@ -3550,18 +3607,18 @@ const SelectionComponent = forwardRef((props, ref) => { value.OptionName === 'Hold' && NavHoldButton ? true : value.OptionName === 'AddCustomer' && - NavAddCustomerButton + NavAddCustomerButton ? true : value.OptionName === 'DineIn' && - (GlobalPreferenceData?.SettingValue !== - 'Y' || - GlobalPreferenceData?.length === 0) + (GlobalPreferenceData?.SettingValue !== + 'Y' || + GlobalPreferenceData?.length === 0) ? true : value.OptionName === 'Search' ? true : false } - // onClick={() => holdoption(value.OptionName)} + // onClick={() => holdoption(value.OptionName)} > {value.OptionName} @@ -3578,7 +3635,7 @@ const SelectionComponent = forwardRef((props, ref) => { Selected Category: - {CategoryCheckList[0]?.ComponentName} + {CategoryCheckList[0]?.ComponentName}
@@ -3599,7 +3656,7 @@ const SelectionComponent = forwardRef((props, ref) => { key={value?.OptionId} disabled={ value.OptionName === 'ImageRight' && - !CatImageSelection + !CatImageSelection ? true : false } @@ -3616,14 +3673,14 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
+
@@ -3636,7 +3693,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Font

{ />
-
+
Add - + { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -3730,7 +3787,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Background Color

{ />
-
+
Add - +
@@ -3878,7 +3935,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Category Overall-Background

@@ -3936,12 +3993,12 @@ const SelectionComponent = forwardRef((props, ref) => { />
-
+
Add - +
@@ -3956,7 +4013,8 @@ const SelectionComponent = forwardRef((props, ref) => { Selected SubCategory: - {SubCategoryCheckList[0]?.ComponentName} + {' '} + {SubCategoryCheckList[0]?.ComponentName}
@@ -3982,12 +4040,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ />
-
+
Add { />
-
+
Add { />
-
+
Add { Selected Card: - {CardCheckList[0]?.ComponentName} + {CardCheckList[0]?.ComponentName}
@@ -4445,14 +4508,14 @@ const SelectionComponent = forwardRef((props, ref) => { disabled={ !SmallImage ? SelectAllPositionImage?.includes( - value?.OptionId - ) + value?.OptionId + ) ? true : false : SelectfliterPositionImage?.length < 4 ? SelectfliterPositionImage.includes( - value?.OptionId - ) + value?.OptionId + ) ? true : false : '' @@ -4464,12 +4527,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ }, ]} > -

+

Card Font

{ />
-
+
Add { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -4575,7 +4637,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Card Background Color

{ />
-
+
Add - +
@@ -4724,7 +4786,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

Card Overall-Background

{ />
-
+
Add - +
@@ -4905,7 +4967,8 @@ const SelectionComponent = forwardRef((props, ref) => { Selected BillTable:{' '} - {BillTableCheckList[0]?.ComponentName} + {' '} + {BillTableCheckList[0]?.ComponentName}
@@ -4929,12 +4992,12 @@ const SelectionComponent = forwardRef((props, ref) => { value.OptionName === 'Hold' && HoldButton ? true : value.OptionName === 'AddCustomer' && - AddCustomerButton + AddCustomerButton ? true : value.OptionName === 'Item' ? true : value.OptionName === 'UnpaidBill' && - !DineInChecked + !DineInChecked ? true : false } @@ -4945,12 +5008,8 @@ const SelectionComponent = forwardRef((props, ref) => { )} -
-
+
+
{ }, ]} > -

+

BillTable Font

{ />
-
+
Add - - +
-
-
- +
+
+ { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); }, - { - validator: async (_, value) => { - await validateSafeInput(value); // To block HTML tags & SQL keywords - return Promise.resolve(); - }, - }, - ]} - > - - -
+ }, + ]} + > + +
-

- * Google Fonts Only -

- - } - handleCancel={TablehandleCancel} - handleSubmit={TablehandleSubmit} - buttonText="SAVE" - /> +
+

+ * Google Fonts Only +

+ + } + handleCancel={TablehandleCancel} + handleSubmit={TablehandleSubmit} + buttonText="SAVE" + />
{SelectedBillTableCheckValues?.filter( (item) => @@ -5043,7 +5101,7 @@ const SelectionComponent = forwardRef((props, ref) => { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -5056,7 +5114,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

BillTable Background Color

{ />
-
+
Add - +
@@ -5194,7 +5252,7 @@ const SelectionComponent = forwardRef((props, ref) => { display: 'flex', gap: '1rem', flexWrap: 'nowrap', - alignItems: "center" + alignItems: 'center', }} >
@@ -5207,7 +5265,7 @@ const SelectionComponent = forwardRef((props, ref) => { }, ]} > -

+

BillTable Overall-Background

{ />
-
+
Add { // (empData?.UpdateAccess === "Y" || SAAccessCommonMaster?.UpdateAccess === "Y") && // Object.keys(templateData)?.length > 0 // ))} - icon={} + icon={} htmlType={true} />
diff --git a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx index 0c73699..9bb884b 100644 --- a/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx +++ b/src/Pages/BookingScreen/Components/OtherConponents/Reprint/BSReprint.jsx @@ -30,7 +30,7 @@ import { SelectedPrintTemplate, GlobalPrinterMappingDtls, getPrinterMappingDetails, - getPrintSelectionComponentData, + // getPrintSelectionComponentData, } from '../../../../../Features/ThemeChange/ThemeChange'; import FormHeader from '../../../../../Pages/PageComponents/FormHeader'; import { ArrowRightOutlined } from '@ant-design/icons'; @@ -82,10 +82,14 @@ import { import { TbSettingsCog } from 'react-icons/tb'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { axiosRetailInstanceData } from '../../../../../Features/AuthenicationToken/AuthenticationToken.js'; -import { MdEdit } from "react-icons/md"; +import { MdEdit } from 'react-icons/md'; import { v4 as uuidv4 } from 'uuid'; import { changeOrderOfferDetail } from '../../../../../Features/Offer/Offer.js'; -import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, changeLoyaltyConsumedQuantities } from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; +import { + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + changeLoyaltyConsumedQuantities, +} from '../../../../../Features/Offer/Offernew/BookingOffernew.js'; import { ChangeTotalAmount } from '../../../../../Features/ExteraCharges/ExtraCharges.js'; import { Radio } from 'antd'; import ReprintPDFDataShare from './ReprintPDFDataShare.jsx'; @@ -93,7 +97,7 @@ import { ImShare } from 'react-icons/im'; const RetailApiurl = import.meta.env.ENV_API_URL; -function BSReprint({ setOpenModel = () => { } }) { +function BSReprint({ setOpenModel = () => {} }) { const dispatch = useDispatch(); const queryClient = useQueryClient(); const appPreferences = useSelector(ApplicationPreferences); @@ -167,7 +171,7 @@ function BSReprint({ setOpenModel = () => { } }) { const AuthToken = sessionStorage.getItem('auth'); const SessionMobileNo = getSession('MobileNo'); const [dateStrings, setDateStrings] = useState([]); - const [type, setType] = useState("Sales"); + const [type, setType] = useState('Sales'); const [showShareModal, setShowShareModal] = useState(false); // ---- 1. Fetch Function ---- const fetchData = async ({ queryKey }) => { @@ -180,7 +184,7 @@ function BSReprint({ setOpenModel = () => { } }) { OrderFromDate: dates?.[0] ?? '', OrderToDate: dates?.[1] ?? '', PageNumber: page, - Type: type + Type: type, }) ).unwrap(); if (Response?.data?.statusCode === 1) { @@ -263,9 +267,8 @@ function BSReprint({ setOpenModel = () => { } }) { // UserId: UserId, }; dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); - + // const Data1 = { AppId, CompId, BranchId }; + // dispatch(getPrintSelectionComponentData(Data1)).unwrap(); }, []); const handleDateChange = (dates, dateStrings) => { @@ -604,7 +607,7 @@ function BSReprint({ setOpenModel = () => { } }) { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { if (data === 'without') { @@ -950,9 +953,8 @@ function BSReprint({ setOpenModel = () => { } }) { onClick={async (e) => await handleEditBill(e, row)} /> ), - } + }, // ] : []) - , { title: () => (
{ } }) { const isWeightScale = item?.ScaleType === 'weight'; if (isWeightScale) { - return acc + ( - Weightasquantity + return ( + acc + + (Weightasquantity ? Math.round(Number(item?.SalesQty || item?.OrderQty || 0)) - : 1 + : 1) ); } return acc + Math.round(Number(item?.SalesQty || item?.OrderQty || 0)); - }, 0) + }, 0); const widthOutTexAmt = table2Data?.[0]?.TaxDetails?.reduce( (sum, item) => sum + (item?.WithOutTaxAmount || 0), @@ -1292,7 +1295,7 @@ function BSReprint({ setOpenModel = () => { } }) { OrderQty: item?.SalesQty, OrderRate: item?.Rate, SellingPrice: item?.Rate, - TaxPercentage: (item?.ProdTaxPercentage || 0) + TaxPercentage: item?.ProdTaxPercentage || 0, // TotalAmt: formatAmount((item.TotalAmt - item.OfferValue)), })); @@ -1302,14 +1305,10 @@ function BSReprint({ setOpenModel = () => { } }) { if (RefDetails?.[0]?.OfferAppliedProductList) { dispatch( - changeFullOfferAppliedProducts( - RefDetails[0]?.OfferAppliedProductList - ) + changeFullOfferAppliedProducts(RefDetails[0]?.OfferAppliedProductList) ); } - - if (CustSuppId) { let res = await dispatch( getCustomerForHold({ @@ -1331,8 +1330,9 @@ function BSReprint({ setOpenModel = () => { } }) { } if (res?.data?.statusCode === 1) { - - const loyaltyFreeProductOfferApplied = (RefDetails?.[0]?.OfferAppliedProductList || [])?.filter( + const loyaltyFreeProductOfferApplied = ( + RefDetails?.[0]?.OfferAppliedProductList || [] + )?.filter( (off) => off?.FreeProductsList?.OfferMode === 'L' && off?.TableUniqueName === 'FreeProduct' @@ -1343,14 +1343,20 @@ function BSReprint({ setOpenModel = () => { } }) { ); if (customerDetails) { - const { CustId, CustName, CustMobile, LoyaltyPointsDetail, TotalLoyaltyPoints } = customerDetails; + const { + CustId, + CustName, + CustMobile, + LoyaltyPointsDetail, + TotalLoyaltyPoints, + } = customerDetails; const data = { CustId: CustId, CustName: CustName, label: CustName ? CustName : CustMobile, value: CustMobile, LoyaltyPointsDetail: LoyaltyPointsDetail, - TotalLoyaltyPoints: TotalLoyaltyPoints + TotalLoyaltyPoints: TotalLoyaltyPoints, }; dispatch(changeOrderOfferDetail([...OrderOfferDetails])); @@ -1383,7 +1389,6 @@ function BSReprint({ setOpenModel = () => { } }) { console.log(loyaltyProdQuantities, 'loyaltyProdQuantities'); } } - } } await dispatch(changeOrderType('Hold')); @@ -1395,7 +1400,8 @@ function BSReprint({ setOpenModel = () => { } }) { await dispatch(changePreviousOrderPayment(OrderPaymentDtl)); await dispatch(changePreviousOrderOfferDetail(OrderOfferDetails)); dispatch(changeOrderCardDetails(updated)); - let temp = updated?.filter((item) => item.OrderType === 'E') + let temp = updated + ?.filter((item) => item.OrderType === 'E') .map((item) => item.InwardDtlId + ' ' + item.BookingTypeName); await dispatch(changeSelProdWiseEst(temp)); @@ -1406,11 +1412,11 @@ function BSReprint({ setOpenModel = () => { } }) { await dispatch(changeEstimateBooking('Sales')); await dispatch(ChangeOverAllDiscSales(parseFloat(OverallDisc))); } - } + }; const typeOptions = [ - { label: "Sales", value: "Sales" }, - { label: "Estimate", value: "Est" }, + { label: 'Sales', value: 'Sales' }, + { label: 'Estimate', value: 'Est' }, ]; const typeChange = (e) => { @@ -1455,15 +1461,17 @@ function BSReprint({ setOpenModel = () => { } }) { />
- {preferenceEstimate &&
- -
} + {preferenceEstimate && ( +
+ +
+ )}
{ } }) { }} />
- setShowShareModal(true)} style={{ cursor: 'pointer' }} /> + setShowShareModal(true)} + style={{ cursor: 'pointer' }} + />
{selectedRows.length > 0 && ( @@ -1507,9 +1519,6 @@ function BSReprint({ setOpenModel = () => { } }) { onClick={() => mutiplePrint('whatsapp')} className="icon-whatsapp" /> - {/* */}
)}
@@ -1519,7 +1528,7 @@ function BSReprint({ setOpenModel = () => { } }) { {countOfProduct > 10 && ( { } }) {
))} - {showShareModal && setShowShareModal(false)} - />} + {showShareModal && ( + setShowShareModal(false)} + /> + )} ); } diff --git a/src/Pages/Product/ProductForm.jsx b/src/Pages/Product/ProductForm.jsx index 2e979ab..1ee090d 100644 --- a/src/Pages/Product/ProductForm.jsx +++ b/src/Pages/Product/ProductForm.jsx @@ -85,6 +85,7 @@ import { } from '../../Features/BrachLogin/BranchLogin.js'; import RackForm from '../Rack/RackForm.jsx'; import { isMobile } from 'react-device-detect'; +import BarCodeScan from '../../Services/BarCodeScan.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const ProductForm = ({ formType }) => { @@ -818,12 +819,19 @@ const ProductForm = ({ formType }) => { // dispatch(changeSetup_OfferValue(e?.target?.value)) }; const handleInput = async (val) => { - if (val?.target?.value?.length >= 5) { + // normalize whether we receive an event (e.target.value) or a raw string + const inputVal = val && val.target && typeof val.target.value === 'string' ? val.target.value : val; + if (!inputVal) return; + + if (inputVal.length >= 5) { let QRCodeData = await dispatch( - getQrcodeData({ QRCode: val?.target?.value }) + getQrcodeData({ QRCode: inputVal }) ).unwrap(); + if (QRCodeData?.data?.statusCode == 0) { - await setQrcodeFinalVal(val?.target?.value); + // valid & unique - update component state and the form field + setQrcodeFinalVal(inputVal); + formRef.current?.setFieldsValue({ QRCode: inputVal }); } else { let existsQrcodeData = QRCodeData?.data?.data?.filter( (item) => @@ -831,17 +839,18 @@ const ProductForm = ({ formType }) => { item.CompId === CompId && item.BranchId === BranchId ); + if (existsQrcodeData?.length > 0) { setQrcodeFinalVal(null); formRef.current?.setFieldsValue({ QRCode: null }); setQrcodeExistsVal(existsQrcodeData?.[0]?.QRCode); - setMessageType('error'); setMessageData('Qrcode Already Exists'); } else { setQrcodeExistsData(QRCodeData.data?.data); setQrcodeExistsDataOpen(true); - await setQrcodeFinalVal(val?.target?.value); + setQrcodeFinalVal(inputVal); + formRef.current?.setFieldsValue({ QRCode: inputVal }); setQrcodeAuto('N'); } } @@ -2685,11 +2694,19 @@ const ProductForm = ({ formType }) => { autoComplete="off" label="Scanner / AddQrcode" onKeyPress={handleKeyPress} + value={QrcodeFinalVal} valueData={QrcodeFinalVal} isOnChange={QrcodeFinalVal ? true : false} onChange={handleInput} disabled={editstate?.QRCode ? true : false} /> + {isMobile && + { + handleInput(value); + }} + /> + } {QrcodeExistsVal && QrcodeExistsVal}
@@ -2904,6 +2921,7 @@ const ProductForm = ({ formType }) => { autoComplete="off" label="Scanner / AddOnePcQrcode" onKeyPress={handleKeyPressSingle} + value={QrcodeSingleFinalVal} valueData={QrcodeSingleFinalVal} isOnChange={ QrcodeSingleFinalVal ? true : false diff --git a/src/check.jsx b/src/check.jsx index 941f1c0..dca963e 100644 --- a/src/check.jsx +++ b/src/check.jsx @@ -1,4608 +1,7758 @@ -import React, { useEffect, useState, useRef } from 'react'; -import { FaWhatsapp, FaPrint, FaParking, FaCartPlus } from 'react-icons/fa'; -import { useDispatch, useSelector } from 'react-redux'; -import { useNavigate } from 'react-router-dom'; +import React, { + lazy, + Suspense, + useCallback, + useEffect, + useRef, + useState, +} from 'react'; +import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import moment from 'moment'; -import { Badge, Popover, Modal, Tooltip } from 'antd'; -import { AiOutlineClose, AiOutlineArrowRight } from 'react-icons/ai'; -import { GiBasket } from 'react-icons/gi'; +import { Badge, Tooltip } from 'antd'; +import defaultimage from '../../../../Images/defaultItemImg.png'; +import FormHeader from '../../../PageComponents/FormHeader'; import { - UpCircleOutlined, - UpOutlined, - TransactionOutlined, -} from '@ant-design/icons'; -import { - printDiv, - extractLastNumberOrderId, - encryptObject, -} from '../../../../Services/Others'; -import PaymentPdfBooking from '../../../paymentpdfPage/PaymentPdfBooking'; -import { Messages } from '../../../../Components/Notifications/Messages'; -import { MdMoneyOff } from 'react-icons/md'; -import paygate from '../../../../Images/paygate.png'; -import defaultupi from '../../../../Images/defaultupi.png'; -import paydevice from '../../../../Images/paydevice.png'; -import paymentFailure from '../../../../Images/payment-failure2.png'; -import BSSummery1 from '../BSBillingTables/BSBillingTableSummery/BSSummery'; -import { DefaultModal } from '../../../../Components/Modal/DefaultModal.jsx'; + SelectedGlobalCardColorDetail, + SelectedGlobalCardFont, + StoredSessionData, + getTemplateData, +} from '../../../../Features/ThemeChange/ThemeChange'; import { Tables } from '../../../../Components/Tables/Table'; -import QrComponent from '../BookingFunctionality/DynamicQr.jsx'; -import QrinScreen from '../BookingFunctionality/DynamicScreenQr.jsx'; -import { ArrowRightOutlined } from '@ant-design/icons'; -import Buttons from '../../../../Components/Forms/Buttons'; -import WpIcon from '../../../../Images/message.png'; -import '../../../../Styles/BookingScreen/Template/BSLayout7/BSC1Payment.scss'; -import '../../../../Styles/BookingScreen/Template/BSLayout7/CustomFloatMenu.scss'; -import PozoPreOrderIcon from '../UtillComponents/Pozo retail icons/PozoPreOrderIcon.jsx'; import { + GlobalProductSubCategorie, + GlobalItemCard, + getLayoutproductCard, GlobalOrderCardDetails, changeOrderCardDetails, - GlobalCustId, - PostBookingData, - GlobalSelectedTableDetails, + changeSearchedData, + ChangeAllItemData, + GlobalAllItemData, + GlobalCardAccess, + getSelectedFavItems, + GlobalSelectedDatas, + GlobalEditfavItems, + GlobalAccessForOthers, + GlobalAlldat, + Globalothersdata, + GlobalProductCategorie, + getCardDataWithoutSub, + changeothersdata, + ChangeNewQrProduct, + GlobalWSProduct, + GlobalNewQrProduct, GlobalBookingType, - changeBookingType, - getConfigType, - PutBookingData, + GlobalSearchData, + getCardDataWithoutSubmodule, + changePreviousOrderLength, + changeHoldOrderDtl, GlobalReorderHoldDetails, - getUnpaidData, - changeReorderHoldDetails, - ChangeNavHoldData, - GlobalReprintModal, - changeSelectedTableDetails, - GlobalNavHoldData, - getPreferenceData, - changeSelectedCustId, - GlobalSelCustId, - changeSelectedOption, - GlobalSelOption, - changeCustomerID, - changeCompoPaymentIconStatus, - getSalesDetailData, - SendPaymentLink, - changeSummeryTotalAmount, - changeCreditFocus, - changeUpiIDprint, - GlobalSelectedCustDisable, - changeSummeryTotalItems, - changeSummeryQty, - changeSummeryTotalWithoutTaxAmount, - changeSummeryTotalTaxAmount, - GlobalEstimateBooking, - GlobalSelProdWiseEst, - changeSelProdWiseEst, - changeEstimateBooking, - GlobalUpiIDprint, - GlobalUpiIDName, - GlobalUpiIDoptionId, - GlobalBookingTypeBoth, - changeSelectTable, - changeSelectChair, + GlobalWeightScalePort, + GlobalWeightScaleWeight, + GlobalExpDateforHeight, GlobalOrderType, - changeReorderProductDetails, - FeatureAddon, - GlobalCommonPaymentOptions, - PostPaymentdevice, - changeUpiIDName, - changeUpiIDoptionId, - GetPaymentdeviceResponse, - PutBookingPaymentStatusChange, - changeCombosearch, - GlobalCombosearch, - Comboget, + GlobalReorderProductDetails, + getConfigType, GlobalPayementloader, - changePaymentloader, - PaymentGatewayGetdetail, - changePaymentTransactionNumber, - Globalunpaidflow, - changeunpaidflow, - PutPendingPaymentList, - changealldata, + GlobalPaymentTransactionNumber, PreferenceData, - changeOrderType, - putSplitpaymentStatus, - GlobalFailedTotalAmt, - GlobalOverAllDiscEstimate, - GlobalOverAllDiscSales, - ChangeOverAllDiscSales, - ChangeOverAllDiscEstimate, - GlobalUnpaidListData, - changeUnpaidData, - getAllCustomer, - GlobalBranchFinancialStatus, - changeSummeryComboOfferAmount, - changeTipAmount, - GlobaltipAmount, - GlobalFeatAddOnData, - GlobalOtherServiceTicketClaim, - changeOtherServiceTicketClaim, - GlobalOtherSevices, - changeOtherServices, - changeComboRedirectionToDefaultLayoutForParking, + changeCardData, + GlobaldraggingComponent, + GlobalisAlphabeticFormat, + GlobalBtoBQuickProductTransfer, + changeBtoBQuickProductTransfer, GlobalRetailWSSalesType, - GlobalCurrentOrderId, - changeCurrentOrderId, - getCreditCustomer, - ChangeSelectedCustDisable, + GlobalisFavClicked, + GlobalCategorieData, + GlobalSubcategorieData, + GlobalProductCardTrigger, + GlobalGetmultipleSearchDatas, + getmultipleSearch, + GlobalAllBookingType, } from '../../../../Features/BookingScreen/BookingData/BookingData'; -import { PrintStyleFunction } from '../../../paymentpdfPage/PrintStyleFunction.js'; import { - gettinghold, - globalholddata, - changeholddata, -} from '../../../../Features/BookingScreen/HoldOption/HoldOption'; - -import { - changetemplateData, - SelectedPrintTemplate, - StoredSessionData, - GlobalprintDatas, - GlobalPrinterMappingDtls, - getPrinterMappingDetails, - getPrintSelectionComponentData, -} from '../../../../Features/ThemeChange/ThemeChange'; -import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; -import { - globalExtraTotalAmount, - ChangeTotalAmount, -} from '../../../../Features/ExteraCharges/ExtraCharges'; -import { - getAddCustomerDetails, - GlobalAddCustomerDetails, -} from '../../../../Features/BookingScreen/Customer/addCustomer'; -import BSCustomerSelect from '../UtillComponents/BSSelectCustomer.jsx'; -import PozoHoldIcon from '../UtillComponents/Pozo retail icons/PozoHoldIcon'; -import PozoDineInIcon from '../UtillComponents/Pozo retail icons/PozoDineIn.jsx'; -import PozoUnpaidIcon from '../UtillComponents/Pozo retail icons/PozoUnpaidIcon.jsx'; -import PozoBillIcon from '../UtillComponents/Pozo retail icons/PozoBIllIcon.jsx'; -import PozoTakeAway from '../UtillComponents/Pozo retail icons/PozoTakeAwayIcon'; -import PozoQuickAddIcon from '../UtillComponents/Pozo retail icons/PozoQuickAddIcon.jsx'; -import PozoReprintIcon from '../UtillComponents/Pozo retail icons/PozoReprintIcon'; -import PozoExtraChargesIcon from '../UtillComponents/Pozo retail icons/PozoExtraChargesIcon.jsx'; -import PozoAddCustomerIcon from '../UtillComponents/Pozo retail icons/PozoAddCustomerIcon.jsx'; -import BsBillingCreditCustomer from '../BookingFunctionality/BSBillingCreditCustomer.jsx'; -import { TfiMoreAlt } from 'react-icons/tfi'; -import BSCreditCustomer from '../UtillComponents/BSCreditCustomer.jsx'; -import PozoAdvanceIcon from '../UtillComponents/Pozo retail icons/PozoAdvanceIcon.jsx'; -import { isMobile } from 'react-device-detect'; -import MobilePrint from '../BookingFunctionality/MobilePrint.jsx'; -import SplitPayment from '../BookingFunctionality/SplitPayment.jsx'; -import BSNavBarEstimate from '../UtillComponents/BSNavBarEst.jsx'; -import CountUp from 'react-countup'; -import BSNavBarPreOrder from '../UtillComponents/BSComboNavBarPreOrder.jsx'; -import { GlobalpreOrderOpen } from '../../../../Features/BookingScreen/PreOrder/PreOrder.js'; -import TokensinglePrint from '../../../paymentpdfPage/TokenOnlyPrints/TokeninsinglePrint.jsx'; -import SingleTokenMobilePrint from '../BookingFunctionality/SingleTokenMobilePrint.jsx'; -import IndividualTokenMobilePrint from '../BookingFunctionality/IndividualTokenMobilePrint.jsx'; -import { getCustomerDisplayWindow } from '../../../../Features/customerDisplayWindow/customerDisplayWindow.js'; -import { - GlobalPreOrderPendingCount, - PreOrderGet, - changePreOrderPendingCount, - changepreOrder, - changePreOrderAdditem, + GlobalPreOrderAdditem, + GlobalPreOrderList, + GlobalpreOrderOpen, changepreOrderList, - changePreOrderCusName, - changePreOrderCusMob, - changePreOrderDate, - changePreOrderTime, - changePreOrderAdd1, - changePreOrderAdd2, - changePreOrderAdvance, - changePreOrderzip, - changePreOrderCity, - changePreOrderDistrict, - changePreOrderState, -} from '../../../../Features/BookingScreen/PreOrder/PreOrder.js'; -import PaymentFailedSales from '../../../Payment/PaymentFailedDetails/PaymentFailedSales.jsx'; -import PozoSplitPaymentIcon from '../UtillComponents/Pozo retail icons/PozoSplitPaymentIcon.jsx'; -import PozoFailedPaymentsIcon from '../UtillComponents/Pozo retail icons/PozoFailedPaymentsIcon.jsx'; +} from '../../../../Features/BookingScreen/PreOrder/PreOrder'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; +import { Messages } from '../../../../Components/Notifications/Messages'; +import '../../../../Styles/BookingScreen/Components/BSItemCards/BSItemCard.scss'; +import WebFont from 'webfontloader'; +import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities'; +import { isMobile } from 'react-device-detect'; import { - Global_CoupenCodeAmount, - Global_loyaltyPointsDiscountAmount, Global_OrderOfferDetail, - Global_OverallOfferAmount, - Global_SalesWiseOfferAmount, -} from '../../../../Features/Offer/Offer.js'; -import { useApplyOfferto_CardDetail } from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx'; -import TooltipWrapper from '../../../../Components/Tooltip/Tooltip'; -import BSNavBarOffer from '../UtillComponents/BSNavBarOffer/BSNavBarOffer.jsx'; -import { getEmpAccess } from '../../../../Features/AppPage/CenterPage.js'; -import { useAuth } from '../../../../AuthContext.jsx'; -import { GlobalBookingStatus } from '../../../../Features/Payment/PaymentReceivedRetail/PaymentReceivedRetail.js'; -import WhatsAppShare from '../../../WhatsAppShare/whatsAppShare.jsx'; -import CryptoJS from 'crypto-js'; -import SMSShare from '../../../WhatsAppShare/SmsShare.jsx'; -import { MdSms } from 'react-icons/md'; + Global_PromoCodeOffers, +} from '../../../../Features/Offer/Offer'; import { - changeSalesPaymentoption, - GlobalSalesPaymentoption, -} from '../../../../Features/Payment/Paymentoptions/Paymentoptions.js'; -import Paymentoption from '../../../Payment/PaymentOptions/PaymentOptions.jsx'; -import BSTipAmount from '../UtillComponents/BSTipAmount.jsx'; + DndContext, + useSensor, + useSensors, + PointerSensor, + TouchSensor, + closestCenter, +} from '@dnd-kit/core'; +import { + SortableContext, + arrayMove, + rectSortingStrategy, +} from '@dnd-kit/sortable'; +import { v4 as uuidv4 } from 'uuid'; + +import { useSortable } from '@dnd-kit/sortable'; +import { CSS } from '@dnd-kit/utilities'; +import { MdOutlineAddShoppingCart } from 'react-icons/md'; +// Js Files +import { + changeFreeProductForLoyalty, + ChangeFreeProductList, + ChangeFullFreeProductList, + changeFullOfferAppliedProducts, + ChangeOfferAppliedProducts, + changeOfferAppliedProductsForLoyalty, + changeTriggerOfferFree, + getOfferinBooking, + GlobalFreeProdList, + GlobalOfferAppliedProducts, + GlobalTriggerOfferFree, + RemoveOfferAppliedProduct, +} from '../../../../Features/Offer/Offernew/BookingOffernew.js'; +import { ExtractDateFormate } from '../../../../Services/Others.js'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin.js'; -import BSOtherServiceClaim from '../UtillComponents/BSOtherServiceClaim.jsx'; -import { OtherServicesCardlistdata } from '../../../../Features/OtherServices/OtherServices.js'; -import { MobilePdfPrint } from '../BookingFunctionality/MobilePdfPrint.js'; -import { PublicQrCodepost } from '../../../../Features/ConfigMasterPage/ConfigMasterPage.js'; -import BSMembership from '../UtillComponents/BSMembership.jsx'; -import CardPopover from '../BSBillingTables/StandardTable/Utils/CardPopover.jsx'; -import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx'; import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; -import { getPaymentOptionsData } from '../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; -import CustomerOrders from '../BookingFunctionality/CustomerOrders.jsx'; +import { bulkpostdata } from '../../../../Features/ProductPage/ProductPage.js'; +// Jsx Files +const VoiceToTextItemCard = lazy( + () => import('../../../VoiceToText/VoiceToTextItemCard.jsx') +); +const validateOffers = lazy(() => import('./ValidateOffer.jsx')); +const AddProduct = lazy( + () => import('../../../../Components/AddProduct/AddProduct.jsx') +); +const ProductPriceChange = lazy( + () => import('../UtillComponents/ProductPriceChange.jsx') +); +const ExpireConfirmModal = lazy( + () => import('../BookingFunctionality/ExpireConfirmModal.jsx') +); +import { useSaleswiseOfferWatcher } from './SalesWiseOffer.jsx'; -const subDirectory = import.meta.env.ENV_BASE_URL; -const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; -const RetailApiurl = import.meta.env.ENV_API_URL; - -const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - -const BSC1Payment = (props) => { - const isF4Pressed = useRef(false); - const applyOffer = useApplyOfferto_CardDetail(); - const { SadminuserAccess } = useAuth(); - let SAAccessCommonMaster = SadminuserAccess?.find( - (e) => e?.MenuName === 'Sales' +export function SortableCard({ id, children, item }) { + const { + attributes, + listeners, + setNodeRef, + transform, + transition, + isDragging, + } = useSortable({ id }); + const style = { + transform: CSS.Transform.toString(transform), + transition, + opacity: isDragging ? 0.5 : 1, + userSelect: 'none', // Prevents text selection during drag + // Add mobile-specific cursor and visual feedback + cursor: isMobile ? 'grab' : 'default', + // Add a subtle shadow for mobile to indicate draggability + boxShadow: isMobile && !isDragging ? '0 2px 4px rgba(0,0,0,0.1)' : 'none', + }; + const draggingComponent = useSelector(GlobaldraggingComponent); + const allowDrag = draggingComponent === 'card'; + return ( +
+ {children} +
); +} - const dispatch = useDispatch(); - const navigate = useNavigate(); - const SessionData = useSelector(StoredSessionData); - const BranchFinancialStatus = useSelector(GlobalBranchFinancialStatus); - const globalTipAmount = useSelector(GlobaltipAmount); - const OtherServiceTicketClaim = useSelector(GlobalOtherServiceTicketClaim); - const RetailWSSalesType = useSelector(GlobalRetailWSSalesType); - const BranchId = SessionData?.BranchId; - const AppName = SessionData?.AppName; - const AppId = SessionData?.AppId; - const CompId = SessionData?.CompId; - const UserId = SessionData?.UserId; - const UserType = SessionData?.UserType; - const AuthToken = SessionData?.AuthToken; - const SessionMobileNo = SessionData?.SessionMobileNo; - const [open, setOpen] = useState(false); - const printerTemplateStyle = useSelector(SelectedPrintTemplate); - const SelectedTableDetails = useSelector(GlobalSelectedTableDetails); - const Custdisable = useSelector(GlobalSelectedCustDisable); - const OrderCardDetail = useSelector(GlobalOrderCardDetails); - const GlobalExtraCharge = useSelector(globalExtraTotalAmount); - const ReportholdData = useSelector(GlobalReorderHoldDetails); - const ReprintModal = useSelector(GlobalReprintModal); - const GetCustId = useSelector(GlobalCustId); - const GlobalUpiID = useSelector(GlobalUpiIDprint); - const SelCustId = useSelector(GlobalSelCustId); - const selOption = useSelector(GlobalSelOption); - const Holddata = useSelector(globalholddata); - const BookingType = useSelector(GlobalBookingType); - const BookingTypeBoth = useSelector(GlobalBookingTypeBoth); - const OrderType = useSelector(GlobalOrderType); - const GlobalAddCustomerDetails1 = useSelector(GlobalAddCustomerDetails); - const SettingDataSelector = useSelector(PreferenceData); - const GlobalSalesPaymentoptions = useSelector(GlobalSalesPaymentoption); - const FeatureAddonData = useSelector(GlobalFeatAddOnData); - - const allowedNames = ['whatsapp', 'Print', 'SMS']; - - const filteredSettingNames = SettingDataSelector?.[0]?.['SettingDtlDetails'] - ?.filter( - (item) => - allowedNames.includes(item?.SettingIdName) && item?.SettingValue === 'Y' - ) - ?.map((item) => item?.SettingIdName); - +const BSItemCard = (props) => { + const cardFunction = props?.cardFunctionality; + // const applyOffer = useApplyOfferto_CardDetail(); + const preferenceDatas = useSelector(PreferenceData, shallowEqual); + const { selectedDate } = useDateStore(); const preferenceOffer = - SettingDataSelector?.[0]?.['SettingDtlDetails']?.find( + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' )?.SettingValue === 'Y'; - const GlobalUpName = useSelector(GlobalUpiIDName); - const GlobalUpiIDoptionIdd = useSelector(GlobalUpiIDoptionId); - const NavHoldData = useSelector(GlobalNavHoldData); - const GlobEstBooking = useSelector(GlobalEstimateBooking); - const GlobProdwisedata = useSelector(GlobalSelProdWiseEst); - const preOrder = useSelector(GlobalpreOrderOpen); - const Comboglobal = useSelector(GlobalCombosearch); - const FailedTotalAmt = useSelector(GlobalFailedTotalAmt); - const OrderOfferDetail = useSelector(Global_OrderOfferDetail); - const [SelectedUpiOption, setSelectedUpiOption] = useState(); - const [credit, setCredit] = useState(false); - const [overAllBal, setOverAllBal] = useState(0); - const [SelectedBookingType, setSelectedBookingType] = useState(null); - const [TotalItems, setTotalItems] = useState(''); - const [showWhatsAppShare, setShowWhatsAppShare] = useState(false); - const [showSMSShare, setSMSShare] = useState(false); - const [TotalWithoutTaxAmount, setTotalWithoutTaxAmount] = useState(''); - const [TotalTaxAmount, setTotalTaxAmount] = useState(''); - const [Qty, setQty] = useState(null); - const [formattedDate, setFormattedDate] = useState(''); - const [UpiOptionOpen, setUpiOptionOpen] = useState(false); - const [customerPreviesOrders, setCustomerPreviesOrders] = useState(false); - const [UpiOption, setUpiOption] = useState(''); - const [UpiId, setUpiId] = useState(); - const [hold, setHold] = useState(false); - const appPreferences = useSelector(ApplicationPreferences); - const commonModulePreference = appPreferences?.find( - (preference) => preference?.PreferredCatName === 'Common Module' - )?.PreferenceCatDetails; - const sportsAppPreference = commonModulePreference?.find( - (preference) => preference?.PreferredSubCatName === 'SportsApp' - ); - const bookingTypePreference = appPreferences?.find( - (preference) => preference?.PreferredCatName === 'Booking Type' - )?.PreferenceCatDetails; - const dinePreference = bookingTypePreference?.find( - (type) => - type?.PreferredSubCatName?.toLowerCase() === 'dine in' && - type?.PreferredStatus === 'Y' - ); - const takeAwayPreference = bookingTypePreference?.find( - (type) => - type?.PreferredSubCatName?.toLowerCase() === 'take away' && - type?.PreferredStatus === 'Y' - ); + const preferenceSingleSales = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName === 'Single Booking Only' + )?.SettingValue === 'Y'; + const AddProductCard = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName === 'AddProductCard' + )?.SettingValue === 'N'; + // const AddCustomerDetails = useSelector( + // GlobalAddCustomerDetails, + // shallowEqual + // ); - const preferenceshortcutkey = SettingDataSelector?.[0]?.[ - 'SettingDtlDetails' - ]?.some( - (item) => - item.SettingIdName.toLowerCase() === 'shortcutkeys' && - item.SettingValue === 'Y' + const offerAppliedProducts = useSelector( + GlobalOfferAppliedProducts, + shallowEqual ); - - const [addcustomer, setAddCustomer] = useState(false); - const [PrintOrderDetails, setPrintOrderDetails] = useState([]); - const tabledata = useSelector(GlobalUnpaidListData); - const [FirstPaymentclick, setFirstPaymentclick] = useState(false); - const [unpaidopen, setUnpaidOpen] = useState(false); - const unpaidFlow = useSelector(Globalunpaidflow); - const [messageType, setMessageType] = useState(null); - const [messageData, setMessageData] = useState(null); - const [reprint1, setReprint1] = useState(false); - const [extraCharges, setExtraCharges] = useState(false); - const [QuickAdd, setQuickAdd] = useState(false); - const [DineInPreference, setDineInPreference] = useState({}); - const [UpinotSelected, setUpinotSelected] = useState(false); - const [qrCode, setQrCode] = useState(false); - const [paybtns, setpaybtns] = useState([]); - const [CreditCustomer, setCreditCustomer] = useState(false); - const [creditCustomerOpen, setcreditCustomerOpen] = useState(false); - const [Success, SetSuccess] = useState(); - const [brachName, setbrachName] = useState(''); - const [UpiOpen, setUpiOpen] = useState(false); - const [ConfigDataList, setConfigDataList] = useState([]); - const BSComboData = props?.hasOwnProperty('optionNames') - ? props['optionNames'] - : null; - const BSComboNavbar = - BSComboData?.BookingLayout?.[0] === 'Combo1' - ? BSComboData?.BookingCombo1 - : BSComboData?.BookingCombo2; - const OfferCheckedInSetup = BSComboNavbar?.[1]?.some( - (some) => some.OptionName === 'Offer' + // const SelectedCust = useSelector(GlobalSelOption, shallowEqual); + const AllCategoryDatas = useSelector(GlobalCategorieData, shallowEqual); + const AllsubcatgoryDatas = useSelector(GlobalSubcategorieData, shallowEqual); + const RetailWSSalesType = useSelector(GlobalRetailWSSalesType, shallowEqual); + const ConfigDataList = useSelector(GlobalAllBookingType, shallowEqual); + const GPreOrderList = useSelector(GlobalPreOrderList, shallowEqual); + const [modelQty, setModelQty] = useState(false); + const [modelstock, setModelstock] = useState(false); + const [ModalVarient, setModalVarient] = useState(false); + const [QtyIndex, setQtyIndex] = useState(0); + const [VarientIndex, setVarientIndex] = useState(0); + const [prodexpir, setProdexpir] = useState(false); + const [initialRun, setInitialRun] = useState(false); + const [Item, setItem] = useState(); + const [VarItem, setVarItem] = useState(0); + const [StockItem, setStockItem] = useState(); + const [noSubcatCardData, setNoSubcatCardData] = useState(); + const [qtydata, setQtydata] = useState(); + const [products, setProducts] = useState([ + { id: 1, name: '', price: '', code: '', size: '1', category: '' }, + ]); + const PreOrderAdditem = useSelector(GlobalPreOrderAdditem, shallowEqual); + const OrderType = useSelector(GlobalOrderType, shallowEqual); + const ProdSubCat = useSelector(GlobalProductSubCategorie); + const ItemCard = useSelector(GlobalItemCard, shallowEqual); + const globaldata = useSelector(GlobalAlldat, shallowEqual); + const { action: quickBranchtoBranchTransfer, selectedProducts } = useSelector( + GlobalBtoBQuickProductTransfer ); - const UomPrint = SettingDataSelector?.[0]?.SettingDtlDetails.filter( - (i) => i.SettingIdName === 'PrintUom' - )?.[0]; - const Estimation = SettingDataSelector?.[0]?.SettingDtlDetails?.find( - (item) => item.SettingIdName == 'Estimation' + const preOrder = useSelector(GlobalpreOrderOpen, shallowEqual); + const templateData = useSelector(getTemplateData, shallowEqual); + const temp5 = templateData?.BookingLayout?.[0] === 'Layout5'; + const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( + (item) => item?.OptionName == 'Offer' ); - const ParkingDisplay = SettingDataSelector?.[0]?.SettingDtlDetails?.find( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'parking' && - setting?.SettingValue === 'Y' + const globalAllItemdata = useSelector(GlobalAllItemData); + const EditfavItems = useSelector(GlobalEditfavItems); + const BookingType = useSelector(GlobalBookingType); + const ProductSearch = useSelector(GlobalSearchData); + const [SelectedProdNames, setSelectedProdNames] = useState(EditfavItems); + const [PreOrderSelectedProdNames, setPreOrderSelectedProdNames] = useState( + [] ); - const MobileA4Print = SettingDataSelector?.[0]?.SettingDtlDetails?.find( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'mobilea4' && - setting?.SettingValue === 'Y' + const [newMoreProductModel, setNewMoreProductModel] = useState(false); + const CardAccess = useSelector(GlobalCardAccess, shallowEqual); + const globalAccessForOthers = useSelector( + GlobalAccessForOthers, + shallowEqual ); - const Weightasquantity = SettingDataSelector?.[0]?.SettingDtlDetails?.some( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'weightasquantity' && - setting?.SettingValue === 'Y' + const SelectedCardColor = useSelector( + SelectedGlobalCardColorDetail, + shallowEqual ); - const [OrderStatus, setOrderStatus] = useState(true); - // const [FeatureAddonData, setFeatureAddonData] = useState([]); - const [Splitpayment, setSplitpayment] = useState(false); - const [urlData, setUrlData] = useState(); - const [PaymentOptions, setPaymentOptions] = useState([]); - const [paybtnselected, setPaybtnselected] = useState(); - const [Paybtnnameselected, setPaybtnnameselected] = useState(); - const [OtherServiceStatus, setOtherServiceStatus] = useState(false); - const allowDecimal = SettingDataSelector?.[0]?.SettingDtlDetails?.find( + const GetmultipleSearchDatas = useSelector( + GlobalGetmultipleSearchDatas, + shallowEqual + ); + const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual); + const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual); + const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); + const otherscarddata = useSelector(Globalothersdata, shallowEqual); + const WSProductdata = useSelector(GlobalWSProduct, shallowEqual); + const NewQrProductData = useSelector(GlobalNewQrProduct, shallowEqual); + const ReportholdData = useSelector(GlobalReorderHoldDetails, shallowEqual); + const ReorderProductData = useSelector( + GlobalReorderProductDetails, + shallowEqual + ); + const WeightScalePort = useSelector(GlobalWeightScalePort, shallowEqual); + const WeightScaleWeight = useSelector(GlobalWeightScaleWeight, shallowEqual); + const PaymentTransactionNumber = useSelector( + GlobalPaymentTransactionNumber, + shallowEqual + ); + const OverAllproductBasedOfferDatas = useSelector( + (state) => state?.BookingOFferNew?.OverAllProductBasedProducts, + shallowEqual + ); + const PromoCodeOffersDatas = useSelector( + Global_PromoCodeOffers, + shallowEqual + ); + const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find( (setting) => setting?.SettingIdName?.toLowerCase() === 'decimal' && setting?.SettingValue === 'Y' ); - const Custombill = SettingDataSelector?.[0]?.SettingDtlDetails?.some( - (setting) => - setting?.SettingIdName?.toLowerCase() === 'customisedbillnumber' && - setting?.SettingValue === 'Y' + const [messageType, setMessageType] = useState(null); + const [messageData, setMessageData] = useState(null); + const [repeatedModel, setRepeatedModel] = useState(false); + const [StockPreferenceDetail, setStockPreferenceDetail] = useState(); + const [QuickAdd, setQuickAdd] = useState(true); + const [onePeiceFlow, setOnePeiceFlow] = useState(false); + const [BillOrderPre, setBillOrderPre] = useState(); + const [qtyExpData, setQtyExpData] = useState(); + const OrderOfferDetail = useSelector(Global_OrderOfferDetail); + // const [freeProductsOffers, setfreeProductsOffers] = useState([]); + const [screenWidth, setScreenWidth] = useState(window.innerWidth); + // const [screenHeight, setScreenHeight] = useState(window.innerHeight); + const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); + const paymentloader = useSelector(GlobalPayementloader, shallowEqual); + const SessionData = useSelector(StoredSessionData, shallowEqual); + const AppId = SessionData?.AppId; + const CompId = SessionData?.CompId; + const BranchId = SessionData?.BranchId; + const UserId = SessionData?.UserId; + const dispatch = useDispatch(); + + const voiceTriggerRef = useRef(null); + const scrollContainerRef = useRef(null); + const isDragging = useRef(false); + const startX = useRef(0); + const scrollLeft = useRef(0); + const itemListScrollRef = useRef(null); + const [selectedBrand, setSelectedBrand] = useState('Others'); + const [showLeftButton, setShowLeftButton] = useState(false); + const [showRightButton, setShowRightButton] = useState(false); + const [ExpiredProduct, setExpiredProduct] = useState(); + + const alphabeticFormat = useSelector(GlobalisAlphabeticFormat); + // const PricingAppPricingName = useSelector(GlobalPricingAppPricingName); + const favouriteCat = useSelector(GlobalisFavClicked, shallowEqual); + const FreeProdList = useSelector(GlobalFreeProdList); + const triggerOfferFree = useSelector(GlobalTriggerOfferFree); + const productCardTrigger = useSelector(GlobalProductCardTrigger); + const appPreferences = useSelector(ApplicationPreferences); + const [expireModal, setExpireModal] = useState({ + open: false, + title: '', + onOk: null, + onCancel: null, + }); + + const salespagefields = appPreferences?.find( + (pref) => pref?.PreferredCatName === 'Sales Page Fields' + )?.PreferenceCatDetails; + const AvailableDate = salespagefields?.find( + (type) => + type?.PreferredSubCatName?.toLowerCase() === 'available date' && + type?.PreferredStatus === 'Y' ); - const [SelectedCardOption, setSelectedCardOption] = useState(null); - const [SelectedUPIPayOption, setSelectedUPIPayOption] = useState('Default'); - const [CardOptionOpen, setCardOptionOpen] = useState(false); - const [CardoptionnotSelected, setCardoptionnotSelected] = useState(false); - const [PaymentgatewayCard, setPaymentgatewayCard] = useState([]); - const [PaymentDeviceCard, setPaymentDeviceCard] = useState([]); - const [PaymentgatewayUPI, setPaymentgatewayUPI] = useState([]); - const [PaymentDeviceUPI, setPaymentDeviceUPI] = useState([]); - const [UpiPayOption, setUpiPayOption] = useState([]); - const [CardPayOption, setCardPayOption] = useState([]); - const [PaymentUpiOptions, setPaymentUpiOptions] = useState([]); - const GlobaluseOptions = useSelector(GlobalCommonPaymentOptions); - const [useOptions, setuseOptions] = useState([]); - const CheckOrderType = OrderCardDetail?.filter( - (a) => a?.BookingTypeName !== BookingType + + const SingleMember = salespagefields?.find( + (type) => + type?.PreferredSubCatName?.toLowerCase() === 'single member' && + type?.PreferredStatus === 'Y' ); - // const [ComboDropDown, setComboDropDown] = useState(); - const paymentloader = useSelector(GlobalPayementloader); - const TokenOnly = SettingDataSelector?.[0]?.SettingDtlDetails?.filter( - (i) => i.SettingIdName === 'TokenOnly' - )?.[0]; - const IndividualToken = SettingDataSelector?.[0]?.SettingDtlDetails?.filter( - (i) => i.SettingIdName === 'AllProductindividualToken' - )?.[0]; - const [UnpaidConfirmation, setUnpaidConfirmation] = useState(false); - const [unpaidselectedindex, setunpaidselectedindex] = useState(); - const [preOrderOpen, setPreOrderOpen] = useState(false); - const preOrderPendingCount = useSelector(GlobalPreOrderPendingCount); - const [failedOrderData, setFailedOrderData] = useState(); - const [OpenFailData, SetOpenFailData] = useState(false); - const [paymentfeataddon, setpaymentfeataddon] = useState(false); - const [isFloatMenuOpen, setIsFloatMenuOpen] = useState(false); - const OverAllSales = useSelector(GlobalOverAllDiscSales); - const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate); - const [blink, setBlink] = useState(false); - const [empData, setEmpData] = useState(); - const [MobileNoWhatsApp, setMobileNoWhatsApp] = useState(); - const printDatas = useSelector(GlobalprintDatas); - const PrinterDetails = useSelector(GlobalPrinterMappingDtls); - const [addnewAccess, setaddnewAccess] = useState(true); - const BookingStatus = useSelector(GlobalBookingStatus); - const PaymentOptionsModeName = - PaymentOptions?.find((e) => e.ModeDefault?.toUpperCase() === 'Y') - ?.ModeName || PaymentOptions?.[0]?.ModeName; - const PaymentOptionsModeId = - PaymentOptions?.find((e) => e.ModeDefault?.toUpperCase() === 'Y')?.ModeId || - PaymentOptions?.[0]?.ModeId; + useSaleswiseOfferWatcher(); - const CheckBookingStatus = - BookingStatus?.find((item) => item.ScreenType === 'Booking') - ?.ScreenStatus ?? 'Open'; - const OverallOfferAmount = useSelector(Global_OverallOfferAmount); + const TakAwayId = ConfigDataList?.find( + (a) => a?.ConfigName === 'TakeAway' + )?.ConfigId; - const [TotalAmount, setTotalAmount] = useState(0); - // for customised invoice number - const { invoiceDate, clearInvoiceDate } = useDateStore(); - const CurrentOrderId = useSelector(GlobalCurrentOrderId); + const DineinId = ConfigDataList?.find( + (a) => a?.ConfigName === 'Dine In' + )?.ConfigId; - console.log(BSComboData, 'BSComboData'); - const canHold = - unpaidFlow === false && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length !== 0 && - CheckOrderType?.length === 0 && - OrderType !== 'Failed' && - CheckBookingStatus !== 'Close' && - !addnewAccess && - BSComboData?.BookingBilling?.[1]?.some( - (e) => e?.OptionName?.toLowerCase() == 'hold' - ); - const canRecall = - unpaidFlow === false && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length == 0 && - OrderType !== 'Failed' && - Holddata?.length > 0 && - CheckBookingStatus !== 'Close' && - !addnewAccess && - BSComboData?.BookingBilling?.[1]?.some( - (e) => e?.OptionName?.toLowerCase() == 'hold' - ); - - const canExtracharge = - BSComboNavbar?.[1]?.some( - (e) => e?.OptionName?.toLowerCase() == 'extracharge' - ) && OrderCardDetail?.length !== 0; - const canSplitPayment = - paybtns?.length > 1 && - OrderCardDetail?.length > 0 && - CheckBookingStatus !== 'Close' && - !addnewAccess; - - console.log(canSplitPayment, 'canSplitPayment'); - const canReprint = BSComboNavbar?.[1]?.some( - (e) => e?.OptionName?.toLowerCase() == 'reprint' - ); - console.log( - BSComboData?.BookingBilling?.[1]?.some( - (e) => e?.OptionName?.toLowerCase() == 'hold' - ), - '11111111111111' - ); - // Usage useEffect(() => { - const fetchCreditCustomer = async () => { - const selectedMode = paybtns?.find( - (pay) => paybtnselected === pay?.ModeId - )?.ModeName; + itemListScrollRef.current?.scrollTo(0, 0); + }, [ProdCat, ProdSubCat, favouriteCat]); - if ( - selectedMode?.toLowerCase() === 'credit' && - (!UpinotSelected || !CardoptionnotSelected) - ) { - setCredit(true); - try { - const res = await dispatch( - getCreditCustomer({ - CompId, - AppId, - BranchId, - CustId: selOption?.CustId, - }) - ).unwrap(); + useEffect(() => { + if ( + triggerOfferFree && + CartOrderDetails?.length > 0 && + FreeProdList?.length > 0 + ) { + console.log('Before call'); + let { ModifiedData, UpdatedFreeProdList, AppliedOffers } = + handleLoyaltyFreeProducts(CartOrderDetails, FreeProdList); + console.log( + 'After call', + ModifiedData, + UpdatedFreeProdList, + AppliedOffers + ); + console.log(AppliedOffers, 'AppliedOffers'); + dispatch(changeOrderCardDetails(ModifiedData)); + dispatch(ChangeFullFreeProductList(UpdatedFreeProdList)); + dispatch(changeFullOfferAppliedProducts(AppliedOffers)); + dispatch(changeTriggerOfferFree(false)); + } + }, [triggerOfferFree]); - if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) { - setOverAllBal(res.data.data[0]?.OverAllBal ?? 0); - } else { - setOverAllBal(0); + function handleLoyaltyFreeProducts(orderCardDtls, freeProdDtls) { + if (!freeProdDtls || freeProdDtls.length === 0) { + return { + ModifiedData: orderCardDtls, + UpdatedFreeProdList: freeProdDtls, + AppliedOffers: [], + }; + } + + const updatedFreeProdList = JSON.parse(JSON.stringify(freeProdDtls)); // deep copy + const AppliedOffers = []; + let ModifiedData = []; + let processedItems = new Set(); // Track processed items + + // Helper function to create applied offer object + function createAppliedOffer( + freeProduct, + usedQty, + inwardDtlId, + orderRate, + bookingType + ) { + const stockDetail = + freeProduct.ProdVariantDetails?.[0]?.StockDetails?.[0]; + + return { + OfferId: freeProduct.OfferId, + OfferAmount: usedQty * orderRate, + OfferMode: freeProduct.OfferMode, + ActualOfferAmount: usedQty * orderRate, + OfferValue: usedQty * orderRate, + TableName: freeProduct.TableName || 'LoyaltyPointsNew', + TableUniqueName: freeProduct.TableUniqueName || 'FreeProduct', + TableUniqueId: '', + ActualFreeQty: usedQty, + Detail: [], + OfferCode: '', + CustId: freeProduct.CustId || '', + UsedCount: (stockDetail?.ProdLoyaltyPoint || 0) * usedQty, + AppliesTo: '', + BookingType: bookingType === 'Dine In' ? 'DineinId' : 'TakAwayId', + FreeProductsList: { + FreeProdId: freeProduct.FreeProdId, + FreeQty: usedQty, + FreeProdName: freeProduct.FreeProdName, + ProdVariantDetails: [ + { + FreeProdVariantName: freeProduct.FreeProdVariantName, + StockDetails: [ + { + ProdOfferId: stockDetail?.ProdOfferId || '', + FreeInwardDtlId: inwardDtlId, + ActiveStatus: 'A', + ProdLoyaltyPoint: stockDetail?.ProdLoyaltyPoint || '', + }, + ], + }, + ], + }, + ProdId: '', + SinglePc: 'N', + StockAvailable: 'N', + ProdVariantName: '', + Type: '', + InwardDtlId: '', + ProdCat: '', + HalfPrice: 'N', + MinQty: '', + }; + } + + // First, handle existing paid products that can be converted to free + updatedFreeProdList.forEach((freeProduct) => { + if (freeProduct.RemainingQty > 0) { + // Find matching paid products by InwardDtlId + const matchingPaidItems = orderCardDtls.filter( + (item) => + freeProduct.ProdVariantDetails?.some((variant) => + variant.StockDetails?.some( + (stock) => stock.FreeInwardDtlId === item.InwardDtlId + ) + ) && + (!item.Offer || item.Offer === 0) && + !item.OfferType && + !item.OfferMode && + !processedItems.has(item.localId) && + item?.SinglePc !== 'Y' + ); + + matchingPaidItems.forEach((paidItem) => { + const remainingFreeQty = freeProduct.RemainingQty; + + if (remainingFreeQty <= 0) return; + + if (paidItem.OrderQty === remainingFreeQty) { + // Remove paid item and convert entire quantity to free + const freeItem = { + ...paidItem, + Offer: paidItem.OrderQty * paidItem.OrderRate, + OfferType: freeProduct.OfferMode, + OfferMode: freeProduct.OfferMode, + OfferMessage: [ + { + OfferId: freeProduct.OfferId, + FreeQty: paidItem.OrderQty, + FreeProdId: freeProduct.FreeProdId, + FreeProdName: freeProduct.FreeProdName, + }, + ], + localId: paidItem.localId + '_converted_free', + }; + + ModifiedData.push(freeItem); + + // Update free product usage + freeProduct.FreeQty = + (freeProduct.FreeQty || 0) + paidItem.OrderQty; + freeProduct.RemainingQty -= paidItem.OrderQty; + + // Create applied offer + AppliedOffers.push( + createAppliedOffer( + freeProduct, + paidItem.OrderQty, + paidItem.InwardDtlId, + paidItem.OrderRate, + paidItem.BookingTypeName + ) + ); + + processedItems.add(paidItem.localId); + } else if (paidItem.OrderQty > remainingFreeQty) { + // Split: convert available free qty to free, keep excess as paid + const freeQty = remainingFreeQty; + const paidQty = paidItem.OrderQty - remainingFreeQty; + + // Create free item + const freeItem = { + ...paidItem, + OrderQty: freeQty, + TotalAmt: freeQty * paidItem.OrderRate, + TaxAmt: ( + (freeQty * paidItem.OrderRate * paidItem.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + freeQty * paidItem.OrderRate - + (freeQty * paidItem.OrderRate * paidItem.TaxPercentage) / 100, + Offer: freeQty * paidItem.OrderRate, + OfferType: freeProduct.OfferMode, + OfferMode: freeProduct.OfferMode, + OfferMessage: [ + { + OfferId: freeProduct.OfferId, + FreeQty: freeQty, + FreeProdId: freeProduct.FreeProdId, + FreeProdName: freeProduct.FreeProdName, + }, + ], + localId: paidItem.localId + '_free_part', + }; + + // Create updated paid item with reduced quantity + const updatedPaidItem = { + ...paidItem, + OrderQty: paidQty, + TotalAmt: paidQty * paidItem.OrderRate, + TaxAmt: ( + (paidQty * paidItem.OrderRate * paidItem.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + paidQty * paidItem.OrderRate - + (paidQty * paidItem.OrderRate * paidItem.TaxPercentage) / 100, + localId: paidItem.localId + '_paid_part', + }; + + ModifiedData.push(freeItem); + ModifiedData.push(updatedPaidItem); + + // Update free product usage + freeProduct.FreeQty = (freeProduct.FreeQty || 0) + freeQty; + freeProduct.RemainingQty -= freeQty; + + // Create applied offer + AppliedOffers.push( + createAppliedOffer( + freeProduct, + freeQty, + paidItem.InwardDtlId, + paidItem.OrderRate, + paidItem.BookingTypeName + ) + ); + + processedItems.add(paidItem.localId); } - } catch (error) { - console.error('Credit fetch failed', error); - setOverAllBal(0); - } - } else { - setCredit(false); - setOverAllBal(0); + }); } - }; + }); - fetchCreditCustomer(); - }, [paybtnselected, selOption, paybtns]); - useEffect(() => { - if (!preOrder) { - const totalSum = OrderCardDetail?.reduce( - (acc, card) => acc + parseFloat(card.OrderRate * card.OrderQty || 0), - 0 - ); + // Process remaining cart items + orderCardDtls.forEach((item) => { + // Skip if already processed + if (processedItems.has(item.localId)) { + return; + } - const extra = GlobalExtraCharge?.reduce( - (acc, obj) => acc + (obj.TotalAmt || 0), - 0 - ); + // Check if item is currently marked as free (has OfferType/OfferMode and Offer > 0) + const isCurrentlyFree = + item.Offer > 0 && (item.OfferType || item.OfferMode); - let withComboSum = 0; - const withComboOffer_CardDetail = OrderCardDetail?.filter( - (item) => item.Type === 'C' - ); - if (withComboOffer_CardDetail?.length > 0) { - withComboSum = formatAmount( - withComboOffer_CardDetail.reduce( - (acc, card) => - acc + - parseFloat(card.OrderRate * card.OrderQty - card.TotalAmt || 0), - 0 + if (isCurrentlyFree) { + // Find matching free product by InwardDtlId + const matchingFreeProduct = updatedFreeProdList.find((freeProd) => + freeProd.ProdVariantDetails?.some((variant) => + variant.StockDetails?.some( + (stock) => stock.FreeInwardDtlId === item.InwardDtlId + ) ) ); - } - let Total = - extra === undefined - ? totalSum - OverallOfferAmount - withComboSum - : totalSum + extra - OverallOfferAmount - withComboSum; + if (matchingFreeProduct) { + const availableFreeQty = matchingFreeProduct.OverAllFreeQty || 0; - // Subtract OtherServiceTicketClaim?.totalTicketamount if present and > 0 - if (OtherServiceTicketClaim?.TotalAmt > 0) { - if (Total - OtherServiceTicketClaim.TotalAmt > 0) { - Total -= OtherServiceTicketClaim.TotalAmt; - } else { - dispatch( - changeOtherServiceTicketClaim({ - TicketId: null, - TotalAmt: 0, - ParkingClaimed: false, - ServiceCategory: null, - }) - ); - } - } else if (OtherServiceTicketClaim?.OtherType == 'Remove') { - dispatch( - changeOtherServiceTicketClaim({ - TicketId: null, - TotalAmt: 0, - ParkingClaimed: false, - ServiceCategory: null, - }) - ); - } + if (item.OrderQty > availableFreeQty) { + // Split: Keep available free qty as free, convert excess to paid + const excessQty = item.OrderQty - availableFreeQty; - let withdiscTotal = - Total - ((OverAllSales || 0) + (OverAllEstimate || 0)); + // Create free portion (if any free qty available) + if (availableFreeQty > 0) { + const freeItem = { + ...item, + OrderQty: availableFreeQty, + TotalAmt: availableFreeQty * item.OrderRate, + TaxAmt: ( + (availableFreeQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + availableFreeQty * item.OrderRate - + (availableFreeQty * item.OrderRate * item.TaxPercentage) / + 100, + Offer: availableFreeQty * item.OrderRate, + }; - setTotalAmount( - withdiscTotal >= 0 - ? (Number(withdiscTotal) + Number(globalTipAmount)).toFixed(2) - : (Number(Total) + Number(globalTipAmount)).toFixed(2) - ); + ModifiedData.push(freeItem); - dispatch( - changeSummeryTotalAmount( - withdiscTotal > 0 ? withdiscTotal : Number(Total) - ) - ); - - dispatch(changeSummeryComboOfferAmount(withComboSum)); - - // if (withdiscTotal <= 0) { - // dispatch(ChangeOverAllDiscSales(0)); - // dispatch(ChangeOverAllDiscEstimate(0)); - // } - } else { - setTotalAmount(0); - dispatch(changeSummeryTotalAmount(0)); - dispatch(changeSummeryComboOfferAmount(0)); - } - }, [ - OrderCardDetail, - GlobalExtraCharge, - OverAllSales, - OverAllEstimate, - globalTipAmount, - OtherServiceTicketClaim, - ]); - useEffect(() => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - }; - dispatch(getPrinterMappingDetails(data)).unwrap(); - const Data1 = { AppId, CompId, BranchId }; - dispatch(getPrintSelectionComponentData(Data1)).unwrap(); - handleOtherData(); - }, []); - useEffect(() => { - if (!preferenceshortcutkey) return; - - const handleKeyPress = (event) => { - if (!event.altKey) return; - - const key = event.key.toLowerCase(); - - switch (key) { - case 'n': - event.preventDefault(); - setQuickOpen(); - break; - - case 'w': - event.preventDefault(); - if (canHold) { - AddBookingDetails('Hold'); - } else if (canRecall) { - HandleholdModelOpen(); - } - break; - - case 'a': - if (canExtracharge) { - event.preventDefault(); - handleextraCharges(); - } - break; - - case 'r': - if (canReprint) { - event.preventDefault(); - handleReprint(); - } - break; - - case 's': - if (canSplitPayment) { - event.preventDefault(); - SplitPaymentOpen(); - } - break; - - default: - break; - } - }; - - window.addEventListener('keydown', handleKeyPress); - return () => { - window.removeEventListener('keydown', handleKeyPress); - }; - }, [ - preferenceshortcutkey, - canHold, - canRecall, - canExtracharge, - canSplitPayment, - ]); - - useEffect(() => { - if (NavHoldData) { - AddBookingDetails('Hold'); - } - }, [NavHoldData]); //change by karthiga - //mohan stoped data - useEffect(() => { - if ( - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow - ) { - setOrderStatus(true); - } else { - setOrderStatus(false); - } - }, [BookingTypeBoth, BookingType, unpaidFlow]); - //mohan end - const paymentFailedStatusFun = async () => { - SetOpenFailData(!OpenFailData); - }; - // useEffect(() => { - // const handleKeyPress = (event) => { - // if (event.shiftKey && event.code === 'KeyM') { - // if ( - // document.activeElement.tagName !== 'INPUT' && - // document.activeElement.tagName !== 'TEXTAREA' - // ) { - // event.preventDefault(); - // setBlink(true); - // } - // } - // }; - // const handleClickOutside = (event) => { - // setBlink(false); - // }; - // window.addEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // return () => { - // window.removeEventListener('keydown', handleKeyPress); - // window.addEventListener('mousedown', handleClickOutside); - // }; - // }, []); - - const handleOtherData = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - }; - let response = await dispatch(OtherServicesCardlistdata(data)).unwrap(); - if (response?.data?.statusCode == 1) { - setOtherServiceStatus(true); - } else { - setOtherServiceStatus(false); - } - }; - - useEffect(() => { - if (SelCustId) { - setpaybtns(PaymentOptions); - } else { - const withoutCustomer = PaymentOptions?.filter?.( - (item) => item?.ModeName?.toLowerCase() !== 'credit' - ); - setpaybtns(withoutCustomer); - } - }, [PaymentUpiOptions, PaymentOptions, SelCustId]); - - useEffect(() => { - if (CompId && BranchId && AppId) { - getHolddata(); - getUnpaiddatas(); - getCustomerData(); - } - }, [CompId, BranchId, AppId]); - - useEffect(() => { - gettodaydate(); - getBookingTypeId(); - getPaymentOptionFeature(); - getPreferenceDinein(); - - // Combodata(); - BadgePendingApi(); - // if (UserType === "Employee") { - // fetchApi() - // } - }, []); - useEffect(() => { - if (UserType !== 'Super Admin' && UserType !== 'Super Admin User') { - getFeatureAddonData(); - } - }, [FeatureAddonData]); - useEffect(() => { - if (UserType === 'Employee') { - fetchApi(); - } - }, [UserType]); - useEffect(() => { - let hasAccess = false; - - if (UserType === 'Admin' || UserType === 'Super Admin') { - hasAccess = true; - } else if (UserType === 'Employee') { - hasAccess = empData?.AddAccess === 'Y'; - } else if (UserType === 'Super Admin User') { - hasAccess = SAAccessCommonMaster?.AddAccess === 'Y'; - } - - setaddnewAccess(!hasAccess); - }, [empData, SAAccessCommonMaster, UserType]); - useEffect(() => { - getBookingTypeId(); - }, [BookingType, BookingTypeBoth]); - - useEffect(() => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - ExtraCharges: GlobalExtraCharge, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }, [GlobalExtraCharge]); - useEffect(() => { - if ( - OrderCardDetail?.length === 1 && - OrderCardDetail?.[0]?.OrderQty === 1 && - !SelCustId - ) { - console.log(OrderCardDetail, 'OrderCardDetail'); - closePrintOption(); - setPrintOrderDetails([]); - } - }, [OrderCardDetail]); - useEffect(() => { - TotalItemsCalculation(); - TotalWithoutTaxRate(); - TotalTaxAmt(); - OrderCardDetail?.length == 0 ? dispatch(changeunpaidflow(false)) : ''; - }, [OrderCardDetail]); - useEffect(() => { - let data = selOption != null ? selOption : GetCustId; - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - customer: data, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }, [selOption, GetCustId]); - useEffect(() => { - let data = GlobalUpiID; - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - upi: data, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - setUpiOption(GlobalUpName); - setSelectedUpiOption(GlobalUpiIDoptionIdd); - setUpiId(GlobalUpiID); - }, [GlobalUpiID]); - useEffect(() => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - paymentMethod: Paybtnnameselected, - Paymentgateway: false, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }, [Paybtnnameselected]); - useEffect(() => { - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - }, [PaymentOptions]); - // useEffect(() => { - // if ( - // PrintOrderDetails?.length > 0 && - // (!filteredSettingNames || - // filteredSettingNames?.includes('Print') || - // filteredSettingNames?.length === 0) && - // ((!filteredSettingNames?.includes('whatsapp') && - // (!isMobile || !filteredSettingNames?.includes('SMS'))) || - // ((filteredSettingNames?.includes('whatsapp') || - // (isMobile && filteredSettingNames?.includes('SMS'))) && - // (!MobileNoWhatsApp || Object.keys(MobileNoWhatsApp).length === 0))) - // ) { - // handlePrintOrToken(); - // } - // }, [PrintOrderDetails]); - - useEffect(() => { - if (!PrintOrderDetails?.length) return; - - const selectedOptions = filteredSettingNames || []; - const count = selectedOptions.length; - - if (count === 0) { - handlePrintOrToken(); - return; - } - if (count === 1) { - const option = selectedOptions[0]; - - switch (option) { - case 'whatsapp': - if (!selOption && MobileNoWhatsApp?.value) { - handleWhatsAppClick(); - } else { - handlePrintOrToken(); - } - return; - - case 'SMS': - if (isMobile) handleSMSClick(); - else handlePrintOrToken(); - return; - - case 'Print': - handlePrintOrToken(); - return; - - // case "Email": - // handleEmailClick(); - // return; - - default: - return; - } - } - return; - }, [PrintOrderDetails]); - - useEffect(() => { - getPaymentOptionFeature(); - }, [GlobaluseOptions]); - const formatAmount = (value) => { - return allowDecimal - ? parseFloat(value || 0).toFixed(2) - : parseInt(value || 0); - }; - const handlePrintOrToken = async () => { - const dinein = - PrintOrderDetails?.[0]?.OrderDetails?.[0]?.productDetails?.some( - (product) => product.BookingTypeName === 'Dine In' - ); - const Tokenthere = - PrintOrderDetails?.[0]?.OrderDetails?.[0]?.productDetails?.some( - (product) => product.TokenAvailable === 'Y' - ); - const PrintLogo = SettingDataSelector?.[0]?.SettingDtlDetails?.filter( - (i) => i.SettingIdName === 'PrintLogo' - )?.[0]; - const PrintGreeting = SettingDataSelector?.[0]?.SettingDtlDetails?.filter( - (i) => i.SettingIdName === 'PrintGreetings' - )?.[0]; - const preferenceDetails = SettingDataSelector?.[0]?.SettingDtlDetails; - if (isMobile) { - if (MobileA4Print) { - await MobileMultiPdfPrintTrigger({ - preferenceDetails, - printerTemplateStyle, - printDatas, - PrinterDetails, - PrintOrderDetails, - SessionData, - bookingTypePreference, - }); - } else { - if (Tokenthere && TokenOnly?.SettingValue === 'Y' && !dinein) { - if (IndividualToken?.SettingValue === 'Y' && !dinein) { - IndividualTokenMobilePrint(PrintOrderDetails, UpiId, 'Booking'); - closePrintOption(); - } else { - SingleTokenMobilePrint(PrintOrderDetails, UpiId, 'Booking'); - closePrintOption(); - } - } else { - MobilePrint( - appPreferences, - PrintOrderDetails, - UpiId, - 'Booking', - SettingDataSelector - ); - closePrintOption(); - } - } - } else { - if (Tokenthere && TokenOnly?.SettingValue === 'Y' && !dinein) { - AllProductTokenFunction(); - } else { - Print(); - } - } - }; - - const handleWhatsAppClick = () => { - setShowWhatsAppShare(true); - }; - const handleSMSClick = () => { - setSMSShare(true); - }; - - //dhana - // Function to check if the button is active - const isButtonActive = () => { - const baseCondition = - FirstPaymentclick === false && - OrderCardDetail?.length > 0 && - paybtnselected && - CheckBookingStatus !== 'Close'; - let accessCondition = true; - if (UserType === 'Employee') { - accessCondition = empData?.AddAccess === 'Y'; - } else if (UserType === 'Super Admin User') { - accessCondition = SAAccessCommonMaster?.AddAccess === 'Y'; - } - return baseCondition && accessCondition; - }; - - // Function to handle the button click - const handleButtonClick = () => { - if (qrCode && SelectedUPIPayOption === 'Default') { - UpiPayment(); - } else { - OrderStatus - ? AddBookingDetails('Dine-In', false) - : AddBookingDetails(BookingType, true); - } - }; - - useEffect(() => { - const handleKeyPress = (event) => { - if (event.key === 'F4' && isButtonActive() && !isF4Pressed.current) { - isF4Pressed.current = true; - // BranchFinancialStatus==='N'? financialYearError(): - handleButtonClick(); - setTimeout(() => { - isF4Pressed.current = false; // Reset after a short delay - }, 1000); - } - }; - - window.addEventListener('keydown', handleKeyPress); - return () => { - window.removeEventListener('keydown', handleKeyPress); - }; - }, [ - FirstPaymentclick, - OrderCardDetail, - paybtnselected, - OrderStatus, - qrCode, - SelectedUPIPayOption, - TotalAmount, - SelectedUpiOption, - SelectedCardOption, - ]); - - //dhana - const fetchApi = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - EmpId: UserId, - }; - let response = await dispatch(getEmpAccess(data)).unwrap(); - let datas = response?.data?.data?.[0]?.EmpAccessDetails?.filter( - (item) => item.ConfigName === 'Sales' - ); - setEmpData(datas?.[0]); - }; - const getCustomerData = async () => { - await dispatch( - getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) - ); - await dispatch( - getAddCustomerDetails({ - CompId: CompId, - AppId: AppId, - branchId: BranchId, - }) - ); - }; - const getPaymentOptionFeature = async () => { - const FiltersalesPayment = GlobaluseOptions?.filter( - (item) => item.FlowName?.toLowerCase() === 'sales' - ); - setuseOptions(FiltersalesPayment); - const filterpaycounter = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'pay at the counter' - ); - const filterpaymentgateway = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'payment gateway' - ); - const filterpaymentdevice = FiltersalesPayment?.[0]?.OptionDetails?.filter( - (item) => item?.OptionName?.toLowerCase() === 'payment device' - ); - const cardinpaymentgateway = - filterpaymentgateway?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('card') - ) || []; - const cardinpaymentdevice = - filterpaymentdevice?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('card') - ) || []; - const upiinpaymentgateway = - filterpaymentgateway?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('upi') - ) || []; - const upiinpaymentdevice = - filterpaymentdevice?.[0]?.ModeDetails?.filter((item) => - item?.ModeName?.toLowerCase()?.includes('upi') - ) || []; - - setPaymentOptions(filterpaycounter?.[0]?.ModeDetails); - setPaymentUpiOptions( - FiltersalesPayment?.[0]?.PaymentDetails?.Payatthecounter - ); - setPaymentDeviceCard(cardinpaymentdevice); - setPaymentgatewayCard(cardinpaymentgateway); - setPaymentgatewayUPI(upiinpaymentgateway); - setPaymentDeviceUPI(upiinpaymentdevice); - const cardoptions = []; - if (cardinpaymentgateway?.length > 0) { - cardoptions.push({ - label: 'Payment Gateway', - value: 'PG', - imgSrc: paygate, - }); - } - if (cardinpaymentdevice?.length > 0) { - cardoptions.push({ - label: 'Payment Device', - value: 'PD', - imgSrc: paydevice, - }); - } - setCardPayOption(cardoptions); - const options = []; - - if (FiltersalesPayment?.[0]?.PaymentDetails?.Payatthecounter?.length > 0) { - options.push({ - label: 'Personal UPI', - value: 'Default', - imgSrc: defaultupi, - }); - } - - if (upiinpaymentgateway?.length > 0) { - options.push({ label: 'Payment Gateway', value: 'PG', imgSrc: paygate }); - } - - if (upiinpaymentdevice?.length > 0) { - options.push({ label: 'Payment Device', value: 'PD', imgSrc: paydevice }); - } - setUpiPayOption(options); - // } - }; - - const getFeatureAddonData = async () => { - // let featureAddon = await dispatch( - // FeatureAddon({ AppId: AppId, UserId: UserId }) - // ).unwrap(); - // if (featureAddon?.data?.statusCode === 1) { - // setFeatureAddonData(featureAddon?.data?.data?.[0]?.FeatAddonHdr?.[0]); - const hasPaymentFeatures = FeatureAddonData?.FeatureDtls?.some( - (item) => - item.FeatureAddonName === 'Payment Gateway' || - item.FeatureAddonName === 'Payment Device' - ); - setpaymentfeataddon(hasPaymentFeatures); - // } else { - // setFeatureAddonData([]); - // setpaymentfeataddon([]); - // } - }; - const handlePaymentMode = (id, name) => { - if (name?.toLowerCase() !== 'credit') { - setOverAllBal(0); - setCredit(false); - } - if (paymentloader === false) { - setPaybtnselected(id); - setPaybtnnameselected(name); - if (CardPayOption?.length === 1) { - setSelectedCardOption(CardPayOption?.[0]?.value); - } - setUpiOptionOpen(false); - setQrCode(false); - setUpinotSelected(false); - setCardoptionnotSelected(false); - } - }; - - const AddCardOption = (data) => { - setSelectedCardOption(data); - setCardOptionOpen(false); - setCardoptionnotSelected(false); - }; - const AddUPIPaymentOption = async (data) => { - setSelectedUpiOption(''); - setUpiOption(''); - setUpiId(''); - await dispatch(changeUpiIDprint(null)); - await dispatch(changeUpiIDName('')); - await dispatch(changeUpiIDoptionId(null)); - setSelectedUPIPayOption(data); - setUpinotSelected(false); - setCardoptionnotSelected(false); - if (data !== 'Default') { - setUpiOptionOpen(false); - } - }; - const addUpiOption = async (id, name, UPIId) => { - await dispatch(changeUpiIDprint(UPIId)); - await dispatch(changeUpiIDName(name)); - await dispatch(changeUpiIDoptionId(id)); - setSelectedUpiOption(id); - setUpiOption(name); - setUpiId(UPIId); - setUpinotSelected(false); - setCardoptionnotSelected(false); - // setQrCode(true) - }; - const handleUPIButtonClick = (id, name) => { - if (paymentloader === false) { - setPaybtnnameselected(name); - setPaybtnselected(id); - let brachName1 = PaymentUpiOptions?.[0]?.BrName; - setbrachName(brachName1); - if (UpiPayOption?.length === 1) { - setSelectedUPIPayOption(UpiPayOption?.[0]?.value); - if (UpiPayOption?.[0]?.value?.toLowerCase() === 'default') { - if (PaymentUpiOptions?.length === 1) { - addUpiOption( - PaymentUpiOptions?.[0]?.Mode, - PaymentUpiOptions?.[0]?.ModeName, - PaymentUpiOptions?.[0]?.UPIId - ); - } - } - } - - setQrCode(true); - SetSuccess(true); - } - }; - const EnableUpiOptions = () => { - setUpiOptionOpen(!UpiOptionOpen); - }; - const EnableCardOptions = () => { - setCardOptionOpen(!CardOptionOpen); - }; - const gettodaydate = () => { - const currentDate = new Date(); - const day = String(currentDate.getDate()).padStart(2, '0'); - const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // Month is 0-based, so we add 1. - const year = currentDate.getFullYear(); - - const tempformattedDate = `${year}-${month}-${day}`; - setFormattedDate(tempformattedDate); - }; - const getPreferenceDinein = async () => { - // const response = await dispatch( - // getPreferenceData({ CompId: CompId, BranchId: BranchId, AppId: AppId }) - // ).unwrap(); - // if (response?.data?.statusCode === 1) { //comment by karthiga - const PreferenceDineDtl = SettingDataSelector?.[0]?.SettingDtlDetails; - const DineinPreference = PreferenceDineDtl.find( - (item) => item.SettingIdName === 'DineIn' - ); - setDineInPreference(DineinPreference || {}); - // } else { - // setDineInPreference(); - // } - }; - const ChangeTakeAway = async () => { - await dispatch(changeBookingType('TakeAway')); - }; - const getBookingTypeId = async () => { - let tempconfigdata = await dispatch( - getConfigType({ TypeName: 'Booking Type' }) - ).unwrap(); - - if (tempconfigdata?.data?.statusCode == 1) { - setConfigDataList(tempconfigdata?.data?.data); - let configdata = tempconfigdata?.data?.data; - let checkName = BookingTypeBoth ? 'DineIn,TakeAway' : BookingType; - - let filterconfigdata = configdata?.find( - (a) => a?.ConfigName === checkName - ); - setSelectedBookingType(filterconfigdata?.ConfigId); - } - }; - - const TokenPrint = async (index) => { - try { - console.log(`Starting token print for index ${index}`); - - const stylePrint = ``; - if (TokenOnly?.SettingValue === 'Y') { - if (IndividualToken?.SettingValue === 'Y') { - await printDiv(`TokenOnlySingle${index}`, stylePrint); - } else { - await printDiv(`TokenOnlyMultiple${index}`, stylePrint); - } - } else { - await printDiv(`TakeawayToken${index}`, stylePrint); - } - } catch (error) { - console.error(`Error printing token for index ${index}:`, error); - } - }; - const AllProductTokenFunction = async () => { - if (IndividualToken?.SettingValue === 'Y') { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - const groupedTokens = orderDetail?.productDetails?.reduce( - (acc, item, idx) => { - if (item.TokenAvailable === 'Y') { - if (!item.CounterName) { - // If CounterName is null or empty - acc[`single-${idx}-${item.ProdId}`] = [item]; // Unique entry for each null/empty CounterName item - } else { - if (!acc[item.CounterName]) { - acc[item.CounterName] = []; - } - acc[item.CounterName].push(item); // Group by CounterName - } - } - return acc; - }, - {} - ); - - // Iterate over grouped tokens and print them - const tokensToPrint = Object.entries(groupedTokens).map( - async ([counterName, items], idx) => { - // Use the counterName (or unique identifier for individual items) as part of the tokenId - const tokenId = `${idx}-${items?.[0]?.ProdId}-${counterName}`; - await TokenPrint(tokenId, items); // Pass all grouped items to the print function - } - ); - if (tokensToPrint?.length > 0) { - await Promise.all(tokensToPrint); + // Create applied offer + AppliedOffers.push( + createAppliedOffer( + matchingFreeProduct, + availableFreeQty, + item.InwardDtlId, + item.OrderRate, + item.BookingTypeName + ) + ); } - setPrintOrderDetails([]); - closePrintOption(); - } - ) - ); - } else { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - await TokenPrint(`${index}-${orderDetail?.OrderId}`); - } - ) - ); - setPrintOrderDetails([]); - closePrintOption(); - } - }; - const getHolddata = async () => { - const data = { CompId: CompId, BranchId: BranchId, AppId: AppId }; - let response = await dispatch(gettinghold(data)).unwrap(); - if (response?.data?.statusCode == 1) { - dispatch(changeholddata(response?.data?.data)); - } else { - dispatch(changeholddata([])); - } - }; - const getUnpaiddatas = async () => { - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - }; - await dispatch(getUnpaidData(data)).unwrap(); - }; + // Handle excess quantity - look for existing paid item in original cart + const existingPaidItem = orderCardDtls.find( + (cartItem) => + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.localId !== item.localId && + (!cartItem.Offer || cartItem.Offer === 0) && + !cartItem.OfferType && + !cartItem.OfferMode + ); - const TotalItemsCalculation = async () => { - let tempTotalitems = OrderCardDetail?.length; - let OverAllQty = OrderCardDetail?.reduce((acc, item) => { - const isWeightScale = item?.ScaleType === 'weight'; + if ( + existingPaidItem && + !processedItems.has(existingPaidItem.localId) + ) { + // Merge excess with existing paid item + const mergedPaidItem = { + ...existingPaidItem, + OrderQty: existingPaidItem.OrderQty + excessQty, + TotalAmt: + (existingPaidItem.OrderQty + excessQty) * item.OrderRate, + TaxAmt: ( + ((existingPaidItem.OrderQty + excessQty) * + item.OrderRate * + item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + (existingPaidItem.OrderQty + excessQty) * item.OrderRate - + ((existingPaidItem.OrderQty + excessQty) * + item.OrderRate * + item.TaxPercentage) / + 100, + }; - if (isWeightScale) { - return ( - acc + (Weightasquantity ? Math.round(Number(item?.OrderQty || 0)) : 1) - ); - } + ModifiedData.push(mergedPaidItem); + processedItems.add(existingPaidItem.localId); // Mark as processed + } else { + // Create new paid item for excess quantity + const paidItem = { + ...item, + OrderQty: excessQty, + TotalAmt: excessQty * item.OrderRate, + TaxAmt: ( + (excessQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + excessQty * item.OrderRate - + (excessQty * item.OrderRate * item.TaxPercentage) / 100, + Offer: 0, + OfferType: undefined, + OfferMode: undefined, + OfferMessage: undefined, + localId: item.localId + '_paid', + }; - return acc + Math.round(Number(item?.OrderQty || 0)); - }, 0); - setTotalItems(tempTotalitems); - setQty(OverAllQty); - }; - const Print = async () => { - const style = await PrintStyleFunction( - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle, - 'Sales' - ); + ModifiedData.push(paidItem); + } + } else if (availableFreeQty > 0) { + // All quantity can remain free + const isAlreadyExists = ModifiedData?.findIndex( + (data) => + data?.OfferMode === item?.OfferMode && + data?.InwardDtlId === item?.InwardDtlId && + data?.ProdId === item?.ProdId && + data?.OfferMessage?.[0]?.OfferId === + item?.OfferMessage?.[0]?.OfferId + ); - const stylesMap = { - 'Style 1': 'PrintStyle1', - 'Style 2': 'PrintStyle2', - 'Style 3': 'PrintStyle3', - 'Style 4': 'PrintStyle4', - 'Style 5': 'PrintStyle5', - 'Style 6': 'PrintStyle6', - 'Style 7': 'PrintStyle7', - 'Style 8': 'PrintStyle8', - 'Style 9': 'PrintStyle9', - 'Style 10': 'PrintStyle10', - 'Style 11': 'PrintStyle11', - 'Style 12': 'PrintStyle12', - 'Style 13': 'RePrint', - A4: 'PrintStyleA4', - A5: 'PrintStyleA5', - A4Standard: 'A4Standard', - TaxInvoice: 'TaxInvoice', - }; + if (isAlreadyExists !== -1) { + // Merge with existing free item + ModifiedData[isAlreadyExists] = { + ...ModifiedData[isAlreadyExists], + OrderQty: + ModifiedData[isAlreadyExists].OrderQty + item.OrderQty, + TotalAmt: + (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * + item.OrderRate, + TaxAmt: ( + ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * + item.OrderRate * + item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * + item.OrderRate - + ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * + item.OrderRate * + item.TaxPercentage) / + 100, + Offer: + (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * + item.OrderRate, + }; + } else { + // Create new free item + const newFreeItem = { + ...item, + TotalAmt: item.OrderQty * item.OrderRate, + TaxAmt: ( + (item.OrderQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + item.OrderQty * item.OrderRate - + (item.OrderQty * item.OrderRate * item.TaxPercentage) / 100, + Offer: item.OrderQty * item.OrderRate, + }; - const selectedStyle = - stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle - ]; + ModifiedData.push(newFreeItem); + } - if (selectedStyle) { - await Promise.all( - PrintOrderDetails?.[0]?.OrderDetails?.map( - async (orderDetail, index) => { - await printDiv(`${selectedStyle}-${index}`, style); // Use unique IDs for each print - if (orderDetail?.BookingTypeName !== 'Dine In') { - const groupedTokens = orderDetail?.productDetails?.reduce( - (acc, item, idx) => { - if (item.TokenAvailable === 'Y') { - if (!item.CounterName) { - // If CounterName is null or empty - acc[`individual-${idx}-${item.ProdId}`] = [item]; // Unique entry for each null/empty CounterName item - } else { - if (!acc[item.CounterName]) { - acc[item.CounterName] = []; - } - acc[item.CounterName].push(item); // Group by CounterName - } - } - return acc; + const appliedOfferAlreadyExists = AppliedOffers.findIndex( + (offer) => + offer?.FreeProductsList?.FreeProdId === + matchingFreeProduct?.FreeProdId && + offer?.TableName === matchingFreeProduct?.TableName && + offer?.TableUniqueName === + matchingFreeProduct?.TableUniqueName && + offer?.OfferId === matchingFreeProduct?.OfferId && + offer?.OfferMode === matchingFreeProduct?.OfferMode && + offer?.FreeProductsList?.ProdVariantDetails?.[0] + ?.StockDetails?.[0]?.FreeInwardDtlId === item?.InwardDtlId + ); + + if (appliedOfferAlreadyExists !== -1) { + AppliedOffers[appliedOfferAlreadyExists] = { + ...AppliedOffers[appliedOfferAlreadyExists], + ActualOfferAmount: + AppliedOffers[appliedOfferAlreadyExists].ActualOfferAmount + + item.OrderQty * item.OrderRate, + ActualFreeQty: + AppliedOffers[appliedOfferAlreadyExists].ActualFreeQty + + item.OrderQty, + OfferAmount: + (AppliedOffers[appliedOfferAlreadyExists].ActualFreeQty + + item.OrderQty) * + item.OrderRate, + OfferValue: + (AppliedOffers[appliedOfferAlreadyExists].ActualFreeQty + + item.OrderQty) * + item.OrderRate, + UsedCount: + (matchingFreeProduct?.ProdVariantDetails?.[0] + ?.StockDetails?.[0]?.ProdLoyaltyPoint || 0) * + (AppliedOffers[appliedOfferAlreadyExists].ActualFreeQty + + item.OrderQty), + FreeProductsList: { + ...AppliedOffers[appliedOfferAlreadyExists].FreeProductsList, + FreeQty: + AppliedOffers[appliedOfferAlreadyExists].FreeProductsList + .FreeQty + item.OrderQty, }, - {} + }; + } else { + // Create applied offer + AppliedOffers.push( + createAppliedOffer( + matchingFreeProduct, + item.OrderQty, + item.InwardDtlId, + item.OrderRate, + item.BookingTypeName + ) ); - - // Iterate over grouped tokens and print them - const tokensToPrint = Object.entries(groupedTokens).map( - async ([counterName, items], idx) => { - // Use the counterName (or unique identifier for individual items) as part of the tokenId - const tokenId = `${idx}-${items?.[0]?.ProdId}-${counterName}`; - await TokenPrint(tokenId, items); // Pass all grouped items to the print function - } - ); - if (tokensToPrint?.length > 0) { - await Promise.all(tokensToPrint); - } } - } - ) - ); + } else { + // No free quantity available, convert to paid + const paidItem = { + ...item, + Offer: 0, + OfferType: undefined, + OfferMode: undefined, + OfferMessage: undefined, + TotalAmt: item.OrderQty * item.OrderRate, + TaxAmt: ( + (item.OrderQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + item.OrderQty * item.OrderRate - + (item.OrderQty * item.OrderRate * item.TaxPercentage) / 100, + }; - setPrintOrderDetails([]); - closePrintOption(); - } + ModifiedData.push(paidItem); + } + } else { + // No matching free product found, convert to paid + const paidItem = { + ...item, + Offer: 0, + OfferType: undefined, + OfferMode: undefined, + OfferMessage: undefined, + }; + + ModifiedData.push(paidItem); + } + } else { + // Item is not currently free, check if it can become free + const matchingFreeProduct = updatedFreeProdList.find( + (freeProd) => + freeProd.ProdVariantDetails?.some((variant) => + variant.StockDetails?.some( + (stock) => stock.FreeInwardDtlId === item.InwardDtlId + ) + ) && freeProd.RemainingQty > 0 + ); + + if (matchingFreeProduct) { + const availableFreeQty = Math.min( + item.OrderQty, + matchingFreeProduct.RemainingQty + ); + + if (availableFreeQty > 0) { + // Create free item for available free quantity + const freeItem = { + ...item, + OrderQty: availableFreeQty, + TotalAmt: availableFreeQty * item.OrderRate, + TaxAmt: ( + (availableFreeQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + availableFreeQty * item.OrderRate - + (availableFreeQty * item.OrderRate * item.TaxPercentage) / 100, + Offer: availableFreeQty * item.OrderRate, + OfferType: matchingFreeProduct.OfferMode, + OfferMode: matchingFreeProduct.OfferMode, + OfferMessage: [ + { + OfferId: matchingFreeProduct.OfferId, + FreeQty: availableFreeQty, + FreeProdId: matchingFreeProduct.FreeProdId, + FreeProdName: matchingFreeProduct.FreeProdName, + }, + ], + localId: item.localId + '_free', + }; + + ModifiedData.push(freeItem); + + // Update free product usage + matchingFreeProduct.FreeQty = + (matchingFreeProduct.FreeQty || 0) + availableFreeQty; + matchingFreeProduct.RemainingQty -= availableFreeQty; + + // Create applied offer + AppliedOffers.push( + createAppliedOffer( + matchingFreeProduct, + availableFreeQty, + item.InwardDtlId, + item.OrderRate, + item.BookingTypeName + ) + ); + + // If there's remaining paid quantity + if (item.OrderQty > availableFreeQty) { + const paidQty = item.OrderQty - availableFreeQty; + const paidItem = { + ...item, + OrderQty: paidQty, + TotalAmt: paidQty * item.OrderRate, + TaxAmt: ( + (paidQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: + paidQty * item.OrderRate - + (paidQty * item.OrderRate * item.TaxPercentage) / 100, + }; + + ModifiedData.push(paidItem); + } + } else { + // No free quantity available, keep as paid + ModifiedData.push(item); + } + } else { + // No matching free product or no remaining free quantity + ModifiedData.push(item); + } + } + + processedItems.add(item.localId); + }); + + return { + ModifiedData, + UpdatedFreeProdList: updatedFreeProdList, + AppliedOffers, + }; + } + + const openExpireModal = ({ title, onOk, onCancel }) => { + setExpireModal({ + open: true, + title, + onOk, + onCancel, + }); }; + const closeExpireModal = () => { + setExpireModal((prev) => ({ ...prev, open: false })); + }; + + async function getOffers() { + await dispatch( + getOfferinBooking({ AppId: AppId, CompId: CompId, BranchId: BranchId }) + ).unwrap(); + } + + useEffect(() => { + const filteredOffers = OrderOfferDetail?.filter( + ({ TableName, TableUniqueName, OfferCode, Type, FreeProductsList }) => { + if ( + (TableName === 'LoyaltyPoints' && + TableUniqueName === 'UniqueId' && + Type === 'A') || + ((TableName === 'CustomerPromo' || + TableName === 'CustomerCoupon' || + TableName === 'OfferCode') && + OfferCode != null && + TableUniqueName === 'UniqueId') + ) { + return FreeProductsList?.ExistingList?.length > 0; + } + if (TableName === 'BuyXGetXOffers') return true; + } + ); + // setfreeProductsOffers(filteredOffers); + + getOffers(); + }, [OrderOfferDetail]); + + useEffect(() => { + if (SelectedCardFont) { + WebFont.load({ + google: { + families: [SelectedCardFont], // Load the selected font + }, + }); + } + }, [SelectedCardFont]); + + const cardData = !globalAccessForOthers + ? CardAccess + ? SelectedDatas?.length > 1 + ? SelectedDatas + : SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0 + ? [] + : SelectedDatas + : ItemCard?.length == 0 || + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + ? noSubcatCardData + : ItemCard + : ''; + + const cardDataForNewPrd = !globalAccessForOthers + ? CardAccess + ? SelectedDatas + : ItemCard?.length == 0 + ? noSubcatCardData + : ItemCard + : ''; + // + function safeRound(amountStr) { - if (amountStr == null) return '0.00'; + if (amountStr == null) return allowDecimal ? '0.00' : '0'; const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); const num = Number(cleaned); - return isNaN(num) ? '0.00' : num.toFixed(2); // return as string with 2 decimals + if (isNaN(num)) return allowDecimal ? '0.00' : '0'; + + return allowDecimal ? num.toFixed(2) : Math.round(num).toString(); } - const TotalWithoutTaxRate = async () => { - const totalwithouttax = OrderCardDetail?.reduce((accumulator, card) => { - return accumulator + parseFloat(card.WithoutTaxRate || 0); - }, 0); - setTotalWithoutTaxAmount(totalwithouttax.toFixed(2)); - await dispatch( - changeSummeryTotalWithoutTaxAmount(totalwithouttax.toFixed(2)) - ); - }; - const TotalTaxAmt = async () => { - const totaltax = OrderCardDetail?.reduce((accumulator, card) => { - return accumulator + parseFloat(card.TaxAmt || 0); - }, 0); - setTotalTaxAmount(totaltax.toFixed(2)); - await dispatch(changeSummeryTotalTaxAmount(totaltax.toFixed(2))); - }; - const HandleholdModelOpen = () => { - setHold(true); - }; - - const handleHoldCancel = () => { - setHold(false); - }; - const handleAddCustomer = () => { - if (Custdisable === false) { - setAddCustomer(true); + useEffect(() => { + // fetchedit(); + getPreferenceStock(); + // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission + }, [preferenceDatas]); + useEffect(() => { + if (AppId && CompId && BranchId) { + // fetchedit(); + GetmultipleSearchData(); } - }; - const handleAddCustomerCancel = () => { - setAddCustomer(false); - }; - const handleOpenChange = (newOpen) => { - setOpen(newOpen); - }; - const hide = () => { - setOpen(false); - }; - const hideDefault = () => { - setUpiOptionOpen(false); - }; - const handlePopoverVisibleChange = (visible) => { - setUpiOptionOpen(visible); - }; + // dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission + }, [AppId, CompId, BranchId]); - const handleextraCharges = () => { - setExtraCharges(true); - }; - const handleextraChargesCancel = () => { - setExtraCharges(false); - }; - - const handleQuickCancel = async () => { - await dispatch(changeCompoPaymentIconStatus(false)); - // - setQuickAdd(false); - }; - const setQuickOpen = async () => { - await dispatch(changeCompoPaymentIconStatus(true)); - setQuickAdd(true); - }; - - const ProductSummary = (salesData) => { - // Create a map to store the aggregated values for each unique product - const productMap = new Map(); - // Iterate over the sales data to aggregate values - salesData.forEach((item) => { - const key = `${item.ProdId}-${item.InwardDtlId}-${item.BookingType}-${item.SinglePc}-${item.OrderRate}`; - if (productMap.has(key)) { - const existingItem = productMap.get(key); - existingItem.OrderQty += item.OrderQty || 0; - existingItem.TotalAmt += item.TotalAmt || 0; - existingItem.TaxAmt = - parseFloat(existingItem.TaxAmt) + parseFloat(item.TaxAmt) || 0; - // existingItem.WithoutTaxRate += parseFloat(item.WithoutTaxRate) || 0; - } else { - // If the key doesn't exist, add a new entry - productMap.set(key, { ...item }); - } - }); - - // Convert the map values back to an array - const aggregatedProducts = Array.from(productMap.values()); - - return aggregatedProducts; - }; - const handleCreditCustomer = (type) => { - setCreditCustomer(false); - if (type == 'Submit') { - Booking(BookingType, true); - } - if (type == 'Cancel') { - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - } - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - const BadgePendingApi = async () => { - let Data = { - compId: CompId, - branchId: BranchId, - appId: AppId, - deliveryStatus: 'P', + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, }; - let PendingResponse = await dispatch(PreOrderGet(Data)).unwrap(); - if (PendingResponse?.data?.statusCode === 1) { - await dispatch( - changePreOrderPendingCount(PendingResponse?.data?.data?.length) - ); + + try { + const response = await dispatch(getmultipleSearch(data)); + } catch (error) { + console.error('Get Search Terms Error:', error); } }; useEffect(() => { - if (OrderCardDetail?.length <= 0) { - dispatch(changeCustomerID(null)); - dispatch(changeSelectedCustId(null)); - dispatch(changeSelectedOption(null)); - dispatch(ChangeSelectedCustDisable(false)); - } - }, [OrderCardDetail]); - - const ClearAllGlobalStateDatas = async (value) => { - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer([]); - } else { - dispatch(changeOrderCardDetails([])); - } - dispatch(changeTipAmount(0)); - await dispatch(ChangeTotalAmount([])); - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); - setFirstPaymentclick(false); - await dispatch(ChangeNavHoldData(false)); - await dispatch(changeCustomerID(null)); - await dispatch(changeSelectedCustId(null)); - await dispatch(changeSelectedOption(null)); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - setQrCode(false); - setUpinotSelected(false); - getHolddata(); - getUnpaiddatas(); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeSelProdWiseEst([])); - await dispatch(ChangeOverAllDiscSales(0)); - await dispatch(ChangeOverAllDiscEstimate(0)); - // await dispatch(changeEstimateBooking(null)) - // clearInvoiceDate - clearInvoiceDate(); - dispatch(changeCurrentOrderId(null)); - await dispatch(changeSelectTable([])); - await dispatch(changeSelectChair([])); - await dispatch(changeSelectedTableDetails([])); - await dispatch(changeOrderType()); - if (value === 'Dine-In') { - navigate(`${subDirectory}sales/dine-in`); - } - let data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - UserId: UserId, - FromDate: currentDateValue, - ToDate: currentDateValue, - }; - await dispatch(getSalesDetailData(data)); - }; - - const AddBookingDetails = async (value, pay) => { - const customerDisplayWindow = getCustomerDisplayWindow(); - - const OnUpiSelected = PaymentOptions?.find( - (item) => item.ModeId === paybtnselected - ); + setPreOrderSelectedProdNames([]); + // dispatch(changePreOrderAdditem(null)); + }, [preOrder]); + useEffect(() => { if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + ProdCat && + ProdSubCat !== NaN && + initialRun && + 'BookingSubCategory' in templateData ) { - SetSuccess(false); - setTimeout(function () { - SetSuccess(true); - // Add your state change code here - // For example: - // setNewState(newValue); - }, 3000); - if (SelectedUpiOption) { - Booking(value, pay); - } else { - setUpinotSelected(true); - setMessageType('error'); - setMessageData('Please Select Upi Option'); + productCardList(); + } + }, [ProdSubCat, productCardTrigger]); + useEffect(() => { + if ( + !initialRun && + (!ProdSubCat || ProdSubCat != NaN || ProdSubCat === 'NaN') && + ProdCat + ) { + setInitialRun(true); + productCardList(); + } + if ( + initialRun && + !('BookingSubCategory' in templateData) && + (!ProdSubCat || ProdSubCat != NaN || ProdSubCat === 'NaN') && + ProdCat + ) { + productCardList(); + } + }, [ProdCat, initialRun]); + useEffect(() => { + if (noSubcatCardData) { + setNoSubcatCardData(); + } + + if ( + ProductSearch?.length > 5 && + GetmultipleSearchDatas.some((e) => e.toLowerCase() === 'qrcode') + ) { + setQuickAdd(true); + } + }, [ProductSearch, GetmultipleSearchDatas]); + + const productCardList = async () => { + //condition + if ( + (templateData?.BookingLayout?.[1]?.some( + (item) => item?.OptionName === 'SubCategory' + ) || + templateData?.BookingCategory?.[0] == 'Category5') && + ProdSubCat && + ProdCat + ) { + let data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + ProdSubCat: ProdSubCat, + ...(AvailableDate && selectedDate + ? { + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } + : {}), + }; + //mohan + let response = await dispatch(getLayoutproductCard(data)).unwrap(); + if (response?.data?.statusCode == 1) { + setNoSubcatCardData(response?.data?.data); } } else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'card' && - PaymentgatewayCard?.length > 0 && - PaymentDeviceCard?.length > 0 + !templateData?.BookingLayout?.[1]?.some( + (item) => item?.OptionName === 'SubCategory' + ) && + templateData?.BookingCategory?.[0] != 'Category5' && + ProdCat ) { - if (SelectedCardOption) { - if (SelectedCardOption?.toLowerCase() === 'pg') { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); + let data = { + compId: CompId, + branchId: BranchId, + appId: AppId, + prodCat: ProdCat, + }; + + // 👇 only add date if AvailableDate is true + if (AvailableDate && selectedDate) { + data.date = selectedDate; + } + + let response = await dispatch(getCardDataWithoutSubmodule(data)).unwrap(); + + if (response?.data?.statusCode == 1) { + setNoSubcatCardData(response?.data?.data); + } + } else if ( + (templateData?.BookingLayout?.[1]?.some( + (item) => item?.OptionName === 'SubCategory' + ) || + templateData?.BookingCategory?.[0] == 'Category5') && + !ProdSubCat && + ProdCat && + ProdSubCat != 'NaN' + ) { + let data = { + compId: CompId, + branchId: BranchId, + appId: AppId, + prodCat: ProdCat, + ...(AvailableDate && selectedDate + ? { + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } + : {}), + }; + + let response = await dispatch(getCardDataWithoutSub(data)).unwrap(); + + if (response?.data?.statusCode == 1) { + setNoSubcatCardData(response?.data?.data); + } + } + }; + + useEffect(() => { + DispatchData(); + }, [SelectedProdNames]); + const DispatchData = async () => { + await dispatch(ChangeAllItemData(SelectedProdNames)); + }; + + useEffect(() => { + if (Object.keys(WSProductdata)?.length > 0) { + AddOrderDetails(WSProductdata); + } + }, [WSProductdata]); + + useEffect(() => { + if (ItemCard?.[0]?.QrBasedSearch === 'Y') { + if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) { + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); + setItem(ItemCard?.[0]); + } else { + setQtydata(ItemCard?.[0]); + SingleQuantity(ItemCard?.[0], false); + } + } else if (ItemCard?.[0]?.OnePcQRBased === 'Y') { + if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) { + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(Item), + }); + setItem(ItemCard?.[0]); + setOnePeiceFlow(true); + } else { + setQtydata(ItemCard?.[0]); + SingleQuantity(ItemCard?.[0], true); + } + } + }, [ItemCard]); + + useEffect(() => { + // let data = otherscarddata + if (Object.keys(otherscarddata)?.length > 0) { + let data = { + Type: otherscarddata?.Type ? otherscarddata?.Type : 'P', + OverallQuantity: otherscarddata?.OverAllQty, + ActiveStatus: otherscarddata?.ActiveStatus, + AvailableFrom: otherscarddata?.AvailableFrom, + AvailableTo: otherscarddata?.AvailableTo, + Cess: otherscarddata?.Cess, + ExpDate: otherscarddata?.ExpDate, + HSNCode: otherscarddata?.HSNCode, + ManufDate: otherscarddata?.ManufDate, + OpeningQty: otherscarddata?.OpeningQty, + ProdType: otherscarddata?.ProdType, + PartNumber: otherscarddata?.PartNumber, + ProdId: otherscarddata?.ProdId, + ProdLogo: otherscarddata?.ProdLogo, + ProdName: otherscarddata?.ProdName, + QRCode: otherscarddata?.QRCode, + QtyBasedPrice: otherscarddata?.QtyBasedPrice, + Rack: otherscarddata?.Rack, + Size: otherscarddata?.Size, + StockAvailable: otherscarddata?.StockAvailable, + TaxId: otherscarddata?.TaxId, + TaxPercentage: otherscarddata?.TaxPercentage, + TaxName: otherscarddata?.TaxIdName, + UniqueId: otherscarddata?.UniqueId, + UomName: otherscarddata?.UomName, + ProdVariantName: otherscarddata?.ProdVariantName, //sri + BalanceQty: otherscarddata?.BalanceQty, + BatchRef: otherscarddata?.BatchRef, + ModelNumber: otherscarddata?.ModelNumber, //sri + FullProductIdentifierDtls: otherscarddata?.FullProductIdentifierDtls, //sri + InwardDate: otherscarddata?.InwardDate, + InwardDtlId: otherscarddata?.InwardDtlId, + InwardId: otherscarddata?.InwardId, + MRP: otherscarddata?.MRP, + Offer: otherscarddata?.OfferPrice, + OrderRate: otherscarddata?.SellPrice, + SellingPrice: otherscarddata?.SellPrice, // edit srii + SuppId: otherscarddata?.SuppId, + SuppName: otherscarddata?.SuppName, + OrderQty: otherscarddata?.Quantity, + OtherProduct: otherscarddata?.OtherProduct, + // 'ProdVariantName': otherscarddata?.ProdVariantName, + BookingTypeName: BookingType, + CounterName: '', //sri + }; + AddOrderDetails(data); + } + // data["OrderRate"] = otherscarddata?.SellPrice + }, [otherscarddata]); + + useEffect(() => { + if (Object.keys(NewQrProductData)?.length > 0) { + let addQrProductData = { ...NewQrProductData }; + addQrProductData['OrderRate'] = addQrProductData['SellPrice']; + addQrProductData['OrderQty'] = addQrProductData['Quantity']; + addQrProductData['SellingPrice'] = addQrProductData['SellPrice']; + addQrProductData['BookingTypeName'] = BookingType; + AddOrderDetails(addQrProductData); + } + }, [NewQrProductData]); + + const getPreferenceStock = async () => { + const PreferenceStckDtl = preferenceDatas?.[0]?.SettingDtlDetails; + const StockPreference = PreferenceStckDtl?.find( + (item) => item.SettingIdName === 'StockSelection' + ); + setStockPreferenceDetail(StockPreference); + const BillOrder = PreferenceStckDtl?.find( + (item) => item.SettingIdName === 'BillItemsOrder' + ); + setBillOrderPre(BillOrder?.SettingValue); + + const expiredDate = + PreferenceStckDtl?.find( + (item) => item.SettingIdName === 'ExpiredSelection' + )?.SettingValue === 'Y'; + setExpiredProduct(expiredDate); + }; + + const CloseModal = () => { + setModelQty(false); + setRepeatedModel(false); + setProdexpir(false); + setOnePeiceFlow(false); + setSelectedBrand('Others'); + }; + const CloseModal1 = () => { + setModelstock(false); + setRepeatedModel(false); + setProdexpir(false); + setOnePeiceFlow(false); + }; + const CloseVarientModal = () => { + setModalVarient(false); + setRepeatedModel(false); + setProdexpir(false); + setOnePeiceFlow(false); + }; + + const Quantity = () => { + setModelQty(true); + }; + const SingleQuantity = (item, onePcs) => { + let count = item?.ProductDetail?.[0]?.ProdVariantDetails?.length; + if (count > 1) { + setModalVarient(true); + } else { + setVarientIndex(0); + SingleStockfun(item, onePcs); + } + }; + const SingleStockfun = (item, onePcs) => { + let count = + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.length; + if ( + StockPreferenceDetail?.SettingValue === 'Y' && + item?.ProductDetail?.[QtyIndex]?.StockAvailable == 'Y' + ) { + if (count > 1) { + setModelstock(true); + } else { + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePcs) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer(item, 0, 0, 0, onePcs); } else { - setMessageType('error'); - setMessageData('Please Select Customer'); + dataTransfer(item, 0, 0, 1, onePcs); } } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); + dataTransfer(item, 0, 0, 0, onePcs); } } else { - Booking(value, pay); + if (Isincart && Isincart?.StockAvailable === 'Y') { + if (Isincart?.BalanceQty > Isincart?.OrderQty) { + dataTransfer(item, 0, 0, 0, onePcs); + } else { + dataTransfer(item, 0, 0, 1, onePcs); + } + } else { + dataTransfer(item, 0, 0, 0, onePcs); + } + } + } + } else { + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePcs) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1) + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer(item, 0, 0, 0, onePcs); + } else { + dataTransfer(item, 0, 0, 1, onePcs); + } + } else { + dataTransfer(item, 0, 0, 0, onePcs); } } else { - setCardoptionnotSelected(true); - setMessageType('error'); - setMessageData('Please Select Card Option'); - } - } else if (OnUpiSelected?.ModeName?.toLowerCase() === 'credit') { - if (!SelCustId) { - setMessageType('error'); - setMessageData('Please Select Customer'); - } else { - setCreditCustomer(true); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderTotalAmount: TotalAmount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); + if (Isincart && Isincart?.StockAvailable === 'Y') { + if (Isincart?.BalanceQty > Isincart?.OrderQty) { + dataTransfer(item, 0, 0, 0, onePcs); + } else { + dataTransfer(item, 0, 0, 1, onePcs); + } } else { - console.error( - 'Customer display window is not available or has been closed.' + dataTransfer(item, 0, 0, 0, onePcs); + } + } + } + }; + + const Stockfun = (index) => { + setVarientIndex(index.key); + const variantDetails = + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] || {}; + const overallExpStatus = variantDetails.OverAllExpStatus; + const count = variantDetails.StockDetails?.length || 0; + + if ( + StockPreferenceDetail?.SettingValue === 'Y' && + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable == 'Y' + ) { + if (count > 1) { + if ( + overallExpStatus === 'N' || + (overallExpStatus === 'Y' && prodexpir) + ) { + setModalVarient(false); + setModelstock(true); + setVarItem(index.key); + if (overallExpStatus === 'Y' && prodexpir) { + setRepeatedModel(true); + } + } else if (overallExpStatus === 'Y' && ExpiredProduct) { + setVarItem(index.key); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); + } + } else { + if ( + overallExpStatus === 'N' || + (overallExpStatus === 'Y' && prodexpir) + ) { + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePeiceFlow) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1) + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } else { + dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow); + } + } else { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } + } else { + if (Isincart && Isincart?.StockAvailable === 'Y') { + if (Isincart?.BalanceQty > Isincart?.OrderQty) { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } else { + dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow); + } + } else { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } + } + + setModelQty(false); + setSelectedBrand('Others'); + setVarItem(index.key); + if (overallExpStatus === 'Y' && prodexpir) { + setProdexpir(false); + setRepeatedModel(true); + return; + } + } else if (overallExpStatus === 'Y' && ExpiredProduct) { + setVarItem(index.key); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); + return; + } + } + } else { + if (overallExpStatus === 'N' || (overallExpStatus === 'Y' && prodexpir)) { + const stockDetails = + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails; + console.log(stockDetails, CartOrderDetails, 'currIndex'); + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePeiceFlow) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1) + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } else { + dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow); + } + } else { + dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow); + } + } else { + const findNextAvailableStockIndex = ( + stockDetails, + CartOrderDetails, + prodId + ) => { + if (!stockDetails || stockDetails.length === 0) return 0; + + for (let i = 0; i < stockDetails.length; i++) { + const stock = stockDetails[i]; + + // Find if this specific stock is already in cart + const cartItem = CartOrderDetails?.find( + (item) => + item?.ProdId === prodId && + item?.InwardDtlId === stock?.InwardDtlId && + item?.OrderRate === stock?.SellPrice && + !item?.SalesId + ); + + // If not in cart, this stock has full balance available - use this + if (!cartItem) { + return i; + } + + // If in cart and NOT fully utilized, continue using this stock + if (cartItem && cartItem?.OrderQty < cartItem?.BalanceQty) { + return i; + } + + // If OrderQty === BalanceQty (fully utilized), move to next stock + // Continue the loop... + } + + // If all stocks are exhausted, return the last index + return stockDetails.length - 1; + }; + + const currentProdId = qtydata?.ProductDetail?.[QtyIndex]?.ProdId; + + // Find the next available stock index dynamically + const nextAvailableIndex = findNextAvailableStockIndex( + stockDetails, + CartOrderDetails, + currentProdId + ); + + dataTransfer( + qtydata, + QtyIndex, + index.key, + nextAvailableIndex, + onePeiceFlow + ); + } + + setModelQty(false); + setSelectedBrand('Others'); + setVarItem(index.key); + if (overallExpStatus === 'Y' && prodexpir) { + setProdexpir(false); + setRepeatedModel(true); + return; + } + } else if (overallExpStatus === 'Y' && ExpiredProduct) { + setVarItem(index.key); + openExpireModal({ + title: 'Variant Expires', + onOk: () => expVerFun(VarItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); + return; + } + setModelQty(false); + setSelectedBrand('Others'); + } + }; + const VarientFun = (index) => { + const QtyExpire = index?.ProdVariantDetails.every( + (item) => item.OverAllExpStatus === 'Y' + ); + if (QtyExpire && ExpiredProduct) { + openExpireModal({ + title: 'Quantity Expires', + onOk: () => expQtyFun(qtyExpData), + onCancel: () => { + setRepeatedModel(false); + (setProdexpir(false), closeExpireModal()); + }, + }); + setQtyExpData(index); + } else { + const selectedProIndex = qtydata?.ProductDetail?.findIndex( + (item) => + item?.ProdId === index?.ProdId && + item?.Size === index?.Size && + item?.UomName === index?.UomName && + item?.Brand === index?.Brand + ); + + if (selectedProIndex !== -1) { + const count = + qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails + ?.length || 0; + + if (count > 1) { + setModelQty(false); + setSelectedBrand('Others'); + setModalVarient(true); + } else { + const item = { QtyIndex: selectedProIndex, VarientIndex: 0 }; + singleVarient(item); + setModelQty(false); + setSelectedBrand('Others'); + } + } + + setQtyIndex(selectedProIndex); + setVarientIndex(0); + setRepeatedModel(false); + } + }; + const singleVarient = (item) => { + let count = + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.length; + + if ( + StockPreferenceDetail?.SettingValue === 'Y' && + qtydata?.ProductDetail?.[item?.QtyIndex]?.StockAvailable == 'Y' + ) { + if (count > 1) { + setModalVarient(false); + setModelstock(true); + // setVarientIndex(index.key) + } else { + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePeiceFlow) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 1, + onePeiceFlow + ); + } + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } + } else { + if (Isincart && Isincart?.StockAvailable === 'Y') { + if (Isincart?.BalanceQty > Isincart?.OrderQty) { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 1, + onePeiceFlow + ); + } + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } + } + setModelQty(false); + setSelectedBrand('Others'); + } + } else { + let Isincart = CartOrderDetails?.find( + (cartItem) => + cartItem?.ProdId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + cartItem?.OrderRate === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && + !cartItem?.SalesId + ); + + if (onePeiceFlow) { + let Isincartonepc = CartOrderDetails?.filter( + (cartItem) => + cartItem?.ProdId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + cartItem?.InwardDtlId === + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && + // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) + !cartItem?.SalesId + ); + let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') { + if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 1, + onePeiceFlow + ); + } + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } + } else { + if (Isincart && Isincart?.StockAvailable === 'Y') { + if (Isincart?.BalanceQty > Isincart?.OrderQty) { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow + ); + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 1, + onePeiceFlow + ); + } + } else { + dataTransfer( + qtydata, + item?.QtyIndex, + item?.VarientIndex, + 0, + onePeiceFlow ); } } - } else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg' - ) { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); - } else { - setMessageType('error'); - setMessageData('Please Select Customer'); - } + setModelQty(false); + setSelectedBrand('Others'); + } + }; + const StockSelected = (item) => { + const stockDetails = + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[item.key] || {}; + const overallExpStatus = stockDetails?.OverAllExpStatus; + + if (overallExpStatus === 'N' || overallExpStatus === 'Y') { + const firstStockDetails = + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[0] + ?.StockDetails?.[item.key] || {}; + const firstOverallExpStatus = firstStockDetails.OverAllExpStatus; + + if ( + overallExpStatus === 'N' || + (firstOverallExpStatus === 'Y' && prodexpir) + ) { + dataTransfer(qtydata, QtyIndex, VarientIndex, item.key, onePeiceFlow); + } else if (overallExpStatus === 'Y' && repeatedModel) { + dataTransfer(qtydata, QtyIndex, VarientIndex, item.key, onePeiceFlow); } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); + openExpireModal({ + title: 'Stock Expires', + onOk: () => expStockFun(StockItem), + onCancel: () => { + setRepeatedModel(false); + setProdexpir(false); + }, + }); + setStockItem(item.key); } - } else if ( - OnUpiSelected?.ModeName?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg' - ) { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - if (SelCustId) { - Booking(value, pay); - } else { - setMessageType('error'); - setMessageData('Please Select Customer'); - } + } + + setProdexpir(false); + setRepeatedModel(false); + }; + + const [priceChangeProduct, setPriceChangeProduct] = useState([]); + const [productPriceChange, setProductPriceChange] = useState(false); + + const CardOnclick = async (item, Parameter) => { + setOnePeiceFlow(Parameter === 'OnePeiceProduct'); + + const transformedItem = { + ...item, + ProductDetail: item.ProductDetail + // .filter((detail) => detail.OnePcsAvailable === "Y") + .map(({ ProdId, ProdName, ProdVariantDetails, ...rest }) => ({ + ProdId, + ProdName, + ProdVariantDetails, + ...rest, + })), + }; + + const modiffiedData = + Parameter === 'OnePeiceProduct' ? transformedItem : item; + setQtydata(modiffiedData); + if (modiffiedData.OverAllExpStatus === 'Y' && ExpiredProduct) { + openExpireModal({ + title: 'Product Expires', + onOk: () => expFun(modiffiedData), + }); + setItem(modiffiedData); + } else if (modiffiedData) { + setQtydata(modiffiedData); + let count = modiffiedData?.ProductDetail?.length; + if (count > 1) { + Quantity(modiffiedData); } else { - setMessageType('error'); - setMessageData('Please Set the customer display'); + setQtyIndex(0); + SingleQuantity(modiffiedData, Parameter === 'OnePeiceProduct'); } + } + }; + const StockDate = (date) => { + let dateVal = moment(date, ['YYYY-MM-DDTHH:mm:ss']).format('DD-MM-YYYY'); + return dateVal; + }; + + const AddOrderDetails = async (item) => { + if (preOrder) { + await handlePreOrder(item); } else { - Booking(value, pay); + await handleRegularOrder(item); } }; - const extrachargesbookingtype = (extradata) => { - const TakAwayId = ConfigDataList?.find( - (a) => a?.ConfigName === 'TakeAway' - )?.ConfigId; - const DineinId = ConfigDataList?.find( - (a) => a?.ConfigName === 'Dine In' - )?.ConfigId; - let tempdata = extradata?.map((data) => ({ - ...data, - BookingType: data?.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, - })); - return tempdata; + const handlePreOrder = async (item) => { + let Response = await dispatch( + getConfigType({ TypeName: 'Booking Type' }) + ).unwrap(); + + let BookingTypeID; + if (Response?.data?.statusCode == 1) { + BookingTypeID = Response?.data?.data?.find( + (item) => item?.ConfigName === 'Dine In' + )?.ConfigId; + } + + let Condition = PreOrderSelectedProdNames?.some( + (obj) => + obj?.InwardDtlId === item?.InwardDtlId && + obj?.SinglePc === item?.SinglePc + ); + + if (PreOrderAdditem !== 'AddItems') { + setMessageData('Have To choose Add Item Before select Any Item '); + setMessageType('error'); + return; + } + + if (Condition) { + setMessageData('Duplicate Data'); + setMessageType('error'); + return; + } + + const calculateWithoutTaxRate = (qty, rate, taxPercentage) => { + const totalAmount = qty * rate; + const taxAmount = ( + (totalAmount * taxPercentage) / + (100 + taxPercentage) + ).toFixed(2); + const withoutTaxRate = (totalAmount - taxAmount).toFixed(2); + + return parseFloat(withoutTaxRate); + }; + + const SelectedProduct = { + ProdId: item?.ProdId, + InwardDtlId: item?.InwardDtlId, + ProdNameQty: item?.ProdName + ' ' + item?.Size + ' ' + item?.UomName, + ProdName: item?.ProdName, + Size: item?.Size, + UomName: item?.UomName, + OrderQty: 1, + OrderRate: item?.OrderRate, + TotalAmt: item?.OrderRate, + Image: null, + Description: null, + Type: item?.Type, + TaxAmt: 0, + RefundQty: 0, + TaxId: item?.TaxId, + OrderStatus: 'O', + OrderType: 'PRE', + SinglePc: item?.SinglePc, + BookingType: BookingTypeID, + WithoutTaxRate: calculateWithoutTaxRate( + 1, + item?.OrderRate, + item?.TaxPercentage + ), + StockAvailable: item?.StockAvailable, + }; + + const Data = + PreOrderSelectedProdNames?.length > 0 + ? [SelectedProduct, ...PreOrderSelectedProdNames] + : [SelectedProduct]; + + await setPreOrderSelectedProdNames(Data); + await dispatch(changepreOrderList(Data)); }; - const Booking = async (value, pay) => { - const TakAwayId = ConfigDataList?.find( - (a) => a?.ConfigName === 'TakeAway' - )?.ConfigId; - const DineinId = ConfigDataList?.find( - (a) => a?.ConfigName === 'Dine In' - )?.ConfigId; + const handleRegularOrder = async (item) => { + const isHoldOrder = OrderType === 'Hold'; + const addFirst = BillOrderPre === 'Y'; + const hasOffer = OfferCheckedInSetup && preferenceOffer; - setFirstPaymentclick(true); - let temporderdetail = OrderCardDetail?.map((a) => ({ - ProdId: a.ProdId, - Type: a.Type, - OrderQty: a.OrderQty, - OrderRate: a.OrderRate, - TotalAmt: a.OrderQty * a.OrderRate, - TaxAmt: a.TaxAmt, - RefundQty: 0, - InwardDtlId: a.InwardDtlId, - TaxId: a.TaxId, - ProdNameQty: - UomPrint?.SettingValue === 'N' - ? `${a.ProdName} ${a.UomName?.toLowerCase() === 'half' ? '(Half)' : ''}` - : `${a.ProdName} ${a.Size} ${a.UomName}`, - OrderStatus: 'O', - OrderType: - BookingType === 'Dine In' || - BookingTypeBoth || - Estimation?.SettingValue == 'N' - ? 'S' - : GlobEstBooking === 'OvrAllEst' - ? 'E' - : GlobEstBooking === 'ParEst' - ? GlobProdwisedata?.includes( - a.InwardDtlId + ' ' + a?.BookingTypeName + const isExistsInFreeProdList = hasOffer + ? FreeProdList?.filter( + (f) => + f?.FreeProdId === item?.ProdId && + f?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId ) - ? 'E' - : 'S' - : 'S', - SinglePc: a.SinglePc, - BookingType: a.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, - OfferValue: a?.Type === 'C' ? a?.OfferPrice : a.Offer, - OfferAmt: a?.Type === 'C' ? a?.TotalAmt : a.Offer, - OfferType: a?.Type === 'C' ? a?.OfferType : '', - CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null, - ProductIdentifierDtls: a.ProductIdentifierDtls, - ModelNumber: a.ModelNumber, - BatchRef: a.BatchRef, - PackageDtl: a.PackageDtl, - })); - const NotSlectedTypeFind = temporderdetail?.find( - (a) => a?.BookingType != SelectedBookingType + ) && + f?.RemainingQty > 0 + ) + : []; + + const calculateTaxAmounts = (qty, rate, taxPercentage) => { + const totalAmount = qty * rate; + const taxAmount = ( + (totalAmount * taxPercentage) / + (100 + taxPercentage) + ).toFixed(2); + const withoutTaxRate = (totalAmount - taxAmount).toFixed(2); + + return { + TotalAmt: totalAmount, + TaxAmt: parseFloat(taxAmount), + WithoutTaxRate: parseFloat(withoutTaxRate), + }; + }; + + // Helper function to create updated cart item + const createUpdatedCartItem = (cartItem, newQty = null) => { + const quantity = newQty || cartItem.OrderQty + 1; + const taxAmounts = calculateTaxAmounts( + quantity, + cartItem.OrderRate, + cartItem.TaxPercentage + ); + + return { + ...cartItem, + OrderQty: quantity, + ...taxAmounts, + }; + }; + + // Helper function to create new item for cart + const createNewCartItem = (item, quantity = 1) => { + const taxAmounts = calculateTaxAmounts( + quantity, + item.OrderRate, + item.TaxPercentage + ); + + return { + ...item, + localId: uuidv4(), + OrderQty: quantity, + ...taxAmounts, + }; + }; + + dispatch(changeHoldOrderDtl(false)); + dispatch(changePreviousOrderLength(CartOrderDetails?.length)); + + const itemMatchCondition = (cartItem) => + cartItem.ProdId === item.ProdId && + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName === item.BookingTypeName && + cartItem.ScaleType === item.ScaleType; + // item.WeightscaleProd !== 'Y'; + const isItemInCart = CartOrderDetails?.find( + (cartItem) => + itemMatchCondition(cartItem) && + !cartItem.SalesId && + ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' + ? true + : cartItem?.OfferMode !== 'B') && + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' + ? true + : cartItem?.Offer === 0) ); - let updatedOfferDetails = OrderOfferDetail; - if (GlobEstBooking !== 'Sales') { - updatedOfferDetails = OrderOfferDetail?.filter( - (item) => - !( - item.TableName === 'LoyaltyPoints' && - item.TableUniqueName === 'UniqueId' && - item.Type === 'A' + + const isItemInCartHold = CartOrderDetails?.find( + (cartItem) => + itemMatchCondition(cartItem) && + ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' + ? true + : cartItem?.OfferMode !== 'B') && + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' + ? true + : cartItem?.Offer === 0) + ); + + // Filter cart items + const otherOrderDataForNormal = CartOrderDetails?.filter( + (cartItem) => + !( + itemMatchCondition(cartItem) && + !cartItem.SalesId && + ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' + ? true + : cartItem?.OfferMode !== 'B') && + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' + ? true + : cartItem?.Offer === 0) + ) + ); + + const otherOrderDataForNormalWithoutSalesId = CartOrderDetails?.filter( + (cartItem) => + !( + itemMatchCondition(cartItem) && + ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' + ? true + : cartItem?.OfferMode !== 'B') && + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' + ? true + : cartItem?.Offer === 0) + ) + ); + + try { + // CASE 1: Item exists in cart, not Dine In, not Hold order + + if (isItemInCart && !isHoldOrder) { + if ( + isExistsInFreeProdList?.length > 0 && + hasOffer && + item?.SinglePc !== 'Y' + ) { + handleFreeProduct(item, isExistsInFreeProdList, addFirst); + } else { + const updatedCartItem = createUpdatedCartItem( + isItemInCart, + item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' + ? ( + (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) + )?.toFixed(3) + : null + ); + const updatedData = addFirst + ? [updatedCartItem, ...otherOrderDataForNormal] + : [...otherOrderDataForNormal, updatedCartItem]; + if (OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && hasOffer) { + handleFreeProductAvailable(updatedCartItem, updatedData, addFirst); + } else { + dispatch(changeOrderCardDetails(updatedData)); + } + } + } + // CASE 2: Item exists in cart (hold), is Hold order + else if (isItemInCartHold && isHoldOrder) { + if ( + isExistsInFreeProdList?.length > 0 && + hasOffer && + item?.SinglePc !== 'Y' + ) { + handleFreeProduct(item, isExistsInFreeProdList, addFirst); + } else { + const updatedCartItem = createUpdatedCartItem( + isItemInCartHold, + item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' + ? ( + (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) + )?.toFixed(3) + : null + ); + const updatedData = addFirst + ? [updatedCartItem, ...otherOrderDataForNormalWithoutSalesId] + : [...otherOrderDataForNormalWithoutSalesId, updatedCartItem]; + if (OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && hasOffer) { + handleFreeProductAvailable(updatedCartItem, updatedData, addFirst); + } else { + dispatch(changeOrderCardDetails(updatedData)); + } + } + } + // CASE 3: New item - not in cart + else { + if (item.OtherProduct === 'Others' || item.ScaleType == 'weight') { + const newCartItem = createNewCartItem(item, item.OrderQty); + const updatedData = addFirst + ? [newCartItem, ...CartOrderDetails] + : [...CartOrderDetails, newCartItem]; + + dispatch(changeOrderCardDetails(updatedData)); + } else { + if ( + isExistsInFreeProdList?.length > 0 && + hasOffer && + item?.SinglePc !== 'Y' + ) { + handleFreeProduct(item, isExistsInFreeProdList, addFirst); + } else { + const newCartItem = createNewCartItem(item, 1); + const updatedData = addFirst + ? [newCartItem, ...CartOrderDetails] + : [...CartOrderDetails, newCartItem]; + if ( + OverAllproductBasedOfferDatas?.ProdDtl?.length > 0 && + hasOffer + ) { + handleFreeProductAvailable(newCartItem, updatedData, addFirst); + } else { + dispatch(changeOrderCardDetails(updatedData)); + } + } + } + } + } catch (error) { + console.error('Error updating order details:', error); + } finally { + // Clean up dispatch calls + dispatch(changeothersdata({})); + dispatch(ChangeNewQrProduct({})); + } + }; + + const handleFreeProduct = (item, filteredFreeProdList, addFirst) => { + if (!filteredFreeProdList?.length) return; + + const offerMode = filteredFreeProdList[0]?.OfferMode; + + // --- helper functions --- + const calcTax = (qty, rate, taxPerc) => + ((qty * rate * taxPerc) / 100).toFixed(2); + + const calcWithoutTax = (qty, rate, taxPerc) => + qty * rate - ((qty * rate * taxPerc) / 100).toFixed(2); + + const updateFreeProductMeta = (base, qty, rate) => ({ + ...base, + FreeQty: qty, + discount: qty * rate, + RemainingQty: base.OverAllFreeQty - qty, + ProdVariantDetails: base.ProdVariantDetails.map((variant) => ({ + ...variant, + StockDetails: variant.StockDetails.map((stock) => ({ + ...stock, + UsedFree: qty, + RemainingFree: stock.RemainingFree - qty, + })), + })), + }); + + const applyOffer = (offerList, updatedItem) => { + if (offerMode === 'L') { + const updated = loyaltyOfferApply( + offerList, + updatedItem, + DineinId, + TakAwayId + ); + dispatch(changeOfferAppliedProductsForLoyalty(updated)); + dispatch(changeFreeProductForLoyalty(offerList[0])); + } else if (offerMode === 'P' || offerMode === 'C' || offerMode === 'O') { + const updated = buildOfferFromChangesForPromoCodes( + PromoCodeOffersDatas?.[0], + offerList, + updatedItem, + DineinId, + TakAwayId + ); + dispatch(changeOfferAppliedProductsForLoyalty(updated)); + dispatch(changeFreeProductForLoyalty(offerList[0])); + } else { + const updated = buildOfferFromChanges( + OverAllproductBasedOfferDatas, + offerList, + updatedItem, + DineinId, + TakAwayId + ); + dispatch(ChangeOfferAppliedProducts(updated)); + dispatch(ChangeFreeProductList(offerList[0])); + } + }; + + // --- main logic --- + let UpdatedData = []; + const existing = CartOrderDetails?.find( + (c) => + c.ProdId === item.ProdId && + c.InwardDtlId === item.InwardDtlId && + c.OrderRate === item.OrderRate && + c.BookingTypeName === item.BookingTypeName && + c.OfferMode === offerMode && + c.Offer > 0 + ); + + const existsInOther = CartOrderDetails?.find( + (c) => + c.ProdId === item.ProdId && + c.InwardDtlId === item.InwardDtlId && + c.OrderRate === item.OrderRate && + c.BookingTypeName !== item.BookingTypeName && + c.OfferMode === offerMode && + c.Offer > 0 + ); + + if (existing) { + let newQty = existing.OrderQty + 1; + const UpdatedCartItem = { + ...existing, + OrderQty: newQty, + TotalAmt: existing.TotalAmt + existing.OrderRate, + Offer: existing.Offer + existing.OrderRate, + TaxAmt: calcTax(newQty, existing.OrderRate, existing.TaxPercentage), + WithoutTaxRate: calcWithoutTax( + newQty, + existing.OrderRate, + existing.TaxPercentage + ), + OfferMessage: [ + { + OfferId: filteredFreeProdList[0].OfferId, + FreeQty: newQty, + FreeProdId: filteredFreeProdList[0].FreeProdId, + FreeProdName: filteredFreeProdList[0].FreeProdName, + }, + ], + }; + if (existsInOther) { + newQty = newQty + existsInOther?.OrderQty; + } + const updatedOfferList = [ + updateFreeProductMeta(filteredFreeProdList[0], newQty, item.OrderRate), + ]; + + UpdatedData = CartOrderDetails.map((c) => + c === existing ? UpdatedCartItem : c + ); + + applyOffer(updatedOfferList, UpdatedCartItem); + } else { + let newQty = 1; + const UpdatedCartItem = { + ...item, + localId: uuidv4(), + OrderQty: newQty, + TotalAmt: item.OrderRate, + Offer: item.OrderRate, + OfferType: offerMode, + OfferMode: offerMode, + TaxAmt: calcTax(1, item.OrderRate, item.TaxPercentage), + WithoutTaxRate: calcWithoutTax(1, item.OrderRate, item.TaxPercentage), + OfferMessage: [ + { + OfferId: filteredFreeProdList[0].OfferId, + FreeQty: 1, + FreeProdId: filteredFreeProdList[0].FreeProdId, + FreeProdName: filteredFreeProdList[0].FreeProdName, + }, + ], + }; + + if (existsInOther) { + newQty = newQty + existsInOther?.OrderQty; + } + + const updatedOfferList = [ + updateFreeProductMeta(filteredFreeProdList[0], newQty, item.OrderRate), + ]; + + UpdatedData = addFirst + ? [UpdatedCartItem, ...CartOrderDetails] + : [...CartOrderDetails, UpdatedCartItem]; + applyOffer(updatedOfferList, UpdatedCartItem); + } + + dispatch(changeOrderCardDetails(UpdatedData)); + }; + + const handleFreeProductAvailable = async (item, cartData, addFirst) => { + const offers = chooseOfferFun(item, cartData); + + if (!offers?.length) { + const indexToCheck = addFirst ? 0 : cartData.length - 1; + const productToCheck = cartData?.[addFirst ? 0 : cartData?.length - 1]; + let updatedCartData = cartData; + if (productToCheck?.OfferMode && productToCheck?.Offer > 0) { + dispatch( + RemoveOfferAppliedProduct({ + ProdId: productToCheck?.ProdId, + InwardDtlId: productToCheck?.InwardDtlId, + OfferType: productToCheck?.OfferMode, + }) + ); + updatedCartData = cartData.map((item, idx) => + idx === indexToCheck + ? { + ...item, + Offer: null, + OfferMessage: undefined, + OfferMode: undefined, + OfferModeType: false, + OfferType: undefined, + OfferValue: null, + } + : item + ); + } + + const { + updatedOrderCardDetails, + updatedFreeProdList, + updatedOfferAppliedProducts, + hasChanges, + } = processFreeProducts(updatedCartData, FreeProdList); + + if (hasChanges) { + dispatch(changeOrderCardDetails(updatedOrderCardDetails)); + dispatch(ChangeFreeProductList(updatedFreeProdList)); + dispatch(ChangeOfferAppliedProducts(updatedOfferAppliedProducts)); + } else { + dispatch(changeOrderCardDetails(updatedOrderCardDetails)); + } + return; + } + + let bestOffer = null; + let OfferNeedToApply = true; + let updatedFreeProductList = []; + let sameProduct = false; + for (const offer of offers) { + if (offer.OfferMode === 'B') { + const { + OfferAmount, + OfferMessage, + OfferApply, + updatedFreeProdList, + ProductOfferType, + } = applyBuyNGetFreeOffer(cartData, offer, item); + + offer.OfferAmount = OfferAmount; + offer.OfferMessage = OfferMessage; + OfferNeedToApply = OfferApply; + updatedFreeProductList = updatedFreeProdList; + sameProduct = ProductOfferType; + } + if (!bestOffer || offer.OfferAmount > bestOffer.OfferAmount) { + bestOffer = offer; + } + } + + const UpdatedCartItemWithOffer = { + ...item, + Offer: + sameProduct || + bestOffer?.OfferMode === 'I' || + bestOffer?.OfferMode === 'Q' + ? bestOffer?.OfferAmount || item.Offer + : item.Offer || bestOffer?.OfferAmount, + OfferType: item?.OfferType || bestOffer?.OfferType, + OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage, + OfferMode: item?.OfferMode || bestOffer?.OfferMode, + OfferModeType: sameProduct, + }; + + const shouldRemove = (c) => + c.ProdId === item.ProdId && + c.InwardDtlId === item.InwardDtlId && + c.OrderRate === item.OrderRate && + c.BookingTypeName === item.BookingTypeName && + ((c?.OfferModeType && c?.OfferMode === 'B' + ? true + : c?.OfferMode !== 'B') && + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' + ? true + : c?.Offer === 0); + + const filteredCart = CartOrderDetails.filter((c) => !shouldRemove(c)); + + const UpdatedDataAfterOffer = addFirst + ? [UpdatedCartItemWithOffer, ...filteredCart] + : [...filteredCart, UpdatedCartItemWithOffer]; + + if (bestOffer && OfferNeedToApply) { + dispatch(ChangeOfferAppliedProducts(bestOffer)); + } + + const { + updatedOrderCardDetails, + updatedFreeProdList, + updatedOfferAppliedProducts, + hasChanges, + } = processFreeProducts(UpdatedDataAfterOffer, updatedFreeProductList); + + // Update the states + dispatch(changeOrderCardDetails(updatedOrderCardDetails)); + + if (hasChanges) { + dispatch(ChangeFullFreeProductList(updatedFreeProdList)); + dispatch(ChangeOfferAppliedProducts(updatedOfferAppliedProducts)); + } else { + dispatch(ChangeFullFreeProductList(updatedFreeProductList)); + } + }; + + function buildOfferFromChangesForPromoCodes( + PromoCodeOffersDatas, + ChangesHappenList, + item, + DineinId, + TakAwayId + ) { + const results = []; + ChangesHappenList.forEach((change) => { + const offer = PromoCodeOffersDatas.ProdOfferDetails.find( + (o) => o.OfferId === change.OfferId + ); + if (offer) { + // 🛠️ Build normalized object + const formatted = { + OfferId: offer?.OfferId || '', + OfferAmount: change?.discount || 0, + OfferType: offer?.OfferType || '', // I / Q / B + ActualOfferAmount: offer?.OfferAmt || 0, + OfferValue: offer?.OfferAmt || 0, + TableName: change?.TableName || '', + TableUniqueName: change?.TableUniqueName || '', + TableUniqueId: change?.TableUniqueId || '', + // OfferType: offer?.ValueType || "", // F / P + Detail: offer?.Detail || [], + OfferCode: offer?.OfferCode || PromoCodeOffersDatas?.OfferCode || '', + CustId: offer?.CustId || '', + UsedCount: offer?.UsedCount || 0, + AppliesTo: offer?.AppliesTo || '', + BookingType: + item?.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, + ActualFreeQty: change?.FreeQty, + + // ✅ Merge FreeProducts from offer + update with ChangesHappenList + FreeProductsList: { + FreeProdId: change?.FreeProdId, + FreeQty: change?.FreeQty, + FreeProdName: change?.FreeProdName, + OfferId: offer?.OfferId, + OverAllFreeQty: change?.OverAllFreeQty, + ProdVariantDetails: change?.ProdVariantDetails?.map((e) => { + return { + FreeProdVariantName: e?.FreeProdVariantName, + StockDetails: e?.StockDetails?.map((exp) => { + return { + ProdOfferId: exp?.ProdOfferId, + FreeInwardDtlId: exp?.FreeInwardDtlId, + ActiveStatus: exp?.ActiveStatus, + }; + }), + }; + }), + }, + // ✅ Always include product-level fields + ProdId: '', + SinglePc: '', + StockAvailable: '', + ProdVariantName: '', + Type: '', + InwardDtlId: '', + ProdCat: '', + HalfPrice: 'N', + MinQty: 0, + }; + + results.push(formatted); + } + }); + + return results; + } + + function buildOfferFromChanges( + OverAllproductBasedOfferDatas, + ChangesHappenList, + item, + DineinId, + TakeAwayId + ) { + const offersById = new Map( + OverAllproductBasedOfferDatas.ProdDtl.map((o) => [o.OfferId, o]) + ); + + return ChangesHappenList.flatMap((change) => { + const offer = offersById.get(change.OfferId); + if (!offer) return []; + + const getFreeProductsList = () => { + const freeProducts = offer.FreeProducts || offer.FreeProductsList || []; + const normalizedList = Array.isArray(freeProducts) + ? freeProducts + : [freeProducts]; + + return normalizedList.map((fp) => { + if (!change?.ProdVariantDetails) { + return { + FreeProdId: fp?.FreeProdId || '', + FreeQty: fp?.FreeQty || 0, + FreeProdName: fp?.FreeProdName || '', + ProdVariantDetails: fp?.ProdVariantDetails || [], + }; + } + + // Merge variant + stock details with change + const updatedVariants = fp.ProdVariantDetails?.map((variant) => { + const changedVariant = change.ProdVariantDetails.find( + (v) => v.FreeProdVariantName === variant.ProdVariantName + ); + + if (!changedVariant) return variant; + + const updatedStock = variant.StockDetails.map((stock) => { + const changedStock = changedVariant.StockDetails.find( + (s) => s.InwardDtlId === stock.InwardDtlId + ); + + if (changedStock) { + const { InwardDtlId, ...rest } = { ...stock, ...changedStock }; + return { ...rest, FreeInwardDtlId: stock.InwardDtlId }; + } + + const { InwardDtlId, ...rest } = stock; + return { ...rest, FreeInwardDtlId: stock.InwardDtlId }; + }); + + return { ...variant, StockDetails: updatedStock }; + }); + + return { + FreeProdId: fp?.FreeProdId || '', + FreeQty: change?.FreeQty ?? (fp?.FreeQty || 0), + FreeProdName: fp?.FreeProdName || '', + ProdVariantDetails: updatedVariants || [], + }; + }); + }; + + return { + OfferId: offer.OfferId || '', + OfferAmount: change?.discount || 0, + OfferMode: offer.OfferType || '', // I / Q / B + ActualOfferAmount: offer.OfferAmt || 0, + OfferValue: offer.OfferAmt || 0, + TableName: offer.TableName || '', + TableUniqueName: offer.TableUniqueName || '', + TableUniqueId: offer.TableUniqueId || '', + ActualFreeQty: change?.FreeQty || 0, + Detail: offer.Detail || [], + OfferCode: offer.OfferCode || '', + CustId: offer.CustId || '', + UsedCount: offer.UsedCount || 0, + AppliesTo: offer.AppliesTo || '', + BookingType: + item?.BookingTypeName === 'Dine In' ? DineinId : TakeAwayId, + FreeProductsList: getFreeProductsList(), + + // Product-level fields + ProdId: change?.ProdId || '', + SinglePc: change?.SinglePc || '', + StockAvailable: change?.StockAvailable || '', + ProdVariantName: change?.ProdVariantName || '', + Type: item?.Type || '', + InwardDtlId: change?.InwardDtlId || '', + ProdCat: change?.ProdCat || '', + HalfPrice: offer.HalfPrice || 'N', + MinQty: offer.MinQty || 0, + }; + }); + } + + const loyaltyOfferApply = (ChangesHappenList, item, DineinId, TakAwayId) => { + const result = []; + const change = ChangesHappenList?.[0]; + const formatted = { + OfferId: change?.OfferId, + OfferAmount: change?.discount || 0, + OfferValue: change?.OfferAmt || 0, + TableName: change?.TableName || '', + TableUniqueName: change?.TableUniqueName || '', + TableUniqueId: change?.TableUniqueId || '', + ProdId: change?.ProdId || '', + SinglePc: change?.SinglePc || '', + StockAvailable: change?.StockAvailable || '', + ProdVariantName: change?.ProdVariantName || '', + ActualFreeQty: change?.FreeQty || 0, + Type: '', + BookingType: item?.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, + InwardDtlId: change?.InwardDtlId || '', + OfferType: change?.OfferMode || '', + Detail: [{}], + ProdCat: change?.ProdCat || '', + CustId: change?.CustId || '', + UsedCount: + change?.ProdVariantDetails?.reduce( + (sum, variant) => + sum + + (variant?.StockDetails?.reduce( + (variantSum, stock) => + variantSum + (stock?.ProdLoyaltyPoint * stock?.UsedFree || 0), + 0 + ) || 0), + 0 + ) || 0, + FreeProductsList: change, + }; + result?.push(formatted); + return result; + }; + + function chooseOfferFun(item, CartData) { + return validateOffers( + item, + OverAllproductBasedOfferDatas, + CartData, + TakAwayId, + DineinId + ); + } + + const handleBulkUpload = async () => { + console.log( + AllCategoryDatas, + AllsubcatgoryDatas, + 'AllsubcatgoryDatas', + ProdSubCat + ); + + let ProdcatName = + AllCategoryDatas?.find((cat) => cat?.ProdCat == ProdCat)?.ProdCatName || + 'General'; + let ProdsubcatName = + AllsubcatgoryDatas?.find((subcat) => subcat?.ProdSubCat == ProdSubCat) + ?.ProdSubCatName || 'General'; + const Postdata = products?.map((e, index) => { + if (e?.name == null || e?.name === '') { + setMessageData(`Product Name is missing at Row ${index + 1} `); + setMessageType('error'); + throw new Error(`Product Name is missing at Row ${index + 1} `); + } + if (e?.price == null || e?.price === '') { + setMessageData( + `Price is missing for product at Row ${index + 1} (${e?.name || 'Unknown'})` + ); + setMessageType('error'); + throw new Error( + `Price is missing for product at index ${index} (${e?.name || 'Unknown'})` + ); + } + + return { + AppId, + CompId, + BranchId, + CreatedBy: UserId, + ProdName: e?.name, + ProdVariantName: '', + ProdCat: ProdcatName, + ProdSubCat: ProdsubcatName, + Brand: '', + PartNumber: '', + HSNCode: '', + ProdNameCode: e?.code, + UOM: e?.UOMName, + Size: e?.size || 1, + MRP: e.price, + SellPrice: e.price, + WhSalePrice: '', + TaxId: 'NIL - 0%', + StockAvailable: 'No', + OnePcsAvailable: 'No', + TokenAvailable: 'No', + AutoGenerateQr: 'No', + AutoGenerateSingleQr: 'No', + OnePcQR: '', + QRCode: '', + Rack: '', + AvailableFrom: null, + AvailableTo: null, + ManufDate: null, + ExpDate: null, + }; + }); + + const response = await dispatch( + bulkpostdata({ ProdDetails: Postdata }) + ).unwrap(); + if (response?.data?.statusCode === 1) { + productCardList(); + setMessageData(response?.data?.message); + setMessageType('success'); + setNewMoreProductModel(false); + setProducts([ + { id: 1, name: '', price: '', code: '', size: '1', category: '' }, + ]); + } else { + setMessageData(response?.data?.message); + setMessageType('error'); + } + }; + function changeFreeProductList(FreeProdList, newFreeProd) { + if (!newFreeProd || !newFreeProd.ProdId || !newFreeProd.InwardDtlId) { + return FreeProdList; // 🚫 Skip invalid payload + } + + const index = FreeProdList.findIndex( + (f) => + f.ProdId === newFreeProd.ProdId && + f.InwardDtlId === newFreeProd.InwardDtlId + ); + + if (index !== -1) { + let existing = JSON.parse(JSON.stringify(FreeProdList[index])); // deep clone + + if (newFreeProd.ProdVariantDetails) { + newFreeProd.ProdVariantDetails.forEach((newVariant) => { + const existingVariant = existing.ProdVariantDetails?.find( + (v) => v.VariantName === newVariant.VariantName + ); + + if (existingVariant) { + newVariant.StockDetails.forEach((newStock) => { + const existingStock = existingVariant.StockDetails?.find( + (s) => s.InwardDtlId === newStock.InwardDtlId + ); + + if (existingStock) { + // ✅ Create a new object instead of mutating + existingStock.EligibleFree = + (existingStock.EligibleFree || 0) + + (newStock.EligibleFree || 0); + existingStock.UsedFree = + (existingStock.UsedFree || 0) + (newStock.UsedFree || 0); + existingStock.RemainingFree = + (existingStock.RemainingFree || 0) + + (newStock.RemainingFree || 0); + } else { + existingVariant.StockDetails = [ + ...existingVariant.StockDetails, + { ...newStock }, + ]; + } + }); + } else { + if (!existing.ProdVariantDetails) existing.ProdVariantDetails = []; + existing.ProdVariantDetails = [ + ...existing.ProdVariantDetails, + { ...newVariant }, + ]; + } + }); + } + + return FreeProdList.map((f, i) => + i === index + ? { + ...existing, + ...newFreeProd, + ProdVariantDetails: existing.ProdVariantDetails, + } + : f + ); + } else { + return [...FreeProdList, { ...newFreeProd }]; + } + } + + function applyBuyNGetFreeOffer(cartItem, offer, item) { + const freeList = offer.FreeProductsList || []; + let totalDiscount = 0; + let offerMessage = ''; + let OfferApply = true; + let sameProductOffer = false; + let updatedFreeProdList = [...FreeProdList]; + freeList.forEach((freeProd) => { + let data = updatedFreeProdList?.find( + (e) => + e.FreeProdId === freeProd.FreeProdId && + e.InwardDtlId === item?.InwardDtlId + ); + // find matching item in cart + const freeCartItem = cartItem.filter( + (c) => + c.ProdId === freeProd.FreeProdId && + freeProd?.ProdVariantDetails?.some((pv) => + pv?.StockDetails?.some((s) => s.InwardDtlId === c.InwardDtlId) ) ); - } - - let temppostdata = { - SalesMode: RetailWSSalesType || 'R', - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - OrderDate: Custombill ? invoiceDate : null, - CustomOrderNo: Custombill ? CurrentOrderId : null, - OrderType: - Object.keys(ReportholdData)?.length > 0 - ? ReportholdData?.OrderType - : 'S', - CustSuppId: SelCustId ? SelCustId : null, - Reference: 'test', - BookingType: - NotSlectedTypeFind && !BookingTypeBoth - ? NotSlectedTypeFind?.BookingType - : SelectedBookingType, - // (NotSlectedTypeFind?.length>0 && !BookingTypeBoth)?NotSlectedTypeFind?.[0]?.BookingTypeName: - - ServiceProvider: 0, - ActiveStatus: 'A', - CreatedBy: UserId, - AddlInfo: 'test', - BillAmount: TotalWithoutTaxAmount, - OverallDiscSales: OverAllSales > 0 ? OverAllSales : 0, - OverallDiscEst: OverAllEstimate > 0 ? OverAllEstimate : 0, - TaxAmount: TotalTaxAmount, - VatAmount: 0, - NetAmount: Math.round(TotalAmount), - PaymentType: - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - GivenAmt: 0, - BalGiven: 0, - BookingMedia: 'DW', - RefundAmount: 0, - ServiceCategory: OtherServiceTicketClaim?.ServiceCategory || null, - OtherServiceTicketId: OtherServiceTicketClaim?.TicketId || null, - OtherServiceTicketAmount: OtherServiceTicketClaim?.TotalAmt || null, - PaymentStatus: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'S' - : 'P', - OrderDtlDetails: - Object.keys(ReportholdData)?.length > 0 - ? ProductSummary(temporderdetail) - : temporderdetail, - // (BookingType === "Dine In" || BookingTypeBoth) - ExtraChargeDetails: - GlobalExtraCharge?.length > 0 - ? extrachargesbookingtype(GlobalExtraCharge) - : null, - SalesTableLinkDetails: - SelectedTableDetails?.length > 0 - ? globalTipAmount === 0 - ? SelectedTableDetails - : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) - : null, - // "Credit": TotalAmount, - // "Debit": 0, - SalesPaymentType: 'normal', - PaymentDetail: [ - { - PaymentType: - Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'pd' - ? PaymentDeviceUPI?.[0]?.ModeId - : SelectedUPIPayOption?.toLowerCase() === 'pg' - ? PaymentgatewayUPI?.[0]?.ModeId - : paybtnselected - : paybtnselected - ? paybtnselected - : null, - // SelectedUPIPayOption?.toLowerCase() === "pg" ? - Amount: Math.round(TotalAmount), - PaymentOptionType: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'PC' - : Paybtnnameselected?.toLowerCase() === 'card' - ? SelectedCardOption - : Paybtnnameselected?.toLowerCase() === 'upi' - ? SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'PC' - : SelectedUPIPayOption - : null, - ModeOfPayment: - SelectedUPIPayOption?.toLowerCase() === 'default' - ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId - : null, - AccountDtl: - Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) - : (Paybtnnameselected?.toLowerCase() === 'upi' && - 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') - ? useOptions?.[0]?.PaymentDetails?.PaymentGateway - : [], - PaymentStatus: - Paybtnnameselected?.toLowerCase() === 'cash' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'credit' - ? 'S' - : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' - ? 'S' - : 'P', - Debit: 0, - Credit: - Paybtnnameselected?.toLowerCase() === 'credit' - ? Math.round(TotalAmount) - : 0, - }, - ], - OrderOfferDetail: updatedOfferDetails, - }; - let PostData = temppostdata; - - if (value === 'Dine-In') { - PostData['PaymentStatus'] = pay ? 'S' : 'P'; - PostData['PaymentDetail'] = !pay && []; - PostData['PaymentType'] = !pay && ''; - } else if (value === 'Hold') { - ((PostData['PaymentStatus'] = pay ? 'S' : 'P'), - (PostData['PaymentDetail'] = !pay && [])); - PostData['PaymentType'] = !pay && ''; - PostData['ActiveStatus'] = pay ? 'A' : 'D'; - } else if (value === 'Unpaid') { - PostData['PaymentStatus'] = pay ? 'S' : 'P'; - PostData['PaymentDetail'] = !pay && []; - PostData['PaymentType'] = !pay && ''; - PostData['PrintType'] = 'Y'; - } - - Object.keys(ReportholdData)?.length > 0 - ? OrderType === 'Failed' - ? PutFailedPayment(PostData, value, pay) - : PutBooking(PostData, value, pay) - : PostBooking(PostData, value); - }; - const PostBooking = async (PostData, value) => { - let response = await dispatch(PostBookingData(PostData)).unwrap(); - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => item?.PaymentOptionType?.toLowerCase() === 'pc' - ); - if ( - PayatCounterfilter?.length === 1 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - setMessageData( - response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + // check if it's same product + inward + const isSameProduct = + offer.ProdId === freeProd.FreeProdId && + freeProd?.ProdVariantDetails?.some((fpv) => + fpv?.StockDetails?.some( + (fs) => fs.InwardDtlId === freeCartItem?.[0]?.InwardDtlId + ) ); - response?.data?.OrderDetails?.length > 0 && - setPrintOrderDetails([response?.data]); - CustomerDisplay(value); - filteredSettingNames?.includes('whatsapp') && - MobileNoWhatsApp?.value && - handleURL([response?.data]); - ClearAllGlobalStateDatas(value); + + if (!isSameProduct) { + const buyQty = offer.BuyQty || 1; + const getQty = freeProd.FreeQty || 0; + + // 🔥 Find how many buy-product are in cart + const buyCartItem = cartItem.find((c) => c.ProdId === offer.ProdId); + + if (buyCartItem) { + const eligibleCycles = Math.floor(buyCartItem.OrderQty / buyQty); + const totalFreeEligible = eligibleCycles * getQty; + + if (totalFreeEligible > 0) { + offerMessage = `Add ${totalFreeEligible} ${freeProd.FreeProdName} free`; + } + } } - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); - } + if (offer.HalfPrice === 'Y' && isSameProduct) { + // 🔥 Half price for same product + totalDiscount += + freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) * + freeCartItem?.[0]?.OrderRate * + 0.5; + sameProductOffer = true; + } else if (isSameProduct) { + // 🔥 Buy N Get M (same product) + const buyQty = offer.BuyQty || 1; + const getQty = freeProd.FreeQty || 0; + + const cycleSize = buyQty + getQty; + const fullCycles = Math.floor( + freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) / + cycleSize + ); + const totalFreeQty = fullCycles * getQty; + + totalDiscount += totalFreeQty * freeCartItem?.[0].OrderRate; + sameProductOffer = true; + // offerMessage = `${freeProd.FreeProdName} -> ${Math.ceil(totalFreeQty / 2)} qty Free Eligible`; } else { - console.log('more pd data'); + // 🔥 Different product free + const buyQty = offer.BuyQty || 1; + const getQty = freeProd.FreeQty; + + // find buy product qty in cart + const buyCartItem = cartItem.filter( + (c) => + c?.ProdId === offer?.ProdId && + (offer?.InwardDtlId ? c?.InwardDtlId === offer?.InwardDtlId : true) + ); + + const buyOrderQty = buyCartItem?.reduce( + (acc, fc) => acc + (fc?.OrderQty || 0), + 0 + ); + + // ✅ total eligible free qty (cycles of Buy X Get Y) + const eligibleCycles = Math.floor(buyOrderQty / buyQty); + const totalFreeQty = eligibleCycles * getQty; + + totalDiscount += 0; + + // 🟢 Offer message handling + if (buyOrderQty === 0) { + offerMessage = `No free eligible right now`; + } else if (buyOrderQty % buyQty !== 0) { + const remainingToNext = buyQty - (buyOrderQty % buyQty); + offerMessage = `Buy ${remainingToNext} more ${offer.ProdName} to get ${getQty} ${freeProd.FreeProdName} free`; + } else if (totalFreeQty > 0) { + offerMessage = `${freeProd.FreeProdName} -> ${totalFreeQty} qty Free Eligible`; + } else { + offerMessage = `No free eligible right now`; + } + + const usedFree = data?.FreeQty || 0; + const remainingFree = Math.max(totalFreeQty - usedFree, 0); + + const FreeProdList = { + OfferId: offer.OfferId, + ProdId: item?.ProdId, + ProdVariantName: item?.ProdVariantName, + StockAvailable: item?.StockAvailable, + OfferMode: offer.OfferMode, + TableName: offer.TableName, + TableUniqueName: offer.TableUniqueName, + InwardDtlId: item?.InwardDtlId || null, + FreeProdId: freeProd.FreeProdId, + FreeProdName: freeProd.FreeProdName, + ProdCat: item?.ProdCat, + SinglePc: item?.SinglePc, + BatchRef: item?.BatchRef, + OverAllFreeQty: totalFreeQty, + FreeQty: usedFree, + RemainingQty: remainingFree, + + ProdVariantDetails: freeProd.ProdVariantDetails.map((variant) => ({ + FreeProdVariantName: variant.ProdVariantName, + StockDetails: variant.StockDetails.map((stock) => { + // 🔎 inward-based usage + const matchedCartItem = cartItem.find( + (c) => + c.ProdId === freeProd.FreeProdId && + c.InwardDtlId === stock.InwardDtlId + ); + + const usedFreeForStock = matchedCartItem?.OrderQty || 0; + const remainingFreeForStock = Math.max( + totalFreeQty - usedFreeForStock, + 0 + ); + + return { + FreeInwardDtlId: stock.InwardDtlId, + ProdOfferId: stock.ProdOfferId, + ActiveStatus: stock.ActiveStatus, + EligibleFree: totalFreeQty, // still overall, can later split if needed + UsedFree: usedFreeForStock, + RemainingFree: remainingFreeForStock, + }; + }), + })), + }; + + updatedFreeProdList = changeFreeProductList( + updatedFreeProdList, + FreeProdList + ); + + OfferApply = false; } - if (PaymentGatewayfilter?.length === 1) { - if ( - PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg' - ) { - await dispatch(changePaymentloader(true)); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderBookingId: PaymentGatewayfilter?.[0]?.OrderId, - Paymentgateway: true, - OrderPaymentId: PaymentGatewayfilter?.[0]?.PaymentOrderId, - OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount, + }); + + return { + OfferAmount: totalDiscount, + OfferMessage: offerMessage, + OfferApply: OfferApply, + updatedFreeProdList: updatedFreeProdList, + ProductOfferType: sameProductOffer ? true : false, + }; + } + + const processFreeProducts = (updatedData, freeProdList) => { + if (!freeProdList || freeProdList.length === 0) { + return { + updatedOrderCardDetails: updatedData, + updatedFreeProdList: freeProdList, + updatedOfferAppliedProducts: [], + hasChanges: false, + }; + } + // Filter only free products with remaining quantity + const availableFreeProdList = freeProdList?.filter( + (prod) => prod?.RemainingQty > 0 + ); + + let updatedOrderCardDetails = []; + let updatedFreeProdList = [...freeProdList]; // Create a copy to avoid mutations + let updatedOfferAppliedProducts = []; // Track offer applied products + let hasChanges = false; + + updatedData?.forEach((item) => { + // STEP 1: Check if item is already a free product (with offer applied) + const foundInFreeProdList = freeProdList?.filter( + (prod) => + prod?.OfferId === item?.OfferMessage?.[0]?.OfferId && + prod?.FreeProdId === item?.ProdId && + prod?.OfferMode === item?.OfferMode && + prod?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) + ); + + // STEP 2: Check if item is a paid product that can be converted to free + const availableFreeProduct = updatedFreeProdList?.find( + (prod) => + prod?.FreeProdId === item?.ProdId && + prod?.RemainingQty > 0 && + prod?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) && + item?.SinglePc !== 'Y' + ); + + const isPaidProductThatCanBeFree = + availableFreeProduct && + (!item.OfferMode || item.OfferMode?.trim() === '') && + (item.Offer === 0 || !item.Offer); + + // STEP 3: Handle paid product conversion to free + if (isPaidProductThatCanBeFree) { + hasChanges = true; // Mark that changes occurred + + const maxFreeQty = Math.min( + item.OrderQty, + availableFreeProduct.RemainingQty + ); + const remainingPaidQty = Math.max( + item.OrderQty - availableFreeProduct.RemainingQty, + 0 + ); + + // Create free item + if (maxFreeQty > 0) { + const freeItem = { + ...item, + OrderQty: maxFreeQty, + TotalAmt: maxFreeQty * item.OrderRate, + Offer: maxFreeQty * item.OrderRate, // Full discount + OfferType: availableFreeProduct.OfferMode, + OfferMode: availableFreeProduct.OfferMode, + TaxAmt: ( + (maxFreeQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: ( + maxFreeQty * item.OrderRate - + (maxFreeQty * item.OrderRate * item.TaxPercentage) / 100 + ).toFixed(2), + OfferMessage: [ + { + OfferId: availableFreeProduct.OfferId, + FreeQty: maxFreeQty, + FreeProdId: availableFreeProduct.FreeProdId, + FreeProdName: availableFreeProduct.FreeProdName, + }, + ], + }; + + // Check if free version already exists in updatedOrderCardDetails + const existingFreeIndex = updatedOrderCardDetails.findIndex( + (od) => + od.ProdId === freeItem.ProdId && + od.InwardDtlId === freeItem.InwardDtlId && + od.OrderRate === freeItem.OrderRate && + od.BookingTypeName === freeItem.BookingTypeName && + od.OfferMode === freeItem.OfferMode && + od.Offer > 0 && + od.MRP === freeItem.MRP + ); + + if (existingFreeIndex !== -1) { + // Merge with existing free item + const existing = updatedOrderCardDetails[existingFreeIndex]; + updatedOrderCardDetails[existingFreeIndex] = { + ...existing, + OrderQty: existing.OrderQty + freeItem.OrderQty, + TotalAmt: existing.TotalAmt + freeItem.TotalAmt, + Offer: existing.Offer + freeItem.Offer, + WithoutTaxRate: ( + parseFloat(existing.WithoutTaxRate) + + parseFloat(freeItem.WithoutTaxRate) + ).toFixed(2), + TaxAmt: ( + parseFloat(existing.TaxAmt) + parseFloat(freeItem.TaxAmt) + ).toFixed(2), }; - customerDisplayWindow.postMessage(updatedData, '*'); } else { - console.error( - 'Customer display window is not available or has been closed.' - ); + freeItem.localId = uuidv4(); + updatedOrderCardDetails.push(freeItem); } - const checkPaymentStatus = async () => { - const intervalId = setInterval(async () => { - try { - let getpaymentgatewaydetail = await dispatch( - PaymentGatewayGetdetail(PaymentGatewayfilter?.[0]?.OrderId) - ).unwrap(); - if (getpaymentgatewaydetail?.data?.statusCode === 1) { - let paymentdataget = - getpaymentgatewaydetail?.data?.PaymentOrderDtl?.find( - (item) => - item?.PaymentOrderId === - PaymentGatewayfilter?.[0]?.PaymentOrderId - )?.PaymentStatus; + // Update the free product list (create new object to avoid mutation) + const freeProductIndex = updatedFreeProdList.findIndex( + (f) => + f.OfferId === availableFreeProduct.OfferId && + f.FreeProdId === availableFreeProduct.FreeProdId + ); - if (paymentdataget === 'S') { - setMessageType('success'); - setMessageData('Payment Success'); - await dispatch(changePaymentloader(false)); - if ( - getpaymentgatewaydetail?.data?.OrderDetails?.length > 0 - ) { - setPrintOrderDetails([getpaymentgatewaydetail?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - } - clearInterval(intervalId); // Stop the loop when payment is successful - } else if (paymentdataget === 'F') { - setMessageType('error'); - setMessageData('Payment Failed'); - await dispatch(changePaymentloader(false)); - setFirstPaymentclick(false); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - clearInterval(intervalId); // Stop the loop when payment fails - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); + if (freeProductIndex !== -1) { + updatedFreeProdList[freeProductIndex] = { + ...updatedFreeProdList[freeProductIndex], + FreeQty: + (updatedFreeProdList[freeProductIndex].FreeQty || 0) + + maxFreeQty, + RemainingQty: + updatedFreeProdList[freeProductIndex].RemainingQty - maxFreeQty, + ProdVariantDetails: updatedFreeProdList[ + freeProductIndex + ].ProdVariantDetails.map((variant) => ({ + ...variant, + StockDetails: variant.StockDetails.map((stock) => { + if (stock.FreeInwardDtlId === item.InwardDtlId) { + return { + ...stock, + UsedFree: (stock.UsedFree || 0) + maxFreeQty, + RemainingFree: Math.max( + (stock.RemainingFree || 0) - maxFreeQty, + 0 + ), + }; } - } - } catch (error) { - console.error('Error fetching payment details: ', error); - } - }, 3000); // Call the API every 3 seconds + return stock; + }), + })), + discount: + (updatedFreeProdList[freeProductIndex].discount || 0) + + maxFreeQty * item.OrderRate, + }; + } + + const filteredOfferAppliedProduct = offerAppliedProducts?.find( + (op) => + op.OfferId === availableFreeProduct.OfferId && + op.ProdId === availableFreeProduct.ProdId && + op.InwardDtlId === availableFreeProduct.InwardDtlId && + op.OfferMode === availableFreeProduct.OfferMode + ); + // Create offer applied product entry + const offerAppliedProduct = { + OfferId: availableFreeProduct.OfferId, + ProdId: availableFreeProduct.ProdId, + InwardDtlId: availableFreeProduct.InwardDtlId, + OfferAmount: + (filteredOfferAppliedProduct?.OfferAmount || 0) + + maxFreeQty * item.OrderRate, // Total discount amount + OfferMode: availableFreeProduct.OfferMode, + OfferType: availableFreeProduct.OfferType, + TableName: availableFreeProduct.TableName, + TableUniqueName: availableFreeProduct.TableUniqueName, + ActualOfferAmount: + (filteredOfferAppliedProduct?.OfferAmount || 0) + + maxFreeQty * item.OrderRate, + OfferValue: + (filteredOfferAppliedProduct?.OfferValue || 0) + + maxFreeQty * item.OrderRate, + ActualFreeQty: + (filteredOfferAppliedProduct?.ActualFreeQty || 0) + maxFreeQty, + AppliesTo: item.ProdId, + BookingType: + item.BookingType || + (item.BookingTypeName === 'Dine In' ? DineinId : TakAwayId), + FreeProductsList: [ + { + FreeProdId: availableFreeProduct.FreeProdId, + FreeQty: + (filteredOfferAppliedProduct?.FreeProductsList?.[0] + ?.FreeQty || 0) + maxFreeQty, + FreeProdName: availableFreeProduct.FreeProdName, + ProdVariantDetails: + availableFreeProduct.ProdVariantDetails || [], + }, + ], + // Product-level fields + SinglePc: item.SinglePc, + StockAvailable: item.StockAvailable, + ProdVariantName: item.ProdVariantName, + Type: item.Type, + ProdCat: item.ProdCat, + HalfPrice: availableFreeProduct.HalfPrice, + MinQty: availableFreeProduct.MinQty, }; - // Call the function to start checking payment status - checkPaymentStatus(); + updatedOfferAppliedProducts.push(offerAppliedProduct); } - } else { - console.log('more pg data'); - } - } else { - setMessageType('error'); - setMessageData(response?.data?.response); - setFirstPaymentclick(false); - // clearInvoiceDate - clearInvoiceDate(); - dispatch(changeCurrentOrderId(null)); - } - }; - const PutBooking = async (putdatas, value, pay) => { - let putdata = putdatas; - putdata['OrderId'] = ReportholdData?.OrderId; - putdata['SalesId'] = ReportholdData?.SalesId; - putdata['UpdatedBy'] = UserId; - if (value === 'Dine-In') { - putdata['PaymentStatus'] = pay ? 'S' : 'P'; - putdata['PaymentDetail'] = !pay && []; - putdata['PaymentType'] = !pay && ''; - } else if (value === 'Hold') { - ((putdata['PaymentStatus'] = pay ? 'S' : 'P'), - (putdata['PaymentDetail'] = !pay && [])); - putdata['PaymentType'] = !pay && ''; - putdata['ActiveStatus'] = pay ? 'A' : 'D'; - } else if (value === 'Unpaid') { - putdata['PaymentStatus'] = pay ? 'S' : 'P'; - putdata['PaymentDetail'] = !pay && []; - putdata['PaymentType'] = !pay && ''; - putdata['PrintType'] = 'Y'; - } - let response = await dispatch(PutBookingData(putdata)).unwrap(); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => item?.PaymentOptionType?.toLowerCase() === 'pc' - ); - if (value !== 'Unpaid') { - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); + // Create paid item for remaining quantity + if (remainingPaidQty > 0) { + const paidItem = { + ...item, + OrderQty: remainingPaidQty, + TotalAmt: remainingPaidQty * item.OrderRate, + TaxAmt: ( + (remainingPaidQty * item.OrderRate * item.TaxPercentage) / + 100 + ).toFixed(2), + WithoutTaxRate: ( + remainingPaidQty * item.OrderRate - + (remainingPaidQty * item.OrderRate * item.TaxPercentage) / 100 + ).toFixed(2), + Offer: 0, + OfferType: '', + OfferMessage: [], + OfferMode: '', + }; - if ( - PayatCounterfilter?.length === 1 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - setMessageData( - response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + // Remove offer-related properties + delete paidItem.OfferType; + delete paidItem.OfferMessage; + delete paidItem.OfferMode; + + // Check if paid version already exists + const existingPaidIndex = updatedOrderCardDetails.findIndex( + (od) => + od.ProdId === paidItem.ProdId && + od.InwardDtlId === paidItem.InwardDtlId && + od.OrderRate === paidItem.OrderRate && + !od.SalesId && + (od.Offer === 0 || !od.Offer) && + od.MRP === paidItem.MRP ); - response?.data?.OrderDetails?.length > 0 && - setPrintOrderDetails([response?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); + + if (existingPaidIndex !== -1) { + // Merge with existing paid item + const existing = updatedOrderCardDetails[existingPaidIndex]; + updatedOrderCardDetails[existingPaidIndex] = { + ...existing, + OrderQty: existing.OrderQty + paidItem.OrderQty, + TotalAmt: existing.TotalAmt + paidItem.TotalAmt, + WithoutTaxRate: ( + parseFloat(existing.WithoutTaxRate) + + parseFloat(paidItem.WithoutTaxRate) + ).toFixed(2), + TaxAmt: ( + parseFloat(existing.TaxAmt) + parseFloat(paidItem.TaxAmt) + ).toFixed(2), + }; + } else { + paidItem.localId = uuidv4(); + updatedOrderCardDetails.push(paidItem); + } } - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); + + return; // Skip the rest of processing for this item + } + + // STEP 4: Handle existing free products (original logic) + if (foundInFreeProdList?.length > 0) { + const freeProduct = foundInFreeProdList[0]; + + if (freeProduct?.RemainingQty !== 0) { + // If there are remaining free quantities, push the original item + const isAlreadyExists = updatedOrderCardDetails.findIndex( + (od) => + od.ProdId === item.ProdId && + od.InwardDtlId === item.InwardDtlId && + od.OrderRate === item.OrderRate && + od.BookingTypeName === item.BookingTypeName && + !od.SalesId && + od.OfferMode === item.OfferMode && + od.Offer > 0 && + od.MRP === item.MRP + ); + + if (isAlreadyExists !== -1) { + updatedOrderCardDetails[isAlreadyExists] = { + ...updatedOrderCardDetails[isAlreadyExists], + OrderQty: + updatedOrderCardDetails[isAlreadyExists].OrderQty + + item.OrderQty, + TotalAmt: + updatedOrderCardDetails[isAlreadyExists].TotalAmt + + item.TotalAmt, + WithoutTaxRate: + updatedOrderCardDetails[isAlreadyExists].WithoutTaxRate + + item.WithoutTaxRate, + Offer: + updatedOrderCardDetails[isAlreadyExists].Offer + item.Offer, + OfferMessage: + updatedOrderCardDetails[isAlreadyExists]?.OfferMessage?.[0] + ?.FreeQty > item?.OfferMessage?.[0]?.FreeQty + ? updatedOrderCardDetails[isAlreadyExists]?.OfferMessage + : item?.OfferMessage, + }; + } else { + updatedOrderCardDetails.push(item); + } + } else if ( + freeProduct?.RemainingQty === 0 && + item?.OrderQty > freeProduct?.FreeQty + ) { + // Split the item into free and paid portions + const freeQty = freeProduct.FreeQty; + const paidQty = item.OrderQty - freeProduct.FreeQty; + + // Create free item (with original offer details) + const freeItem = { + ...item, + OrderQty: freeQty, + WithoutTaxRate: freeQty * item.OrderRate, + TotalAmt: freeQty * item.OrderRate, + Offer: freeQty * item.OrderRate, + }; + + // Create paid item (without offer details) + const paidItem = { + ...item, + OrderQty: paidQty, + TotalAmt: paidQty * (item.SellingPrice || item.OrderRate), + WithoutTaxRate: paidQty * item.OrderRate, + Offer: 0, + OfferType: '', + OfferMessage: [], + OfferMode: '', + }; + + delete paidItem.OfferType; + delete paidItem.OfferMessage; + delete paidItem.OfferMode; + + updatedOrderCardDetails.push(freeItem); + + const isAlreadyExists = updatedOrderCardDetails.findIndex( + (od) => + od.ProdId === paidItem.ProdId && + od.InwardDtlId === paidItem.InwardDtlId && + od.OrderRate === paidItem.OrderRate && + !od.SalesId && + (od.Offer === 0 || !od.Offer) + ); + + if (isAlreadyExists !== -1) { + const existingItem = updatedOrderCardDetails[isAlreadyExists]; + updatedOrderCardDetails[isAlreadyExists] = { + ...existingItem, + OrderQty: existingItem.OrderQty + paidItem.OrderQty, + TotalAmt: existingItem.TotalAmt + paidItem.TotalAmt, + WithoutTaxRate: + existingItem.WithoutTaxRate + paidItem.WithoutTaxRate, + }; + } else { + paidItem.localId = uuidv4(); + updatedOrderCardDetails.push(paidItem); } } else { - console.log('more pd data'); - } - if (PaymentGatewayfilter?.length === 1) { - await PaymentGatewayFlow(PaymentGatewayfilter); - } else { - console.log('more pg data'); + updatedOrderCardDetails.push(item); } } else { - // clearInvoiceDate - clearInvoiceDate(); - dispatch(changeCurrentOrderId(null)); + // STEP 5: No matching free product found, push original item + updatedOrderCardDetails.push(item); } - } else { - setPrintOrderDetails([response?.data]); + }); - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer([]); - } else { - dispatch(changeOrderCardDetails([])); - } - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); - setFirstPaymentclick(false); - await dispatch(changeBookingType('TakeAway')); - await dispatch(changeSelectTable([])); - await dispatch(changeSelectChair([])); - getUnpaiddatas(); - } - }; - const PutFailedPayment = async (PayData, value, pay) => { - console.log(PayData?.PaymentDetail?.[0]?.PaymentType, 'mohanPayData'); - let tempsplitdata = { - CompId: PayData?.CompId, - BranchId: PayData?.BranchId, - AppId: PayData?.AppId, - CustSuppId: PayData?.SelCustId ? SelCustId : null, - UpdatedBy: UserId, - OrderId: ReportholdData?.OrderId, - PaymentType: PayData?.PaymentDetail?.[0]?.PaymentType, - Amount: FailedTotalAmt, - PaymentOptionType: PayData?.PaymentDetail?.[0]?.PaymentOptionType, - ModeOfPayment: PayData?.PaymentDetail?.[0]?.ModeOfPayment, - AccountDtl: PayData?.PaymentDetail?.[0]?.AccountDtl, - PaymentStatus: PayData?.PaymentDetail?.[0]?.PaymentStatus, - Debit: PayData?.PaymentDetail?.[0]?.Debit, - Credit: PayData?.PaymentDetail?.[0]?.Credit, + return { + updatedOrderCardDetails, + updatedFreeProdList, + updatedOfferAppliedProducts, + hasChanges, }; - - let response = await dispatch( - putSplitpaymentStatus(tempsplitdata) - ).unwrap(); - if (response?.data?.statusCode == 1) { - let Paymentdevicefilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pd' && - item?.PaymentStatus === 'P' - ); - let PaymentGatewayfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pg' && - item?.PaymentStatus === 'P' - ); - let PayatCounterfilter = response?.data?.PaymentOrderDtl?.filter( - (item) => - item?.PaymentOptionType?.toLowerCase() === 'pc' && - item?.PaymentType === PayData?.PaymentDetail?.[0]?.PaymentType - ); - if ( - PayatCounterfilter?.length > 0 || - response?.data?.PaymentOrderDtl?.length === 0 - ) { - setMessageType('success'); - - // setSplitSelPayMode({...SplitSelPayMode,...{[`PaymentStatus-${i}`]:"S"}}) - - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - upi: null, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - setMessageData( - response?.data?.response + - ' ' + - (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]); - CustomerDisplay(); - ClearAllGlobalStateDatas(); - } - } - if (Paymentdevicefilter?.length === 1) { - if ( - Paymentdevicefilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pd' - ) { - PaymentDeviceFlow(Paymentdevicefilter, value); - } - } - - if (PaymentGatewayfilter?.length === 1) { - if ( - PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg' - ) { - PaymentGatewayFlow(PaymentGatewayfilter, value); - } - } - } }; - const PaymentDeviceFlow = async (Paymentdevicefilter, value) => { - await dispatch(changePaymentloader(true)); - await dispatch( - changePaymentTransactionNumber(Paymentdevicefilter?.[0]?.PaymentOrderId) + + const returnCount = (ProdName, currentQty, orderDetails, overallpcs) => { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdName === ProdName + ); + 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 + ) + ); + }, + 0 ); - let paymentdetail = { - TransactionNumber: Paymentdevicefilter?.[0]?.PaymentOrderId, - SequenceNumber: 1, - AllowedPaymentMode: - Paymentdevicefilter?.[0]?.PaymentTypeName?.toLowerCase() === 'card' - ? '1' - : Paymentdevicefilter?.[0]?.PaymentTypeName?.toLowerCase() === 'upi' - ? '10' - : '', - Amount: `${parseInt(Paymentdevicefilter?.[0]?.Amount) * 100}`, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - UserID: useOptions?.[0]?.PDConfigDetails?.[0]?.UserId, - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - AutoCancelDurationInMinutes: - useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes, - }; - let apiresponse = await dispatch(PostPaymentdevice(paymentdetail)).unwrap(); - if (apiresponse?.ResponseMessage?.toLowerCase() === 'approved') { - let pendingPaymentList = { - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - PlutusTransactionReferenceId: apiresponse?.PlutusTransactionReferenceID, - PaymentOrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - UpdatedBy: UserId, - }; - await dispatch(PutPendingPaymentList(pendingPaymentList)).unwrap(); - let isApproved = false; - const startTime = Date.now(); - let postpaymentdata = { - MerchantID: useOptions?.[0]?.PDConfigDetails?.[0]?.MerchantId, - SecurityToken: useOptions?.[0]?.PDConfigDetails?.[0]?.SecurityToken, - ClientID: useOptions?.[0]?.PDConfigDetails?.[0]?.ClientId, - StoreID: useOptions?.[0]?.PDConfigDetails?.[0]?.StoreId, - IMEI: useOptions?.[0]?.PDConfigDetails?.[0]?.IMEI, - PlutusTransactionReferenceID: apiresponse?.PlutusTransactionReferenceID, - }; - // Loop to call the second API every 3 seconds - while (!isApproved) { - let ApiResponseget = await dispatch( - GetPaymentdeviceResponse(postpaymentdata) - ).unwrap(); - - if (ApiResponseget?.ResponseMessage?.toLowerCase() === 'txn approved') { - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'S', - Amount: Paymentdevicefilter?.[0]?.Amount, - ResponseDtl: [ApiResponseget], - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - 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 && - setPrintOrderDetails([bookingpaymentupdate?.data]); - CustomerDisplay(value); - ClearAllGlobalStateDatas(value); - dispatch(changePaymentloader(false)); - } - isApproved = true; - console.log('Transaction Approved!'); - // Exit the loop - break; - } - - // Check if 1 minute has passed - if ( - Date.now() - startTime > - useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 - ) { - // 60,000 ms = 1 minute - - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'F', - Amount: Paymentdevicefilter?.[0]?.Amount, - ResponseDtl: [ApiResponseget], - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - setMessageType('error'); - setMessageData( - `Payment Failed. Your Transaction Number is ${Paymentdevicefilter?.[0]?.PaymentOrderId}` - ); - setFirstPaymentclick(false); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - dispatch(changePaymentloader(false)); - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - } - - console.error('Transaction not approved within 1 minute.'); - // Send an error message or handle the timeout - // You can dispatch an action, show a notification, etc. - break; - } - - // Wait for 3 seconds before making the next call - await new Promise((resolve) => setTimeout(resolve, 3000)); - } - } else { - let putbookingdata = { - OrderBookingId: Paymentdevicefilter?.[0]?.OrderId, - OrderId: Paymentdevicefilter?.[0]?.PaymentOrderId, - PaymentStatus: 'F', - Amount: Paymentdevicefilter?.[0]?.Amount, - PaymentType: Paymentdevicefilter?.[0]?.PaymentType, - UpdatedBy: UserId, - }; - let bookingpaymentupdate = await dispatch( - PutBookingPaymentStatusChange(putbookingdata) - ).unwrap(); - if (bookingpaymentupdate?.data?.statusCode === 1) { - setMessageType('error'); - setMessageData(apiresponse?.ResponseMessage); - setFirstPaymentclick(false); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - dispatch(changePaymentloader(false)); - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - } - } - }; - const PaymentGatewayFlow = async (PaymentGatewayfilter) => { - if (PaymentGatewayfilter?.[0]?.PaymentOptionType?.toLowerCase() === 'pg') { - await dispatch(changePaymentloader(true)); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderBookingId: PaymentGatewayfilter?.[0]?.OrderId, - Paymentgateway: true, - OrderPaymentId: PaymentGatewayfilter?.[0]?.PaymentOrderId, - OrderTotalAmount: PaymentGatewayfilter?.[0]?.Amount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - const checkPaymentStatus = async () => { - const intervalId = setInterval(async () => { - try { - let getpaymentgatewaydetail = await dispatch( - PaymentGatewayGetdetail(PaymentGatewayfilter?.[0]?.OrderId) - ).unwrap(); - - if (getpaymentgatewaydetail?.data?.statusCode === 1) { - let paymentdataget = - getpaymentgatewaydetail?.data?.PaymentOrderDtl?.find( - (item) => - item?.PaymentOrderId === - PaymentGatewayfilter?.[0]?.PaymentOrderId - )?.PaymentStatus; - - if (paymentdataget === 'S') { - setMessageType('success'); - setMessageData('Payment Success'); - await dispatch(changePaymentloader(false)); - if (getpaymentgatewaydetail?.data?.OrderDetails?.length > 0) { - setPrintOrderDetails([getpaymentgatewaydetail?.data]); - CustomerDisplay(value); - - ClearAllGlobalStateDatas(value); - } - clearInterval(intervalId); // Stop the loop when payment is successful - } else if (paymentdataget === 'F') { - setMessageType('error'); - setMessageData('Payment Failed'); - await dispatch(changePaymentloader(false)); - setFirstPaymentclick(false); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - clearInterval(intervalId); // Stop the loop when payment fails - CustomerDisplayRemovedData(); - ClearAllGlobalStateDatas(value); - // const customerDisplayWindow = getCustomerDisplayWindow(); - // if (customerDisplayWindow && !customerDisplayWindow.closed) { - // const updatedData = { - // userData: OrderCardDetail, - // ExtraCharges: GlobalExtraCharge, - // upi: GlobalUpiID, - // customer: selOption != null ? selOption : GetCustId, - // paymentMethod: Paybtnnameselected, - // Paymentgateway: false, - // OrderTotalAmount:PaymentGatewayfilter?.[0]?.Amount - - // }; - // customerDisplayWindow.postMessage(updatedData, '*'); - // } + // Include combo consumption from ReorderProductData (SetCount == 0) + try { + const reorderComboLines = (ReorderProductData || []).filter( + (a) => a?.Type === 'C' + ); + if (reorderComboLines?.length > 0) { + const reorderComboConsumed = reorderComboLines.reduce( + (sum, comboLine) => { + const setZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!setZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((inner, d) => { + const nameMatches = + d?.ProdName === ProdName || d?.ProductName === ProdName; + if (nameMatches && d?.StockAvailable === 'Y') { + const compQty = parseInt(d?.ProductQty ?? 1); + return inner + orderQty * (isNaN(compQty) ? 1 : compQty); } + return inner; + }, 0); + return sum + consumed; + }, + 0 + ); + totalSelectedProductQty = + parseInt(totalSelectedProductQty || 0) + + parseInt(reorderComboConsumed || 0); + } + } catch (_) {} + let getCurrentProdDtl = orderDetails?.filter( + (a) => a?.ProdName === ProdName + ); + let ComboProdDtl = orderDetails?.filter((a) => a?.Type === 'C'); + if (overallpcs === 'Y' && ComboProdDtl?.length > 0) { + getCurrentProdDtl = getCurrentProdDtl?.filter((a) => a?.Type !== 'C'); + } + let totalOrderQty = getCurrentProdDtl?.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 + ) + ); + }, 0); + + // Combo adjustment: + // If combos (Type === 'C') include this product and that component has SetCount == 0 + // and StockAvailable === 'Y', treat each occurrence as consuming one unit. + if (Array.isArray(ComboProdDtl) && ComboProdDtl.length > 0) { + try { + const comboExtraQty = ComboProdDtl.reduce((sum, comboLine) => { + // Use combo-level SetCount when detail-level SetCount is absent + const comboSetCountZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!comboSetCountZero) return sum; + const details = comboLine?.ProdDetail; + if (!Array.isArray(details)) return sum; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((innerSum, d) => { + const nameMatches = + d?.ProdName === ProdName || d?.ProductName === ProdName; + const stockYes = d?.StockAvailable === 'Y'; + if (nameMatches && stockYes) { + const compQty = parseInt(d?.ProductQty ?? 1); + return innerSum + orderQty * (isNaN(compQty) ? 1 : compQty); } - } catch (error) { - console.error('Error fetching payment details: ', error); - } - }, 3000); // Call the API every 3 seconds - }; + return innerSum; + }, 0); + return sum + consumed; + }, 0); + totalOrderQty = + parseInt(totalOrderQty || 0) + parseInt(comboExtraQty || 0); + } catch (e) { + // ignore structure mismatches + } + } + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(currentQty) > + parseInt( + Object?.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object?.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); - // Call the function to start checking payment status - checkPaymentStatus(); + return parseInt(count); + } else { + let count = 0; + return count; } }; - const CustomerDisplayRemovedData = () => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - userData: [], - ExtraCharges: [], - Paymentgateway: false, - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' + const returnOnepcCount = (ProdName, currentQty, orderDetails, overallpcs) => { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdName === ProdName + ); + 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 = orderDetails?.filter( + (a) => a?.ProdName === ProdName + ); + + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) ); + }, 0); + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(currentQty) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; } }; - const CustomerDisplay = (value) => { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (value == 'TakeAway') { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - userData: [], - ExtraCharges: [], - Paymentgateway: false, - upioption1: 'okk', - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' + const returnQtyCount = (ProdId, item, orderDetails) => { + if (onePeiceFlow) { + let ItemQuantity = item?.ProdVariantDetails?.reduce( + (accumulator, card) => { + return accumulator + parseInt(card.OverAllPcs || 0); + }, + 0 + ); + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId + ); + let totalSelectedProductQty = SelectedProduct?.reduce( + (accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, + 0 + ); + + // Include combo consumption from ReorderProductData (pieces flow) + try { + const reorderComboLines = (ReorderProductData || []).filter( + (a) => a?.Type === 'C' ); + if (reorderComboLines?.length > 0) { + const reorderComboConsumed = reorderComboLines.reduce( + (sum, comboLine) => { + const setZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!setZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((inner, d) => { + if (d?.ProdId === ProdId && d?.StockAvailable === 'Y') { + const compQty = parseInt(d?.ProductQty ?? 1); + return inner + orderQty * (isNaN(compQty) ? 1 : compQty); + } + return inner; + }, 0); + return sum + consumed; + }, + 0 + ); + totalSelectedProductQty = + parseInt(totalSelectedProductQty || 0) + + parseInt(reorderComboConsumed || 0); + } + } catch (_) {} + let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + // Include combo consumption for pieces flow + try { + const comboLines = orderDetails?.filter((a) => a?.Type === 'C') || []; + const comboConsumed = comboLines.reduce((sum, comboLine) => { + const comboSetZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!comboSetZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumedForThisCombo = details.reduce((inner, d) => { + if (d?.ProdId === ProdId && d?.StockAvailable === 'Y') { + const compQty = parseInt(d?.ProductQty ?? 1); + return inner + orderQty * (isNaN(compQty) ? 1 : compQty); + } + return inner; + }, 0); + return sum + consumedForThisCombo; + }, 0); + totalOrderQty = + parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); + } catch (_) {} + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(ItemQuantity) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(ItemQuantity) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + + return parseInt(count); + } else { + let count = 0; + return count; } } else { - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' + let ItemQuantity = item?.ProdVariantDetails?.reduce( + (accumulator, card) => { + return accumulator + parseInt(card.OverAllQty || 0); + }, + 0 + ); + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId + ); + 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 + ) + ); + }, + 0 + ); + + // Include combo consumption from ReorderProductData (quantity flow) + try { + const reorderComboLines = (ReorderProductData || []).filter( + (a) => a?.Type === 'C' ); + if (reorderComboLines?.length > 0) { + const reorderComboConsumed = reorderComboLines.reduce( + (sum, comboLine) => { + const setZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!setZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((inner, d) => { + if (d?.ProdId === ProdId && d?.StockAvailable === 'Y') { + return inner + orderQty; + } + return inner; + }, 0); + return sum + consumed; + }, + 0 + ); + totalSelectedProductQty = + parseInt(totalSelectedProductQty || 0) + + parseInt(reorderComboConsumed || 0); + } + } catch (_) {} + let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); + let totalOrderQty = getCurrentProdDtl?.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 + ) + ); + }, 0); + // Include combo consumption for quantity flow + try { + const comboLines = orderDetails?.filter((a) => a?.Type === 'C') || []; + const comboConsumed = comboLines.reduce((sum, comboLine) => { + const comboSetZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!comboSetZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumedForThisCombo = details.reduce((inner, d) => { + if (d?.ProdId === ProdId && d?.StockAvailable === 'Y') { + return inner + orderQty; + } + return inner; + }, 0); + return sum + consumedForThisCombo; + }, 0); + totalOrderQty = + parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); + } catch (_) {} + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(ItemQuantity) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(ItemQuantity) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + + return parseInt(count); + } else { + let count = 0; + return count; } } }; - const columns = [ + + const returnCountStock = ( + ProdId, + currentQty, + orderDetails, + InwardDtlId, + onepcavailable, + overallpcs + ) => { + if (onepcavailable === 'Y') { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId + ); + let totalSelectedProductQty = SelectedProduct?.reduce( + (accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, + 0 + ); + + // Include combo consumption from ReorderProductData (pieces + batch) + try { + const reorderComboLines = (ReorderProductData || []).filter( + (a) => a?.Type === 'C' + ); + if (reorderComboLines?.length > 0) { + const reorderComboConsumed = reorderComboLines.reduce( + (sum, comboLine) => { + const setZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!setZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((inner, d) => { + if ( + d?.ProdId === ProdId && + d?.InwardDtlId === InwardDtlId && + d?.StockAvailable === 'Y' + ) { + const compQty = parseInt(d?.ProductQty ?? 1); + return inner + orderQty * (isNaN(compQty) ? 1 : compQty); + } + return inner; + }, 0); + return sum + consumed; + }, + 0 + ); + totalSelectedProductQty = + parseInt(totalSelectedProductQty || 0) + + parseInt(reorderComboConsumed || 0); + } + } catch (_) {} + let getCurrentProdDtl = orderDetails?.filter( + (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId + ); + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + + // Include combo consumption (no one-piece logic for combos) + try { + const comboLines = orderDetails?.filter((a) => a?.Type === 'C') || []; + const comboConsumed = comboLines.reduce((sum, comboLine) => { + const comboSetZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!comboSetZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumedForThisCombo = details.reduce((inner, d) => { + if ( + d?.ProdId === ProdId && + d?.InwardDtlId === InwardDtlId && + d?.StockAvailable === 'Y' + ) { + const compQty = parseInt(d?.ProductQty ?? 1); + return inner + orderQty * (isNaN(compQty) ? 1 : compQty); + } + return inner; + }, 0); + return sum + consumedForThisCombo; + }, 0); + totalOrderQty = + parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); + } catch (_) {} + + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(currentQty) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; + } + } else { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId && a?.InwardDtlId === 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 + ) + ); + }, + 0 + ); + + // Include combo consumption from ReorderProductData (quantity + batch) + try { + const reorderComboLines = (ReorderProductData || []).filter( + (a) => a?.Type === 'C' + ); + if (reorderComboLines?.length > 0) { + const reorderComboConsumed = reorderComboLines.reduce( + (sum, comboLine) => { + const setZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!setZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumed = details.reduce((inner, d) => { + if ( + d?.ProdId === ProdId && + d?.InwardDtlId === InwardDtlId && + d?.StockAvailable === 'Y' + ) { + return inner + orderQty; + } + return inner; + }, 0); + return sum + consumed; + }, + 0 + ); + totalSelectedProductQty = + parseInt(totalSelectedProductQty || 0) + + parseInt(reorderComboConsumed || 0); + } + } catch (_) {} + let getCurrentProdDtl = orderDetails?.filter( + (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId + ); + + let totalOrderQty = getCurrentProdDtl?.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 + ) + ); + }, 0); + + // Include combo consumption for quantity flow + try { + const comboLines = orderDetails?.filter((a) => a?.Type === 'C') || []; + const comboConsumed = comboLines.reduce((sum, comboLine) => { + const comboSetZero = + comboLine?.SetCount === 0 || comboLine?.SetCount === '0'; + if (!comboSetZero) return sum; + const details = Array.isArray(comboLine?.ProdDetail) + ? comboLine?.ProdDetail + : []; + const orderQty = parseInt(comboLine?.OrderQty || 1); + const consumedForThisCombo = details.reduce((inner, d) => { + if ( + d?.ProdId === ProdId && + d?.InwardDtlId === InwardDtlId && + d?.StockAvailable === 'Y' + ) { + return inner + orderQty; + } + return inner; + }, 0); + return sum + consumedForThisCombo; + }, 0); + totalOrderQty = + parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); + } catch (_) {} + + let OverallProdQty = totalOrderQty - totalSelectedProductQty; + if ( + parseInt(currentQty) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? OverallProdQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; + } + } + }; + + const returnVariantStock = ( + ProdId, + currentQty, + orderDetails, + ProdVariantName + ) => { + if (onePeiceFlow) { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName + ); + 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 = orderDetails?.filter( + (a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName + ); + let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { + return ( + accumulator + + parseInt( + card?.StockAvailable === 'Y' + ? card.SinglePc !== 'Y' + ? card.OrderQty * card.NoOfPcs + : card.OrderQty + : 0 + ) + ); + }, 0); + + if ( + parseInt(currentQty) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? totalOrderQty - totalSelectedProductQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? totalOrderQty - totalSelectedProductQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; + } + } else { + let SelectedProduct = ReorderProductData?.filter( + (a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName + ); + 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 + ) + ); + }, + 0 + ); + let getCurrentProdDtl = orderDetails?.filter( + (a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName + ); + let totalOrderQty = getCurrentProdDtl?.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 + ) + ); + }, 0); + + if ( + parseInt(currentQty) > + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? totalOrderQty - totalSelectedProductQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ) + ) { + let count = + parseInt(currentQty) - + parseInt( + Object.keys(ReportholdData)?.length > 0 && totalOrderQty + ? totalOrderQty - totalSelectedProductQty + : getCurrentProdDtl + ? totalOrderQty + : 0 + ); + return parseInt(count); + } else { + let count = 0; + return count; + } + } + }; + + const varientcolumns = [ { - title: 'Sl.No', - key: 'sno', - align: 'center', - width: '100px', - render: (text, object, index) => ( - {index + 1} + title: 'Variant Name', + dataIndex: 'VarientName', + key: 'VarientName', + align: 'left', + render: (_, record, index) => ( + 0 || + record.StockCount === 'Stock Not Maintained' + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record.VarientName} + ), - }, - { - title: 'Table Name/Chair Name', - dataIndex: 'TableName', - key: 'TableName', - width: '150px', - onCell: (_, record, index) => { + onCell: (record) => { return { onClick: () => { - Unpaidfun(record); + if ( + record.StockCount > 0 || + record.StockCount === 'Stock Not Maintained' + ) { + Stockfun(record); + } }, }; }, }, { - title: 'Order Id', - dataIndex: 'OrderID', - key: 'OrderID', - width: '150px', - align: 'right', - onCell: (_, record, index) => { + title: 'Stock Count', + dataIndex: 'StockCount', + key: 'StockCount', + align: 'Right', + render: (_, record, index) => ( + 0 || + record.StockCount === 'Stock Not Maintained' + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record.StockCount} + + ), + onCell: (record) => { return { onClick: () => { - Unpaidfun(record); - }, - }; - }, - }, - { - title: "Item's", - dataIndex: 'ProductName', - key: 'ProductName', - width: '250px', - onCell: (_, record, index) => { - return { - onClick: () => { - Unpaidfun(record); + if ( + record.StockCount > 0 || + record.StockCount === 'Stock Not Maintained' + ) { + Stockfun(record); + } }, }; }, }, { title: 'Amount', - dataIndex: 'TotalAmount', - key: 'TotalAmount', - width: '150px', + dataIndex: 'Amount', + key: 'Amount', align: 'right', - render: (text) => {safeRound(text)}, - onCell: (_, record, index) => { + render: (_, record, index) => ( + 0 || + record.StockCount === 'Stock Not Maintained' + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record.Amount} + + ), + onCell: (record) => { return { onClick: () => { - Unpaidfun(record); + if ( + record.StockCount > 0 || + record.StockCount === 'Stock Not Maintained' + ) { + Stockfun(record); + } }, }; }, }, ]; + const stockcolumns = [ + { + title: 'Batch No', + dataIndex: 'Batch No', + key: 'Batch No', + align: 'center', + render: (text, record, index) => ( + 0 + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record?.['Batch No']} + + ), + onCell: (record) => { + return { + onClick: () => { + if (record.StockCount > 0) { + StockSelected(record); + } + }, + }; + }, + }, + { + title: 'Stock Count', + dataIndex: 'StockCount', + key: 'StockCount', + align: 'center', + render: (_, record, index) => ( + 0 + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record.StockCount} + + ), + onCell: (record) => { + return { + onClick: () => { + if (record.StockCount > 0) { + StockSelected(record); + } + }, + }; + }, + }, + { + title: 'Stock Date', + dataIndex: 'Stock Date', + key: 'Stock Date', + align: 'center', + render: (_, record, index) => ( + 0 + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record?.['Stock Date']} + + ), + onCell: (record) => { + return { + onClick: () => { + if (record.StockCount > 0) { + StockSelected(record); + } + }, + }; + }, + }, + { + title: 'Exp Date', + dataIndex: 'ExpDate', + key: 'ExpDate', + align: 'center', + render: (_, record, index) => ( + 0 + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {record.ExpDate} + + ), + onCell: (record) => { + return { + onClick: () => { + if (record.StockCount > 0) { + StockSelected(record); + } + }, + }; + }, + }, + { + title: 'Price', + dataIndex: 'Price', + key: 'Price', + align: 'center', + render: (_, record, index) => ( + 0 + ? { color: '#000', cursor: 'pointer' } + : { color: '#f49898', cursor: 'not-allowed' } + } + > + {safeRound(record.Price)} + + ), + onCell: (record) => { + return { + onClick: () => { + if (record.StockCount > 0) { + StockSelected(record); + } + }, + }; + }, + }, + ]; + const qtydataSource = []; - const TableData = []; - tabledata?.map((item) => - TableData.push({ - TableName: item.SalesTableLinkDetails?.map((item) => - item.ChairName == null ? item.TableName : item.ChairName - )?.join(','), - OrderID: extractLastNumberOrderId(item?.OrderId, item?.FYStatus), - ProductName: item.productDetails - ?.map( - (item) => - item?.ProdName + - '-' + - (item?.Type != 'C' ? item?.OrderQty : '1 Combo') + qtydata?.ProductDetail?.map((item, index) => { + qtydataSource.push({ + key: index, + Quantity: item?.Size + ' ' + item?.UomName, + Amount: item?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice, + }); + }); + const varientdataSource = []; + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.map((item, index) => { + varientdataSource.push({ + key: index, + VarientName: item?.ProdVariantName, + Amount: onePeiceFlow + ? item?.StockDetails?.[0]?.OnePcsPrice + : item?.StockDetails?.[0]?.SellPrice, + StockCount: + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable === 'Y' + ? onePeiceFlow + ? returnVariantStock( + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.ProdVariantName + ) + : returnVariantStock( + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) + : 'Stock Not Maintained', + VariantAvailableFrom: item?.AvailableFrom, + VariantAvailableTo: item?.AvailableTo, + SlotStatus: item?.StockDetails?.[0]?.SlotStatus, + InwardDtlId: item?.StockDetails?.[0]?.InwardDtlId, + BookedDate: selectedDate, + BookedQty: item?.StockDetails?.[0]?.BookedQty, + TotalSlotQty: item?.StockDetails?.[0]?.TotalSlotQty, + }); + }); + + const stockdataSource = []; + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.map((item, index) => { + const expDate = new Date(item?.ExpDate); + stockdataSource.push({ + key: index, + 'Batch No': item?.BatchRef, + StockCount: onePeiceFlow + ? returnCountStock( + item?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.InwardDtlId, + 'Y' + ) + : returnCountStock( + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId, + 'N', + item?.OverAllPcs + ), + 'Stock Date': ExtractDateFormate(item?.InwardDate), + Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, + ExpDate: + expDate != 'Invalid Date' || null || undefined || '' + ? ExtractDateFormate(item?.ExpDate) + : '-', + }); + }); + + const extractProductDetails = (a, QtyIndex, VarientIndex, stockIndex) => { + const detail = a?.ProductDetail?.[QtyIndex]; + const variant = detail?.ProdVariantDetails?.[VarientIndex]; + const stock = variant?.StockDetails?.[stockIndex]; + + return { detail, variant, stock }; + }; + + const buildOrderData = ( + a, + detail, + variant, + stock, + size, + orderRate, + onePcs, + weightscale + ) => { + const { ProdCat, Type, OverAllQty: OverallQuantity, CounterName } = a || {}; + const { + ActiveStatus, + AvailableFrom, + AvailableTo, + Cess, + HSNCode, + BrandName, + OpeningQty, + PartNumber, + ProdId, + ProdLogo, + ProdName, + QRCode, + QtyBasedPrice, + Rack, + StockAvailable, + TokenAvailable, + TaxId, + TaxPercentage, + TaxIdName: TaxName, + UniqueId, + UomName, + DiscountLimitType, + DiscountLimit, + } = detail || {}; + + const { + NoOfPcs, + BalanceQty, + BatchRef, + ModelNumber, + ProductIdentifierDtls: FullProductIdentifierDtls, + InwardDate, + InwardDtlId, + ExpDate, + InwardId, + MRP, + OnePcsPrice, + SellPrice, + SuppId, + SuppName, + OverAllPcs, + OfferPrice: Offer, + TotalSlotQty, + BookedQty, + } = stock || {}; + const BalanceBookedQty = TotalSlotQty || 0 - BookedQty || 0; + + const { + ProdVariantName, + AvailableFrom: VariantAvailableFrom, + AvailableTo: VariantAvailableTo, + } = variant || {}; + + return { + ProdCat, + Type, + OverallQuantity, + ActiveStatus, + AvailableFrom, + AvailableTo, + Cess, + HSNCode, + BrandName, + OpeningQty, + PartNumber, + ProdId, + ProdLogo, + ProdName, + QRCode, + QtyBasedPrice, + Rack, + Size: size, + StockAvailable, + TokenAvailable, + TaxId, + TaxPercentage, + TaxName, + UniqueId, + UomName: onePcs ? 'PCS' : UomName, + SinglePc: onePcs ? 'Y' : 'N', + NoOfPcs, + ProdVariantName, + VariantAvailableFrom, + VariantAvailableTo, + BalanceQty, + BatchRef, + ModelNumber, + FullProductIdentifierDtls, + InwardDate, + InwardDtlId, + ExpDate, + InwardId, + MRP: onePcs ? OnePcsPrice : MRP, + OrderRate: orderRate, + SellingPrice: orderRate, + SuppId, + SuppName, + OverAllPcs, + Offer, + BookingTypeName: BookingType, + CounterName, + DiscountLimitType, + DiscountLimit, + BookedDate: selectedDate, + BalanceBookedQty, + ScaleType: weightscale ? weightscale : '', + }; + }; + + const resetProductModal = () => { + setModelQty(false); + setSelectedBrand('Others'); + setModalVarient(false); + setModelstock(false); + setQtyIndex(0); + setVarientIndex(0); + setVarItem(0); + setItem(); + setStockItem(); + dispatch(changeSearchedData('')); + setOnePeiceFlow(false); + }; + + const dataTransfer = async ( + a, + QtyIndex, + VarientIndex, + stockIndex, + onePcs + ) => { + const { detail, variant, stock } = extractProductDetails( + a, + QtyIndex, + VarientIndex, + stockIndex + ); + + console.log(stock, 'stock in dataTransfer'); + // mohan 05-08-2025 + const price = onePcs + ? stock?.OnePcsPrice + : RetailWSSalesType === 'W' + ? stock?.WhSalePrice || stock?.SellPrice + : stock?.SellPrice; + const size = onePcs ? '1' : detail?.Size; + if (quickBranchtoBranchTransfer) { + const data = buildOrderData( + a, + detail, + variant, + stock, + size, + price, + onePcs + ); + if (!selectedProducts?.some((s) => s.ProdId === detail?.ProdId)) { + dispatch( + changeBtoBQuickProductTransfer({ + action: quickBranchtoBranchTransfer, + selectedProducts: [ + ...selectedProducts, + { + ...data, + OrderQty: 1, + TotalAmt: parseFloat(detail?.OrderRate).toFixed(2), + }, + ], + }) + ); + } else { + setMessageType('error'); + setMessageData('Product already added'); + } + } else { + const isKgsProduct = + (detail?.UomName?.toLowerCase() === 'kgs' || + detail?.UomName?.toLowerCase() === 'kg') && + detail?.Size === '1'; + console.log( + isKgsProduct, + WeightScalePort, + WeightScaleWeight, + 'isKgsProduct' + ); + if ( + WeightScalePort === true && + isKgsProduct && + WeightScaleWeight > 0.005 && + WeightScaleWeight !== null + ) { + let weightscale = 'weight'; + // if (isKgsProduct) { + // if (WeightScaleWeight > 0 && WeightScaleWeight !== null) { + const basePrice = onePcs ? stock?.OnePcsPrice : stock?.SellPrice; + const totalRate = ( + (basePrice / 1000) * + (parseFloat(WeightScaleWeight) * 1000) + ).toFixed(2); + let orderqty = parseFloat(WeightScaleWeight); + const data = buildOrderData( + a, + detail, + variant, + stock, + detail?.Size, + basePrice, + onePcs, + weightscale + ); + let fulldata = { + ...data, + OrderQty: orderqty, + }; + + await AddOrderDetails(fulldata); + // dispatch(changeWeightScaleWeight(null)); + setRepeatedModel(false); + setProdexpir(false); + resetProductModal(); + } else { + const isValidPcs = + onePcs && stock?.NoOfPcs > 0 && stock?.OnePcsPrice > 0; + const allowNonPcs = + !onePcs || + (detail?.StockAvailable !== 'Y' && onePcs && stock?.OnePcsPrice > 0); + + if (isValidPcs || allowNonPcs) { + const data = buildOrderData( + a, + detail, + variant, + stock, + size, + price, + onePcs + ); + + resetProductModal(); + AddOrderDetails(data); + } else { + setMessageType('error'); + setMessageData( + 'Please add No.of pieces Inside the box in Product master' + ); + resetProductModal(); + } + } + } + }; + + useEffect(() => { + setPreOrderSelectedProdNames(GPreOrderList); + }, [GPreOrderList]); + + const pickData = (e, item) => { + if (e.target.checked === true) { + setSelectedProdNames([ + ...globalAllItemdata, + { + ProdName: item.ProdName, + ProdId: item.ProductDetail?.[0]?.ProdId, + ProdCat: item.ProdCat, + ProdCatName: item.ProdCatName, + }, + ]); + } else { + console.log('SelectedProdNames', SelectedProdNames); + setSelectedProdNames( + SelectedProdNames?.filter( + (data) => + !(data?.ProdName == item.ProdName && data?.ProdCat == item.ProdCat) ) - ?.join(','), - TotalAmount: item.NetAmount, + ); + } + }; + + const handleQuickCancel = async () => { + setQuickAdd(false); + dispatch(changeSearchedData('')); + + // Base data for all calls + let baseData = { + CompId, + BranchId, + AppId, + }; + + // 👇 Only add date if AvailableDate and selectedDate exist + if (AvailableDate && selectedDate) { + baseData.Date = selectedDate; + } + // 1️⃣ Favourite items + await dispatch(getSelectedFavItems(baseData)).unwrap(); + + // 2️⃣ For layout with SubCategory + let data1 = { + ...baseData, + ProdSubCat, + }; + + // 3️⃣ For layout without SubCategory + let data2 = { + compId: CompId, + branchId: BranchId, + appId: AppId, + prodCat: ProdCat, + ...(AvailableDate && selectedDate ? { date: selectedDate } : {}), // conditionally add + }; + + if ( + templateData?.BookingLayout?.[1]?.some( + (item) => item?.OptionName === 'SubCategory' + ) && + ProdSubCat + ) { + await dispatch(getLayoutproductCard(data1)).unwrap(); + } else if ( + !templateData?.BookingLayout?.[1]?.some( + (item) => item?.OptionName === 'SubCategory' + ) + ) { + await dispatch(getCardDataWithoutSubmodule(data2)).unwrap(); + } else { + await dispatch(getCardDataWithoutSub(data2)).unwrap(); + } + }; + + const onComplete = useCallback(() => { + setMessageData(null); + setMessageType(null); + }, []); + + const expFun = (item) => { + console.log(item, 'itemitemitemitemitemitemitemitem'); + let count = item?.ProductDetail?.length; + if (count > 1) { + Quantity(); + } else { + setVarItem(0); + SingleQuantity(item, onePeiceFlow); + } + + closeExpireModal(); + setProdexpir(true); + setQtydata(item); + }; + let brandMapping = {}; + // Group product details by Brand ID + qtydata?.ProductDetail?.forEach((item) => { + const brandId = item?.BrandName; + if (!brandMapping[brandId]) { + brandMapping[brandId] = []; + } + brandMapping[brandId].push(item); + }); + const BrandCheckresult = qtydata?.ProductDetail?.every((product) => { + return product.BrandName === null || product.BrandName === undefined; + }); + const ItemSellingPrice = (item) => { + // const variantWithDetails = item?.ProductDetail?.find((variant) => variant?.ProdVariantDetails?.length > 0); + + if (preferenceSingleSales && item.OnePcsAvailable === 'Y') { + return ( + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.OnePcsPrice || null + ); + // OnePcsPrice + } + + const variantWithDetails = item?.ProductDetail?.find( + (variant) => + variant?.ProdVariantDetails?.length > 0 && + variant?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice + ); + if (variantWithDetails) { + // Access the details of the first variant with ProdVariantDetails + const firstVariantDetails = + variantWithDetails?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.SellPrice; + return firstVariantDetails; + } else { + // Handle the case where no variant satisfies the condition + return null; // or any other value you want to return + } + }; + + const ItemSize = (item) => { + if (preferenceSingleSales && item?.OnePcsAvailable === 'Y') { + return 1; + } + const variantWithDetails = item?.ProductDetail?.find( + (variant) => variant?.ProdVariantDetails?.length > 0 + ); + + if (variantWithDetails) { + // Access the details of the first variant with ProdVariantDetails + const firstVariantDetails = variantWithDetails?.Size; + return firstVariantDetails; + } else { + // Handle the case where no variant satisfies the condition + return null; // or any other value you want to return + } + }; + const ItemUomName = (item) => { + if (preferenceSingleSales && item?.OnePcsAvailable === 'Y') { + return 'PCS'; + } + const variantWithDetails = item?.ProductDetail?.find( + (variant) => variant?.ProdVariantDetails?.length > 0 + ); + + if (variantWithDetails) { + // Access the details of the first variant with ProdVariantDetails + const firstVariantDetails = variantWithDetails?.UomName; + return firstVariantDetails; + } else { + // Handle the case where no variant satisfies the condition + return null; // or any other value you want to return + } + }; + const expQtyFun = (index) => { + const selectedProIndex = qtydata?.ProductDetail?.findIndex( + (item) => + item?.ProdId === index?.ProdId && + item?.Size === index?.Size && + item?.UomName === index?.UomName && + item?.Brand === index?.Brand + ); + + if (selectedProIndex !== -1) { + const count = + qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails?.length || + 0; + + if (count > 1) { + setModelQty(false); + setSelectedBrand('Others'); + setModalVarient(true); + } else { + const item = { QtyIndex: selectedProIndex, VarientIndex: 0 }; + singleVarient(item); + setModelQty(false); + setSelectedBrand('Others'); + } + } + + setQtyIndex(selectedProIndex); + setRepeatedModel(true); + closeExpireModal(); + }; + + const expVerFun = (item) => { + let count = + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[item] + ?.StockDetails?.length; + if (count > 1) { + setRepeatedModel(true); + setModalVarient(false); + setModelstock(true); + } else { + setRepeatedModel(true); + dataTransfer(qtydata, QtyIndex, item, 0, onePeiceFlow); + setModelQty(false); + setSelectedBrand('Others'); + } + closeExpireModal(); + }; + + const expStockFun = (item) => { + dataTransfer(qtydata, QtyIndex, VarientIndex, item, onePeiceFlow); + closeExpireModal(); + }; + + const getMaxBrandWidth = () => { + let maxBrandDataLength = 0; + + // Iterate through each brand and find the maximum length of the specified key + Object.values(brandMapping).forEach((brand) => { + const keyDataLength = brand.length; + if (keyDataLength > maxBrandDataLength) { + maxBrandDataLength = keyDataLength; + } + }); + + // Set your width logic here based on the maxBrandDataLength + const maxWidth = maxBrandDataLength >= 5 ? 750 : 'max-content'; + + return maxWidth; + }; + + useEffect(() => { + function handleResize() { + setScreenWidth(window.innerWidth); + } + + window.addEventListener('resize', handleResize); + + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); + + // Example usage for checking the length of 'ProdVariantDetails' + const widthBasedOnProdVariantDetails = getMaxBrandWidth(); + const ExpDate = useSelector(GlobalExpDateforHeight); + let containerHeight = ''; + + if (templateData?.BookingLayout?.[0] === 'Layout1') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 340}px` + : '63vh' + : screenWidth < 600 + ? `${props?.screenHeight - 350}px` + : '62vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '63vh' + : screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '62vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '60vh' + : screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '59vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '60vh' + : screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '59vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '60vh' + : screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '59vh' + : '76vh'; + } + } else if (templateData?.BookingLayout?.[0] === 'Layout2') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '60vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '63vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '62vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '63vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '62vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '61vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '59vh' + : '74vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 310}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : '75vh'; + } + } else if (templateData?.BookingLayout?.[0] === 'Layout3') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 390}px` + : '58vh' + : screenWidth < 600 + ? `${props?.screenHeight - 400}px` + : '57vh' + : '73vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 390}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 400}px` + : '56vh' + : '73vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 395}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 400}px` + : '56vh' + : '73vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 390}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 400}px` + : '56vh' + : '75vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 385}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 395}px` + : '56vh' + : '72vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 385}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 395}px` + : '56vh' + : '72vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 390}px` + : '57vh' + : screenWidth < 600 + ? `${props?.screenHeight - 400}px` + : '56vh' + : '72vh'; + } + } else if (templateData?.BookingLayout?.[0] === 'Layout4') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 220}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 230}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 230}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 240}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 230}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 240}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '73vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : '88vh'; + } + } else if (templateData?.BookingLayout?.[0] === 'Layout5') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 280}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 290}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 280}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 280}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '70vh' + : '88vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 270}px` + : '72vh' + : screenWidth < 600 + ? `${props?.screenHeight - 280}px` + : '70vh' + : '88vh'; + } + } else if (templateData?.BookingLayout?.[0] === 'Layout6') { + if (templateData?.BookingBilling?.[0] == 'Billing1') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 340}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing2') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 260}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 370}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing3') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing4') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing5') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 290}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 300}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing6') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 320}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 330}px` + : '60vh' + : '76vh'; + } else if (templateData?.BookingBilling?.[0] == 'Billing7') { + containerHeight = isMobile + ? ExpDate >= 7 + ? screenWidth < 600 + ? `${props?.screenHeight - 280}px` + : '61vh' + : screenWidth < 600 + ? `${props?.screenHeight - 290}px` + : '60vh' + : '76vh'; + } + } + + //new + const [draggableCardData, setDraggableCardData] = useState([]); + useEffect(() => { + if (Array.isArray(cardData)) { + const withIds = cardData.map((item, idx) => ({ + ...item, + id: item?.ProductDetail?.[0]?.ProdName + '-' + idx, + })); + setDraggableCardData(withIds); + } + }, [cardData, alphabeticFormat]); + + const sensors = useSensors( + useSensor(PointerSensor, { + activationConstraint: { + distance: isMobile ? 5 : 8, // <- reduced distance for mobile + }, + }), + useSensor(TouchSensor, { + activationConstraint: { + delay: isMobile ? 50 : 100, // <- even faster response for mobile + tolerance: isMobile ? 10 : 8, // <- more tolerance for mobile touch + }, }) ); - const Unpaidfun = async (event) => { - const UpdatedData = tabledata?.[event]?.productDetails; - dispatch(changeunpaidflow(true)); - if ( - OrderCardDetail?.length > 0 && - (BookingType === 'Dine In' || BookingTypeBoth) - ) { - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer([]); - } else { - dispatch(changeOrderCardDetails([])); - } - // 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); - setunpaidselectedindex(event); - } else { - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer(UpdatedData); - } else { - dispatch(changeOrderCardDetails(UpdatedData)); - } - dispatch(changeReorderHoldDetails([tabledata?.[event]]?.[0])); - await dispatch( - changeReorderProductDetails(tabledata?.[event]?.productDetails) - ); - dispatch(ChangeTotalAmount(tabledata?.[event]?.ExtraChargeDetails)); - setUnpaidOpen(false); + const handleDragEnd = (event) => { + const { active, over } = event; + + // Ensure `over` is not null + if (!over) return; + + if (active.id !== over.id) { + const oldIndex = draggableCardData.findIndex((i) => i.id === active.id); + const newIndex = draggableCardData.findIndex((i) => i.id === over.id); + + const updatedData = arrayMove(draggableCardData, oldIndex, newIndex); + + setDraggableCardData(updatedData); + + dispatch(changeCardData(updatedData)); } }; - const UnpaidOk = async () => { - setOrderStatus(false); - await dispatch(changeSelectedTableDetails([])); - await dispatch(changeSelectTable([])); - await dispatch(changeSelectChair([])); - await dispatch(changeBookingType('TakeAway')); - await dispatch( - changeOrderCardDetails(tabledata?.[unpaidselectedindex]?.productDetails) - ); - await dispatch( - changeReorderProductDetails( - tabledata?.[unpaidselectedindex]?.productDetails - ) - ); - await dispatch( - changeReorderHoldDetails([tabledata?.[unpaidselectedindex]]?.[0]) - ); - await dispatch( - ChangeTotalAmount(tabledata?.[unpaidselectedindex]?.ExtraChargeDetails) - ); - await dispatch(changeUnpaidData(true)); - setUnpaidOpen(false); - setUnpaidConfirmation(false); - }; - const Unpaidclose = async () => { - dispatch(changeunpaidflow(false)); - setUnpaidOpen(false); - setUnpaidConfirmation(false); - }; + const updateScrollButtons = () => { + const container = scrollContainerRef.current; + if (!container) return; - const Recipt = async () => { - AddBookingDetails('Unpaid', false); - }; - const navigateDineIn = async () => { - navigate(`${subDirectory}sales/dine-in`); - await dispatch(changeBookingType('Dine In')); - await dispatch(changeEstimateBooking('Sales')); - if (OrderType === 'Hold') { - await dispatch(changeReorderHoldDetails({})); - await dispatch(changeReorderProductDetails([])); + const { scrollLeft, scrollWidth, clientWidth } = container; - if (OfferCheckedInSetup && preferenceOffer) { - await applyOffer([]); - } else { - dispatch(changeOrderCardDetails([])); - } - } + console.log( + container, + 'sl:', + scrollLeft, + 'w:', + scrollWidth, + 'cw:', + clientWidth + ); + + setShowLeftButton(scrollLeft > 5); + setShowRightButton(scrollLeft + clientWidth < scrollWidth - 5); }; useEffect(() => { - if (ReprintModal === true) { - setReprint1(false); - } - }, [ReprintModal]); - const handleReprint = () => { - // setReprint1(true) - window.dispatchEvent(new Event('CLICK REPRINT')); - }; - const handleReprintCancel = () => { - setReprint1(false); - }; - const today = new Date(); - const year = today.getFullYear(); - // Note: Months are zero-based, so we add 1 to get the actual month - const month = today.getMonth() + 1; - const day = today.getDate(); + const container = scrollContainerRef.current; + if (!container) return; - // Creating a formatted date string (in the format YYYY-MM-DD) - const Todaydate = `${day < 10 ? '0' : ''}${day}-${month < 10 ? '0' : ''}${month}-${year}`; - const OrderId = PrintOrderDetails?.[0]?.OrderDetails?.[0]?.OrderId; - let MobileNo = selOption?.value; - useEffect(() => { - if (selOption) { - closePrintOption(); - setMobileNoWhatsApp(selOption); - } - }, [selOption]); - const UpiPayment = () => { - if (OrderStatus) { - AddBookingDetails('Dine-In', false); - } else { - if (SelectedUpiOption && TotalAmount == 0) { - Upimodel('Submit'); - } else if (SelectedUpiOption) { - setUpiOpen(true); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - OrderTotalAmount: TotalAmount, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - } else { - setUpinotSelected(true); - setMessageType('error'); - setMessageData('Please Select Upi Option'); - } - } - }; + // ✅ Call once after layout + requestAnimationFrame(() => { + updateScrollButtons(); + }); - const onFinalSubmit = async () => { - let url = `${MainHomeUrl}payment-page?amt=${TotalAmount}&Id=${MobileNo}&cus=${SelCustId} &CusN=${selOption?.CustName}&Br=${brachName}`; - let response = await dispatch(SendPaymentLink({ MobileNo, url })).unwrap(); - if (response?.data?.statusCode === 1) { - setMessageType('success'); - setMessageData('Link Sent Successfully'); - } - }; - const Upimodel = (type) => { - setUpiOpen(false); - if (type == 'Submit') { - AddBookingDetails(BookingType, true); - } - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedRemovedData = { - type: 'remove', - keyValue: 'OrderTotalAmount', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - const CreditCustomerHAndleCancel = async () => { - setcreditCustomerOpen(false); - await dispatch(changeCreditFocus(false)); - }; + container.addEventListener('scroll', updateScrollButtons); + window.addEventListener('resize', updateScrollButtons); - const CreditCustomerFun = async () => { - if ( - OrderCardDetail?.length === 0 && - (selOption?.value !== undefined || - GlobalAddCustomerDetails1.length > 0 || - GetCustId.CustMobile !== undefined) - ) { - setcreditCustomerOpen(true); - await dispatch(changeCreditFocus(true)); - } else { - if (selOption?.value == undefined) { - setMessageType('warning'); - setMessageData('Please Select the Customer'); - } - } - }; - const changeOrderStatus = () => { - setOrderStatus(!OrderStatus); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - }; - // split payments - const SplitPaymentOpen = () => { - if (OrderCardDetail?.length > 0) { - const updatedData = { - userData: OrderCardDetail, - ExtraCharges: GlobalExtraCharge, - customer: selOption != null ? selOption : GetCustId, - Paymentgateway: false, - }; - setFailedOrderData(updatedData); - setSplitpayment(true); - } else { - setMessageType('warning'); - setMessageData('Please Select the Product'); - } - }; + const resizeObserver = new ResizeObserver(updateScrollButtons); + resizeObserver.observe(container); - const handlePopoverVisibleChangeCard = (visible) => { - setCardOptionOpen(visible); - }; - - const handlesplitpaymentclose = () => { - setSplitpayment(false); - setPaybtnnameselected(PaymentOptionsModeName); - setPaybtnselected(PaymentOptionsModeId); - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedData = { - paymentMethod: PaymentOptions?.[0]?.ModeName, - Paymentgateway: false, - }; - customerDisplayWindow.postMessage(updatedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - }; - // const handleClick = async () => { - // if (Comboglobal == false) { - // await dispatch(changeCombosearch(true)); - // } else { - // await dispatch(changeCombosearch(false)); - // } - // }; - - // const Combodata = async () => { - // let data = { - // AppId: AppId, - // CompId: CompId, - // BranchId: BranchId, - // ActiveStatus: 'A', - // }; - - // let Response = await dispatch(Comboget(data)).unwrap(); - // if (Response?.data?.statusCode == 1) { - // setComboDropDown(Response?.data?.data); - // } - // }; - - const openPreOrder = async () => { - setPreOrderOpen((prevState) => !prevState); - if (preOrderOpen) { - const customerDisplayWindow = getCustomerDisplayWindow(); - if (customerDisplayWindow && !customerDisplayWindow.closed) { - const updatedRemovedData = { - userData: [], - ExtraCharges: [], - paymentMethod: 'Cash', - type: 'remove', - keyValue: 'customer', - }; - customerDisplayWindow.postMessage(updatedRemovedData, '*'); - } else { - console.error( - 'Customer display window is not available or has been closed.' - ); - } - await dispatch(changeBookingType('TakeAway')); - await dispatch(changepreOrder(false)); - await dispatch(changepreOrderList(null)); - await dispatch(changePreOrderCusName(null)); - await dispatch(changePreOrderCusMob(null)); - await dispatch(changePreOrderDate()); - await dispatch(changePreOrderTime(null)); - await dispatch(changePreOrderAdd1(null)); - await dispatch(changePreOrderAdd2(null)); - await dispatch(changePreOrderAdvance(null)); - await dispatch(changePreOrderzip(null)); - await dispatch(changePreOrderCity(null)); - await dispatch(changePreOrderDistrict(null)); - await dispatch(changePreOrderState(null)); - await dispatch(changePreOrderAdditem('AddDetails')); - await dispatch(changeSelectedOption(null)); - await dispatch(changeCustomerID(null)); - await dispatch(changealldata(false)); - await dispatch(changeSelectedCustId(null)); - } - }; - - const closePrintOption = () => { - setShowWhatsAppShare(false); - setSMSShare(false); - setPrintOrderDetails([]); - setMobileNoWhatsApp(); - }; - - // const orderIdsArray = - // PrintOrderDetails?.[0]?.OrderDetails?.map( - // (orderDetail) => orderDetail?.OrderId - // ) || []; - - const handleURL = async (PrintOrderDetails) => { - let orderIdsArray = PrintOrderDetails?.[0]?.OrderDetails?.map( - (orderDetail) => orderDetail?.OrderId - ); - const encrypted = encryptObject(orderIdsArray); - - const postData = { - Url: encrypted, - CreatedBy: UserId, + return () => { + container.removeEventListener('scroll', updateScrollButtons); + window.removeEventListener('resize', updateScrollButtons); + resizeObserver.disconnect(); }; - if (orderIdsArray) { - const res = await dispatch(PublicQrCodepost(postData)).unwrap(); - const urlData = res?.data?.ReferenceNo; - setUrlData(urlData); + }, [modelstock, ModalVarient, modelQty]); + + const handleScrollClickLeft = (scrollOffset) => { + scrollContainerRef.current.scrollBy({ + left: -scrollOffset, + behavior: 'smooth', + }); + }; + + const handleScrollClickRight = (scrollOffset) => { + scrollContainerRef.current.scrollBy({ + left: scrollOffset, + behavior: 'smooth', + }); + }; + // const isDragging = useRef(false); + + // MOUSE EVENTS + const handleMouseDown = (e) => { + isDragging.current = true; + startX.current = e.pageX - scrollContainerRef.current.offsetLeft; + scrollLeft.current = scrollContainerRef.current.scrollLeft; + scrollContainerRef.current.style.cursor = 'grabbing'; + }; + + const handleMouseMove = (e) => { + if (!isDragging.current) return; + e.preventDefault(); // Important: prevents text selection and smooth scroll interference + const x = e.pageX - scrollContainerRef.current.offsetLeft; + const walk = (x - startX.current) * 0.8; // Adjust multiplier for speed + scrollContainerRef.current.scrollLeft = scrollLeft.current - walk; + }; + + const handleMouseUp = () => { + isDragging.current = false; + scrollContainerRef.current.style.cursor = 'grab'; + }; + + // TOUCH EVENTS + const handleTouchStart = (e) => { + isDragging.current = true; + startX.current = e.touches[0].pageX - scrollContainerRef.current.offsetLeft; + scrollLeft.current = scrollContainerRef.current.scrollLeft; + }; + + const handleTouchMove = (e) => { + if (!isDragging.current) return; + e.preventDefault(); // Prevents native scrolling + const x = e.touches[0].pageX - scrollContainerRef.current.offsetLeft; + const walk = (x - startX.current) * 0.8; // Adjust multiplier as needed + scrollContainerRef.current.scrollLeft = scrollLeft.current - walk; + }; + + const handleTouchEnd = () => { + isDragging.current = false; + }; + + const allProducts = Object.values(brandMapping).flat(); + + const brandGroups = {}; + allProducts.forEach((product) => { + const brandName = + product.BrandName && + product.BrandName !== 'null' && + product.BrandName !== 'undefined' && + product.BrandName.trim() !== '' + ? product.BrandName + : 'Others'; + + if (!brandGroups[brandName]) { + brandGroups[brandName] = []; } + + brandGroups[brandName].push(product); + }); + + useEffect(() => { + const brandKeys = Object.keys(brandGroups || {}); + if (brandKeys.length === 0) return; + // Only set if selectedBrand is not present in the new brandGroups + if (!brandKeys.includes(selectedBrand)) { + if (brandKeys.includes('Others')) { + setSelectedBrand('Others'); + } else { + setSelectedBrand(brandKeys[0]); + } + } + }, [brandGroups]); + + const sortedBrandNames = Object.keys(brandGroups).sort((a, b) => + a === 'Others' ? -1 : b === 'Others' ? 1 : 0 + ); + + const [prodname, setprodname] = useState(''); + const [prodQty, setprodQty] = useState(0); + const normalize = (str) => str?.toLowerCase()?.replace(/\s+/g, ' ')?.trim(); + + const result = prodname + ? (cardData || [])?.filter( + (item) => + normalize(item.ProdName).includes(normalize(prodname)) || + normalize(item.ProdCatName).includes(normalize(prodname)) || + item.ProductDetail?.some((detail) => + normalize(detail.ProdName).includes(normalize(prodname)) + ) + ) + : cardData; + + console.log(prodQty, 'cardDatacardData', result, prodname); + const AddnewProduct = () => { + setNewMoreProductModel(true); }; + useEffect(() => { + const item = result?.[0]; + const detail = item?.ProductDetail?.[0]; - const customerNameOrMobile = MobileNoWhatsApp?.CustName?.trim() - ? `Dear ${MobileNoWhatsApp?.CustName}` - : `Dear ${MobileNoWhatsApp?.value}`; - const documentUrl = `${MainHomeUrl}viewbill?code=${urlData}`; - const encodedMessage = `${customerNameOrMobile},\n\n🙏 Thank you for being a valuable customer!\n\n🧾 To view your bill, please click the link below:\n${documentUrl}`; - const handlepaymentoptions = async () => { - await dispatch(changeSalesPaymentoption(true)); - await dispatch( - getPaymentOptionsData({ - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - }) - ); - }; + const isInStock = + detail?.StockAvailable === 'Y' && item?.OverAllQty > prodQty; + const isStockNotTracked = detail?.StockAvailable === 'N'; - const handleotherservices = () => { - dispatch(changeOtherServices(true)); - dispatch(changeComboRedirectionToDefaultLayoutForParking(true)); - dispatch( - changetemplateData({ - AppName, - SelectedApplication: AppId, - Type: 'ParkingRedirect', - }) - ); - }; + if (result?.length > 0 && prodname && (isInStock || isStockNotTracked)) { + // CardOnclick(item,(item?.OnePcsAvailable && preferenceSingleSales) && 'OnePeiceProduct' ); + CardOnclick( + result?.[0], + result?.[0]?.OnePcsAvailable === 'Y' && + preferenceSingleSales && + 'OnePeiceProduct' + ); + // AddOrderDetails2(result?.[0]) + } else if (item?.OverAllQty < prodQty) { + setMessageType('error'); + setMessageData('NoStack'); + } + }, [prodname]); + function getClassNameBasedOnCard(type) { + switch (type) { + case 'Card1': + return 'AddNewProductSalesBTNCard1'; + case 'Card2': + return 'AddNewProductSalesBTNCard2'; + case 'Card3': + return 'AddNewProductSalesBTNCard3'; + case 'Card4': + return 'AddNewProductSalesBTNCard4'; + default: + return 'AddNewProductSalesBTNCard1'; + } + } - return ( - <> -
- -
-
- {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'QuickAdd' && ( - -
- -
- Quick Add - - (Alt + N) - -
-
-
- )} - {item?.OptionName == 'DineIn' && - DineInPreference?.SettingValue === 'Y' && - dinePreference && ( - -
- - DINE IN -
-
- )} - {item?.OptionName == 'TakeAway' && takeAwayPreference && ( - -
- BookingType !== 'TakeAway' && ChangeTakeAway() - } - style={{ - pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', - }} - > - - {/* TAKE AWAY */} - Take Away -
-
- )} - - ))} + function encrypt(code, key) { + let encrypted = ( + Suspense Loading...
}> + <> +
+ {messageType && messageData && ( + + )} - {OtherServiceStatus && ( +
{ + // trigger child function + voiceTriggerRef?.current?.listening(); + }} + style={{ + position: 'absolute', + zIndex: '12', + top: + templateData?.BookingLayout?.[0] === 'Layout5' || + templateData?.BookingLayout?.[0] === 'Layout4' || + templateData?.BookingLayout?.[0] === 'Layout6' + ? '2.5rem' + : '', + }} + > + { + setprodname(data.product); + setprodQty(data.qty); + }} + /> +
+ {/*

{prodname}

*/} +
- + {/*
*/} + {cardData?.length > 0 ? ( + <> + + item.id)} + strategy={rectSortingStrategy} + > +
+ {AddProductCard && !favouriteCat && ProdCat && ( +
+ + Add Product +
+ )} + {draggableCardData.map((item) => ( + + {templateData?.BookingCard?.[0] != 'Card4' ? ( +
0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) + ? 'BkPrdCardActive' + : 'BkPrdCardDeActive' + } + > + {!isMobile ? ( + + {globaldata && ( + pickData(e, item)} + style={{ + position: 'absolute', + zIndex: 1, + transform: 'scale(1.5)', + cursor: 'pointer', + }} + checked={( + globalAllItemdata || EditfavItems + )?.some( + // (a) => a?.ProdName === item?.ProdName + (a) => + a?.ProdName === item?.ProdName && + a?.ProdCat === item?.ProdCat + )} + /> + )} + +
+ // handleMouseDownItemCard(e, item) + // } + // onMouseUp={(e) => + // handleMouseUpItemCard(e, item) + // } + // onMouseLeave={handleMouseLeave} + // onTouchStart={(e) => + // handleTouchStartItemCard(e, item) + // } + // onTouchEnd={(e) => + // handleTouchEndItemCard(e, item) + // } + // onTouchCancel={handleTouchCancelItemCard} + // onContextMenu={(e) => e.preventDefault()} + onClick={(e) => { + if ( + !( + (item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) + : returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) + ) + ) { + e.stopPropagation(); + } else { + CardOnclick( + item, + item?.OnePcsAvailable === 'Y' && + preferenceSingleSales && + 'OnePeiceProduct' + ); + } + }} + data-aos="zoom-in" + data-aos-duration="600" + > + {(cardFunction?.BigImage || + cardFunction?.SmallImage) && ( + + )} +
+

+ {item?.ProdName}{' '} + {(item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) + : returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( + '' + ) : ( +

+ No Stock +

+ )} +

+ {cardFunction?.Price && + ((item?.OverAllQty !== undefined && + (!preferenceSingleSales + ? item?.OverAllQty !== 0 + : item?.OverAllPcs !== 0) && + item?.OverAllQty !== null) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + )) && ( +

+ ₹ {ItemSellingPrice(item)}  + + <> + ({ItemSize(item)}{' '} + {ItemUomName(item)}) + + +

+ )} +
+ + {cardFunction?.StockCount && + item?.OverAllQty !== undefined && + (!preferenceSingleSales + ? item?.OverAllQty !== 0 + : item?.OverAllPcs !== 0) && ( +
+ {item?.ProductDetail?.some( + (item) => + item?.StockAvailable === 'Y' + ) && + item?.OverAllQty !== null && ( + + )} +
+ )} +
+ + {item?.ProductDetail?.filter( + (item) => item.OnePcsAvailable == 'Y' + ).length !== 0 && + !preferenceSingleSales && ( +
{ + if ( + !( + (item?.OverAllQty !== + undefined && + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== + 'Y' + ) + ) + ) { + e.stopPropagation(); + } else { + CardOnclick( + item, + 'OnePeiceProduct' + ); + } + }} + style={{ + fontFamily: + SelectedCardFont || '', + backgroundColor: + SelectedCardColor?.FontColor || + '#ffffff', + color: + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0 || + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) + ? cardFunction?.Background + ? SelectedCardColor?.BackgroundColor || + '#000000' + : '#fff' + : '#ff4d4f', + }} + > + {SingleMember ? 'Single' : '1 PCS'} +
+ )} +
+ ) : ( + <> + {globaldata && ( + pickData(e, item)} + style={{ + position: 'absolute', + zIndex: 1, + transform: 'scale(1.5)', + cursor: 'pointer', + }} + checked={( + globalAllItemdata || EditfavItems + )?.some( + // (a) => a?.ProdName === item?.ProdName + (a) => + a?.ProdName === item?.ProdName && + a?.ProdCat === item?.ProdCat + )} + /> + )} + +
{ + if ( + !( + (item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) + : returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) + ) + ) { + e.stopPropagation(); + } else { + CardOnclick( + item, + item?.OnePcsAvailable === 'Y' && + preferenceSingleSales && + 'OnePeiceProduct' + ); + } + }} + // data-aos="zoom-in" data-aos-duration="600" + > + {(cardFunction?.BigImage || + cardFunction?.SmallImage) && ( + + )} +
+

+ {item?.ProdName}{' '} + {(item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) + : returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( + '' + ) : ( +

+ No Stock +

+ )} +

+ {cardFunction?.Price && + ((item?.OverAllQty !== undefined && + (!preferenceSingleSales + ? item?.OverAllQty !== 0 + : item?.OverAllPcs !== 0) && + item?.OverAllQty !== null) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + )) && ( +

+ ₹ {ItemSellingPrice(item)}  + {/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice}  */} + {/* {ItemSellingPrice(item)} */} + + ({ItemSize(item)}{' '} + {ItemUomName(item)}) + +

+ )} +
+ + {cardFunction?.StockCount && + item?.OverAllQty !== undefined && + (!preferenceSingleSales + ? item?.OverAllQty !== 0 + : item?.OverAllPcs !== 0) && ( +
+ {item?.ProductDetail?.some( + (item) => + item?.StockAvailable === 'Y' + ) && + item?.OverAllQty !== null && ( + + )} +
+ )} +
+ {item?.ProductDetail?.filter( + (item) => item.OnePcsAvailable == 'Y' + ).length !== 0 && + !preferenceSingleSales && ( +
{ + if ( + !( + (item?.OverAllQty !== + undefined && + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== + 'Y' + ) + ) + ) { + e.stopPropagation(); + } else { + CardOnclick( + item, + 'OnePeiceProduct' + ); + } + }} + style={{ + fontFamily: + SelectedCardFont || '', + backgroundColor: + SelectedCardColor?.FontColor || + '#ffffff', + color: + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0 || + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) + ? cardFunction?.Background + ? SelectedCardColor?.BackgroundColor || + '#000000' + : '#fff' + : '#ff4d4f', + }} + > + {SingleMember ? 'Single' : '1 PCS'} +
+ )} + + )} +
+ ) : ( +
0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) + ? 'card4Main card4Main-active' + : 'card4Main card4Main-deactive' + } + // onMouseDown={(e) => + // handleMouseDownItemCard(e, item) + // } + // onMouseUp={(e) => + // handleMouseUpItemCard(e, item, true) + // } + // onMouseLeave={handleMouseLeave} + // onTouchStart={(e) => + // handleTouchStartItemCard(e, item) + // } + // onTouchEnd={(e) => + // handleTouchEndItemCard(e, item, true) + // } + // onTouchCancel={handleTouchCancelItemCard} + // onContextMenu={(e) => e.preventDefault()} + onClick={(e) => { + if ( + !( + (item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) + : returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) + ) + ) { + e.stopPropagation(); // Prevent event bubbling if no stock or condition isn't met + } else { + // Ensure this only runs if the "One Piece" condition isn't triggered + if ( + !e.target.closest('.card4Main-onepiece') + ) { + CardOnclick( + item, + item?.OnePcsAvailable === 'Y' && + preferenceSingleSales && + 'OnePeiceProduct' + ); + // This will trigger if you're clicking outside the "One Piece" button + } + } + }} + > + {/* Global Data Checkbox */} + {globaldata && ( + e.stopPropagation()} + onChange={(e) => { + e.stopPropagation(); + pickData(e, item); + }} + style={{ + position: 'absolute', + zIndex: 1, + transform: 'scale(1.5)', + cursor: 'pointer', + }} + checked={( + globalAllItemdata || EditfavItems + )?.some( + (a) => + a?.ProdName === item?.ProdName && + a?.ProdCat === item?.ProdCat + )} + /> + )} + + {/* Tooltip for Product Name */} + +
+ +
+
+ +
+
+ {item?.ProdName} + {(item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) + : returnOnepcCount( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? ( + '' + ) : ( +

+ No Stock +

+ )} +
+ {((item?.OverAllQty !== undefined && + !preferenceSingleSales + ? returnCount( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) + : returnOnepcCount( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + )) && ( +
+
+ ₹ {ItemSellingPrice(item)} +
+ +
+ <> + ({ItemSize(item)}{' '} + {ItemUomName(item)}) + +
+
+ )} +
+ + {/* Stock Count Badge */} + {cardFunction?.StockCount && + item?.OverAllQty !== undefined && + (!preferenceSingleSales + ? item?.OverAllQty !== 0 + : item?.OverAllPcs !== 0) && ( +
+ {item?.ProductDetail?.some( + (item) => item?.StockAvailable === 'Y' + ) && + item?.OverAllQty !== null && ( + + )} +
+ )} + + {/* One Piece Button */} + {item?.ProductDetail?.filter( + (item) => item.OnePcsAvailable == 'Y' + ).length !== 0 && + !preferenceSingleSales && ( +
{ + e.stopPropagation(); // Stop event propagation to the parent div + + if ( + !( + (item?.OverAllQty !== undefined && + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) + ) + ) { + return; // Don't proceed if the condition isn't met + } else { + CardOnclick( + item, + 'OnePeiceProduct' + ); // This only runs when you click the "One Piece" button + } + }} + style={{ + fontFamily: SelectedCardFont || '', + backgroundColor: + SelectedCardColor?.FontColor || + '#ffffff', + color: + returnOnepcCount( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0 || + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== 'Y' + ) + ? cardFunction?.Background + ? SelectedCardColor?.BackgroundColor || + '#000000' + : '#fff' + : '#ff4d4f', + }} + > + {SingleMember ? 'Single' : '1 PCS'} +
+ )} +
+ )} +
+ ))} +
+
+
+ + ) : ProductSearch?.length > 5 && + GetmultipleSearchDatas.some( + (e) => e.toLowerCase() === 'qrcode' + ) && + (cardData?.length == 0 || cardData == undefined) ? ( +
+ {/* cardData mohan 18-04-2025 */} + +
+ ) : ( + <> +
+
+
+
+
 
+
+
+
 
+
+
+
 
+
+
+
 
+
+
+
+
+ + )} + {paymentloader === true && ( +
+
+
+
 
+
+
+
 
+
+
+
 
+
+
+
 
+
+

+ {' '} + Please wait while we process your payment +

+ {PaymentTransactionNumber != null && ( +

+ Transaction Number : {PaymentTransactionNumber} +

+ )} +
+
+ )} +
+
+
+ {expireModal?.open && ( + { + expireModal.onOk?.(); + closeExpireModal(); + }} + onCancel={() => { + expireModal.onCancel?.(); + closeExpireModal(); + }} + /> + )} + + {modelQty && ( + + +
+ } + open={modelQty} + width={800} + handleCancel={CloseModal} + footer={null} + maskTransitionName="" + transitionName="" + children={ +
+
+
+

Item Name:

+
+
+

+ {qtydata?.ProdName} +

+
+
+ {/* Horizontal scroll container */} + +
+ {/* Left Scroll Button */} + {showLeftButton && ( +
handleScrollClickLeft(200)} + style={{ + position: 'absolute', + left: 0, + top: '35%', + transform: 'translateY(-50%)', + zIndex: 10, + background: '#fff', + padding: '0.5rem', + cursor: 'pointer', + boxShadow: '0 0 5px rgba(0,0,0,0.2)', + }} + > + ◄ +
+ )} + + {/* Scroll Container */} +
+ {Object.keys(brandGroups) + .sort((a, b) => + a === 'Others' ? -1 : b === 'Others' ? 1 : 0 + ) + .map((brand) => ( +
setSelectedBrand(brand)} + style={{ + minWidth: '150px', + background: + selectedBrand === brand + ? '#cce5ff' + : '#f4f4f4', + borderRadius: '8px', + padding: '0.8rem', + flexShrink: 0, + cursor: 'pointer', + userSelect: 'none', + textAlign: 'center', + fontWeight: + selectedBrand === brand ? 'bold' : 'normal', + }} + > + {brand === 'Others' ? 'Others' : brand} +
+ ))} +
+ + {/* Right Scroll Button */} + {showRightButton && ( +
handleScrollClickRight(200)} + style={{ + position: 'absolute', + right: 0, + top: '35%', + transform: 'translateY(-50%)', + zIndex: 10, + background: '#fff', + padding: '0.5rem', + cursor: 'pointer', + boxShadow: '0 0 5px rgba(0,0,0,0.2)', + }} + > + ► +
+ )} +
+ {/* Selected brand products */} +
+

+ {selectedBrand === 'Others' ? 'Others' : selectedBrand}{' '} + Products +

+
    + {(brandGroups[selectedBrand] || []).map( + (product, index) => { + const qtyCount = returnQtyCount( + product?.ProdId, + product, + CartOrderDetails + ); + const isAvailable = product?.StockAvailable !== 'Y'; + const isDisabled = qtyCount > 0 || isAvailable; + + return ( +
    +
    VarientFun(product)} + > +
    + {`Product +
    +
    + +
    + +
    +

    + {product?.Size + ' ' + product?.UomName} +

    + {!isDisabled && ( +

    + No Stock +

    + )} + {isDisabled && ( +

    + + ₹ + +   + {safeRound( + product?.ProdVariantDetails?.[0] + ?.StockDetails?.[0]?.SellPrice + )} +

    + )} +
    +
    +
    + ); + } + )} +
+
+ + {Object.keys(brandMapping).length === 0 && ( +

No product details available

+ )} +
+
+ } + /> + )} + {modelstock && ( + + +
+ } + open={modelstock} + // width={500} + footer={null} + top={0} + handleCancel={CloseModal1} + maskTransitionName="" + transitionName="" + children={ +
+
- - Other Services -
- -
- )} -
- -
- {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'Offer' && ( -
- -
- )} - {item?.OptionName == 'ExtraCharge' && ( - -
-
- - {/* EXTRA CHARGE */} - Extra Charge +
+
+

Item Name:

- -
- (Alt + A) +
+

+ {qtydata?.ProdName}{' '} + {!qtydata?.ProductDetail?.[ + QtyIndex + ]?.ProdVariantDetails?.[ + VarientIndex + ]?.ProdVariantName?.toLowerCase()?.includes( + 'variant' + ) && ( + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )} +

- - )} - {item?.OptionName == 'RePrint' && ( - -
-
- - Re-Print +
+
+

Item Unit:

+
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

- - - (Alt + R) -
- - )} - - ))} - {/* {reprint1 && ( - - )} */} - {extraCharges && ( - - )} - {QuickAdd && ( - - )} - {creditCustomerOpen && ( - - )} - {TotalAmount == 0 && Success && ( -
- -
- )} - {TotalAmount > 0 && - qrCode && - PaymentUpiOptions?.length > 0 && - SelectedUpiOption && ( -
- +
+
+ +
- )} - - {PaymentUpiOptions?.length > 0 && OrderId && ( -
- -
- )} -
-
- -
-
-
setIsFloatMenuOpen(!isFloatMenuOpen)} - > - -
- - {isFloatMenuOpen && ( -
- {!OtherServiceStatus && ( -
- -
- -

Parking

-
-
-
- )} - {BSComboNavbar?.[1]?.map((item) => ( - <> - {item?.OptionName == 'QuickAdd' && ( -
- -
- -

- Quick Add
(Alt +N) -

-
-
-
- )} - {item?.OptionName == 'DineIn' && - DineInPreference?.SettingValue === 'Y' && ( - <> -
- -
- -

Dine In

-
-
-
- {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && ( -
- -
- )} - - )} - {item?.OptionName == 'TakeAway' && ( -
- -
- -

Take Away

-
-
-
- )} - {item?.OptionName == 'Offer' && ( -
- -
- )} - {item?.OptionName == 'ExtraCharge' && ( -
- -
- -

Extra Charge

-
-
-
- )} - {item?.OptionName == 'RePrint' && ( -
- -
- -

Re Print

-
-
-
- )} - - ))} -
- )} -
-
- -
- -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - }} - > - {paybtns?.length > 0 ? ( - paybtns?.map((payment) => ( -
- -
- )) - ) : ( -
- Please Set Payment Options -
- )} - - {paybtns?.length > 1 && ( -
0) && - !unpaidFlow && - OrderStatus - ? 'none' - : 'auto', - opacity: - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus - ? 0.5 - : 1, - }} - > - - {' '} -
-
- - Split Pay -
-
-
-
- )} -
-
- - {/*
- -
*/} - -
- -
-
-
-
-
Items
-
:
-
- {' '} - {TotalItems}{' '} -
-
-
-
Qty
-
:
-
{Qty}
-
-
-
-
-
- -
- {(addcustomer || hold) && ( - setHold(false)} + } /> )} -
- {Estimation?.SettingValue == 'Y' && - BookingType !== 'Dine In' && - !BookingTypeBoth && ( -
- -
- )} - {BSComboData?.BookingBilling?.[1]?.map((item) => ( - <> - {/* {item?.OptionName=="Hold" && */} - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length != 0 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} -
- AddBookingDetails('Hold')} - style={{ - cursor: 'pointer', - // color: '' ? '#52c41a' : '#1292EE', - }} - />{' '} -

Hold

-
-
- ) - : ''} - - {unpaidFlow == false - ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - -
- HandleholdModelOpen()} - style={{ - cursor: 'pointer', - // color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', - }} - /> -
-
-
- ) - : ''} - {tabledata?.length > 0 && dinePreference && ( - <> - {item?.OptionName == 'UnpaidBill' && ( - - {' '} -
- { - (setUnpaidOpen(true), getUnpaiddatas()); - }} - /> -
-
- )} - - )} - - ))} - {BSComboData?.BookingBilling?.[1]?.filter( - (item) => item.OptionName === 'AddCustomer' - ).length === 1 ? ( - <> - {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' - ) - ) - ) && ( - - -
0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : '#1292eeff', - color: '#fff', - height: '40px', - width: '45px', - borderRadius: '6px', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - padding: '8px 8px 12px 8px', - }} - > - {' '} - 0 && 'not-allowed', - // color: - // OrderCardDetail?.length > 0 || - // (selOption?.value === undefined && - // GlobalAddCustomerDetails1?.length === 0 && - // GetCustId?.CustMobile === undefined) - // ? 'gray' - // : '#1292eeff', - fontSize: '28px', - }} - />{' '} -

Adv Amt

-
-
-
- )} - - ) : ( - '' - )} - - {/* Customer Orders */} - {GetCustId && ( - - {' '} -
{ - 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(255, 255, 255)', - color: '#fff', - height: '40px', - width: '45px', - borderRadius: '6px', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - padding: '5px 5px 6px 5px', - background: 'rgb(18, 146, 238)' - }} - > - Cust Orders -
-
- )} - {FeatureAddonData?.FeatureDtls?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'preorder' - ) && ( - <> - { -
0 || OrderType === 'Failed' - ? 'none' - : 'auto', - opacity: OrderCardDetail?.length > 0 ? 0.5 : 1, - }} - > - - - { - openPreOrder(); - }} - /> - - -
- } - - )} - {preOrderOpen && } - {sportsAppPreference && } - {dinePreference && - (BookingType === 'Dine In' || - BookingTypeBoth || - CheckOrderType?.length > 0) && - !unpaidFlow && ( - <> - - {' '} - - FirstPaymentclick === false && !addnewAccess - ? changeOrderStatus() - : '' - } - style={{ - pointerEvents: OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - {FirstPaymentclick === false && - !addnewAccess && - !OrderStatus && } - - )} - {OrderCardDetail?.length > 0 && ParkingDisplay && ( -
- -
- )} - {unpaidFlow == true ? ( - - { - Recipt(); - }} - /> - - ) : ( - '' - )} - {/*
- - - - } - trigger="click" - open={open} - onOpenChange={handleOpenChange} - > - - -
*/} - {/* {ComboDropDown?.length >= 1 && ( -
- - + - -
- )} */} - {paymentfeataddon && ( - -
{ - paymentFailedStatusFun(); - }} - style={{ - width: '27px', - cursor: 'pointer', - fontWeight: '600', - color: 'rgb(18, 146, 238)', - }} - > -
-
- )} - {OpenFailData && ( - - )} -
-
-
- {BSComboData?.BookingBilling?.[1]?.map((item) => ( - <> - {item?.OptionName == 'AddCustomer' && !preOrderOpen && ( -
- - -
- -
-
-
- )} - - ))} - -
- - - - +

+ {qtydata?.ProdName} +

+
+
+
+
+

Item Unit:

+
+
+

+ {qtydata?.ProductDetail?.[QtyIndex]?.Size}{' '} + {onePeiceFlow + ? 'PCS' + : qtydata?.ProductDetail?.[QtyIndex]?.UomName} +

+
+
+
+ +
+ +
+
+ } + /> + )} + {productPriceChange && priceChangeProduct?.length > 0 && ( + + )} + + {newMoreProductModel && ( + setNewMoreProductModel(false)} + children={ <> -
- - - + } - trigger="click" - open={open} - onOpenChange={handleOpenChange} - > - - - - -
-
- {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'); - }} - /> -
- )} -
- {UpiOpen && ( - { - 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'); - }} - /> -
-
-
- } - /> - )} - {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 && ( -
- {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={ -
- -
- } - /> - {customerPreviesOrders && ( - setCustomerPreviesOrders(false)} - footer={false} - width={700} - className={'ModalPaymentGatewayEmbedded'} - children={ - <> - setCustomerPreviesOrders(false)} - /> - - } - /> - )} - - ); + + + ); + for (let i = 0; i < code?.length; i++) { + encrypted += String.fromCharCode( + code.charCodeAt(i) ^ key.charCodeAt(i % key.length) + ); + } + return encrypted; + } + + function decrypt(encrypted, key) { + // Implement decryption logic + let decrypted = encrypt(); + for (let i = 0; i < encrypted?.length; i++) { + decrypted += String.fromCharCode( + encrypted.charCodeAt(i) ^ key.charCodeAt(i % key.length) + ); + } + return decrypted; + } + + const encryptedCode = encrypt(); // Encrypted React component code + const decryptionKey = decrypt(); // Decryption key (keep it secure) + const decryptedCode = decrypt(encryptedCode, decryptionKey); + + return <>{encrypt()}; }; -export default BSC1Payment; +export default React.memo(BSItemCard); diff --git a/src/routesConfig.jsx b/src/routesConfig.jsx index d90267a..f48462a 100644 --- a/src/routesConfig.jsx +++ b/src/routesConfig.jsx @@ -684,7 +684,7 @@ const initSession = () => { sessionStorage.setItem( 'auth', - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcwOTIyMDEyLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.8iuEF8S7kW1OvVUda3YAx9v7ilp-uy9PVfbBvCPoq20' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiOTM2MDY0MjI0NCIsIlBhc3N3b3JkIjoiWkB6MTIzNCIsImF1ZCI6WyJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTIiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTQiLCJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMTMiXSwiZXhwIjoxNzcxODcyOTYwLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xLjM3OjgwMDEifQ.tRA41-3-m2VYm_jkndGPLzB-jxzuO1XvG94Fmf6NTGQ' ); };