import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import {
  extractLastNumber,
  extractLastNumberOrderId,
} from '../../../Services/Others';
import {
  GlobalprintSlNo,
  GlobalprintItem,
  GlobalprintMRP,
  GlobalprintDiscount,
  GlobalprintQuantity,
  GlobalprintRate,
  GlobalprintAmount,
  GlobalprintHsnCode,
  GlobalprintQrcodet,
  GlobalPritdummyData,
  GloabalFieldDetails,
  changeReprintDataFound,
  GlobalprintSignature,
  GlobalprinttermsAndConditions,
  GlobalSignatureImage,
  Globalnotes,
  GlobalthemeFormat,
  GlobalBillName,
  GlobalSelectedPrintHeaderColor,
  GlobalSelectedPrintHeaderFontColor,
  GlobalSelectedTableHeaderColor,
  GlobalSelectedTableHeaderFontColor,
  GlobalSelectedTableBodyColor,
  GlobalSelectedTableBodyFontColor,
  GlobalRowType,
  GlobalSelectedFooterColor,
  GlobalSelectedFooterFontColor,
} from '../../../Features/ThemeChange/ThemeChange';
import { GlobalUpiIDprint } from '../../../Features/BookingScreen/BookingData/BookingData';
import '../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.scss';
import QRCode from 'react-qr-code';
import signature from '../../../Images/signatureimage.jpg';
import { ApplicationPreferences } from '../../../Features/BrachLogin/BranchLogin';
import { isMobile } from 'react-device-detect';

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

  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);
  const GlobalBilltext = useSelector(GlobalBillName);

  let TermsAndConditions = printDatas?.TermsandConditions;
  let SignatureImg = printDatas?.Signature;
  let Notestext = printDatas?.Notes;
  let BillName = printDatas?.PrintHdrName;
  let FormatTheme = printDatas?.PrintType == 'S' ? true : false;
  let PageSize = printDatas?.PageSize;
  const chunkSize = isMobile ? 10 : PageSize == 'A5' ? 10 : 16;
  let dataSource = table2Data?.productDetails || [];
  const Signature = FieldDetails?.['signature'];
  const TermsnAdCondition = FieldDetails?.['terms&conditions'];

  // Paginate the data
  const productsData = table2Data?.productDetails || [];

  console.log(productsData, 'productsData');

  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 ? 10 : PageSize == 'A5' ? 5 : 13);

  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}`;

  console.log(printDatas, 'FormatTheme', FormatTheme);

  const purchaseData = table2Data?.productDetails || [];
  const calculatedTotalQuantity = purchaseData?.reduce((total, item) => {
    return total + (Number(item?.SalesQty) || 0);
  }, 0);

  //
  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="PrintStyle10MasterDiv"
          id={`PrintStyle10`}
          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
                      ? '257mm'
                      : '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="PrintStyle10-print" style={{ ...headerStyle }}>
                  <div
                    className="ShopName"
                    style={{
                      fontWeight: '600',
                    }}
                  >
                    {GlobaldummyData ? 'ABC Shop' : table2Data?.BrName}{' '}
                  </div>
                  <div
                    className="Address"
                    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
                          : '')}
                    <p style={{ fontSize: '9px', fontWeight: '600' }}>
                      Mobile:+91{' '}
                      {GlobaldummyData ? '8428XXXXXX' : table2Data?.BrMobile}
                    </p>
                    {table2Data?.OrderType === 'E' && (
                      <div style={{ textTransform: 'uppercase' }}>Estimate</div>
                    )}

                    {table2Data?.OrderType === 'E' ? (
                      ''
                    ) : (
                      <div style={{ textTransform: 'uppercase' }}>
                        {GlobaldummyData
                          ? GlobalBilltext
                            ? GlobalBilltext
                            : 'Cash' + ' Bill'
                          : BillName
                            ? BillName
                            : PaymentStatus?.length === 1
                              ? PaymentStatus?.[0]?.PaymentTypeName + ' Bill'
                              : ''}
                      </div>
                    )}
                  </div>
                </div>
                <div
                  style={{
                    fontSize: '9.27px',
                    fontWeight: '600',
                    textAlign: 'right',
                  }}
                >
                  {' '}
                  {GlobaldummyData ? formattedDate : Date1}{' '}
                </div>
                <hr class="straightline" />
              </div>

              <div
                style={{ marginTop: GlobaldummyData ? '9rem' : '0rem' }}
                className="print-body"
              >
                <div className="PrintStyle10-print-tableMaster">
                  <table className="PrintStyle10-print-table">
                    <thead>
                      <tr>
                        {SLNO && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'center',
                              ...tableHeaderStyle,
                            }}
                          >
                            S.No
                          </th>
                        )}
                        {Item && <th style={{ ...tableHeaderStyle }}>Item</th>}
                        {HsnCode && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            HSN
                          </th>
                        )}
                        {MRP && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            MRP
                          </th>
                        )}
                        {Rate && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            Rate
                          </th>
                        )}
                        {Quantity && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            Qty
                          </th>
                        )}
                        {Discount && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            Disc
                          </th>
                        )}
                        {Amount && (
                          <th
                            style={{
                              width: '10px',
                              textAlign: 'right',
                              ...tableHeaderStyle,
                            }}
                          >
                            Amount
                          </th>
                        )}
                      </tr>
                    </thead>
                    <tbody>
                      {dataChunk.map((row, rowIndex) => (
                        <tr
                          key={rowIndex}
                          style={{
                            ...(rowIndex % 2 !== 1 && rowtypeStyle === 'even'
                              ? {
                                  ...tableBodyStyle,
                                }
                              : rowIndex % 2 === 1 && rowtypeStyle === 'odd'
                                ? {
                                    ...tableBodyStyle,
                                  }
                                : {}),
                          }}
                        >
                          {SLNO && (
                            <td style={{ textAlign: 'center' }}>
                              {rowIndex + 1 + chunkIndex * chunkSize}
                            </td>
                          )}
                          {/* Item Name fallback order */}
                          {Item && (
                            <td>
                              {row.ProdName ||
                                row.ItemName ||
                                row.ProductName ||
                                row.Item ||
                                row.Name ||
                                ''}
                            </td>
                          )}
                          {/* HSN fallback order */}
                          {HsnCode && (
                            <td style={{ textAlign: 'right' }}>
                              {row.HSN ||
                                row.HSNCode ||
                                row.HsnCode ||
                                row.Hsn ||
                                ''}
                            </td>
                          )}
                          {/* MRP fallback order */}
                          {MRP && (
                            <td style={{ textAlign: 'right' }}>
                              {row.MRP !== undefined
                                ? Number(row.MRP).toFixed(2)
                                : row.Mrp !== undefined
                                  ? Number(row.Mrp).toFixed(2)
                                  : ''}
                            </td>
                          )}
                          {/* Rate fallback order */}
                          {Rate && (
                            <td style={{ textAlign: 'right' }}>
                              {row.Rate !== undefined
                                ? Number(row.Rate).toFixed(2)
                                : row.SaleRate !== undefined
                                  ? Number(row.SaleRate).toFixed(2)
                                  : ''}
                            </td>
                          )}
                          {/* Quantity fallback order */}
                          {Quantity && (
                            <td style={{ textAlign: 'right' }}>
                              {row.SalesQty !== undefined
                                ? Number(row.SalesQty).toFixed(2)
                                : row.Qty !== undefined
                                  ? Number(row.Qty).toFixed(2)
                                  : ''}
                            </td>
                          )}
                          {/* Discount fallback order */}
                          {Discount && (
                            <td style={{ textAlign: 'right' }}>
                              {row.discount !== undefined
                                ? Number(row.discount).toFixed(2)
                                : row.Disc !== undefined
                                  ? Number(row.Disc).toFixed(2)
                                  : ''}
                            </td>
                          )}
                          {/* Amount fallback order */}
                          {Amount && (
                            <td style={{ textAlign: 'right' }}>
                              {row.TotalAmt !== undefined
                                ? Number(row.TotalAmt).toFixed(2)
                                : row.Amount !== undefined
                                  ? Number(row.Amount).toFixed(2)
                                  : ''}
                            </td>
                          )}
                        </tr>
                      ))}
                    </tbody>
                  </table>
                </div>
              </div>

              {chunkIndex === paginatedChunks.length - 1 &&
                !shouldFooterBeOnNewPage &&
                FormatTheme && (
                  <>
                    <div>
                      <hr class="straightline" />
                    </div>

                    <div
                      className="itemtotal"
                      style={{
                        display: 'flex',
                        flexDirection: 'column',
                        rowGap: '0.1rem',
                        fontSize: 'clamp(0.7rem, 2.5vw, 1rem)',

                        fontWeight: '600',
                      }}
                    >
                      {/* <div className="PrintStyle10-total">
                      <div>Amount :</div>
                      <div>{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}</div>
                    </div> */}
                    </div>

                    <div>
                      {((OrderDetailGST?.length > 0 &&
                        OrderDetailGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailIGST?.length > 0 &&
                          OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                        (OrderDetailVAT?.length > 0 &&
                          OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
                        <>
                          <hr class="straightline" />

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

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

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

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

                                        <td
                                          style={{
                                            fontSize: '10px',
                                            textAlign: 'center',
                                            fontWeight: '600',
                                          }}
                                        >
                                          {Number(item.TotalAmt).toFixed(2)}
                                        </td>
                                      </tr>
                                    ))}
                                  </table>
                                </>
                              )}
                          </div>
                          <hr class="straightline" />
                        </>
                      )}
                    </div>
                    <div
                      className="cardDetail"
                      style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
                        paddingTop: '0.5rem 0.5rem',
                        fontWeight: '600',
                      }}
                    >
                      <div
                        className="PrintStyle10-Details"
                        style={{ fontSize: '12px', fontWeight: '600' }}
                      >
                        {/* <div>{PaymentStatus?.length === 1 ? PaymentStatus?.[0]?.PaymentTypeName : "Split"} &nbsp; Payment : &nbsp;{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}/- </div> */}
                        <div>
                          {' '}
                          Purchase Order No:{' '}
                          {GlobaldummyData
                            ? '553'
                            : table2Data?.OrderId &&
                              extractLastNumberOrderId(
                                table2Data?.OrderId,
                                table2Data?.FYStatus
                              )}{' '}
                        </div>

                        {GlobaldummyData && <div> Cashier : Cashier Name</div>}
                        {CashierName &&
                          CashierName !== undefined &&
                          CashierName !== null &&
                          !GlobaldummyData && (
                            <div>Cashier : {CashierName}</div>
                          )}
                        {GlobaldummyData && (
                          <div> Customer : Customer Name</div>
                        )}
                        {table2Data?.CustSuppName &&
                          table2Data?.CustSuppName !== undefined &&
                          table2Data?.CustSuppName !== null &&
                          !GlobaldummyData && (
                            <div>
                              Supplier Name : {table2Data?.CustSuppName}
                            </div>
                          )}

                        {table2Data?.BookingTypeName == 'Dine In' && (
                          <div
                            style={{
                              marginLeft: '14px',
                              padding: 0,
                              fontSize: '12px',
                              fontWeight: '600',
                            }}
                          >
                            Waiter :{' '}
                            {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                          </div>
                        )}
                        {/* <div> CARD NO : ********67</div>
            <div> CARD HOLDER : CARD HOLDER NAME</div>
            <div> TOTAL SAVING : 100</div> */}
                      </div>
                      {GlobaldummyData
                        ? GlobalQrcodet && (
                            <div>
                              <img
                                src="https://api.pozo.app/pozo-common-image-api/upload?fileId=65b8c5d8b57fb175882d6517.png"
                                alt="QR Code"
                              />
                              <div
                                style={{
                                  fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
                                  display: 'flex',
                                  alignItems: 'center',
                                  justifyContent: 'center',
                                  fontWeight: '600',
                                }}
                              >
                                {' '}
                                Scan To Pay{' '}
                              </div>
                              <div
                                className="Rupees"
                                style={{
                                  display: 'flex',
                                  alignItems: 'center',
                                  justifyContent: 'center',
                                  fontWeight: '600',
                                }}
                              >
                                {' '}
                                ₹{' '}
                                {GlobaldummyData
                                  ? '1,066'
                                  : Number(table2Data?.NetAmount).toFixed(2)}
                              </div>
                            </div>
                          )
                        : Qrcodet &&
                          table2Data?.PaymentTypeName == 'UPI' && (
                            <div
                              style={{
                                display: 'flex',
                                flexDirection: 'column',
                                justifyContent: 'center',
                                alignItems: 'center',
                                fontWeight: '600',
                              }}
                            >
                              <QRCode
                                value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                                size={80}
                              />
                              <div
                                style={{ fontSize: '10px', fontWeight: '600' }}
                              >
                                Scan to Pay{' '}
                              </div>
                              <div
                                style={{ fontSize: '10px', fontWeight: '600' }}
                              >
                                ₹
                                {GlobaldummyData
                                  ? '1,066'
                                  : Number(table2Data?.NetAmount).toFixed(2)}
                              </div>
                            </div>
                          )}
                    </div>

                    <div
                      style={{
                        display: 'flex',
                        flexDirection: 'column',
                        alignItems: 'center',
                        fontWeight: '600',
                      }}
                    >
                      {/* <h6 style={{ textAlign: "center", margin: '5px 0 0' }}>Purchase Order No: {GlobaldummyData ? '5' : table2Data?.SalesId && extractLastNumber(table2Data?.SalesId)}
                    </h6> */}
                      {/* <div> Terms & Condition</div>
          <div

          >
            Xxxx Yyyy Xxxx Yyyy Xxxx Yyyy Xxxx Yyyy
          </div> */}
                    </div>
                    <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: '95%',
                          padding: '0 1rem',
                          justifyContent: GlobaltermsAndConditions
                            ? 'space-between'
                            : 'flex-end',
                          alignItems: 'center',
                          ...footerColorStyle,
                        }}
                      >
                        {TermsnAdCondition == true && (
                          <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' && (
                      <div
                        className="thankyou"
                        style={{
                          marginTop: '5px',
                          fontSize: '10px',
                          fontWeight: '600',
                        }}
                      >
                        Thank You
                      </div>
                    )}
                  </>
                )}
            </div>
          ))}

          {shouldFooterBeOnNewPage && FormatTheme && (
            <div
              className="print-page"
              style={{
                display: 'flex',
                flexDirection: 'column',
                minHeight: PageSize == 'A5' ? '200mm' : '297mm',
                justifyContent: 'flex-end',
                pageBreakBefore: 'always',
              }}
            >
              <div
                className="page-footerA4Style11"
                style={{
                  marginTop: 'auto',
                  pageBreakBefore: 'avoid',
                  pageBreakInside: 'avoid',
                  minHeight: 'auto',
                }}
              >
                <>
                  <div>
                    <hr class="straightline" />
                  </div>

                  <div
                    className="itemtotal"
                    style={{
                      display: 'flex',
                      flexDirection: 'column',
                      rowGap: '0.1rem',
                      fontSize: 'clamp(0.7rem, 2.5vw, 1rem)',

                      fontWeight: '600',
                    }}
                  >
                    {/* <div className="PrintStyle10-items" >
                      <div>Qty :</div>
                      <div>{GlobaldummyData ? '8' : calculatedTotalQuantity}</div>
                    </div>
                    <div className="PrintStyle10-items" >
                      <div>Items :</div>
                      <div>{GlobaldummyData ? '8' : totalQuantityFilter?.length}</div>
                    </div> */}

                    {/* <div className="PrintStyle10-total">
                      <div>Amount :</div>
                      <div>{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}</div>
                    </div> */}
                  </div>

                  <div>
                    {((OrderDetailGST?.length > 0 &&
                      OrderDetailGST?.[0]?.TaxAmt > 0) ||
                      (OrderDetailIGST?.length > 0 &&
                        OrderDetailIGST?.[0]?.TaxAmt > 0) ||
                      (OrderDetailVAT?.length > 0 &&
                        OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
                      <>
                        <hr class="straightline" />

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

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

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

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

                                      <td
                                        style={{
                                          fontSize: '10px',
                                          textAlign: 'center',
                                          fontWeight: '600',
                                        }}
                                      >
                                        {Number(item.TotalAmt).toFixed(2)}
                                      </td>
                                    </tr>
                                  ))}
                                </table>
                              </>
                            )}
                        </div>
                        <hr class="straightline" />
                      </>
                    )}
                  </div>
                  <div
                    className="cardDetail"
                    style={{
                      display: 'flex',
                      justifyContent: 'space-between',
                      fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
                      paddingTop: '0.5rem 0.5rem',
                      fontWeight: '600',
                    }}
                  >
                    <div
                      className="PrintStyle10-Details"
                      style={{ fontSize: '12px', fontWeight: '600' }}
                    >
                      {/* <div>{PaymentStatus?.length === 1 ? PaymentStatus?.[0]?.PaymentTypeName : "Split"} &nbsp; Payment : &nbsp;{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}/- </div> */}
                      <div>
                        {' '}
                        Purchase Order No :{' '}
                        {GlobaldummyData
                          ? '553'
                          : table2Data?.OrderId &&
                            extractLastNumberOrderId(
                              table2Data?.OrderId,
                              table2Data?.FYStatus
                            )}{' '}
                      </div>

                      {GlobaldummyData && <div> Cashier : Cashier Name</div>}
                      {CashierName &&
                        CashierName !== undefined &&
                        CashierName !== null &&
                        !GlobaldummyData && <div>Cashier : {CashierName}</div>}
                      {GlobaldummyData && <div> Customer : Customer Name</div>}
                      {table2Data?.CustSuppName &&
                        table2Data?.CustSuppName !== undefined &&
                        table2Data?.CustSuppName !== null &&
                        !GlobaldummyData && (
                          <div>Supplier Name : {table2Data?.CustSuppName}</div>
                        )}

                      {table2Data?.BookingTypeName == 'Dine In' && (
                        <div
                          style={{
                            marginLeft: '14px',
                            padding: 0,
                            fontSize: '12px',
                            fontWeight: '600',
                          }}
                        >
                          Waiter :{' '}
                          {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                        </div>
                      )}
                      {/* <div> CARD NO : ********67</div>
            <div> CARD HOLDER : CARD HOLDER NAME</div>
            <div> TOTAL SAVING : 100</div> */}
                    </div>
                    {GlobaldummyData
                      ? GlobalQrcodet && (
                          <div>
                            <img
                              src="https://api.pozo.app/pozo-common-image-api/upload?fileId=65b8c5d8b57fb175882d6517.png"
                              alt="QR Code"
                            />
                            <div
                              style={{
                                fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
                                display: 'flex',
                                alignItems: 'center',
                                justifyContent: 'center',
                                fontWeight: '600',
                              }}
                            >
                              {' '}
                              Scan To Pay{' '}
                            </div>
                            <div
                              className="Rupees"
                              style={{
                                display: 'flex',
                                alignItems: 'center',
                                justifyContent: 'center',
                                fontWeight: '600',
                              }}
                            >
                              {' '}
                              ₹{' '}
                              {GlobaldummyData
                                ? '1,066'
                                : Number(table2Data?.NetAmount).toFixed(2)}
                            </div>
                          </div>
                        )
                      : Qrcodet &&
                        table2Data?.PaymentTypeName == 'UPI' && (
                          <div
                            style={{
                              display: 'flex',
                              flexDirection: 'column',
                              justifyContent: 'center',
                              alignItems: 'center',
                              fontWeight: '600',
                            }}
                          >
                            <QRCode
                              value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                              size={80}
                            />
                            <div
                              style={{ fontSize: '10px', fontWeight: '600' }}
                            >
                              Scan to Pay{' '}
                            </div>
                            <div
                              style={{ fontSize: '10px', fontWeight: '600' }}
                            >
                              ₹
                              {GlobaldummyData
                                ? '1,066'
                                : Number(table2Data?.NetAmount).toFixed(2)}
                            </div>
                          </div>
                        )}
                  </div>

                  <div
                    style={{
                      display: 'flex',
                      flexDirection: 'column',
                      alignItems: 'center',
                      fontWeight: '600',
                    }}
                  >
                    {/* <h6 style={{ textAlign: "center", margin: '5px 0 0' }}>Purchase Order No {GlobaldummyData ? '5' : table2Data?.SalesId && extractLastNumber(table2Data?.SalesId)}
                    </h6> */}
                    {/* <div> Terms & Condition</div>
          <div

          >
            Xxxx Yyyy Xxxx Yyyy Xxxx Yyyy Xxxx Yyyy
          </div> */}
                  </div>
                  <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: '95%',
                        padding: '0 1rem',
                        justifyContent: GlobaltermsAndConditions
                          ? 'space-between'
                          : 'flex-end',
                        alignItems: 'center',
                        ...footerColorStyle,
                      }}
                    >
                      {TermsnAdCondition == true && (
                        <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' && (
                    <div
                      className="thankyou"
                      style={{
                        marginTop: '5px',
                        fontSize: '10px',
                        fontWeight: '600',
                      }}
                    >
                      Thank You{' '}
                    </div>
                  )}
                </>
              </div>
            </div>
          )}
        </div>
      ) : (
        <div
          className="PrintStyle10MasterDiv"
          id={`PrintStyle10`}
          style={{ fontFamily: "'Courier New', Courier, monospace" }}
        >
          <div className="PrintStyle10-print" style={{ ...headerStyle }}>
            <div
              className="ShopName"
              style={{
                fontWeight: '600',
              }}
            >
              {GlobaldummyData ? 'ABC Shop' : table2Data?.BrName}{' '}
            </div>
            <div
              className="Address"
              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
                    : '')}
              <p style={{ fontSize: '9px', fontWeight: '600' }}>
                Mobile:+91{' '}
                {GlobaldummyData ? '8428XXXXXX' : table2Data?.BrMobile}
              </p>
              {table2Data?.OrderType === 'E' && (
                <div style={{ textTransform: 'uppercase' }}>Estimate</div>
              )}

              {table2Data?.OrderType === 'E' ? (
                ''
              ) : (
                <div style={{ textTransform: 'uppercase' }}>
                  {GlobaldummyData
                    ? GlobalBilltext
                      ? GlobalBilltext
                      : 'Cash' + ' Bill'
                    : BillName
                      ? BillName
                      : PaymentStatusSuccess?.length === 1
                        ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill'
                        : ''}
                </div>
              )}
            </div>
          </div>
          <div
            style={{
              fontSize: '9.27px',
              fontWeight: '600',
              textAlign: 'right',
            }}
          >
            {' '}
            {GlobaldummyData ? formattedDate : Date1}{' '}
          </div>
          <hr class="straightline" />
          {
            <>
              {
                <div
                  style={{
                    display: 'flex',
                    width: '100%',
                    justifyContent: 'center',
                    alignItems: 'center',
                    fontSize: '12px',
                    fontWeight: '600',
                  }}
                >
                  Take Away
                </div>
              }

              <table className="PrintStyle10-print-table">
                <thead>
                  <tr>
                    {GlobaldummyData
                      ? GlobalSlNo && <th style={{ width: '10px' }}>S.N</th>
                      : SLNO && <th style={{ width: '10px' }}>S.N</th>}
                    {GlobaldummyData
                      ? GlobalItem && <th style={{ width: '10px' }}>Item</th>
                      : Item && <th style={{ width: '10px' }}>Item</th>}
                    {GlobaldummyData
                      ? GlobalQuantity && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Qty
                          </th>
                        )
                      : Quantity && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Qty
                          </th>
                        )}
                    {GlobaldummyData
                      ? GlobalHsnCode && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            HSN
                          </th>
                        )
                      : HsnCode && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            HSN
                          </th>
                        )}
                    {GlobaldummyData
                      ? GlobalMRP && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            MRP
                          </th>
                        )
                      : MRP && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            MRP
                          </th>
                        )}
                    {GlobaldummyData
                      ? GlobalDiscount && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Dis{' '}
                          </th>
                        )
                      : Discount && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Dis{' '}
                          </th>
                        )}
                    {GlobaldummyData
                      ? GlobalRate && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Rate
                          </th>
                        )
                      : Rate && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Rate
                          </th>
                        )}
                    {GlobaldummyData
                      ? GlobalAmount && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Amt
                          </th>
                        )
                      : Amount && (
                          <th style={{ width: '10px', textAlign: 'right' }}>
                            Amt
                          </th>
                        )}
                  </tr>
                </thead>
                <tbody>
                  {productsData?.map((item, index) => {
                    return (
                      <tr
                        key={index}
                        style={{
                          ...(index % 2 !== 1 && rowtypeStyle === 'even'
                            ? {
                                ...tableBodyStyle,
                              }
                            : index % 2 === 1 && rowtypeStyle === 'odd'
                              ? {
                                  ...tableBodyStyle,
                                }
                              : {}),
                        }}
                      >
                        {GlobaldummyData
                          ? GlobalSlNo && (
                              <td
                                style={{ width: '10px', textAlign: 'center' }}
                              >
                                {index + 1}
                              </td>
                            )
                          : SLNO && (
                              <td
                                style={{ width: '10px', textAlign: 'center' }}
                              >
                                {index + 1}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalItem && (
                              <td style={{ width: '10px', textAlign: 'left' }}>
                                {item?.ProdName}({item?.Size + item?.UomName})
                              </td>
                            )
                          : Item && (
                              <td
                                style={{
                                  display: 'flex',
                                  flexDirection: 'column',
                                }}
                              >
                                <div>{item?.ProdName}</div>
                                <div>
                                  ({item?.Size ? item?.Size : '1'}{' '}
                                  {item?.SinglePc == 'Y'
                                    ? 'PCS'
                                    : item?.Type != 'C'
                                      ? item?.UomName
                                      : 'COMBO'}
                                  )
                                  {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>
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalQuantity && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.SalesQty}
                              </td>
                            )
                          : Quantity && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.SalesQty}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalHsnCode && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.HSN}
                              </td>
                            )
                          : HsnCode && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.HSN}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalMRP && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.MRP}
                              </td>
                            )
                          : MRP && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.SinglePc === 'Y'
                                  ? item?.Rate
                                  : item?.MRP}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalDiscount && (
                              <td style={{ textAlign: 'right' }}>
                                {item.discount}
                              </td>
                            )
                          : Discount && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.Type != 'C'
                                  ? item?.OfferAmt || 0
                                  : item?.OfferValue || 0}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalRate && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.Rate}
                              </td>
                            )
                          : Rate && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.Rate}
                              </td>
                            )}
                        {GlobaldummyData
                          ? GlobalAmount && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.TotalAmt}
                              </td>
                            )
                          : Amount && (
                              <td style={{ textAlign: 'right' }}>
                                {item?.Type != 'C'
                                  ? item?.TotalAmt - item?.OfferAmt || 0
                                  : item?.TotalAmt - item?.OfferValue || 0}
                              </td>
                            )}
                      </tr>
                    );
                  })}
                </tbody>
              </table>
            </>
          }

          <div>
            <hr class="straightline" />
          </div>

          <div
            className="itemtotal"
            style={{
              display: 'flex',
              flexDirection: 'column',
              rowGap: '0.1rem',
              fontSize: 'clamp(0.7rem, 2.5vw, 1rem)',

              fontWeight: '600',
            }}
          >
            {/* <div className="PrintStyle10-items" >
              <div>Qty :</div>
              <div>{GlobaldummyData ? '8' : calculatedTotalQuantity}</div>
            </div>
            <div className="PrintStyle10-items" >
              <div>Items :</div>
              <div>{GlobaldummyData ? '8' : totalQuantityFilter?.length}</div>
            </div> */}

            {/* <div className="PrintStyle10-total">
              <div>Amount :</div>
              <div>{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}</div>
            </div> */}
          </div>

          {/* <div style={{ display: "flex", justifyContent: "space-evenly", marginTop: '5px' }}>
          <p style={{ marginTop: '5px', padding: 0, fontSize: "17px", fontWeight: "600" }}>{table2Data?.PaymentTypeName} &nbsp;Payment : &nbsp;{Number(table2Data?.NetAmount).toFixed(2)}/- </p>
        </div> */}

          <div>
            {((OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0) ||
              (OrderDetailIGST?.length > 0 &&
                OrderDetailIGST?.[0]?.TaxAmt > 0) ||
              (OrderDetailVAT?.length > 0 &&
                OrderDetailVAT?.[0]?.TaxAmt > 0)) && (
              <>
                <hr class="straightline" />

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

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

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

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

                              <td
                                style={{
                                  fontSize: '10px',
                                  textAlign: 'center',
                                  fontWeight: '600',
                                }}
                              >
                                {Number(item.TotalAmt).toFixed(2)}
                              </td>
                            </tr>
                          ))}
                        </table>
                      </>
                    )}
                </div>
                <hr class="straightline" />
              </>
            )}
          </div>
          <div
            className="cardDetail"
            style={{
              display: 'flex',
              justifyContent: 'space-between',
              fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
              paddingTop: '0.5rem 0.5rem',
              fontWeight: '600',
            }}
          >
            <div
              className="PrintStyle10-Details"
              style={{ fontSize: '12px', fontWeight: '600' }}
            >
              {GlobaldummyData && <div> Cashier : Cashier Name</div>}
              {CashierName &&
                CashierName !== undefined &&
                CashierName !== null &&
                !GlobaldummyData && <div>Cashier : {CashierName}</div>}
              {GlobaldummyData && <div> Customer : Customer Name</div>}
              {table2Data?.CustSuppName &&
                table2Data?.CustSuppName !== undefined &&
                table2Data?.CustSuppName !== null &&
                !GlobaldummyData && (
                  <div>Customer : {table2Data?.CustSuppName}</div>
                )}

              {table2Data?.BookingTypeName == 'Dine In' && (
                <div
                  style={{
                    marginLeft: '14px',
                    padding: 0,
                    fontSize: '12px',
                    fontWeight: '600',
                  }}
                >
                  Waiter : {table2Data?.SalesTableLinkDetails?.[0]?.WaiterName}
                </div>
              )}
            </div>
            {GlobaldummyData
              ? GlobalQrcodet && (
                  <div>
                    <img
                      src="https://api.pozo.app/pozo-common-image-api/upload?fileId=65b8c5d8b57fb175882d6517.png"
                      alt="QR Code"
                    />
                    <div
                      style={{
                        fontSize: 'clamp(0.3rem, 2.5vw, 1rem)',
                        display: 'flex',
                        alignItems: 'center',
                        justifyContent: 'center',
                        fontWeight: '600',
                      }}
                    >
                      {' '}
                      Scan To Pay{' '}
                    </div>
                    <div
                      className="Rupees"
                      style={{
                        display: 'flex',
                        alignItems: 'center',
                        justifyContent: 'center',
                        fontWeight: '600',
                      }}
                    >
                      {' '}
                      ₹{' '}
                      {GlobaldummyData
                        ? '1,066'
                        : Number(table2Data?.NetAmount).toFixed(2)}
                    </div>
                  </div>
                )
              : Qrcodet &&
                table2Data?.PaymentTypeName == 'UPI' && (
                  <div
                    style={{
                      display: 'flex',
                      flexDirection: 'column',
                      justifyContent: 'center',
                      alignItems: 'center',
                      fontWeight: '600',
                    }}
                  >
                    <QRCode
                      value={`upi://pay?pa=${GlobalUpiID}&pn=Merchant&am=${table2Data?.NetAmount}&cu=INR`}
                      size={80}
                    />
                    <div style={{ fontSize: '10px', fontWeight: '600' }}>
                      Scan to Pay{' '}
                    </div>
                    <div style={{ fontSize: '10px', fontWeight: '600' }}>
                      ₹
                      {GlobaldummyData
                        ? '1,066'
                        : Number(table2Data?.NetAmount).toFixed(2)}
                    </div>
                  </div>
                )}
          </div>

          <div
            style={{
              display: 'flex',
              flexDirection: 'column',
              alignItems: 'center',
              fontWeight: '600',
            }}
          >
            <h6 style={{ textAlign: 'center', margin: '5px 0 0' }}>
              YOUR ORDER NO:{' '}
              {GlobaldummyData
                ? '5'
                : table2Data?.SalesId && extractLastNumber(table2Data?.SalesId)}
            </h6>
          </div>
          <div
            className="page-footerA4Style11"
            style={{
              marginTop: 'auto',
              pageBreakBefore: 'avoid',
              pageBreakInside: 'avoid',
              minHeight: 'auto',
            }}
          >
            {GlobaldummyData
              ? GlobalIsnotes && (
                  <div>
                    <p
                      style={{
                        padding: '0rem 1rem',
                        marginTop: GlobalthemeFormatr ? '6vh' : '',
                      }}
                    >
                      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: '95%',
                padding: '0 1rem',
                justifyContent: GlobaltermsAndConditions
                  ? 'space-between'
                  : 'flex-end',
                alignItems: 'center',
                ...footerColorStyle,
              }}
            >
              {TermsnAdCondition == true && (
                <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' && (
            <div
              className="thankyou"
              style={{ marginTop: '5px', fontSize: '10px', fontWeight: '600' }}
            >
              Thank You{' '}
            </div>
          )}
        </div>
      )}
    </>
  );
};

export default PurchaseOrdStyle10;
