import React from 'react';
import { useSelector } from 'react-redux';
import signature from '../../../Images/signatureimage.jpg';
import {
  GlobalprintSlNo,
  GlobalprintItem,
  GlobalprintMRP,
  GlobalprintDiscount,
  GlobalprintQuantity,
  GlobalprintRate,
  GlobalprintAmount,
  GlobalprintHsnCode,
  GlobalprintQrcodet,
  GlobalPritdummyData,
  changeReprintDataFound,
  GloabalFieldDetails,
  GlobalprintSignature,
  GlobalprinttermsAndConditions,
  GlobalSignatureImage,
  Globalnotes,
  GlobalthemeFormat,
  GlobalBillName,
  GlobalSelectedPrintHeaderColor,
  GlobalSelectedPrintHeaderFontColor,
  GlobalSelectedTableHeaderColor,
  GlobalSelectedTableHeaderFontColor,
  GlobalSelectedTableBodyColor,
  GlobalSelectedTableBodyFontColor,
  GlobalRowType,
  GlobalSelectedFooterColor,
  GlobalSelectedFooterFontColor,
} from '../../../Features/ThemeChange/ThemeChange';
import { useDispatch } from 'react-redux';
import {
  extractLastNumber,
  extractLastNumberOrderId,
} from '../../../Services/Others';
import { isMobile } from 'react-device-detect';

const PurchaseOrdStyle3 = ({
  index,
  totalQuantityFilter,
  Date1,
  totalQuantity,
  OrderDetailGST,
  OrderDetailIGST,
  OrderDetailVAT,
  table2Data,
  PaymentStatus,
  PrintLogo,
  PrintGreeting,
  printDatas,
}) => {
  const dispatch = useDispatch();
  // const FieldDetails = useSelector(GloabalFieldDetails);
  const FieldDetails = printDatas?.FieldDetails?.reduce((acc, item) => {
    acc[item.ConfigName] = true;
    return acc;
  }, {});

  console.log(table2Data, 'table2Data?.BrMobile');

  const SLNO = FieldDetails?.['Sl.No'];
  const Item = FieldDetails?.['Item'];
  const MRP = FieldDetails?.['MRP'];
  const Discount = FieldDetails?.['Discount'];
  const Quantity = FieldDetails?.['Quantity'];
  const Rate = FieldDetails?.['Rate'];
  const Amount = FieldDetails?.['Amount'];
  const HsnCode = FieldDetails?.['HsnCode'];
  const Qrcodet = FieldDetails?.['Qrcode'];
  const GlobalSlNo = useSelector(GlobalprintSlNo);
  const GlobalItem = useSelector(GlobalprintItem);
  const GlobalMRP = useSelector(GlobalprintMRP);
  const GlobalDiscount = useSelector(GlobalprintDiscount);
  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);

  console.log(printDatas, 'GlobalthemeFormatr');

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

  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 purchaseData = table2Data?.productDetails || [];
  // Calculate SalesWiseOffers total amount

  const products = [
    {
      ProdName: 'ITEM 1',
      Rate: 88.0,
      SalesQty: 2,
      MRP: 100,
      TotalAmt: 176,
      discount: 0,
      HSN: '01',
    },
    {
      ProdName: 'ITEM 2',
      Rate: 300.0,
      SalesQty: 1,
      MRP: 350,
      TotalAmt: 300,
      discount: 0,
      HSN: '02',
    },
    {
      ProdName: 'ITEM 3',
      Rate: 200.0,
      SalesQty: 1,
      MRP: 250,
      TotalAmt: 200,
      discount: 0,
      HSN: '03',
    },
    {
      ProdName: 'ITEM 4',
      Rate: 30.0,
      SalesQty: 1,
      MRP: 50,
      TotalAmt: 30,
      discount: 0,
      HSN: '04',
    },
    {
      ProdName: 'ITEM 5',
      Rate: 30.0,
      SalesQty: 1,
      MRP: 50,
      TotalAmt: 30,
      discount: 0,
      HSN: '05',
    },
    {
      ProdName: 'ITEM 6',
      Rate: 130.0,
      SalesQty: 1,
      MRP: 150,
      TotalAmt: 130,
      discount: 0,
      HSN: '06',
    },
    {
      ProdName: 'ITEM 7',
      Rate: 230.0,
      SalesQty: 1,
      MRP: 250,
      TotalAmt: 230,
      discount: 0,
      HSN: '08',
    },
  ];

  const chunkSize = isMobile ? 16 : PageSize == 'A5' ? 11 : 16;

  let dataSource = [];

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

  // 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 > (isMobile ? 11 : PageSize == 'A5' ? 5 : 10);

  //
  const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor);
  const SelectedHeaderFontColor = useSelector(
    GlobalSelectedPrintHeaderFontColor
  );
  const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor);
  const SelectedTableHeaderFontColor = useSelector(
    GlobalSelectedTableHeaderFontColor
  );
  const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor);
  const SelectedTableBodyFontColor = useSelector(
    GlobalSelectedTableBodyFontColor
  );
  const SelectedRowType = useSelector(GlobalRowType);
  const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor);
  const SelectedTableFooterFontColor = useSelector(
    GlobalSelectedFooterFontColor
  );

  //
  let printColors = printDatas?.PrintColors;
  const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor;
  const tableHeaderColor = printColors?.find(
    (obj) => obj.tableHeaderColor
  )?.tableHeaderColor;
  const tableBodyColor = printColors?.find(
    (obj) => obj.tableBodyColor
  )?.tableBodyColor;
  const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor;

  //
  const headerStyle = {
    backgroundColor: GlobaldummyData
      ? SelectedHeaderColor
      : headerColor?.background,

    color: GlobaldummyData ? SelectedHeaderFontColor : headerColor?.font,
  };
  const tableHeaderStyle = {
    backgroundColor: GlobaldummyData
      ? SelectedTableHeaderColor
      : tableHeaderColor?.background,

    color: GlobaldummyData
      ? SelectedTableHeaderFontColor
      : tableHeaderColor?.font,
  };

  const tableBodyStyle = {
    backgroundColor: GlobaldummyData
      ? SelectedTableBodyColor
      : tableBodyColor?.background,
    color: GlobaldummyData ? SelectedTableBodyFontColor : tableBodyColor?.font,
  };

  const rowtypeStyle = GlobaldummyData
    ? SelectedRowType
    : tableBodyColor?.rowType;

  const footerColorStyle = {
    backgroundColor: GlobaldummyData
      ? SelectedTableFooterColor
      : footerColor?.background,
    color: GlobaldummyData ? SelectedTableFooterFontColor : footerColor?.font,
  };

  return (
    <>
      {FormatTheme ? (
        <div
          className="PrintStyle3MasterDiv"
          id={`PrintStyle3`}
          style={{
            fontFamily: "'Courier New', Courier, monospace",
            position: 'relative',
            width: '100%',
            minHeight: isMobile
              ? PageSize === 'A5'
                ? '210mm'
                : '297mm'
              : 'auto',
          }}
        >
          {paginatedChunks.map((dataChunk, chunkIndex) => (
            //  <div className={`container print-chunk${chunkIndex > 0 ? ' print-page-break' : ''}`} style={{ display: "flex", flexDirection: "column", justifyContent: ((chunkIndex === paginatedChunks.length - 1) && (!shouldFooterBeOnNewPage)) && FormatTheme ? "space-between" : "", height: FormatTheme ? PageSize == "A5" ? '170mm' : "257mm" : "", }} key={chunkIndex}>
            <div
              className={
                isMobile
                  ? `invoice-wrapper 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: FormatTheme
                  ? PageSize == 'A5'
                    ? '170mm'
                    : isMobile
                      ? '295mm'
                      : '257mm'
                  : '',
              }}
              key={chunkIndex}
            >
              {/* <div className="header" style={{ position: GlobaldummyData ? "absolute" : "fixed", top: 0, width: "100%" }}> */}
              <div
                className="header"
                style={{
                  position: isMobile
                    ? GlobaldummyData
                      ? 'absolute'
                      : 'fixed'
                    : '',
                  top: 0,
                  width: '100%',
                }}
              >
                <div className="PrintStyle3-print" style={{ ...headerStyle }}>
                  <div style={{ fontSize: '30px', fontweight: '900' }}>
                    {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
                  </div>
                  <div style={{ fontweight: '600' }}>
                    {' '}
                    {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
                          : '')}
                    {table2Data?.BrGSTIN && (
                      <div>
                        GST NO :
                        {GlobaldummyData
                          ? '334bhbsagbysfgbfgbu'
                          : table2Data?.BrGSTIN}
                        , CIN :u00045hhsgbubufsdug
                      </div>
                    )}
                    <div style={{ fontWeight: '600' }}>
                      {' '}
                      Mobile : +91{' '}
                      {GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile}
                    </div>
                  </div>
                </div>
                <hr className="PrintStyle3-print-dottline" />
                <div className="PrintStyle3-print-ordr-dtls">
                  <div style={{ lineheight: '50px' }}>
                    <div style={{ fontSize: '14px', fontWeight: 600 }}>
                      {' '}
                      BILL NO :
                      {GlobaldummyData
                        ? '51'
                        : table2Data?.OrderId &&
                          extractLastNumberOrderId(
                            table2Data?.OrderId,
                            table2Data?.FYStatus
                          )}{' '}
                    </div>
                    <div style={{ fontSize: '14px', fontWeight: 600 }}>
                      {' '}
                      {GlobaldummyData ? formattedDate : Date1}
                    </div>
                  </div>
                </div>
                <hr className="PrintStyle3-print-dottline" />
              </div>

              <div
                className="print-body"
                style={{ marginTop: GlobaldummyData ? '9rem' : '0rem' }}
              >
                <div className="PrintStyle3-print-tableMaster">
                  {(purchaseData?.length > 0 || GlobaldummyData) && (
                    <div
                      style={{ width: '95%' }}
                      className="PrintStyle3-print-table"
                    >
                      <div
                        style={{
                          display: 'flex',
                          justifyContent: 'space-between',
                          width: '100%',
                          fontweight: '600',
                          gap: '0.2rem',
                          ...tableHeaderStyle,
                        }}
                      >
                        {GlobaldummyData
                          ? GlobalSlNo && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'center',
                                  fontWeight: 600,
                                }}
                              >
                                S.No
                              </div>
                            )
                          : SLNO && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'center',
                                  fontWeight: 600,
                                }}
                              >
                                S.No
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalItem && (
                              <div
                                style={{
                                  width: '200%',
                                  textAlign: 'left',
                                  fontWeight: 600,
                                }}
                              >
                                ITEM
                              </div>
                            )
                          : Item && (
                              <div
                                style={{
                                  width: '300%',
                                  textAlign: 'left',
                                  fontWeight: 600,
                                }}
                              >
                                ITEM
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalHsnCode && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                HSN
                              </div>
                            )
                          : HsnCode && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                HSN
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalMRP && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                MRP
                              </div>
                            )
                          : MRP && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                MRP
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalQuantity && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                QTY
                              </div>
                            )
                          : Quantity && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                QTY
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalRate && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                RATE
                              </div>
                            )
                          : Rate && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                RATE
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalDiscount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                DIS{' '}
                              </div>
                            )
                          : Discount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                DIS{' '}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalAmount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                AMT
                              </div>
                            )
                          : Amount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                AMT
                              </div>
                            )}
                      </div>

                      <div style={{ marginTop: '5px' }}>
                        {dataChunk?.map((item, index) => (
                          <div
                            style={{
                              display: 'flex',
                              justifyContent: 'space-between',
                              width: '100%',
                              gap: '0.2rem',
                              ...(index % 2 !== 1 && rowtypeStyle === 'even'
                                ? {
                                    ...tableBodyStyle,
                                  }
                                : index % 2 === 1 && rowtypeStyle === 'odd'
                                  ? {
                                      ...tableBodyStyle,
                                    }
                                  : {}),
                            }}
                          >
                            {GlobaldummyData
                              ? GlobalSlNo && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'center',
                                    }}
                                  >
                                    {index + 1}
                                  </div>
                                )
                              : SLNO && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'center',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {chunkIndex * chunkSize + index + 1}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalItem && (
                                  <div
                                    style={{ width: '300%', textAlign: 'left' }}
                                  >
                                    {item?.ProdName}
                                  </div>
                                )
                              : Item && (
                                  <div
                                    style={{
                                      display: 'flex',
                                      flexDirection: 'column',
                                      width: '300%',
                                      textAlign: 'left',
                                      fontWeight: 600,
                                    }}
                                  >
                                    <div>{item?.ProdName}</div>
                                    <div>
                                      ({item?.Size ? item?.Size : '1'}{' '}
                                      {item?.SinglePc == 'Y'
                                        ? 'PCS'
                                        : item?.Type != 'C'
                                          ? item?.UomName
                                          : 'COMBO'}
                                      ) &nbsp;{' '}
                                      {item?.BrandName !== null
                                        ? item?.BrandName
                                        : ''}
                                      &nbsp;
                                      {item?.ProductIdentifierDtls?.length > 0
                                        ? item?.ProductIdentifierDtls?.filter(
                                            (items) =>
                                              !(
                                                items.SerialNumber == '' ||
                                                items.SerialNumber == null
                                              )
                                          )?.map((a) => {
                                            return <div>{a.SerialNumber}</div>;
                                          })
                                        : ''}{' '}
                                      {item?.ProductIdentifierDtls?.length > 0
                                        ? item?.ProductIdentifierDtls.filter(
                                            (item1) =>
                                              item1.IMEI1 !== '' ||
                                              item1.IMEI2 !== ''
                                          )?.map((item2) => {
                                            const imei1 = item2.IMEI1 || '';
                                            const imei2 = item2.IMEI2 || '';
                                            return (
                                              <div>
                                                {[imei1, imei2]
                                                  .filter(Boolean)
                                                  .join(',')}
                                              </div>
                                            );
                                          })
                                        : ''}
                                    </div>
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalHsnCode && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                    }}
                                  >
                                    {item?.HSN}
                                  </div>
                                )
                              : HsnCode && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {item?.HSN}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalMRP && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                    }}
                                  >
                                    {item?.MRP}
                                  </div>
                                )
                              : MRP && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {item?.SinglePc === 'Y'
                                      ? item?.Rate
                                      : item?.MRP}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalQuantity && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'center',
                                    }}
                                  >
                                    {item?.SalesQty}
                                  </div>
                                )
                              : Quantity && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {item?.SalesQty}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalRate && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                    }}
                                  >
                                    {item?.Rate}
                                  </div>
                                )
                              : Rate && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {item?.Rate}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalDiscount && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                    }}
                                  >
                                    {item?.discount}
                                  </div>
                                )
                              : Discount && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {item?.Type != 'C'
                                      ? item?.OfferAmt || 0
                                      : item?.OfferValue || 0}
                                  </div>
                                )}
                            {GlobaldummyData
                              ? GlobalAmount && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                    }}
                                  >
                                    {item?.TotalAmt}
                                  </div>
                                )
                              : Amount && (
                                  <div
                                    style={{
                                      width: '100%',
                                      textAlign: 'right',
                                      fontWeight: 600,
                                    }}
                                  >
                                    {' '}
                                    {item?.Type != 'C'
                                      ? item?.TotalAmt - item?.OfferAmt || 0
                                      : item?.TotalAmt - item?.OfferValue || 0}
                                  </div>
                                )}
                          </div>
                        ))}
                      </div>
                    </div>
                  )}
                </div>
              </div>

              {chunkIndex === paginatedChunks.length - 1 &&
                !shouldFooterBeOnNewPage &&
                FormatTheme && (
                  <>
                    <div className="PrintStyle3-print-ttlovrl"></div>

                    <div className="PrintStyle3-print-ttlovrl">
                      {((OrderDetailGST?.length > 0 &&
                        OrderDetailGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailIGST?.length > 0 &&
                          OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailVAT?.length > 0 &&
                          OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
                        <>
                          <div>
                            <div
                              style={{
                                margin: 0,
                                padding: 0,
                                fontSize: '12px',
                                textAlign: 'center',
                              }}
                            >
                              --------- GST Breakup Details -----------
                            </div>
                            {OrderDetailGST?.length > 0 &&
                              OrderDetailGST?.[0]?.TaxAmt > 0 && (
                                <table style={{ width: '90%' }}>
                                  <tr>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      Taxable Amount
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      CGST (
                                      {OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      SGST (
                                      {OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      Total Amount
                                    </td>
                                  </tr>
                                  {OrderDetailGST?.map((item) => (
                                    <tr>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.WithOutTaxAmount).toFixed(
                                          2
                                        )}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.CGST).toFixed(2)}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.SGST).toFixed(2)}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          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={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Taxable Amount
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        IGST (
                                        {OrderDetailIGST?.[0]?.TaxPercentage}%)
                                      </td>

                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Total Amount
                                      </td>
                                    </tr>
                                    {OrderDetailIGST?.map((item) => (
                                      <tr>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(
                                            item.WithOutTaxAmount
                                          ).toFixed(2)}
                                        </td>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TaxAmt).toFixed(2)}
                                        </td>

                                        <td
                                          style={{
                                            fontSize: '10px',
                                            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={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Taxable Amount
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        VAT (
                                        {OrderDetailVAT?.[0]?.TaxPercentage}%)
                                      </td>

                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Total Amount
                                      </td>
                                    </tr>
                                    {OrderDetailVAT?.map((item) => (
                                      <tr>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(
                                            item.WithOutTaxAmount
                                          ).toFixed(2)}
                                        </td>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TaxAmt).toFixed(2)}
                                        </td>

                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TotalAmt).toFixed(2)}
                                        </td>
                                      </tr>
                                    ))}
                                  </table>
                                </>
                              )}
                          </div>
                        </>
                      )}
                    </div>
                    {/* <hr className="PrintStyle3-print-dottline" /> */}

                    {/* <br/> */}

                    <div
                      className="PrintStyle3-print-stradrs"
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                      }}
                    >
                      <div
                        style={{
                          display: 'flex',
                          flexDirection: 'column',
                          justifyContent: 'center',
                          width: '100%',
                        }}
                      >
                        <div style={{ fontSize: '14px', fontWeight: 600 }}>
                          Your Order No :
                          {GlobaldummyData
                            ? '01'
                            : table2Data?.SalesId &&
                              extractLastNumber(table2Data?.SalesId)}
                        </div>

                        {GlobaldummyData && (
                          <div style={{ fontSize: '14px', fontWeight: 600 }}>
                            {' '}
                            Customer : Customer Name
                          </div>
                        )}
                        {table2Data?.CustSuppName &&
                          table2Data?.CustSuppName !== undefined &&
                          table2Data?.CustSuppName !== null &&
                          !GlobaldummyData && (
                            <div style={{ fontSize: '14px', fontWeight: 600 }}>
                              Customer : {table2Data?.CustSuppName}
                            </div>
                          )}
                      </div>
                    </div>
                    {/* <br/> */}

                    {/* <hr className="PrintStyle3-print-dottline" /> */}

                    <div
                      className="page-footerA4Style11"
                      style={{
                        marginTop: 'auto',
                        pageBreakBefore: 'avoid',
                        pageBreakInside: 'avoid',
                        minHeight: 'auto',
                      }}
                    >
                      {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
                        style={{
                          display: 'flex',
                          width: '90%',
                          padding: '0 1rem',
                          justifyContent: GlobaltermsAndConditions
                            ? 'space-between'
                            : 'flex-end',
                          alignItems: 'center',
                          ...footerColorStyle,
                        }}
                      >
                        {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',
                                  }}
                                >
                                  <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' && (
                      <>
                        {/* <br/> */}

                        <div
                          className="PrintStyle3-print-ftr"
                          style={{ fontWeight: 600 }}
                        >
                          Thank You{' '}
                        </div>
                      </>
                    )}
                  </>
                )}
            </div>
          ))}

          {shouldFooterBeOnNewPage && FormatTheme && (
            <div
              className="print-page"
              style={{
                display: 'flex',
                flexDirection: 'column',
                minHeight: PageSize == 'A5' ? '200mm' : '260mm',
                justifyContent: 'flex-end',
                pageBreakBefore: 'always',
                position: !isMobile && 'relative',
              }}
            >
              <div
                className="page-footerA4Style11"
                style={{
                  marginTop: 'auto',
                  pageBreakBefore: 'avoid',
                  pageBreakInside: 'avoid',
                  minHeight: 'auto',
                }}
              >
                <div
                  style={{
                    position: isMobile && 'absolute',
                    bottom: '10',
                    width: '100%',
                    left: '0',
                  }}
                >
                  <>
                    <div className="PrintStyle3-print-ttlovrl">
                      {((OrderDetailGST?.length > 0 &&
                        OrderDetailGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailIGST?.length > 0 &&
                          OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailVAT?.length > 0 &&
                          OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
                        <>
                          <div>
                            <div
                              style={{
                                margin: 0,
                                padding: 0,
                                fontSize: '12px',
                                textAlign: 'center',
                              }}
                            >
                              --------- GST Breakup Details -----------
                            </div>
                            {OrderDetailGST?.length > 0 &&
                              OrderDetailGST?.[0]?.TaxAmt > 0 && (
                                <table style={{ width: '90%' }}>
                                  <tr>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      Taxable Amount
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      CGST (
                                      {OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      SGST (
                                      {OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                                    </td>
                                    <td
                                      style={{
                                        fontSize: '10px',
                                        textAlign: 'center',
                                      }}
                                    >
                                      Total Amount
                                    </td>
                                  </tr>
                                  {OrderDetailGST?.map((item) => (
                                    <tr>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.WithOutTaxAmount).toFixed(
                                          2
                                        )}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.CGST).toFixed(2)}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        {Number(item.SGST).toFixed(2)}
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          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={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Taxable Amount
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        IGST (
                                        {OrderDetailIGST?.[0]?.TaxPercentage}%)
                                      </td>

                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Total Amount
                                      </td>
                                    </tr>
                                    {OrderDetailIGST?.map((item) => (
                                      <tr>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(
                                            item.WithOutTaxAmount
                                          ).toFixed(2)}
                                        </td>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TaxAmt).toFixed(2)}
                                        </td>

                                        <td
                                          style={{
                                            fontSize: '10px',
                                            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={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Taxable Amount
                                      </td>
                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        VAT (
                                        {OrderDetailVAT?.[0]?.TaxPercentage}%)
                                      </td>

                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                        }}
                                      >
                                        Total Amount
                                      </td>
                                    </tr>
                                    {OrderDetailVAT?.map((item) => (
                                      <tr>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(
                                            item.WithOutTaxAmount
                                          ).toFixed(2)}
                                        </td>
                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TaxAmt).toFixed(2)}
                                        </td>

                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                          }}
                                        >
                                          {Number(item.TotalAmt).toFixed(2)}
                                        </td>
                                      </tr>
                                    ))}
                                  </table>
                                </>
                              )}
                          </div>
                        </>
                      )}
                    </div>
                    <hr className="PrintStyle3-print-dottline" />

                    {/* <br/> */}

                    <div
                      className="PrintStyle3-print-stradrs"
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                      }}
                    >
                      <div
                        style={{
                          display: 'flex',
                          flexDirection: 'column',
                          justifyContent: 'center',
                          width: '100%',
                        }}
                      >
                        <div style={{ fontSize: '14px', fontWeight: 600 }}>
                          Your Order No :
                          {GlobaldummyData
                            ? '01'
                            : table2Data?.SalesId &&
                              extractLastNumber(table2Data?.SalesId)}
                        </div>

                        {GlobaldummyData && (
                          <div style={{ fontSize: '14px', fontWeight: 600 }}>
                            {' '}
                            Customer : Customer Name
                          </div>
                        )}
                        {table2Data?.CustSuppName &&
                          table2Data?.CustSuppName !== undefined &&
                          table2Data?.CustSuppName !== null &&
                          !GlobaldummyData && (
                            <div style={{ fontSize: '14px', fontWeight: 600 }}>
                              Customer : {table2Data?.CustSuppName}
                            </div>
                          )}
                      </div>
                    </div>
                    {/* <br/> */}

                    <hr className="PrintStyle3-print-dottline" />

                    <div
                      className="page-footerA4Style11"
                      style={{
                        marginTop: 'auto',
                        pageBreakBefore: 'avoid',
                        pageBreakInside: 'avoid',
                        minHeight: 'auto',
                      }}
                    >
                      {GlobaldummyData
                        ? GlobalIsnotes && (
                            <div>
                              <p
                                style={{
                                  padding: '0rem 1rem',
                                  marginTop: GlobalthemeFormatr ? '3vh' : '',
                                }}
                              >
                                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
                        style={{
                          display: 'flex',
                          width: '90%',
                          padding: '0 1rem',
                          justifyContent: GlobaltermsAndConditions
                            ? 'space-between'
                            : 'flex-end',
                          alignItems: 'center',
                          ...footerColorStyle,
                        }}
                      >
                        {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',
                                  }}
                                >
                                  <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' && (
                      <>
                        {/* <br/> */}

                        <div
                          className="PrintStyle3-print-ftr"
                          style={{ fontWeight: 600 }}
                        >
                          Thank You{' '}
                        </div>
                      </>
                    )}
                  </>
                </div>
              </div>
            </div>
          )}
        </div>
      ) : (
        <div
          className="PrintStyle3MasterDiv"
          id={`PrintStyle3`}
          style={{ fontFamily: "'Courier New', Courier, monospace" }}
        >
          <div className="PrintStyle3-print" style={{ ...headerStyle }}>
            <div style={{ fontSize: '30px', fontweight: '900' }}>
              {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
            </div>
            <div style={{ fontweight: '600' }}>
              {' '}
              {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
                    : '')}
              {table2Data?.BrGSTIN && (
                <div>
                  GST NO :
                  {GlobaldummyData
                    ? '334bhbsagbysfgbfgbu'
                    : table2Data?.BrGSTIN}
                  , CIN :u00045hhsgbubufsdug
                </div>
              )}
              <div style={{ fontWeight: '600' }}>
                {' '}
                Mobile : +91{' '}
                {GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile}
              </div>
            </div>
          </div>
          <hr className="PrintStyle3-print-dottline" />
          <div className="PrintStyle3-print-ordr-dtls">
            <div style={{ lineheight: '50px' }}>
              <div style={{ fontSize: '14px', fontWeight: 600 }}>
                {' '}
                BILL NO :
                {GlobaldummyData
                  ? '51'
                  : table2Data?.OrderId &&
                    extractLastNumberOrderId(
                      table2Data?.OrderId,
                      table2Data?.FYStatus
                    )}{' '}
              </div>
              <div style={{ fontSize: '14px', fontWeight: 600 }}>
                {' '}
                {GlobaldummyData ? formattedDate : Date1}
              </div>
            </div>
          </div>
          <hr className="PrintStyle3-print-dottline" />
          <div className="PrintStyle3-print-tableMaster">
            {(purchaseData?.length > 0 || GlobaldummyData) && (
              <div style={{ width: '95%' }} className="PrintStyle3-print-table">
                <div
                  style={{
                    display: 'flex',
                    justifyContent: 'space-between',
                    width: '100%',
                    fontweight: '600',
                    gap: '0.2rem',
                    ...tableHeaderStyle,
                  }}
                >
                  {GlobaldummyData
                    ? GlobalSlNo && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'center',
                            fontWeight: 600,
                          }}
                        >
                          S.No
                        </div>
                      )
                    : SLNO && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'center',
                            fontWeight: 600,
                          }}
                        >
                          S.No
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalItem && (
                        <div
                          style={{
                            width: '200%',
                            textAlign: 'left',
                            fontWeight: 600,
                          }}
                        >
                          ITEM
                        </div>
                      )
                    : Item && (
                        <div
                          style={{
                            width: '300%',
                            textAlign: 'left',
                            fontWeight: 600,
                          }}
                        >
                          ITEM
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalHsnCode && (
                        <div
                          style={{
                            width: '150%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          HSN
                        </div>
                      )
                    : HsnCode && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          HSN
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalMRP && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          MRP
                        </div>
                      )
                    : MRP && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          MRP
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalQuantity && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          QTY
                        </div>
                      )
                    : Quantity && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          QTY
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalRate && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          RATE
                        </div>
                      )
                    : Rate && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          RATE
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalDiscount && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          DIS{' '}
                        </div>
                      )
                    : Discount && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          DIS{' '}
                        </div>
                      )}
                  {GlobaldummyData
                    ? GlobalAmount && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          AMT
                        </div>
                      )
                    : Amount && (
                        <div
                          style={{
                            width: '100%',
                            textAlign: 'right',
                            fontWeight: 600,
                          }}
                        >
                          AMT
                        </div>
                      )}
                </div>

                <div style={{ marginTop: '5px' }}>
                  {(GlobaldummyData ? products : purchaseData)?.map(
                    (item, index) => (
                      <div
                        style={{
                          display: 'flex',
                          justifyContent: 'space-between',
                          width: '100%',
                          gap: '0.2rem',
                          ...(index % 2 !== 1 && rowtypeStyle === 'even'
                            ? {
                                ...tableBodyStyle,
                              }
                            : index % 2 === 1 && rowtypeStyle === 'odd'
                              ? {
                                  ...tableBodyStyle,
                                }
                              : {}),
                        }}
                      >
                        {GlobaldummyData
                          ? GlobalSlNo && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {index + 1}
                              </div>
                            )
                          : SLNO && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'center',
                                  fontWeight: 600,
                                }}
                              >
                                {index + 1}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalItem && (
                              <div style={{ width: '300%', textAlign: 'left' }}>
                                {item?.ProdName}
                              </div>
                            )
                          : Item && (
                              <div
                                style={{
                                  display: 'flex',
                                  flexDirection: 'column',
                                  width: '300%',
                                  textAlign: 'left',
                                  fontWeight: 600,
                                }}
                              >
                                <div>{item?.ProdName}</div>
                                <div>
                                  ({item?.Size ? item?.Size : '1'}{' '}
                                  {item?.SinglePc == 'Y'
                                    ? 'PCS'
                                    : item?.Type != 'C'
                                      ? item?.UomName
                                      : 'COMBO'}
                                  ) &nbsp;{' '}
                                  {item?.BrandName !== null
                                    ? item?.BrandName
                                    : ''}
                                  &nbsp;
                                  {item?.ProductIdentifierDtls?.length > 0
                                    ? item?.ProductIdentifierDtls?.filter(
                                        (items) =>
                                          !(
                                            items.SerialNumber == '' ||
                                            items.SerialNumber == null
                                          )
                                      )?.map((a) => {
                                        return <div>{a.SerialNumber}</div>;
                                      })
                                    : ''}{' '}
                                  {item?.ProductIdentifierDtls?.length > 0
                                    ? item?.ProductIdentifierDtls.filter(
                                        (item1) =>
                                          item1.IMEI1 !== '' ||
                                          item1.IMEI2 !== ''
                                      )?.map((item2) => {
                                        const imei1 = item2.IMEI1 || '';
                                        const imei2 = item2.IMEI2 || '';
                                        return (
                                          <div>
                                            {[imei1, imei2]
                                              .filter(Boolean)
                                              .join(',')}
                                          </div>
                                        );
                                      })
                                    : ''}
                                </div>
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalHsnCode && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.HSN}
                              </div>
                            )
                          : HsnCode && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {item?.HSN}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalMRP && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.MRP}
                              </div>
                            )
                          : MRP && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {item?.SinglePc === 'Y'
                                  ? item?.Rate
                                  : item?.MRP}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalQuantity && (
                              <div
                                style={{ width: '100%', textAlign: 'center' }}
                              >
                                {item?.SalesQty}
                              </div>
                            )
                          : Quantity && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {item?.SalesQty}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalRate && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.Rate}
                              </div>
                            )
                          : Rate && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {item?.Rate}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalDiscount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.discount}
                              </div>
                            )
                          : Discount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {item?.Type != 'C'
                                  ? item?.OfferAmt || 0
                                  : item?.OfferValue || 0}
                              </div>
                            )}
                        {GlobaldummyData
                          ? GlobalAmount && (
                              <div
                                style={{ width: '100%', textAlign: 'right' }}
                              >
                                {item?.TotalAmt}
                              </div>
                            )
                          : Amount && (
                              <div
                                style={{
                                  width: '100%',
                                  textAlign: 'right',
                                  fontWeight: 600,
                                }}
                              >
                                {' '}
                                {item?.Type != 'C'
                                  ? item?.TotalAmt - item?.OfferAmt || 0
                                  : item?.TotalAmt - item?.OfferValue || 0}
                              </div>
                            )}
                      </div>
                    )
                  )}
                </div>
              </div>
            )}
          </div>

          <hr className="PrintStyle3-print-dottline" />

          {/* <br/> */}

          <div className="PrintStyle3-print-ttlovrl">
            {((OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0) ||
              (OrderDetailIGST?.length > 0 &&
                OrderDetailIGST?.[0]?.TaxAmt > 0) ||
              (OrderDetailVAT?.length > 0 &&
                OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
              <>
                <div>
                  <div
                    style={{
                      margin: 0,
                      padding: 0,
                      fontSize: '12px',
                      textAlign: 'center',
                    }}
                  >
                    --------- GST Breakup Details -----------
                  </div>
                  {OrderDetailGST?.length > 0 &&
                    OrderDetailGST?.[0]?.TaxAmt > 0 && (
                      <table style={{ width: '90%' }}>
                        <tr>
                          <td style={{ fontSize: '10px', textAlign: 'center' }}>
                            Taxable Amount
                          </td>
                          <td style={{ fontSize: '10px', textAlign: 'center' }}>
                            CGST ({OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                          </td>
                          <td style={{ fontSize: '10px', textAlign: 'center' }}>
                            SGST ({OrderDetailGST?.[0]?.TaxPercentage / 2}%)
                          </td>
                          <td style={{ fontSize: '10px', textAlign: 'center' }}>
                            Total Amount
                          </td>
                        </tr>
                        {OrderDetailGST?.map((item) => (
                          <tr>
                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              {Number(item.WithOutTaxAmount).toFixed(2)}
                            </td>
                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              {Number(item.CGST).toFixed(2)}
                            </td>
                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              {Number(item.SGST).toFixed(2)}
                            </td>
                            <td
                              style={{ fontSize: '10px', 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={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              Taxable Amount
                            </td>
                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              IGST ({OrderDetailIGST?.[0]?.TaxPercentage}%)
                            </td>

                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              Total Amount
                            </td>
                          </tr>
                          {OrderDetailIGST?.map((item) => (
                            <tr>
                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                }}
                              >
                                {Number(item.WithOutTaxAmount).toFixed(2)}
                              </td>
                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                }}
                              >
                                {Number(item.TaxAmt).toFixed(2)}
                              </td>

                              <td
                                style={{
                                  fontSize: '10px',
                                  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={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              Taxable Amount
                            </td>
                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              VAT ({OrderDetailVAT?.[0]?.TaxPercentage}%)
                            </td>

                            <td
                              style={{ fontSize: '10px', textAlign: 'center' }}
                            >
                              Total Amount
                            </td>
                          </tr>
                          {OrderDetailVAT?.map((item) => (
                            <tr>
                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                }}
                              >
                                {Number(item.WithOutTaxAmount).toFixed(2)}
                              </td>
                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                }}
                              >
                                {Number(item.TaxAmt).toFixed(2)}
                              </td>

                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                }}
                              >
                                {Number(item.TotalAmt).toFixed(2)}
                              </td>
                            </tr>
                          ))}
                        </table>
                      </>
                    )}
                </div>
              </>
            )}
          </div>
          <hr className="PrintStyle3-print-dottline" />

          {/* <br/> */}

          <div
            className="PrintStyle3-print-stradrs"
            style={{ display: 'flex', justifyContent: 'space-between' }}
          >
            <div
              style={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'center',
                width: '100%',
              }}
            >
              <div style={{ fontSize: '14px', fontWeight: 600 }}>
                Your Order No :
                {GlobaldummyData
                  ? '01'
                  : table2Data?.SalesId &&
                    extractLastNumber(table2Data?.SalesId)}
              </div>

              {table2Data?.CustSuppName &&
                table2Data?.CustSuppName !== undefined &&
                table2Data?.CustSuppName !== null &&
                !GlobaldummyData && (
                  <div style={{ fontSize: '14px', fontWeight: 600 }}>
                    Customer : {table2Data?.CustSuppName}
                  </div>
                )}
            </div>
          </div>

          <hr className="PrintStyle3-print-dottline" />

          <div
            className="page-footerA4Style11"
            style={{
              marginTop: 'auto',
              pageBreakBefore: 'avoid',
              pageBreakInside: 'avoid',
              minHeight: 'auto',
            }}
          >
            {Notestext && (
              <div>
                <p style={{ padding: '0rem 1rem' }}>{Notestext}</p>

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

            <div
              style={{
                display: 'flex',
                width: '90%',
                padding: '0 1rem',
                justifyContent: GlobaltermsAndConditions
                  ? 'space-between'
                  : 'flex-end',
                alignItems: 'center',
                ...footerColorStyle,
              }}
            >
              {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>
              )}

              {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' && (
            <>
              {/* <br/> */}

              <div
                className="PrintStyle3-print-ftr"
                style={{ fontWeight: 600 }}
              >
                Thank You
              </div>
            </>
          )}
          {/* <div onClick={Print}> print</div> */}
        </div>
      )}
    </>
  );
};

export default PurchaseOrdStyle3;
