diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx index 07327ae..5ca4c63 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BST1Payment.jsx @@ -127,6 +127,7 @@ import { changeSearchedData, GlobalSelectedCustDisable, GlobalOrderStatus, + PostCancelPayment, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import FeaturesFunctionalities from '../../BookingFunctionality/FeaturesFunctionalities'; import { @@ -944,7 +945,7 @@ export default function BST1Payment() { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; if (selectedStyle) { @@ -1392,6 +1393,15 @@ export default function BST1Payment() { : AddBookingDetails(BookingType, true); } }; + // PostCancelPayment + const CancelPayment = async () => { + const response = await dispatch(PostCancelPayment({OrderId: businessUPIOrderId})).unwrap() + if (response?.data?.statusCode) { + ClearAllGlobalStateDatas(); + CustomerDisplay(); + setBusinessUPI(false); + } + } const financialYearError = async () => { setMessageType('error'); setMessageData('Financial Year-Based Sales Not Yet Started'); @@ -2069,15 +2079,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', @@ -2170,7 +2180,7 @@ export default function BST1Payment() { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2187,9 +2197,9 @@ export default function BST1Payment() { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', @@ -2205,8 +2215,8 @@ export default function BST1Payment() { ? PaymentgatewayUPI?.[0]?.ModeId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId + (busupi) => busupi?.ModeId === UpiId + )?.ModeId : paybtnselected : paybtnselected ? paybtnselected @@ -2219,15 +2229,15 @@ export default function BST1Payment() { salesBillEdit && currentOrderNetAmount < previousNetAmount ? null : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId + ?.MerchantId : null, PaymentOptionType: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - (refundPaySelectedName?.toLowerCase() === 'cash' || - refundPaySelectedName?.toLowerCase() === 'credit') + currentOrderNetAmount < previousNetAmount && + (refundPaySelectedName?.toLowerCase() === 'cash' || + refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : Paybtnnameselected?.toLowerCase() === 'cash' ? 'PC' @@ -2247,29 +2257,29 @@ export default function BST1Payment() { ? null : SelectedUPIPayOption?.toLowerCase() === 'default' ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId + ?.UPIDetailId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.MerchantUPIId + (busupi) => busupi?.ModeId === UpiId + )?.MerchantUPIId : null, AccountDtl: salesBillEdit && currentOrderNetAmount < previousNetAmount ? [] : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) + (upipay) => upipay?.UPIId === UpiId + ) : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pd') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pd') + SelectedUPIPayOption?.toLowerCase() === 'pd') || + (Paybtnnameselected?.toLowerCase() === 'card' && + SelectedCardOption?.toLowerCase() === 'pd') ? useOptions?.[0]?.PaymentDetails?.PaymentDevice : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg') + SelectedUPIPayOption?.toLowerCase() === 'pg') || + (Paybtnnameselected?.toLowerCase() === 'card' && + SelectedCardOption?.toLowerCase() === 'pg') ? useOptions?.[0]?.PaymentDetails?.PaymentGateway : [], PaymentStatus: @@ -2280,13 +2290,13 @@ export default function BST1Payment() { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', Debit: salesBillEdit && - currentOrderNetAmount < previousNetAmount && - refundPaySelectedName?.toLowerCase() === 'credit' + currentOrderNetAmount < previousNetAmount && + refundPaySelectedName?.toLowerCase() === 'credit' ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, Credit: salesBillEdit @@ -2362,14 +2372,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]); @@ -2526,14 +2536,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]); @@ -2634,14 +2644,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]); @@ -2816,14 +2826,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]); @@ -2841,7 +2851,7 @@ export default function BST1Payment() { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3650,29 +3660,29 @@ export default function BST1Payment() { {tableOptions.find( (item) => item.OptionName === 'AddCustomer' ) && ( -