import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import QrImg from '../../../../Images/qrcode.jpg';
import {
  extractLastNumber,
  extractLastNumberOrderId,
} from '../../../../Services/Others';
import {
  GlobalprintSlNo,
  GlobalprintItem,
  GlobalprintMRP,
  GlobalprintDiscount,
  GlobalprintQuantity,
  GlobalprintRate,
  GlobalprintAmount,
  GlobalprintHsnCode,
  GlobalprintQrcodet,
  GlobalPritdummyData,
  GloabalFieldDetails,
  changeReprintDataFound,
  GlobalprintSignature,
  GlobalprinttermsAndConditions,
  GlobalSignatureImage,
  Globalnotes,
  GlobalthemeFormat,
  GlobalBillName,
  GlobalprintCashierName,
  GlobalprintLogo,
  GlobalprintCredit,
  GlobalprintTax,
} from '../../../../Features/ThemeChange/ThemeChange';
import {
  GlobalUpiIDprint,
  PreferenceData,
} from '../../../../Features/BookingScreen/BookingData/BookingData';
import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle5.scss';
import QRCode from 'react-qr-code';
import signature from '../../../../Images/signatureimage.jpg';
import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin';
import { isMobile } from 'react-device-detect';
import { settingDataSelector } from '../../../../Features/PreferenceMaster/PreferenceMaster';
import Logo from '../../../../Images/Logo.jpg';

const PrintStyle5 = ({
  index,
  ExtraChargeTotal,
  totalQuantityFilter,
  Date1,
  CashierName,
  totalQuantity,
  OrderDetailGST,
  OrderDetailIGST,
  OrderDetailVAT,
  table2Data,
  PaymentStatus,
  PrintGreeting,
  printDatas,
  base64Image,
  PrintLogo,
  isPdf,
  sportsAppPreference,
  SalesModePref,
  MembershipApplied = null,
}) => {
  console.log(table2Data, 'table2Data');
  const dispatch = useDispatch();
  const GlobalUpiID = useSelector(GlobalUpiIDprint);
  const FieldDetails = useSelector(GloabalFieldDetails);
  const SLNO = FieldDetails?.['Sl.No'];
  const Item = FieldDetails?.['Item'];
  const MRP = FieldDetails?.['MRP'];
  const Discount = FieldDetails?.['Discount'];
  const Tax = FieldDetails?.['Tax'];
  const Quantity = FieldDetails?.['Quantity'];
  const Rate = FieldDetails?.['Rate'];
  const Amount = FieldDetails?.['Amount'];
  const HsnCode = FieldDetails?.['HsnCode'];
  const Qrcodet = FieldDetails?.['Qrcode'];
  const CashierNameField = FieldDetails?.['CashierName'];
  const LogoField = FieldDetails?.['Logo'];
  const CreditDetails = FieldDetails?.['Credit details'];
   const WeightasKg = FieldDetails?.['Weight'];
  const GlobalSlNo = useSelector(GlobalprintSlNo);
  const GlobalItem = useSelector(GlobalprintItem);
  const GlobalMRP = useSelector(GlobalprintMRP);
  const GlobalDiscount = useSelector(GlobalprintDiscount);
  const GlobalTax = useSelector(GlobalprintTax);
  const GlobalQuantity = useSelector(GlobalprintQuantity);
  const GlobalRate = useSelector(GlobalprintRate);
  const GlobalAmount = useSelector(GlobalprintAmount);
  const GlobalHsnCode = useSelector(GlobalprintHsnCode);
  const GlobalQrcodet = useSelector(GlobalprintQrcodet);
  const GlobaldummyData = useSelector(GlobalPritdummyData);
  const GlobalSignature = useSelector(GlobalprintSignature);
  const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions);
  const GlobalSignatureImages = useSelector(GlobalSignatureImage);
  const GlobalIsnotes = useSelector(Globalnotes);
  const GlobalthemeFormatr = useSelector(GlobalthemeFormat);
  const GlobalBilltext = useSelector(GlobalBillName);
  const appPreferences = useSelector(ApplicationPreferences);
  const SettingData = useSelector(PreferenceData);
  const GlobalCashierName = useSelector(GlobalprintCashierName);
  const GlobalLogo = useSelector(GlobalprintLogo);
  const GlobalCredit = useSelector(GlobalprintCredit);
  const estimatePrintHeader =
    SettingData?.[0]?.SettingDtlDetails?.find(
      (setting) =>
        setting?.SettingIdName?.toLowerCase() === 'estimateprintheader'
    )?.SettingValue === '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 paymentTypeUPI = PaymentStatus?.find(
    (ps) => ps.PaymentTypeName === 'UPI'
  );

  console.log(GlobalDiscount, Discount, 'Discount');

  let TermsAndConditions = printDatas?.TermsandConditions;
  let SignatureImg = printDatas?.Signature;
  let Notestext = printDatas?.Notes;
  let BillName = printDatas?.PrintHdrName;
  let FormatTheme = printDatas?.PrintType == 'S' ? true : false;
  let PageSize = printDatas?.PageSize;
  const Signature = FieldDetails?.['signature'];
  const TermsnAdCondition = FieldDetails?.['terms&conditions'];

  let PaymentStatusSuccess = PaymentStatus?.filter(
    (ps) => ps.PaymentStatus === 'S'
  );
  const keysLength = Object.keys(table2Data ?? {}).length;
  if (keysLength > 0) {
    dispatch(changeReprintDataFound(true));
  }

  const currentDate = new Date();
  const day = currentDate.getDate().toString().padStart(2, '0');
  const monthNames = [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec',
  ];
  const monthIndex = currentDate.getMonth();
  const year = currentDate.getFullYear().toString().slice(-2);

  const formattedDate = `${day}-${monthNames[monthIndex]}-${year}`;
  const TakeawayData = table2Data?.productDetails?.filter(
    (item) => item.BookingTypeName?.toLowerCase() === 'takeaway'
  );
  const DineInData = table2Data?.productDetails?.filter(
    (item) => item.BookingTypeName?.toLowerCase() === 'dine in'
  );

  const TakeawayTotal = TakeawayData?.reduce(
    (accumulator, currentValue) => accumulator + currentValue.TotalAmt,
    0
  );
  const DineInTotal = DineInData?.reduce(
    (accumulator, currentValue) => accumulator + currentValue.TotalAmt,
    0
  );
  const PackageDetails = table2Data?.PackageDtl;
  const aggregatedPayments = PaymentStatusSuccess?.reduce(
    (acc, paymentdata) => {
      const paymentType = paymentdata?.PaymentTypeName;
      const amount = Number(paymentdata?.Amount);

      if (acc[paymentType]) {
        acc[paymentType] += amount;
      } else {
        acc[paymentType] = amount;
      }

      return acc;
    },
    {}
  );
  const productsData = table2Data?.productDetails || [];
  const offers = table2Data?.OrderOfferDetails || [];

  let TotalOfferAmount = 0;

  // Calculate SalesWiseOffers total amount
  offers.forEach((offer) => {
    if (offer.TableName === 'SalesWiseOffers') {
      TotalOfferAmount += offer.OfferAmount;
    }
  });
  const hasMappedOffer = offers.some((offer) =>
    ['ItemWiseOffers', 'BundleOffers', 'QuantityWiseOffers'].includes(
      offer.TableName
    )
  );

  if (hasMappedOffer) {
    const productTotal = productsData?.reduce(
      (acc, item) =>
        acc + (item?.Type != 'C' ? item.OfferAmt : item.OfferValue || 0),
      0
    );
    TotalOfferAmount += productTotal;
  } else {
    const Combothere = productsData?.filter((item) => item?.Type == 'C');
    const CombothereTotal = Combothere?.reduce(
      (acc, item) => acc + (item.OfferValue || 0),
      0
    );
    TotalOfferAmount += CombothereTotal;
  }

  const products = [
    {
      ProdName: 'ITEM 1',
      Rate: 88.0,
      SalesQty: 2,
      MRP: 100,
      TotalAmt: 176,
      discount: 0,
      HSN: '01',
      Size: 250,
      UomName: 'g',
      ProdTaxPercentage: 5,
    },
    {
      ProdName: 'ITEM 2',
      Rate: 300.0,
      SalesQty: 1,
      MRP: 350,
      TotalAmt: 300,
      discount: 0,
      HSN: '02',
      Size: 250,
      UomName: 'g',
      ProdTaxPercentage: 5,
    },
    {
      ProdName: 'ITEM 3',
      Rate: 200.0,
      SalesQty: 1,
      MRP: 250,
      TotalAmt: 200,
      discount: 0,
      HSN: '03',
      Size: 250,
      UomName: 'g',
      ProdTaxPercentage: 0,
    },
    {
      ProdName: 'ITEM 4',
      Rate: 30.0,
      SalesQty: 1,
      MRP: 50,
      TotalAmt: 30,
      discount: 0,
      HSN: '04',
      Size: 250,
      UomName: 'g',
      ProdTaxPercentage: 18,
    },
  ];

  const chunkSize = PageSize == 'A5' ? 5 : 9;
  let dataSource = [];

  if (GlobaldummyData || TakeawayData?.length > 0) {
    dataSource = GlobaldummyData ? products : TakeawayData;
  } else if (DineInData?.length > 0) {
    dataSource = DineInData;
  }

  // Paginate the data
  const paginatedChunks = [];
  for (let i = 0; i < dataSource.length; i += chunkSize) {
    paginatedChunks.push(dataSource.slice(i, i + chunkSize));
  }
  const lastChunkRows =
    paginatedChunks.length > 0
      ? paginatedChunks[paginatedChunks.length - 1].length
      : 0;
  const shouldFooterBeOnNewPage = lastChunkRows > (PageSize == 'A5' ? 2 : 7);

  return (
    <>
      {FormatTheme ? (
        <div
          className="PrintStyle5-MasterDiv"
          id={`PrintStyle5-${index}`}
          style={{
            fontFamily: "'Courier New', Courier, monospace",
            position: 'relative',
            width: '100%',
            minHeight: isMobile ? '' : PageSize == 'A5' ? '210mm' : '297mm',
          }}
        >
          {paginatedChunks.map((dataChunk, chunkIndex) => (
            <div
              className={
                isMobile
                  ? `container pdf-page`
                  : `container print-chunk${chunkIndex > 0 ? ' print-page-break' : ''}`
              }
              style={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent:
                  chunkIndex === paginatedChunks.length - 1 &&
                  !shouldFooterBeOnNewPage &&
                  FormatTheme
                    ? 'space-between'
                    : '',
                height: isMobile
                  ? '295mm'
                  : FormatTheme
                    ? PageSize == 'A5'
                      ? '170mm'
                      : '257mm'
                    : '',
              }}
              key={chunkIndex}
            >
              {/* <div className="header" style={{ position: isMobile ? "" : GlobaldummyData ? "absolute" : "fixed", top: 0, width: "100%" }}> */}
              <div
                className="header"
                style={{
                  position: isMobile
                    ? ''
                    : GlobaldummyData
                      ? 'absolute'
                      : isPdf
                        ? 'static'
                        : 'fixed',
                  top: 0,
                  width: '100%',
                }}
              >
                {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                  ''
                ) : (
                  <div className="PrintStyle5-Head">
                    <div
                      style={{
                        alignItems: 'center',
                        justifyContent: 'center',
                        display: 'flex',
                      }}
                    >
                      {GlobaldummyData && GlobalLogo ? (
                        <img
                          className="PrintStyle2-BrandImage"
                          src={Logo}
                          alt="image"
                        />
                      ) : null}
                      {base64Image &&
                      (PrintLogo?.SettingValue === 'Y' || LogoField) ? (
                        <img
                          className="PrintStyle2-BrandImage"
                          src={GlobaldummyData ? Logo : base64Image}
                          alt="image"
                          width={100}
                        />
                      ) : null}
                      <div
                        style={{
                          fontSize: 'clamp(2rem, 2.5vw, 2rem)',
                          fontWeight: '600',
                        }}
                      >
                        {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
                      </div>
                    </div>

                    <div>Low Prices... Love the Saving... </div>
                    <div>
                      {GlobaldummyData
                        ? 'BranchAddress, Town- 635XXX City - State'
                        : (table2Data?.AddressDetails?.[0]?.Address1 || '') +
                          (table2Data?.AddressDetails?.[0]?.City
                            ? (table2Data?.AddressDetails?.[0]?.Address1 &&
                              table2Data?.AddressDetails?.[0]?.City
                                ? '-'
                                : '') + table2Data?.AddressDetails?.[0]?.City
                            : '') +
                          (table2Data?.AddressDetails?.[0]?.Zip
                            ? (table2Data?.AddressDetails?.[0]?.City &&
                              table2Data?.AddressDetails?.[0]?.Zip
                                ? '-'
                                : '') + table2Data?.AddressDetails?.[0]?.Zip
                            : '')}
                    </div>
                    <div style={{ fontSize: '14px', fontWeight: '600' }}>
                      {' '}
                      Mobile :
                      {GlobaldummyData
                        ? '1234567890'
                        : table2Data?.BrMobile}{' '}
                    </div>
                    {table2Data?.OrderType === 'E' && (
                      <div style={{ textTransform: 'uppercase' }}>
                        Estimate{' '}
                        {SalesModePref?.SettingValue == 'Y' &&
                          `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
                      </div>
                    )}
                    {table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div style={{ textTransform: 'uppercase' }}>
                        {GlobaldummyData
                          ? 'Cash'
                          : BillName
                            ? BillName
                            : PaymentStatusSuccess?.length === 1
                              ? PaymentStatusSuccess?.[0]?.PaymentTypeName
                              : ''}{' '}
                        {SalesModePref?.SettingValue == 'Y' &&
                          `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
                      </div>
                    )}

                    <hr />
                  </div>
                )}
                {!estimatePrintHeader && table2Data?.OrderType === 'E' && (
                  <div
                    style={{ textTransform: 'uppercase', textAlign: 'center' }}
                  >
                    Estimate{' '}
                    {SalesModePref?.SettingValue == 'Y' &&
                      `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
                  </div>
                )}

                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'space-between',
                    fontSize: '14px',
                    fontWeight: '600',
                  }}
                >
                  {' '}
                  <div> {GlobaldummyData ? formattedDate : Date1} </div>{' '}
                  <div>
                    {' '}
                    Bill No :
                    {GlobaldummyData
                      ? '553'
                      : table2Data?.OrderId &&
                        extractLastNumberOrderId(
                          table2Data?.OrderId,
                          table2Data?.FYStatus
                        )}{' '}
                  </div>{' '}
                </div>

                <hr />
              </div>

              <div
                style={{ marginTop: GlobaldummyData ? '9rem' : '0rem' }}
                className="print-body"
              >
                {(TakeawayData?.length > 0 || GlobaldummyData) && (
                  <>
                    {takeAwayPreference && (
                      <div
                        style={{
                          display: 'flex',
                          width: '100%',
                          justifyContent: 'center',
                          alignItems: 'center',
                        }}
                      >
                        {' '}
                        TakeAway
                      </div>
                    )}
                    <div
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        fontWeight: '600',
                        fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                        width: '100%',
                        gap: '0.5rem',
                      }}
                    >
                      {GlobaldummyData
                        ? GlobalSlNo && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              S.No
                            </div>
                          )
                        : SLNO && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              S.No
                            </div>
                          )}
                      {GlobaldummyData ? (
                        (GlobalItem || GlobalQuantity) && (
                          <div style={{ width: '300%', textAlign: 'center' }}>
                            {' '}
                            {GlobaldummyData
                              ? GlobalItem && 'ITEM /DES /'
                              : 'ITEM /DES /'}{' '}
                            {GlobaldummyData
                              ? GlobalQuantity && 'QTY'
                              : 'QTY'}{' '}
                          </div>
                        )
                      ) : (
                        <div style={{ width: '300%', textAlign: 'center' }}>
                          {' '}
                          {GlobaldummyData
                            ? GlobalItem && 'ITEM /DES /'
                            : Item && 'ITEM /DES /'}{' '}
                          {GlobaldummyData
                            ? GlobalQuantity && 'QTY'
                            : Quantity &&   WeightasKg ?'QTY/Kg' :'QTY'}{' '}
                        </div>
                      )}
                      {GlobaldummyData
                        ? GlobalHsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              HSN
                            </div>
                          )
                        : HsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              HSN
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalMRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              MRP
                            </div>
                          )
                        : MRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              MRP
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalRate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              RATE
                            </div>
                          )
                        : Rate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              RATE
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalDiscount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              DIS{' '}
                            </div>
                          )
                        : Discount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              DIS{' '}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalTax && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              TAX %{' '}
                            </div>
                          )
                        : Tax &&
                          table2Data?.OrderType !== 'E' && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              TAX %{' '}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalAmount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              Amt{' '}
                            </div>
                          )
                        : Amount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              AMT{' '}
                            </div>
                          )}
                    </div>

                    <hr className="hrline" />

                    {dataChunk?.map((item, index) => (
                      <div
                        key={index}
                        className="PrintStyle5-print-prddtls"
                        style={{
                          display: 'flex',
                          justifyContent: 'space-between',
                          fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                          fontWeight: '600',
                          width: '100%',
                          gap: '0.5rem',
                        }}
                      >
                        {GlobaldummyData
                          ? GlobalSlNo && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {index + 1}
                              </div>
                            )
                          : SLNO && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {chunkIndex * chunkSize + index + 1}
                              </div>
                            )}
                        {GlobaldummyData ? (
                          (GlobalItem || GlobalQuantity) && (
                            <div style={{ textAlign: 'left', width: '300%' }}>
                              {GlobaldummyData ? (
                                GlobalItem && (
                                  <>
                                    <div>{item?.ProdName}</div>
                                    <div>{item?.Size + item?.UomName}</div>
                                  </>
                                )
                              ) : (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>
                                    {item?.Size +
                                      item?.UomName +
                                      '-' +
                                      (GlobaldummyData
                                        ? GlobalQuantity && item?.SalesQty
                                        : item?.SalesQty)}
                                  </div>
                                </>
                              )}
                            </div>
                          )
                        ) : (
                          <div style={{ textAlign: 'left', width: '300%' }}>
                            {GlobaldummyData ? (
                              GlobalItem && (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>{item?.Size + item?.UomName}</div>
                                </>
                              )
                            ) : (
                              <>
                                <div>{item?.ProdName}</div>
                                {PackageDetails?.filter(
                                  (pkg) => pkg.ProdId === item.ProdId
                                ).length > 0 ? (
                                  <div>
                                    {PackageDetails?.filter(
                                      (pkg) => pkg.ProdId === item.ProdId
                                    )?.map((item, index) => (
                                      <span
                                        key={index}
                                        style={{ display: 'block' }}
                                      >
                                        {item.ParcelCount} PCS {item.ParcelQty}{' '}
                                        PACK ({item.ParcelType})
                                      </span>
                                    ))}
                                    {(item?.ProductIdentifierDtls?.filter(
                                      (items) =>
                                        items.SerialNumber &&
                                        items.SerialNumber !== ''
                                    )?.map((a, index) => (
                                      <div key={`serial-${index}`}>
                                        {a.SerialNumber}
                                      </div>
                                    )) || '') +
                                      (item?.ProductIdentifierDtls?.filter(
                                        (item1) => item1.IMEI1 || item1.IMEI2
                                      )?.map((item2, index) => {
                                        const imei1 = item2.IMEI1 || '';
                                        const imei2 = item2.IMEI2 || '';
                                        return (
                                          <div key={`imei-${index}`}>
                                            {[imei1, imei2]
                                              .filter(Boolean)
                                              .join(',')}
                                          </div>
                                        );
                                      }) || '') +
                                      (GlobaldummyData
                                        ? GlobalQuantity && item?.SalesQty
                                        : item?.SalesQty)}
                                  </div>
                                ) : (
                                  <div>
                                    {(item?.Size || '1') +
                                      (item?.SinglePc === 'Y'
                                        ? 'PCS'
                                        : item?.Type !== 'C'
                                          ? item?.UomName
                                          : 'COMBO') +
                                      (item?.BrandName || '') +
                                      (item?.ProductIdentifierDtls?.filter(
                                        (items) =>
                                          items.SerialNumber &&
                                          items.SerialNumber !== ''
                                      )?.map((a, index) => (
                                        <div key={`serial-${index}`}>
                                          {a.SerialNumber}
                                        </div>
                                      )) || '') +
                                      (item?.ProductIdentifierDtls?.filter(
                                        (item1) => item1.IMEI1 || item1.IMEI2
                                      )?.map((item2, index) => {
                                        const imei1 = item2.IMEI1 || '';
                                        const imei2 = item2.IMEI2 || '';
                                        return (
                                          <div key={`imei-${index}`}>
                                            {[imei1, imei2]
                                              .filter(Boolean)
                                              .join(',')}
                                          </div>
                                        );
                                      }) || '') +
                                      '-' +
                                      (GlobaldummyData
                                        ? GlobalQuantity && item?.SalesQty
                                        : item?.SalesQty)}
                                  </div>
                                )}
                              </>
                            )}
                          </div>
                        )}
                        {GlobaldummyData
                          ? GlobalHsnCode && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.HSN}
                              </div>
                            )
                          : HsnCode && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.HSN}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalMRP && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.MRP}
                              </div>
                            )
                          : MRP && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.SinglePc === 'Y'
                                  ? item?.Rate
                                  : item?.MRP}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalRate && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Rate}
                              </div>
                            )
                          : Rate && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Rate}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalDiscount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.discount}
                              </div>
                            )
                          : Discount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Type != 'C'
                                  ? item?.OfferAmt || 0
                                  : item?.OfferValue || 0}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalTax && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.ProdTaxPercentage}
                              </div>
                            )
                          : Tax &&
                            table2Data?.OrderType !== 'E' && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.ProdTaxPercentage || 0}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalAmount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.TotalAmt}
                              </div>
                            )
                          : Amount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {' '}
                                {item?.Type != 'C'
                                  ? item?.TotalAmt - item?.OfferAmt || 0
                                  : item?.TotalAmt - item?.OfferValue || 0}
                              </div>
                            )}
                      </div>
                    ))}
                  </>
                )}
                {DineInData?.length > 0 && dinePreference && (
                  <>
                    <div
                      style={{
                        display: 'flex',
                        width: '100%',
                        justifyContent: 'center',
                        alignItems: 'center',
                      }}
                    >
                      {' '}
                      DineIn
                    </div>
                    <div
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        fontWeight: '600',
                        fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                        width: '100%',
                        gap: '0.5rem',
                      }}
                    >
                      {GlobaldummyData
                        ? GlobalSlNo && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              S.No
                            </div>
                          )
                        : SLNO && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              S.No
                            </div>
                          )}
                      {GlobaldummyData ? (
                        (GlobalItem || GlobalQuantity) && (
                          <div style={{ width: '300%', textAlign: 'center' }}>
                            {' '}
                            {GlobaldummyData
                              ? GlobalItem && 'ITEM /DES /'
                              : 'ITEM /DES /'}{' '}
                            {GlobaldummyData
                              ? GlobalQuantity && 'QTY'
                              : 'QTY'}{' '}
                          </div>
                        )
                      ) : (
                        <div style={{ width: '300%', textAlign: 'center' }}>
                          {' '}
                          {GlobaldummyData
                            ? GlobalItem && 'ITEM /DES /'
                            : Item && 'ITEM /DES /'}{' '}
                          {GlobaldummyData
                            ? GlobalQuantity && 'QTY'
                            : Quantity && WeightasKg ?'Qty/Kg' :'Qty'}{' '}
                        </div>
                      )}
                      {GlobaldummyData
                        ? GlobalHsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              HSN
                            </div>
                          )
                        : HsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              HSN
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalMRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              MRP
                            </div>
                          )
                        : MRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              MRP
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalRate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              RATE
                            </div>
                          )
                        : Rate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              RATE
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalDiscount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              DIS{' '}
                            </div>
                          )
                        : Discount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              DIS{' '}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalTax && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              TAX %{' '}
                            </div>
                          )
                        : Tax &&
                          table2Data?.OrderType !== 'E' && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              TAX %{' '}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalAmount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              Amt{' '}
                            </div>
                          )
                        : Amount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              AMT{' '}
                            </div>
                          )}
                    </div>

                    <hr className="hrline" />

                    {dataChunk?.map((item, index) => (
                      <div
                        key={index}
                        className="PrintStyle5-print-prddtls"
                        style={{
                          display: 'flex',
                          justifyContent: 'space-between',
                          fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                          fontWeight: '600',
                          width: '100%',
                          gap: '0.5rem',
                        }}
                      >
                        {GlobaldummyData
                          ? GlobalSlNo && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {index + 1}
                              </div>
                            )
                          : SLNO && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {chunkIndex * chunkSize + index + 1}
                              </div>
                            )}
                        {GlobaldummyData ? (
                          (GlobalItem || GlobalQuantity) && (
                            <div style={{ textAlign: 'left', width: '300%' }}>
                              {GlobaldummyData ? (
                                GlobalItem && (
                                  <>
                                    <div>{item?.ProdName}</div>
                                    <div>{item?.Size + item?.UomName}</div>
                                  </>
                                )
                              ) : (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>
                                    {item?.Size +
                                      item?.UomName +
                                      '-' +
                                      (GlobaldummyData
                                        ? GlobalQuantity && item?.SalesQty
                                        : item?.SalesQty)}
                                  </div>
                                </>
                              )}
                            </div>
                          )
                        ) : (
                          <div style={{ textAlign: 'left', width: '300%' }}>
                            {GlobaldummyData ? (
                              GlobalItem && (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>{item?.Size + item?.UomName}</div>
                                </>
                              )
                            ) : (
                              <>
                                <div>{item?.ProdName}</div>
                                <div>
                                  {(item?.Size ? item?.Size : '1') +
                                    (item?.SinglePc == 'Y'
                                      ? 'PCS'
                                      : item?.Type != 'C'
                                        ? item?.UomName
                                        : 'COMBO') +
                                    '-' +
                                    (GlobaldummyData
                                      ? GlobalQuantity && item?.SalesQty
                                      : item?.SalesQty)}
                                </div>
                              </>
                            )}
                          </div>
                        )}
                        {GlobaldummyData
                          ? GlobalHsnCode && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.HSN}
                              </div>
                            )
                          : HsnCode && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.HSN}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalMRP && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.MRP}
                              </div>
                            )
                          : MRP && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.SinglePc === 'Y'
                                  ? item?.Rate
                                  : item?.MRP}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalRate && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Rate}
                              </div>
                            )
                          : Rate && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Rate}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalDiscount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.discount}
                              </div>
                            )
                          : Discount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Type != 'C'
                                  ? item?.OfferAmt || 0
                                  : item?.OfferValue || 0}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalTax && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.ProdTaxPercentage}
                              </div>
                            )
                          : Tax &&
                            table2Data?.OrderType !== 'E' && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.ProdTaxPercentage || 0}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalAmount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.TotalAmt}
                              </div>
                            )
                          : Amount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {' '}
                                {item?.Type != 'C'
                                  ? item?.TotalAmt - item?.OfferAmt || 0
                                  : item?.TotalAmt - item?.OfferValue || 0}
                              </div>
                            )}
                      </div>
                    ))}
                  </>
                )}
              </div>

              {chunkIndex === paginatedChunks.length - 1 &&
                !shouldFooterBeOnNewPage &&
                FormatTheme && (
                  <>
                    {table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div>
                        {((OrderDetailGST?.length > 0 &&
                          OrderDetailGST?.[0]?.TaxAmt > 0) ||
                          (OrderDetailIGST?.length > 0 &&
                            OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                          (OrderDetailVAT?.length > 0 &&
                            OrderDetailVAT?.[0]?.TaxAmt > 0)) &&
                          table2Data?.NetAmount !== 0 && (
                            <>
                              <hr className="hrline" />

                              <div>
                                <div
                                  style={{
                                    margin: 0,
                                    padding: 0,
                                    textAlign: 'center',
                                  }}
                                >
                                  --------- GST Breakup Details -----------
                                </div>
                                {OrderDetailGST?.length > 0 &&
                                  OrderDetailGST?.[0]?.TaxAmt > 0 && (
                                    <table style={{ width: '90%' }}>
                                      <tr>
                                        <td style={{ textAlign: 'right' }}></td>
                                        <td style={{ textAlign: 'center' }}>
                                          Taxable Amount
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          CGST
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          SGST
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          Total Amount
                                        </td>
                                      </tr>
                                      {OrderDetailGST?.map((item) => (
                                        <tr>
                                          <td style={{ textAlign: 'right' }}>
                                            {item?.TaxPercentage || 0}%
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(
                                              item.WithOutTaxAmount
                                            ).toFixed(2)}
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.CGST).toFixed(2)}
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.SGST).toFixed(2)}
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.TotalAmt).toFixed(2)}
                                          </td>
                                        </tr>
                                      ))}
                                    </table>
                                  )}

                                {OrderDetailIGST?.length > 0 &&
                                  OrderDetailIGST?.[0]?.TaxAmt > 0 && (
                                    <>
                                      <div
                                        style={{
                                          border: '0.01px dashed black',
                                          margin: '10px 0 5px 10px',
                                          width: '90%',
                                        }}
                                      ></div>
                                      <table style={{ width: '90%' }}>
                                        <tr>
                                          <td
                                            style={{ textAlign: 'right' }}
                                          ></td>
                                          <td style={{ textAlign: 'center' }}>
                                            Taxable Amount
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            IGST
                                          </td>

                                          <td style={{ textAlign: 'center' }}>
                                            Total Amount
                                          </td>
                                        </tr>
                                        {OrderDetailIGST?.map((item) => (
                                          <tr>
                                            <td style={{ textAlign: 'right' }}>
                                              {item?.TaxPercentage || 0}%
                                            </td>
                                            <td style={{ textAlign: 'center' }}>
                                              {Number(
                                                item.WithOutTaxAmount
                                              ).toFixed(2)}
                                            </td>
                                            <td style={{ textAlign: 'center' }}>
                                              {Number(item.TaxAmt).toFixed(2)}
                                            </td>

                                            <td style={{ textAlign: 'center' }}>
                                              {Number(item.TotalAmt).toFixed(2)}
                                            </td>
                                          </tr>
                                        ))}
                                      </table>
                                    </>
                                  )}
                                {OrderDetailVAT?.length > 0 &&
                                  OrderDetailVAT?.[0]?.TaxAmt > 0 && (
                                    <>
                                      <div
                                        style={{
                                          border: '0.01px dashed black',
                                          margin: '10px 0 5px 10px',
                                          width: '90%',
                                        }}
                                      ></div>
                                      <table style={{ width: '90%' }}>
                                        <tr>
                                          <td
                                            style={{ textAlign: 'right' }}
                                          ></td>
                                          <td style={{ textAlign: 'center' }}>
                                            Taxable Amount
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            VAT
                                          </td>

                                          <td style={{ textAlign: 'center' }}>
                                            Total Amount
                                          </td>
                                        </tr>
                                        {OrderDetailVAT?.map((item) => (
                                          <tr>
                                            <td style={{ textAlign: 'right' }}>
                                              {item?.TaxPercentage || 0}%
                                            </td>
                                            <td style={{ textAlign: 'center' }}>
                                              {Number(
                                                item.WithOutTaxAmount
                                              ).toFixed(2)}
                                            </td>
                                            <td style={{ textAlign: 'center' }}>
                                              {Number(item.TaxAmt).toFixed(2)}
                                            </td>

                                            <td style={{ textAlign: 'center' }}>
                                              {Number(item.TotalAmt).toFixed(2)}
                                            </td>
                                          </tr>
                                        ))}
                                      </table>
                                    </>
                                  )}
                              </div>
                              <hr className="hrline" />
                            </>
                          )}
                      </div>
                    )}

                    <div>
                      <div className="align-style">
                        {' '}
                        <div>Items : </div>{' '}
                        <div>
                          {GlobaldummyData ? '8' : totalQuantityFilter?.length}
                        </div>{' '}
                      </div>
                      <div className="align-style">
                        {' '}
                        <div>Qty : </div>{' '}
                        <div>{GlobaldummyData ? '9' : totalQuantity}</div>{' '}
                      </div>
                      {/* {ExtraChargeTotal>0 &&<div className="align-style">  <div>Extra Charges  : </div>  <div> {ExtraChargeTotal}</div> </div>} */}
                      {(table2Data?.OverallDisc > 0 ||
                        TotalOfferAmount > 0) && (
                        <div className="align-style">
                          {' '}
                          <div>Off : </div>{' '}
                          <div>
                            {GlobaldummyData
                              ? '100'
                              : Number(
                                  TotalOfferAmount + table2Data?.OverallDisc
                                ).toFixed(2)}
                          </div>{' '}
                        </div>
                      )}

                      <hr className="hrline" />

                      <div
                        className="align-style"
                        style={{ fontWeight: '600', fontSize: '19px' }}
                      >
                        {' '}
                        <div>Amount </div> <div> : </div>{' '}
                        <div>
                          {GlobaldummyData
                            ? '1,066'
                            : Number(table2Data?.NetAmount).toFixed(2)}
                        </div>{' '}
                      </div>

                      <hr className="hrline" />
                      {/* 
          <div className="align-style" style={{ fontWeight: '400', }}>  <div>You Pay  : </div>  <div>1066.00</div>  </div>
          <div className="align-style">  <div>Recived Amt  : </div>   <div>1066.00</div>  </div>
          <div className="align-style">  <div>Balance Amt  : </div>  <div>0.00</div>  </div> */}
                    </div>

                    <br />

                    <div
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        alignItems: 'center',
                      }}
                    >
                      <div style={{ fontSize: '13px' }}>
                        {DineInData?.length > 0 && TakeawayData?.length > 0 && (
                          <>
                            {takeAwayPreference && (
                              <div>
                                Takeaway:&nbsp;
                                {Number(TakeawayTotal).toFixed(2)}
                              </div>
                            )}
                            {dinePreference && (
                              <div>
                                Dine In:&nbsp;
                                {Number(DineInTotal).toFixed(2)}{' '}
                              </div>
                            )}
                          </>
                        )}
                        {/* <div style={{ display: 'flex', justifyContent: 'flex-start', }}>CARD : *********12</div>
            <div style={{ display: 'flex', justifyContent: 'flex-start', }}>CARD HOLDER : CARD HOLDER NAME</div> */}
                        <div
                          style={{
                            display: 'flex',
                            justifyContent: 'space-evenly',
                            marginTop: '5px',
                          }}
                        >
                          <div
                            style={{
                              marginTop: '5px',
                              padding: 0,
                              fontSize: '17px',
                              fontWeight: '600',
                            }}
                          >
                            {PaymentStatusSuccess?.length === 1
                              ? PaymentStatusSuccess?.[0]?.PaymentTypeName
                              : 'Split'}{' '}
                            &nbsp;Payment : &nbsp;
                            {GlobaldummyData
                              ? '1,066'
                              : Number(table2Data?.NetAmount).toFixed(2)}
                            /-{' '}
                          </div>
                        </div>
                        {GlobaldummyData
                          ? GlobalCredit && (
                              <div
                                style={{
                                  textAlign: 'center',
                                  fontSize: '12px',
                                  display: 'flex',
                                  justifyContent: 'space-evenly',
                                  justifyContent: 'space-evenly',
                                  fontWeight: '600',
                                  lineHeight: '14px',
                                }}
                              >
                                <h6>Advance Amount:</h6>
                                <h6>Opening Balance:</h6>
                              </div>
                            )
                          : CreditDetails &&
                            table2Data?.CustomerDetails?.length > 0 && (
                              <div
                                style={{
                                  textAlign: 'center',
                                  fontSize: '15px',
                                  fontWeight: '600',
                                  lineHeight: '14px',
                                }}
                              >
                                {/* OLD CREDIT BAL */}
                                {PaymentStatusSuccess?.[0]?.PaymentTypeName ===
                                  'Credit' && (
                                  <>
                                    {table2Data.CustomerDetails[0]
                                      .OldCreditBal > 0 ? (
                                      <p>
                                        Advance Amount:
                                        {
                                          table2Data.CustomerDetails[0]
                                            .OldCreditBal
                                        }
                                      </p>
                                    ) : table2Data.CustomerDetails[0]
                                        .OldCreditBal < 0 ? (
                                      <p>
                                        {' '}
                                        Opening Balance:{' '}
                                        {Math.abs(
                                          table2Data.CustomerDetails[0]
                                            .OldCreditBal
                                        )}
                                      </p>
                                    ) : null}
                                  </>
                                )}

                                {/* CURRENT CREDIT BAL */}
                                {table2Data.CustomerDetails[0]
                                  .CurrentCreditBal > 0 ? (
                                  <p>
                                    {' '}
                                    Current Advance Amount:{' '}
                                    {
                                      table2Data.CustomerDetails[0]
                                        .CurrentCreditBal
                                    }
                                  </p>
                                ) : table2Data.CustomerDetails[0]
                                    .CurrentCreditBal < 0 ? (
                                  <p>
                                    {' '}
                                    Current Balance Amount:{' '}
                                    {Math.abs(
                                      table2Data.CustomerDetails[0]
                                        .CurrentCreditBal
                                    )}
                                  </p>
                                ) : null}
                              </div>
                            )}
                        <hr />
                        {/* <div style={{ display: 'flex', justifyContent: 'flex-start', fontWeight: '600', fontSize: '16px', }} >TOTAL SAVING : 10.00</div> */}
                      </div>

                      {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                        ''
                      ) : (
                        <div>
                          {GlobaldummyData
                            ? GlobalQrcodet && (
                                <div>
                                  <div>
                                    {' '}
                                    <img
                                      src={QrImg}
                                      alt=""
                                      style={{
                                        width: '100px',
                                        height: '100px',
                                      }}
                                    />{' '}
                                  </div>
                                  <div>Scan to Pay </div>
                                  <div style={{ fontWeight: '600' }}>
                                    {' '}
                                    {GlobaldummyData
                                      ? '1,066'
                                      : Number(table2Data?.NetAmount).toFixed(
                                          2
                                        )}
                                  </div>
                                </div>
                              )
                            : Qrcodet &&
                              paymentTypeUPI && (
                                <div
                                  style={{
                                    display: 'flex',
                                    flexDirection: 'column',
                                    justifyContent: 'center',
                                    alignItems: 'center',
                                  }}
                                >
                                  <QRCode
                                    value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                                    size={80}
                                  />
                                  <div style={{}}>Scan to Pay </div>
                                  <div style={{}}>
                                    ₹
                                    {GlobaldummyData
                                      ? '1,066'
                                      : Number(table2Data?.NetAmount).toFixed(
                                          2
                                        )}
                                  </div>
                                </div>
                              )}
                        </div>
                      )}
                    </div>
                    <div>
                      YOUR ORDER NO:{' '}
                      {table2Data?.SalesId &&
                        extractLastNumber(table2Data?.SalesId)}
                    </div>
                    <div className="PrintStyle4-FourthP">
                      {PaymentStatusSuccess?.length > 1 && (
                        <>
                          {/* <p>Split Payment:</p> */}
                          {Object.keys(aggregatedPayments).map(
                            (paymentType) => (
                              <div
                                key={paymentType}
                                style={{
                                  margin: 0,
                                  padding: 0,
                                  fontSize: '12px',
                                }}
                              >
                                {paymentType}:{' '}
                                {aggregatedPayments[paymentType].toFixed(2)}
                              </div>
                            )
                          )}
                        </>
                      )}
                      {GlobaldummyData && GlobalCashierName && (
                        <div className="PrintStyle4-FourthSmallwordings">
                          {' '}
                          Cashier : Cashier Name
                        </div>
                      )}
                      {CashierName &&
                        CashierName !== undefined &&
                        CashierName !== null &&
                        !GlobaldummyData &&
                        CashierNameField && (
                          <div className="PrintStyle4-FourthSmallwordings">
                            Cashier : {CashierName}
                          </div>
                        )}
                      {GlobaldummyData && (
                        <div className="PrintStyle4-FourthSmallwordings">
                          {' '}
                          Customer : Customer Name
                        </div>
                      )}
                      {table2Data?.CustSuppName &&
                        table2Data?.CustSuppName !== undefined &&
                        table2Data?.CustSuppName !== null &&
                        !GlobaldummyData && (
                          <div className="PrintStyle4-FourthSmallwordings">
                            Customer : {table2Data?.CustSuppName}
                          </div>
                        )}

                      {table2Data?.BookingTypeName == 'Dine In' &&
                        dinePreference &&
                        table2Data?.SalesTableLinkDetails?.[0]?.WaiterName && (
                          <div className="PrintStyle4-FourthSmallwordings">
                            Captain :{' '}
                            {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                          </div>
                        )}
                      {sportsAppPreference && MembershipApplied && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'center',
                            paddingTop: '10px',
                          }}
                        >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
                      )}
                    </div>

                    <div
                      className="page-footerA4Style11"
                      style={{
                        marginTop: 'auto',
                        pageBreakBefore: 'avoid',
                        pageBreakInside: 'avoid',
                        minHeight: 'auto',
                      }}
                    >
                      {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                        ''
                      ) : (
                        <div>
                          {GlobaldummyData
                            ? GlobalIsnotes && (
                                <div>
                                  <p style={{ padding: '0rem 1rem' }}>
                                    Notes : 10 days Return policy
                                  </p>

                                  <hr className="PrintA4Style11-print-dottline" />
                                </div>
                              )
                            : Notestext && (
                                <div>
                                  <p style={{ padding: '0rem 1rem' }}>
                                    {Notestext}
                                  </p>

                                  <hr className="PrintA4Style11-print-dottline" />
                                </div>
                              )}
                        </div>
                      )}

                      {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                        ''
                      ) : (
                        <div
                          style={{
                            display: 'flex',
                            width: '90%',
                            padding: '0 1rem',
                            justifyContent: GlobaltermsAndConditions
                              ? 'space-between'
                              : 'flex-end',
                            alignItems: 'center',
                          }}
                        >
                          {GlobaldummyData
                            ? GlobaltermsAndConditions && (
                                <div
                                  style={{
                                    margin: '8px 0',
                                    padding: '8px',
                                    fontFamily: 'sans-serif',
                                    width: '100%',
                                  }}
                                >
                                  <p
                                    style={{
                                      fontSize: '13px',
                                      fontWeight: 'bold',
                                      marginBottom: '6px',
                                    }}
                                  >
                                    Terms & Conditions
                                  </p>
                                  <ol
                                    style={{
                                      fontSize: '12px',
                                      paddingLeft: '18px',
                                      margin: 0,
                                      lineHeight: '1',
                                      textAlign: 'left',
                                    }}
                                  >
                                    <li>
                                      Once goods are sold, they are not
                                      exchangeable or refundable.
                                    </li>
                                    <li>
                                      Please check the product before leaving
                                      the counter.
                                    </li>
                                  </ol>
                                </div>
                              )
                            : TermsnAdCondition == true &&
                              TermsAndConditions?.length > 0 && (
                                <div
                                  style={{
                                    margin: '8px 0',
                                    fontFamily: 'sans-serif',
                                    width: '100%',
                                    display: 'flex',
                                    flexDirection: 'column',
                                    alignItems: 'flex-start',
                                  }}
                                >
                                  <p
                                    style={{
                                      fontSize: '13px',
                                      fontWeight: 'bold',
                                      marginBottom: '6px',
                                    }}
                                  >
                                    Terms & Conditions
                                  </p>
                                  <ol
                                    style={{
                                      fontSize: '12px',
                                      paddingLeft: '18px',
                                      margin: 0,
                                      lineHeight: '1',
                                    }}
                                  >
                                    {TermsAndConditions?.map((item) => (
                                      <li style={{ textAlign: 'start' }}>
                                        {item?.TermsandConditions}
                                      </li>
                                    ))}
                                    {/* <li>Please check the product before leaving the counter.</li> */}
                                  </ol>
                                </div>
                              )}

                          {GlobaldummyData
                            ? GlobalSignature && (
                                <div
                                  style={{
                                    display: 'flex',
                                    flexDirection: 'column',
                                    alignItems: 'flex-end',
                                    paddingBottom: '1rem',
                                  }}
                                >
                                  <p
                                    style={{
                                      fontSize: '13px',
                                      fontWeight: 'bold',
                                      marginBottom: '6px',
                                    }}
                                  >
                                    Signature
                                  </p>
                                  <img
                                    style={{ width: '70px', height: '40px' }}
                                    src={
                                      GlobalSignatureImages
                                        ? GlobalSignatureImages
                                        : signature
                                    }
                                    alt=""
                                  />
                                </div>
                              )
                            : Signature == true && (
                                <div
                                  style={{
                                    display: 'flex',
                                    flexDirection: 'column',
                                    alignItems: 'center',
                                    marginTop: '1rem',
                                    paddingBottom: '1rem',
                                  }}
                                >
                                  <p
                                    style={{
                                      fontSize: '13px',
                                      fontWeight: 'bold',
                                      marginBottom: '6px',
                                    }}
                                  >
                                    Signature
                                  </p>
                                  <img
                                    style={{ width: '100px', height: '60px' }}
                                    src={SignatureImg}
                                    alt=""
                                  />
                                </div>
                              )}
                        </div>
                      )}
                    </div>

                    {PrintGreeting?.SettingValue === 'Y' && (
                      <div
                        style={{
                          display: 'flex',
                          justifyContent: 'center',
                          fontWeight: '600',
                          textTransform: 'uppercase',
                        }}
                      >
                        Thank You Visit Again
                      </div>
                    )}
                  </>
                )}
            </div>
          ))}

          {shouldFooterBeOnNewPage && FormatTheme && (
            <div
              className="print-page"
              style={{
                display: 'flex',
                flexDirection: 'column',
                minHeight: PageSize == 'A5' ? '200mm' : '260mm',
                justifyContent: 'flex-end',
                pageBreakBefore: 'always',
              }}
            >
              <div
                className="page-footerA4Style11"
                style={{
                  marginTop: 'auto',
                  pageBreakBefore: 'avoid',
                  pageBreakInside: 'avoid',
                  minHeight: 'auto',
                }}
              >
                <>
                  {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                    ''
                  ) : (
                    <div>
                      {((OrderDetailGST?.length > 0 &&
                        OrderDetailGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailIGST?.length > 0 &&
                          OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailVAT?.length > 0 &&
                          OrderDetailVAT?.[0]?.TaxAmt > 0)) &&
                        table2Data?.NetAmount !== 0 && (
                          <>
                            <hr className="hrline" />

                            <div>
                              <div
                                style={{
                                  margin: 0,
                                  padding: 0,
                                  textAlign: 'center',
                                }}
                              >
                                --------- GST Breakup Details -----------
                              </div>
                              {OrderDetailGST?.length > 0 &&
                                OrderDetailGST?.[0]?.TaxAmt > 0 && (
                                  <table style={{ width: '90%' }}>
                                    <tr>
                                      <td style={{ textAlign: 'right' }}></td>
                                      <td style={{ textAlign: 'center' }}>
                                        Taxable Amount
                                      </td>
                                      <td style={{ textAlign: 'center' }}>
                                        CGST
                                      </td>
                                      <td style={{ textAlign: 'center' }}>
                                        SGST
                                      </td>
                                      <td style={{ textAlign: 'center' }}>
                                        Total Amount
                                      </td>
                                    </tr>
                                    {OrderDetailGST?.map((item) => (
                                      <tr>
                                        <td style={{ textAlign: 'right' }}>
                                          {item?.TaxPercentage || 0}%
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          {Number(
                                            item.WithOutTaxAmount
                                          ).toFixed(2)}
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          {Number(item.CGST).toFixed(2)}
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          {Number(item.SGST).toFixed(2)}
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          {Number(item.TotalAmt).toFixed(2)}
                                        </td>
                                      </tr>
                                    ))}
                                  </table>
                                )}

                              {OrderDetailIGST?.length > 0 &&
                                OrderDetailIGST?.[0]?.TaxAmt > 0 && (
                                  <>
                                    <div
                                      style={{
                                        border: '0.01px dashed black',
                                        margin: '10px 0 5px 10px',
                                        width: '90%',
                                      }}
                                    ></div>
                                    <table style={{ width: '90%' }}>
                                      <tr>
                                        <td style={{ textAlign: 'right' }}></td>
                                        <td style={{ textAlign: 'center' }}>
                                          Taxable Amount
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          IGST
                                        </td>

                                        <td style={{ textAlign: 'center' }}>
                                          Total Amount
                                        </td>
                                      </tr>
                                      {OrderDetailIGST?.map((item) => (
                                        <tr>
                                          <td style={{ textAlign: 'right' }}>
                                            {item?.TaxPercentage || 0}%
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(
                                              item.WithOutTaxAmount
                                            ).toFixed(2)}
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.TaxAmt).toFixed(2)}
                                          </td>

                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.TotalAmt).toFixed(2)}
                                          </td>
                                        </tr>
                                      ))}
                                    </table>
                                  </>
                                )}
                              {OrderDetailVAT?.length > 0 &&
                                OrderDetailVAT?.[0]?.TaxAmt > 0 && (
                                  <>
                                    <div
                                      style={{
                                        border: '0.01px dashed black',
                                        margin: '10px 0 5px 10px',
                                        width: '90%',
                                      }}
                                    ></div>
                                    <table style={{ width: '90%' }}>
                                      <tr>
                                        <td style={{ textAlign: 'right' }}></td>
                                        <td style={{ textAlign: 'center' }}>
                                          Taxable Amount
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          VAT
                                        </td>
                                        <td style={{ textAlign: 'center' }}>
                                          Total Amount
                                        </td>
                                      </tr>
                                      {OrderDetailVAT?.map((item) => (
                                        <tr>
                                          <td style={{ textAlign: 'right' }}>
                                            {item?.TaxPercentage || 0}%
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(
                                              item.WithOutTaxAmount
                                            ).toFixed(2)}
                                          </td>
                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.TaxAmt).toFixed(2)}
                                          </td>

                                          <td style={{ textAlign: 'center' }}>
                                            {Number(item.TotalAmt).toFixed(2)}
                                          </td>
                                        </tr>
                                      ))}
                                    </table>
                                  </>
                                )}
                            </div>
                            <hr className="hrline" />
                          </>
                        )}
                    </div>
                  )}

                  <div>
                    <div className="align-style">
                      {' '}
                      <div>Items : </div>{' '}
                      <div>
                        {GlobaldummyData ? '8' : totalQuantityFilter?.length}
                      </div>{' '}
                    </div>
                    <div className="align-style">
                      {' '}
                      <div>Qty : </div>{' '}
                      <div>{GlobaldummyData ? '9' : totalQuantity}</div>{' '}
                    </div>
                    {/* {ExtraChargeTotal>0 &&<div className="align-style">  <div>Extra Charges  : </div>  <div> {ExtraChargeTotal}</div> </div>} */}
                    {(table2Data?.OverallDisc > 0 || TotalOfferAmount > 0) && (
                      <div className="align-style">
                        {' '}
                        <div>Off : </div>{' '}
                        <div>
                          {GlobaldummyData
                            ? '100'
                            : Number(
                                TotalOfferAmount + table2Data?.OverallDisc
                              ).toFixed(2)}
                        </div>{' '}
                      </div>
                    )}

                    <hr className="hrline" />

                    <div
                      className="align-style"
                      style={{ fontWeight: '600', fontSize: '19px' }}
                    >
                      {' '}
                      <div>Amount </div> <div> : </div>{' '}
                      <div>
                        {GlobaldummyData
                          ? '1,066'
                          : Number(table2Data?.NetAmount).toFixed(2)}
                      </div>{' '}
                    </div>

                    <hr className="hrline" />
                  </div>

                  <br />

                  <div
                    style={{
                      display: 'flex',
                      justifyContent: 'space-between',
                      alignItems: 'center',
                    }}
                  >
                    <div style={{ fontSize: '13px' }}>
                      {DineInData?.length > 0 && TakeawayData?.length > 0 && (
                        <>
                          {takeAwayPreference && (
                            <div>
                              Takeaway:&nbsp;{Number(TakeawayTotal).toFixed(2)}
                            </div>
                          )}
                          {dinePreference && (
                            <div>
                              Dine In:&nbsp;
                              {Number(DineInTotal).toFixed(2)}{' '}
                            </div>
                          )}
                        </>
                      )}

                      <div
                        style={{
                          display: 'flex',
                          justifyContent: 'space-evenly',
                          marginTop: '5px',
                        }}
                      >
                        <div
                          style={{
                            marginTop: '5px',
                            padding: 0,
                            fontSize: '17px',
                            fontWeight: '600',
                          }}
                        >
                          {PaymentStatusSuccess?.length === 1
                            ? PaymentStatusSuccess?.[0]?.PaymentTypeName
                            : 'Split'}{' '}
                          &nbsp;Payment : &nbsp;
                          {GlobaldummyData
                            ? '1,066'
                            : Number(table2Data?.NetAmount).toFixed(2)}
                          /-{' '}
                        </div>
                      </div>
                      {GlobaldummyData
                        ? GlobalCredit && (
                            <div
                              style={{
                                textAlign: 'center',
                                fontSize: '12px',
                                display: 'flex',
                                justifyContent: 'space-evenly',
                                justifyContent: 'space-evenly',
                                fontWeight: '600',
                                lineHeight: '14px',
                              }}
                            >
                              <h6>Advance Amount:</h6>
                              <h6>Opening Balance:</h6>
                            </div>
                          )
                        : CreditDetails &&
                          table2Data?.CustomerDetails?.length > 0 && (
                            <div
                              style={{
                                textAlign: 'center',
                                fontSize: '15px',
                                fontWeight: '600',
                                lineHeight: '14px',
                              }}
                            >
                              {/* OLD CREDIT BAL */}
                              {PaymentStatusSuccess?.[0]?.PaymentTypeName ===
                                'Credit' && (
                                <>
                                  {table2Data.CustomerDetails[0].OldCreditBal >
                                  0 ? (
                                    <p>
                                      Advance Amount:
                                      {
                                        table2Data.CustomerDetails[0]
                                          .OldCreditBal
                                      }
                                    </p>
                                  ) : table2Data.CustomerDetails[0]
                                      .OldCreditBal < 0 ? (
                                    <p>
                                      {' '}
                                      Opening Balance:{' '}
                                      {Math.abs(
                                        table2Data.CustomerDetails[0]
                                          .OldCreditBal
                                      )}
                                    </p>
                                  ) : null}
                                </>
                              )}

                              {/* CURRENT CREDIT BAL */}
                              {table2Data.CustomerDetails[0].CurrentCreditBal >
                              0 ? (
                                <p>
                                  {' '}
                                  Current Advance Amount:{' '}
                                  {
                                    table2Data.CustomerDetails[0]
                                      .CurrentCreditBal
                                  }
                                </p>
                              ) : table2Data.CustomerDetails[0]
                                  .CurrentCreditBal < 0 ? (
                                <p>
                                  {' '}
                                  Current Balance Amount:{' '}
                                  {Math.abs(
                                    table2Data.CustomerDetails[0]
                                      .CurrentCreditBal
                                  )}
                                </p>
                              ) : null}
                            </div>
                          )}
                      <hr />
                      {/* <div style={{ display: 'flex', justifyContent: 'flex-start', fontWeight: '600', fontSize: '16px', }} >TOTAL SAVING : 10.00</div> */}
                    </div>

                    {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div>
                        {GlobaldummyData
                          ? GlobalQrcodet && (
                              <div>
                                <div>
                                  {' '}
                                  <img
                                    src={QrImg}
                                    alt=""
                                    style={{ width: '100px', height: '100px' }}
                                  />{' '}
                                </div>
                                <div>Scan to Pay </div>
                                <div style={{ fontWeight: '600' }}>
                                  {' '}
                                  {GlobaldummyData
                                    ? '1,066'
                                    : Number(table2Data?.NetAmount).toFixed(2)}
                                </div>
                              </div>
                            )
                          : Qrcodet &&
                            paymentTypeUPI && (
                              <div
                                style={{
                                  display: 'flex',
                                  flexDirection: 'column',
                                  justifyContent: 'center',
                                  alignItems: 'center',
                                }}
                              >
                                <QRCode
                                  value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                                  size={80}
                                />
                                <div style={{}}>Scan to Pay </div>
                                <div style={{}}>
                                  ₹
                                  {GlobaldummyData
                                    ? '1,066'
                                    : Number(table2Data?.NetAmount).toFixed(2)}
                                </div>
                              </div>
                            )}
                      </div>
                    )}
                  </div>
                  <div>
                    YOUR ORDER NO:{' '}
                    {table2Data?.SalesId &&
                      extractLastNumber(table2Data?.SalesId)}
                  </div>
                  <div className="PrintStyle4-FourthP">
                    {PaymentStatusSuccess?.length > 1 && (
                      <>
                        {/* <p>Split Payment:</p> */}
                        {Object.keys(aggregatedPayments).map((paymentType) => (
                          <div
                            key={paymentType}
                            style={{ margin: 0, padding: 0, fontSize: '12px' }}
                          >
                            {paymentType}:{' '}
                            {aggregatedPayments[paymentType].toFixed(2)}
                          </div>
                        ))}
                      </>
                    )}
                    {GlobaldummyData && GlobalCashierName && (
                      <div className="PrintStyle4-FourthSmallwordings">
                        {' '}
                        Cashier : Cashier Name
                      </div>
                    )}
                    {CashierName &&
                      CashierName !== undefined &&
                      CashierName !== null &&
                      !GlobaldummyData &&
                      CashierNameField && (
                        <div className="PrintStyle4-FourthSmallwordings">
                          Cashier : {CashierName}
                        </div>
                      )}
                    {GlobaldummyData && (
                      <div className="PrintStyle4-FourthSmallwordings">
                        {' '}
                        Customer : Customer Name
                      </div>
                    )}
                    {table2Data?.CustSuppName &&
                      table2Data?.CustSuppName !== undefined &&
                      table2Data?.CustSuppName !== null &&
                      !GlobaldummyData && (
                        <div className="PrintStyle4-FourthSmallwordings">
                          Customer : {table2Data?.CustSuppName}
                        </div>
                      )}

                    {table2Data?.BookingTypeName == 'Dine In' &&
                      dinePreference &&
                      table2Data?.SalesTableLinkDetails?.[0]?.WaiterName && (
                        <div className="PrintStyle4-FourthSmallwordings">
                          Captain :{' '}
                          {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                        </div>
                      )}
                    {sportsAppPreference && MembershipApplied && (
                      <div
                        style={{
                          width: '100%',
                          textAlign: 'center',
                          paddingTop: '10px',
                        }}
                      >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
                    )}
                  </div>

                  <div
                    className="page-footerA4Style11"
                    style={{
                      marginTop: 'auto',
                      pageBreakBefore: 'avoid',
                      pageBreakInside: 'avoid',
                      minHeight: 'auto',
                    }}
                  >
                    {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div>
                        {GlobaldummyData
                          ? GlobalIsnotes && (
                              <div>
                                <p style={{ padding: '0rem 1rem' }}>
                                  Notes : 10 days Return policy
                                </p>

                                <hr className="PrintA4Style11-print-dottline" />
                              </div>
                            )
                          : Notestext && (
                              <div>
                                <p style={{ padding: '0rem 1rem' }}>
                                  {Notestext}
                                </p>

                                <hr className="PrintA4Style11-print-dottline" />
                              </div>
                            )}
                      </div>
                    )}

                    {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div
                        style={{
                          display: 'flex',
                          width: '90%',
                          padding: '0 1rem',
                          justifyContent: GlobaltermsAndConditions
                            ? 'space-between'
                            : 'flex-end',
                          alignItems: 'center',
                        }}
                      >
                        {GlobaldummyData
                          ? GlobaltermsAndConditions && (
                              <div
                                style={{
                                  margin: '8px 0',
                                  padding: '8px',
                                  fontFamily: 'sans-serif',
                                  width: '100%',
                                }}
                              >
                                <p
                                  style={{
                                    fontSize: '13px',
                                    fontWeight: 'bold',
                                    marginBottom: '6px',
                                  }}
                                >
                                  Terms & Conditions
                                </p>
                                <ol
                                  style={{
                                    fontSize: '12px',
                                    paddingLeft: '18px',
                                    margin: 0,
                                    lineHeight: '1',
                                    textAlign: 'left',
                                  }}
                                >
                                  <li>
                                    Once goods are sold, they are not
                                    exchangeable or refundable.
                                  </li>
                                  <li>
                                    Please check the product before leaving the
                                    counter.
                                  </li>
                                </ol>
                              </div>
                            )
                          : TermsnAdCondition == true &&
                            TermsAndConditions?.length > 0 && (
                              <div
                                style={{
                                  margin: '8px 0',
                                  fontFamily: 'sans-serif',
                                  width: '100%',
                                  display: 'flex',
                                  flexDirection: 'column',
                                  alignItems: 'flex-start',
                                }}
                              >
                                <p
                                  style={{
                                    fontSize: '13px',
                                    fontWeight: 'bold',
                                    marginBottom: '6px',
                                  }}
                                >
                                  Terms & Conditions
                                </p>
                                <ol
                                  style={{
                                    fontSize: '12px',
                                    paddingLeft: '18px',
                                    margin: 0,
                                    lineHeight: '1',
                                  }}
                                >
                                  {TermsAndConditions?.map((item) => (
                                    <li style={{ textAlign: 'start' }}>
                                      {item?.TermsandConditions}
                                    </li>
                                  ))}
                                  {/* <li>Please check the product before leaving the counter.</li> */}
                                </ol>
                              </div>
                            )}

                        {GlobaldummyData
                          ? GlobalSignature && (
                              <div
                                style={{
                                  display: 'flex',
                                  flexDirection: 'column',
                                  alignItems: 'flex-end',
                                  paddingBottom: '1rem',
                                }}
                              >
                                <p
                                  style={{
                                    fontSize: '13px',
                                    fontWeight: 'bold',
                                    marginBottom: '6px',
                                  }}
                                >
                                  Signature
                                </p>
                                <img
                                  style={{ width: '70px', height: '40px' }}
                                  src={
                                    GlobalSignatureImages
                                      ? GlobalSignatureImages
                                      : signature
                                  }
                                  alt=""
                                />
                              </div>
                            )
                          : Signature == true && (
                              <div
                                style={{
                                  display: 'flex',
                                  flexDirection: 'column',
                                  alignItems: 'center',
                                  marginTop: '1rem',
                                  paddingBottom: '1rem',
                                }}
                              >
                                <p
                                  style={{
                                    fontSize: '13px',
                                    fontWeight: 'bold',
                                    marginBottom: '6px',
                                  }}
                                >
                                  Signature
                                </p>
                                <img
                                  style={{ width: '100px', height: '60px' }}
                                  src={SignatureImg}
                                  alt=""
                                />
                              </div>
                            )}
                      </div>
                    )}
                  </div>

                  {PrintGreeting?.SettingValue === 'Y' && (
                    <div
                      style={{
                        display: 'flex',
                        justifyContent: 'center',
                        fontWeight: '600',
                        textTransform: 'uppercase',
                      }}
                    >
                      Thank You Visit Again
                    </div>
                  )}
                </>
              </div>
            </div>
          )}
        </div>
      ) : (
        <div
          className="PrintStyle5-MasterDiv"
          id={`PrintStyle5-${index}`}
          style={{ fontFamily: "'Courier New', Courier, monospace" }}
        >
          {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
            ''
          ) : (
            <div className="PrintStyle5-Head">
              <div
                style={{
                  display: 'flex',
                  flexDirection: 'row',
                  alignItems: 'center',
                }}
              >
                {GlobaldummyData && GlobalLogo ? (
                  <img
                    className="PrintStyle2-BrandImage"
                    src={Logo}
                    alt="image"
                  />
                ) : null}
                {base64Image &&
                (PrintLogo?.SettingValue === 'Y' || LogoField) ? (
                  <img
                    className="PrintStyle2-BrandImage"
                    src={GlobaldummyData ? Logo : base64Image}
                    alt="image"
                    width={100}
                  />
                ) : null}
                <div
                  style={{
                    fontSize: 'clamp(2rem, 2.5vw, 2rem)',
                    fontWeight: '600',
                  }}
                >
                  {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
                </div>
              </div>
              <div>Low Prices... Love the Saving... </div>
              <div>
                {GlobaldummyData
                  ? 'BranchAddress, Town- 635XXX City - State'
                  : (table2Data?.AddressDetails?.[0]?.Address1 || '') +
                    (table2Data?.AddressDetails?.[0]?.City
                      ? (table2Data?.AddressDetails?.[0]?.Address1 &&
                        table2Data?.AddressDetails?.[0]?.City
                          ? '-'
                          : '') + table2Data?.AddressDetails?.[0]?.City
                      : '') +
                    (table2Data?.AddressDetails?.[0]?.Zip
                      ? (table2Data?.AddressDetails?.[0]?.City &&
                        table2Data?.AddressDetails?.[0]?.Zip
                          ? '-'
                          : '') + table2Data?.AddressDetails?.[0]?.Zip
                      : '')}
              </div>
              <div style={{ fontSize: '14px', fontWeight: '600' }}>
                {' '}
                Mobile :
                {GlobaldummyData ? '1234567890' : table2Data?.BrMobile}{' '}
              </div>
              {table2Data?.OrderType === 'E' && (
                <div style={{ textTransform: 'uppercase' }}>
                  Estimate{' '}
                  {SalesModePref?.SettingValue == 'Y' &&
                    `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
                </div>
              )}
              {table2Data?.OrderType === 'E' ? (
                ''
              ) : (
                <div style={{ textTransform: 'uppercase' }}>
                  {GlobaldummyData
                    ? GlobalBilltext
                      ? GlobalBilltext
                      : 'Cash' + ' Bill'
                    : BillName
                      ? BillName
                      : PaymentStatusSuccess?.length === 1
                        ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill'
                        : ''}{' '}
                  {SalesModePref?.SettingValue == 'Y' &&
                    `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
                </div>
              )}

              <hr />
            </div>
          )}
          {!estimatePrintHeader && table2Data?.OrderType === 'E' && (
            <div style={{ textTransform: 'uppercase', textAlign: 'center' }}>
              Estimate{' '}
              {SalesModePref?.SettingValue == 'Y' &&
                `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`}
            </div>
          )}

          <div className="PrintStyle5-print-table">
            <div
              style={{
                display: 'flex',
                justifyContent: 'space-between',
                fontSize: '14px',
                fontWeight: '600',
              }}
            >
              {' '}
              <div> {GlobaldummyData ? formattedDate : Date1} </div>{' '}
              <div>
                {' '}
                Bill No :
                {GlobaldummyData
                  ? '553'
                  : table2Data?.OrderId &&
                    extractLastNumberOrderId(
                      table2Data?.OrderId,
                      table2Data?.FYStatus
                    )}{' '}
              </div>{' '}
            </div>

            <hr />
            {(TakeawayData?.length > 0 || GlobaldummyData) && (
              <>
                {takeAwayPreference && (
                  <div
                    style={{
                      display: 'flex',
                      width: '100%',
                      justifyContent: 'center',
                      alignItems: 'center',
                    }}
                  >
                    {' '}
                    TakeAway
                  </div>
                )}
                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'space-between',
                    fontWeight: '600',
                    fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                    width: '100%',
                    gap: '0.5rem',
                  }}
                >
                  {GlobaldummyData
                    ? GlobalSlNo && (
                        <div style={{ width: '100%', textAlign: 'center' }}>
                          S.No
                        </div>
                      )
                    : SLNO && (
                        <div style={{ width: '100%', textAlign: 'center' }}>
                          S.No
                        </div>
                      )}
                  {GlobaldummyData ? (
                    (GlobalItem || GlobalQuantity) && (
                      <div style={{ width: '300%', textAlign: 'center' }}>
                        {' '}
                        {GlobaldummyData
                          ? GlobalItem && 'ITEM /DES /'
                          : 'ITEM /DES /'}{' '}
                        {GlobaldummyData ? GlobalQuantity && 'QTY' : 'QTY'}{' '}
                      </div>
                    )
                  ) : (
                    <div style={{ width: '300%', textAlign: 'center' }}>
                      {' '}
                      {GlobaldummyData
                        ? GlobalItem && 'ITEM /DES /'
                        : Item && 'ITEM /DES /'}{' '}
                      {GlobaldummyData
                        ? GlobalQuantity && 'QTY'
                        : Quantity && WeightasKg ?'Qty/Kg' :'Qty'}{' '}
                    </div>
                  )}
                  {GlobaldummyData
                    ? GlobalHsnCode && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          HSN
                        </div>
                      )
                    : HsnCode && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          HSN
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalMRP && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          MRP
                        </div>
                      )
                    : MRP && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          MRP
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalRate && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          RATE
                        </div>
                      )
                    : Rate && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          RATE
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalDiscount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          DIS{' '}
                        </div>
                      )
                    : Discount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          DIS{' '}
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalTax && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          TAX %{' '}
                        </div>
                      )
                    : Tax &&
                      table2Data?.OrderType !== 'E' && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          TAX %{' '}
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalAmount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          {' '}
                          Amt{' '}
                        </div>
                      )
                    : Amount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          {' '}
                          AMT{' '}
                        </div>
                      )}
                </div>

                <hr className="hrline" />

                {(GlobaldummyData ? products : TakeawayData)?.map(
                  (item, index) => (
                    <div
                      key={index}
                      className="PrintStyle5-print-prddtls"
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                        fontWeight: '600',
                        width: '100%',
                        gap: '0.5rem',
                      }}
                    >
                      {GlobaldummyData
                        ? GlobalSlNo && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              {index + 1}
                            </div>
                          )
                        : SLNO && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              {index + 1}
                            </div>
                          )}
                      {GlobaldummyData ? (
                        (GlobalItem || GlobalQuantity) && (
                          <div style={{ textAlign: 'left', width: '300%' }}>
                            {GlobaldummyData ? (
                              GlobalItem && (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>{item?.Size + item?.UomName}</div>
                                </>
                              )
                            ) : (
                              <>
                                <div>{item?.ProdName}</div>
                                <div>
                                  {item?.Size +
                                    item?.UomName +
                                    '-' +
                                    (GlobaldummyData
                                      ? GlobalQuantity && item?.SalesQty
                                      : item?.SalesQty)}
                                </div>
                              </>
                            )}
                          </div>
                        )
                      ) : (
                        <div style={{ textAlign: 'left', width: '300%' }}>
                          {GlobaldummyData ? (
                            GlobalItem && (
                              <>
                                <div>{item?.ProdName}</div>
                                <div>{item?.Size + item?.UomName}</div>
                              </>
                            )
                          ) : (
                            <>
                              <div>{item?.ProdName}</div>
                              {PackageDetails?.filter(
                                (pkg) => pkg.ProdId === item.ProdId
                              ).length > 0 ? (
                                <div>
                                  {PackageDetails?.filter(
                                    (pkg) => pkg.ProdId === item.ProdId
                                  )?.map((item, index) => (
                                    <span
                                      key={index}
                                      style={{ display: 'block' }}
                                    >
                                      {item.ParcelCount} PCS {item.ParcelQty}{' '}
                                      PACK ({item.ParcelType})
                                    </span>
                                  ))}

                                  {(item?.BrandName || '') +
                                    (item?.ProductIdentifierDtls?.filter(
                                      (items) =>
                                        items.SerialNumber &&
                                        items.SerialNumber !== ''
                                    )?.map((a, index) => (
                                      <div key={`serial-${index}`}>
                                        {a.SerialNumber}
                                      </div>
                                    )) || '') +
                                    (item?.ProductIdentifierDtls?.filter(
                                      (item1) => item1.IMEI1 || item1.IMEI2
                                    )?.map((item2, index) => {
                                      const imei1 = item2.IMEI1 || '';
                                      const imei2 = item2.IMEI2 || '';
                                      return (
                                        <div key={`imei-${index}`}>
                                          {[imei1, imei2]
                                            .filter(Boolean)
                                            .join(',')}
                                        </div>
                                      );
                                    }) || '') +
                                    '-' +
                                    (GlobaldummyData
                                      ? GlobalQuantity && item?.SalesQty
                                      : item?.SalesQty)}
                                </div>
                              ) : (
                                <div>
                                  {(item?.Size || '1') +
                                    (item?.SinglePc === 'Y'
                                      ? 'PCS'
                                      : item?.Type !== 'C'
                                        ? item?.UomName
                                        : 'COMBO') +
                                    (item?.BrandName || '') +
                                    (item?.ProductIdentifierDtls?.filter(
                                      (items) =>
                                        items.SerialNumber &&
                                        items.SerialNumber !== ''
                                    )?.map((a, index) => (
                                      <div key={`serial-${index}`}>
                                        {a.SerialNumber}
                                      </div>
                                    )) || '') +
                                    (item?.ProductIdentifierDtls?.filter(
                                      (item1) => item1.IMEI1 || item1.IMEI2
                                    )?.map((item2, index) => {
                                      const imei1 = item2.IMEI1 || '';
                                      const imei2 = item2.IMEI2 || '';
                                      return (
                                        <div key={`imei-${index}`}>
                                          {[imei1, imei2]
                                            .filter(Boolean)
                                            .join(',')}
                                        </div>
                                      );
                                    }) || '') +
                                    '-' +
                                    (GlobaldummyData
                                      ? GlobalQuantity && item?.SalesQty
                                      : item?.SalesQty)}
                                </div>
                              )}
                            </>
                          )}
                        </div>
                      )}
                      {GlobaldummyData
                        ? GlobalHsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.HSN}
                            </div>
                          )
                        : HsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.HSN}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalMRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.MRP}
                            </div>
                          )
                        : MRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.SinglePc === 'Y' ? item?.Rate : item?.MRP}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalRate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Rate}
                            </div>
                          )
                        : Rate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Rate}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalDiscount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.discount}
                            </div>
                          )
                        : Discount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Type != 'C'
                                ? item?.OfferAmt || 0
                                : item?.OfferValue || 0}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalTax && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.ProdTaxPercentage}
                            </div>
                          )
                        : Tax &&
                          table2Data?.OrderType !== 'E' && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.ProdTaxPercentage || 0}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalAmount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.TotalAmt}
                            </div>
                          )
                        : Amount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              {item?.Type != 'C'
                                ? item?.TotalAmt - item?.OfferAmt || 0
                                : item?.TotalAmt - item?.OfferValue || 0}
                            </div>
                          )}
                    </div>
                  )
                )}
              </>
            )}
            {DineInData?.length > 0 && dinePreference && (
              <>
                <div
                  style={{
                    display: 'flex',
                    width: '100%',
                    justifyContent: 'center',
                    alignItems: 'center',
                  }}
                >
                  {' '}
                  DineIn
                </div>
                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'space-between',
                    fontWeight: '600',
                    fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                    width: '100%',
                    gap: '0.5rem',
                  }}
                >
                  {GlobaldummyData
                    ? GlobalSlNo && (
                        <div style={{ width: '100%', textAlign: 'center' }}>
                          S.No
                        </div>
                      )
                    : SLNO && (
                        <div style={{ width: '100%', textAlign: 'center' }}>
                          S.No
                        </div>
                      )}
                  {GlobaldummyData ? (
                    (GlobalItem || GlobalQuantity) && (
                      <div style={{ width: '300%', textAlign: 'center' }}>
                        {' '}
                        {GlobaldummyData
                          ? GlobalItem && 'ITEM /DES /'
                          : 'ITEM /DES /'}{' '}
                        {GlobaldummyData ? GlobalQuantity && 'QTY' : 'QTY'}{' '}
                      </div>
                    )
                  ) : (
                    <div style={{ width: '300%', textAlign: 'center' }}>
                      {' '}
                      {GlobaldummyData
                        ? GlobalItem && 'ITEM /DES /'
                        : Item && 'ITEM /DES /'}{' '}
                      {GlobaldummyData
                        ? GlobalQuantity && 'QTY'
                        : Quantity && WeightasKg ?'Qty/Kg' :'Qty'}{' '}
                    </div>
                  )}
                  {GlobaldummyData
                    ? GlobalHsnCode && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          HSN
                        </div>
                      )
                    : HsnCode && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          HSN
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalMRP && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          MRP
                        </div>
                      )
                    : MRP && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          MRP
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalRate && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          RATE
                        </div>
                      )
                    : Rate && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          RATE
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalDiscount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          DIS{' '}
                        </div>
                      )
                    : Discount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          DIS{' '}
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalTax && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          TAX %{' '}
                        </div>
                      )
                    : Tax &&
                      table2Data?.OrderType !== 'E' && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          TAX %{' '}
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalAmount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          {' '}
                          Amt{' '}
                        </div>
                      )
                    : Amount && (
                        <div style={{ width: '100%', textAlign: 'right' }}>
                          {' '}
                          AMT{' '}
                        </div>
                      )}
                </div>

                <hr className="hrline" />

                {(GlobaldummyData ? products : DineInData)?.map(
                  (item, index) => (
                    <div
                      key={index}
                      className="PrintStyle5-print-prddtls"
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        fontSize: 'clamp(1rem, 2.5vw, 1.2rem)',
                        fontWeight: '600',
                        width: '100%',
                        gap: '0.5rem',
                      }}
                    >
                      {GlobaldummyData
                        ? GlobalSlNo && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              {index + 1}
                            </div>
                          )
                        : SLNO && (
                            <div style={{ width: '100%', textAlign: 'center' }}>
                              {index + 1}
                            </div>
                          )}
                      {GlobaldummyData ? (
                        (GlobalItem || GlobalQuantity) && (
                          <div style={{ textAlign: 'left', width: '300%' }}>
                            {GlobaldummyData ? (
                              GlobalItem && (
                                <>
                                  <div>{item?.ProdName}</div>
                                  <div>{item?.Size + item?.UomName}</div>
                                </>
                              )
                            ) : (
                              <>
                                <div>{item?.ProdName}</div>
                                <div>
                                  {item?.Size +
                                    item?.UomName +
                                    '-' +
                                    (GlobaldummyData
                                      ? GlobalQuantity && item?.SalesQty
                                      : item?.SalesQty)}
                                </div>
                              </>
                            )}
                          </div>
                        )
                      ) : (
                        <div style={{ textAlign: 'left', width: '300%' }}>
                          {GlobaldummyData ? (
                            GlobalItem && (
                              <>
                                <div>{item?.ProdName}</div>
                                <div>{item?.Size + item?.UomName}</div>
                              </>
                            )
                          ) : (
                            <>
                              <div>{item?.ProdName}</div>
                              <div>
                                {(item?.Size ? item?.Size : '1') +
                                  (item?.SinglePc == 'Y'
                                    ? 'PCS'
                                    : item?.Type != 'C'
                                      ? item?.UomName
                                      : 'COMBO') +
                                  '-' +
                                  (GlobaldummyData
                                    ? GlobalQuantity && item?.SalesQty
                                    : item?.SalesQty)}
                              </div>
                            </>
                          )}
                        </div>
                      )}
                      {GlobaldummyData
                        ? GlobalHsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.HSN}
                            </div>
                          )
                        : HsnCode && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.HSN}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalMRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.MRP}
                            </div>
                          )
                        : MRP && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.SinglePc === 'Y' ? item?.Rate : item?.MRP}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalRate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Rate}
                            </div>
                          )
                        : Rate && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Rate}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalDiscount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.discount}
                            </div>
                          )
                        : Discount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.Type != 'C'
                                ? item?.OfferAmt || 0
                                : item?.OfferValue || 0}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalTax && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.ProdTaxPercentage}
                            </div>
                          )
                        : Tax &&
                          table2Data?.OrderType !== 'E' && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.ProdTaxPercentage || 0}
                            </div>
                          )}
                      {GlobaldummyData
                        ? GlobalAmount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {item?.TotalAmt}
                            </div>
                          )
                        : Amount && (
                            <div style={{ width: '100%', textAlign: 'right' }}>
                              {' '}
                              {item?.Type != 'C'
                                ? item?.TotalAmt - item?.OfferAmt || 0
                                : item?.TotalAmt - item?.OfferValue || 0}
                            </div>
                          )}
                    </div>
                  )
                )}
              </>
            )}
            {table2Data?.OrderType === 'E' ? (
              ''
            ) : (
              <div>
                {((OrderDetailGST?.length > 0 &&
                  OrderDetailGST?.[0]?.TaxAmt > 0) ||
                  (OrderDetailIGST?.length > 0 &&
                    OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                  (OrderDetailVAT?.length > 0 &&
                    OrderDetailVAT?.[0]?.TaxAmt > 0)) &&
                  table2Data?.NetAmount !== 0 && (
                    <>
                      <hr className="hrline" />

                      <div>
                        <div
                          style={{ margin: 0, padding: 0, textAlign: 'center' }}
                        >
                          --------- GST Breakup Details -----------
                        </div>
                        {OrderDetailGST?.length > 0 &&
                          OrderDetailGST?.[0]?.TaxAmt > 0 && (
                            <table style={{ width: '90%' }}>
                              <tr>
                                <td style={{ textAlign: 'right' }}></td>
                                <td style={{ textAlign: 'center' }}>
                                  Taxable Amount
                                </td>
                                <td style={{ textAlign: 'center' }}>CGST</td>
                                <td style={{ textAlign: 'center' }}>SGST</td>
                                <td style={{ textAlign: 'center' }}>
                                  Total Amount
                                </td>
                              </tr>
                              {OrderDetailGST?.map((item) => (
                                <tr>
                                  <td style={{ textAlign: 'right' }}>
                                    {item?.TaxPercentage || 0}%
                                  </td>
                                  <td style={{ textAlign: 'center' }}>
                                    {Number(item.WithOutTaxAmount).toFixed(2)}
                                  </td>
                                  <td style={{ textAlign: 'center' }}>
                                    {Number(item.CGST).toFixed(2)}
                                  </td>
                                  <td style={{ textAlign: 'center' }}>
                                    {Number(item.SGST).toFixed(2)}
                                  </td>
                                  <td style={{ textAlign: 'center' }}>
                                    {Number(item.TotalAmt).toFixed(2)}
                                  </td>
                                </tr>
                              ))}
                            </table>
                          )}

                        {OrderDetailIGST?.length > 0 &&
                          OrderDetailIGST?.[0]?.TaxAmt > 0 && (
                            <>
                              <div
                                style={{
                                  border: '0.01px dashed black',
                                  margin: '10px 0 5px 10px',
                                  width: '90%',
                                }}
                              ></div>
                              <table style={{ width: '90%' }}>
                                <tr>
                                  <td style={{ textAlign: 'right' }}></td>
                                  <td style={{ textAlign: 'center' }}>
                                    Taxable Amount
                                  </td>
                                  <td style={{ textAlign: 'center' }}>IGST</td>

                                  <td style={{ textAlign: 'center' }}>
                                    Total Amount
                                  </td>
                                </tr>
                                {OrderDetailIGST?.map((item) => (
                                  <tr>
                                    <td style={{ textAlign: 'right' }}>
                                      {item?.TaxPercentage || 0}%
                                    </td>
                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.WithOutTaxAmount).toFixed(2)}
                                    </td>
                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.TaxAmt).toFixed(2)}
                                    </td>

                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.TotalAmt).toFixed(2)}
                                    </td>
                                  </tr>
                                ))}
                              </table>
                            </>
                          )}
                        {OrderDetailVAT?.length > 0 &&
                          OrderDetailVAT?.[0]?.TaxAmt > 0 && (
                            <>
                              <div
                                style={{
                                  border: '0.01px dashed black',
                                  margin: '10px 0 5px 10px',
                                  width: '90%',
                                }}
                              ></div>
                              <table style={{ width: '90%' }}>
                                <tr>
                                  <td style={{ textAlign: 'right' }}></td>
                                  <td style={{ textAlign: 'center' }}>
                                    Taxable Amount
                                  </td>
                                  <td style={{ textAlign: 'center' }}>VAT</td>
                                  <td style={{ textAlign: 'center' }}>
                                    Total Amount
                                  </td>
                                </tr>
                                {OrderDetailVAT?.map((item) => (
                                  <tr>
                                    <td style={{ textAlign: 'right' }}>
                                      {item?.TaxPercentage || 0}%
                                    </td>
                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.WithOutTaxAmount).toFixed(2)}
                                    </td>
                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.TaxAmt).toFixed(2)}
                                    </td>

                                    <td style={{ textAlign: 'center' }}>
                                      {Number(item.TotalAmt).toFixed(2)}
                                    </td>
                                  </tr>
                                ))}
                              </table>
                            </>
                          )}
                      </div>
                      <hr className="hrline" />
                    </>
                  )}
              </div>
            )}

            <div>
              <div className="align-style">
                {' '}
                <div>Items : </div>{' '}
                <div>
                  {GlobaldummyData ? '8' : totalQuantityFilter?.length}
                </div>{' '}
              </div>
              <div className="align-style">
                {' '}
                <div>Qty : </div>{' '}
                <div>{GlobaldummyData ? '9' : totalQuantity}</div>{' '}
              </div>
              {/* {ExtraChargeTotal>0 &&<div className="align-style">  <div>Extra Charges  : </div>  <div> {ExtraChargeTotal}</div> </div>} */}
              {(table2Data?.OverallDisc > 0 || TotalOfferAmount > 0) && (
                <div className="align-style">
                  {' '}
                  <div>Off : </div>{' '}
                  <div>
                    {GlobaldummyData
                      ? '100'
                      : Number(
                          TotalOfferAmount + table2Data?.OverallDisc
                        ).toFixed(2)}
                  </div>{' '}
                </div>
              )}

              <hr className="hrline" />

              <div
                className="align-style"
                style={{ fontWeight: '600', fontSize: '19px' }}
              >
                {' '}
                <div>Amount </div> <div> : </div>{' '}
                <div>
                  {GlobaldummyData
                    ? '1,066'
                    : Number(table2Data?.NetAmount).toFixed(2)}
                </div>{' '}
              </div>

              <hr className="hrline" />
              {/* 
              <div className="align-style" style={{ fontWeight: '400', }}>  <div>You Pay  : </div>  <div>1066.00</div>  </div>
              <div className="align-style">  <div>Recived Amt  : </div>   <div>1066.00</div>  </div>
              <div className="align-style">  <div>Balance Amt  : </div>  <div>0.00</div>  </div> */}
            </div>

            <br />
            {/* <hr className="hrline" /> */}

            <div
              style={{
                display: 'flex',
                justifyContent: 'space-between',
                alignItems: 'center',
              }}
            >
              <div style={{ fontSize: '13px' }}>
                {DineInData?.length > 0 && TakeawayData?.length > 0 && (
                  <>
                    {takeAwayPreference && (
                      <div>
                        Takeaway:&nbsp;{Number(TakeawayTotal).toFixed(2)}
                      </div>
                    )}
                    {dinePreference && (
                      <div>Dine In:&nbsp;{Number(DineInTotal).toFixed(2)} </div>
                    )}
                  </>
                )}
                {/* <div style={{ display: 'flex', justifyContent: 'flex-start', }}>CARD : *********12</div>
                <div style={{ display: 'flex', justifyContent: 'flex-start', }}>CARD HOLDER : CARD HOLDER NAME</div> */}
                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'space-evenly',
                    marginTop: '5px',
                  }}
                >
                  <div
                    style={{
                      marginTop: '5px',
                      padding: 0,
                      fontSize: '17px',
                      fontWeight: '600',
                    }}
                  >
                    {PaymentStatusSuccess?.length === 1
                      ? PaymentStatusSuccess?.[0]?.PaymentTypeName
                      : 'Split'}{' '}
                    &nbsp;Payment : &nbsp;
                    {GlobaldummyData
                      ? '1,066'
                      : Number(table2Data?.NetAmount).toFixed(2)}
                    /-{' '}
                  </div>
                </div>
                {GlobaldummyData
                  ? GlobalCredit && (
                      <div
                        style={{
                          textAlign: 'center',
                          fontSize: '12px',
                          display: 'flex',
                          justifyContent: 'space-evenly',
                          justifyContent: 'space-evenly',
                          fontWeight: '600',
                          lineHeight: '14px',
                        }}
                      >
                        <h6>Advance Amount:</h6>
                        <h6>Opening Balance:</h6>
                      </div>
                    )
                  : CreditDetails &&
                    table2Data?.CustomerDetails?.length > 0 && (
                      <div
                        style={{
                          textAlign: 'center',
                          fontSize: '15px',
                          fontWeight: '600',
                          lineHeight: '14px',
                        }}
                      >
                        {/* OLD CREDIT BAL */}
                        {PaymentStatusSuccess?.[0]?.PaymentTypeName ===
                          'Credit' && (
                          <>
                            {table2Data.CustomerDetails[0].OldCreditBal > 0 ? (
                              <p>
                                Advance Amount:
                                {table2Data.CustomerDetails[0].OldCreditBal}
                              </p>
                            ) : table2Data.CustomerDetails[0].OldCreditBal <
                              0 ? (
                              <p>
                                {' '}
                                Opening Balance:{' '}
                                {Math.abs(
                                  table2Data.CustomerDetails[0].OldCreditBal
                                )}
                              </p>
                            ) : null}
                          </>
                        )}

                        {/* CURRENT CREDIT BAL */}
                        {table2Data.CustomerDetails[0].CurrentCreditBal > 0 ? (
                          <p>
                            {' '}
                            Current Advance Amount:{' '}
                            {table2Data.CustomerDetails[0].CurrentCreditBal}
                          </p>
                        ) : table2Data.CustomerDetails[0].CurrentCreditBal <
                          0 ? (
                          <p>
                            {' '}
                            Current Balance Amount:{' '}
                            {Math.abs(
                              table2Data.CustomerDetails[0].CurrentCreditBal
                            )}
                          </p>
                        ) : null}
                      </div>
                    )}
                <hr />
                {/* <div style={{ display: 'flex', justifyContent: 'flex-start', fontWeight: '600', fontSize: '16px', }} >TOTAL SAVING : 10.00</div> */}
              </div>

              {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                ''
              ) : (
                <div>
                  {GlobaldummyData
                    ? GlobalQrcodet && (
                        <div>
                          <div>
                            {' '}
                            <img
                              src={QrImg}
                              alt=""
                              style={{ width: '100px', height: '100px' }}
                            />{' '}
                          </div>
                          <div>Scan to Pay </div>
                          <div style={{ fontWeight: '600' }}>
                            {' '}
                            {GlobaldummyData
                              ? '1,066'
                              : Number(table2Data?.NetAmount).toFixed(2)}
                          </div>
                        </div>
                      )
                    : Qrcodet &&
                      paymentTypeUPI && (
                        <div
                          style={{
                            display: 'flex',
                            flexDirection: 'column',
                            justifyContent: 'center',
                            alignItems: 'center',
                          }}
                        >
                          <QRCode
                            value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                            size={80}
                          />
                          <div style={{}}>Scan to Pay </div>
                          <div style={{}}>
                            ₹
                            {GlobaldummyData
                              ? '1,066'
                              : Number(table2Data?.NetAmount).toFixed(2)}
                          </div>
                        </div>
                      )}
                </div>
              )}
            </div>
            <div>
              YOUR ORDER NO:{' '}
              {table2Data?.SalesId && extractLastNumber(table2Data?.SalesId)}
            </div>
            <div className="PrintStyle4-FourthP">
              {PaymentStatusSuccess?.length > 1 && (
                <>
                  {/* <p>Split Payment:</p> */}
                  {Object.keys(aggregatedPayments).map((paymentType) => (
                    <div
                      key={paymentType}
                      style={{ margin: 0, padding: 0, fontSize: '12px' }}
                    >
                      {paymentType}:{' '}
                      {aggregatedPayments[paymentType].toFixed(2)}
                    </div>
                  ))}
                </>
              )}
              {GlobaldummyData && GlobalCashierName && (
                <div className="PrintStyle4-FourthSmallwordings">
                  {' '}
                  Cashier : Cashier Name
                </div>
              )}
              {CashierName &&
                CashierName !== undefined &&
                CashierName !== null &&
                !GlobaldummyData &&
                CashierNameField && (
                  <div className="PrintStyle4-FourthSmallwordings">
                    Cashier : {CashierName}
                  </div>
                )}
              {GlobaldummyData && (
                <div className="PrintStyle4-FourthSmallwordings">
                  {' '}
                  Customer : Customer Name
                </div>
              )}
              {table2Data?.CustSuppName &&
                table2Data?.CustSuppName !== undefined &&
                table2Data?.CustSuppName !== null &&
                !GlobaldummyData && (
                  <div className="PrintStyle4-FourthSmallwordings">
                    Customer : {table2Data?.CustSuppName}
                  </div>
                )}

              {table2Data?.BookingTypeName == 'Dine In' &&
                table2Data?.SalesTableLinkDetails?.[0]?.WaiterName && (
                  <div className="PrintStyle4-FourthSmallwordings">
                    Captain :{' '}
                    {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                  </div>
                )}
              {sportsAppPreference && MembershipApplied && (
                <div
                  style={{
                    width: '100%',
                    textAlign: 'center',
                    paddingTop: '10px',
                  }}
                >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
              )}
              <div style={{ letterSpacing: '5px', fontSize: '14px' }}>
                ********************************************************************************************************************************
              </div>
            </div>

            <div>
              <div
                className="page-footerA4Style11"
                style={{
                  marginTop: 'auto',
                  pageBreakBefore: 'avoid',
                  pageBreakInside: 'avoid',
                  minHeight: 'auto',
                }}
              >
                {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                  ''
                ) : (
                  <div>
                    {GlobaldummyData
                      ? GlobalIsnotes && (
                          <div>
                            <p style={{ padding: '0rem 1rem' }}>
                              Notes : 10 days Return policy
                            </p>

                            <hr className="PrintA4Style11-print-dottline" />
                          </div>
                        )
                      : Notestext && (
                          <div>
                            <p style={{ padding: '0rem 1rem' }}>{Notestext}</p>

                            <hr className="PrintA4Style11-print-dottline" />
                          </div>
                        )}
                  </div>
                )}

                {!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
                  ''
                ) : (
                  <div
                    style={{
                      display: 'flex',
                      width: '90%',
                      padding: '0 1rem',
                      justifyContent: GlobaltermsAndConditions
                        ? 'space-between'
                        : 'flex-end',
                      alignItems: 'center',
                    }}
                  >
                    {GlobaldummyData
                      ? GlobaltermsAndConditions && (
                          <div
                            style={{
                              margin: '8px 0',
                              padding: '8px',
                              fontFamily: 'sans-serif',
                              width: '100%',
                            }}
                          >
                            <p
                              style={{
                                fontSize: '13px',
                                fontWeight: 'bold',
                                marginBottom: '6px',
                              }}
                            >
                              Terms & Conditions
                            </p>
                            <ol
                              style={{
                                fontSize: '12px',
                                paddingLeft: '18px',
                                margin: 0,
                                lineHeight: '1',
                                textAlign: 'left',
                              }}
                            >
                              <li>
                                Once goods are sold, they are not exchangeable
                                or refundable.
                              </li>
                              <li>
                                Please check the product before leaving the
                                counter.
                              </li>
                            </ol>
                          </div>
                        )
                      : TermsnAdCondition == true &&
                        TermsAndConditions?.length > 0 && (
                          <div
                            style={{
                              margin: '8px 0',
                              fontFamily: 'sans-serif',
                              width: '100%',
                              display: 'flex',
                              flexDirection: 'column',
                              alignItems: 'flex-start',
                            }}
                          >
                            <p
                              style={{
                                fontSize: '13px',
                                fontWeight: 'bold',
                                marginBottom: '6px',
                              }}
                            >
                              Terms & Conditions
                            </p>
                            <ol
                              style={{
                                fontSize: '12px',
                                paddingLeft: '18px',
                                margin: 0,
                                lineHeight: '1',
                              }}
                            >
                              {TermsAndConditions?.map((item) => (
                                <li style={{ textAlign: 'start' }}>
                                  {item?.TermsandConditions}
                                </li>
                              ))}
                            </ol>
                          </div>
                        )}

                    {GlobaldummyData
                      ? GlobalSignature && (
                          <div
                            style={{
                              display: 'flex',
                              flexDirection: 'column',
                              alignItems: 'flex-end',
                              paddingBottom: '1rem',
                            }}
                          >
                            <p
                              style={{
                                fontSize: '13px',
                                fontWeight: 'bold',
                                marginBottom: '6px',
                              }}
                            >
                              Signature
                            </p>
                            <img
                              style={{ width: '70px', height: '40px' }}
                              src={
                                GlobalSignatureImages
                                  ? GlobalSignatureImages
                                  : signature
                              }
                              alt=""
                            />
                          </div>
                        )
                      : Signature == true && (
                          <div
                            style={{
                              display: 'flex',
                              flexDirection: 'column',
                              alignItems: 'center',
                              marginTop: '1rem',
                              paddingBottom: '1rem',
                            }}
                          >
                            <p
                              style={{
                                fontSize: '13px',
                                fontWeight: 'bold',
                                marginBottom: '6px',
                              }}
                            >
                              Signature
                            </p>
                            <img
                              style={{ width: '100px', height: '60px' }}
                              src={SignatureImg}
                              alt=""
                            />
                          </div>
                        )}
                  </div>
                )}
              </div>

              {PrintGreeting?.SettingValue === 'Y' && (
                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'center',
                    fontWeight: '600',
                    textTransform: 'uppercase',
                  }}
                >
                  Thank You Visit Again
                </div>
              )}
            </div>
          </div>
        </div>
      )}
    </>
  );
};

export default PrintStyle5;
