import{r as L,c as U,d,b as r,I as T}from"./app-DTeOhhdM.js";import{l as q}from"./defualtLogo-C0dU5cUD.js";import{n as W}from"./numberToWords.min-02Sh2OYb.js";function V({sales:h,auth:z}){var y,f,v,w,_,k,I,F,S,A;const{permission:s}=L.useContext(U),n=e=>Number.isFinite(Number(e))?Number(e):0,C=e=>{var l,m,p,x,D;return(((l=e==null?void 0:e.product)==null?void 0:l.name)??((p=(m=e==null?void 0:e.attribute)==null?void 0:m.product)==null?void 0:p.name)??((D=(x=e==null?void 0:e.arribute)==null?void 0:x.product)==null?void 0:D.name)??(e==null?void 0:e.name)??(e==null?void 0:e.product_name)??"")||"—"},t=h&&typeof h=="object"&&!Array.isArray(h)?h:{},O=Array.isArray(t.details)?t.details:[],b=(t==null?void 0:t.invoice_no)??"",P=t!=null&&t.created_at?new Date(t.created_at).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric",timeZone:"UTC"}):"—",c={name:d.name,address:d.address,email:d.email,phone:d.phone,slogan:d.slogan},a={name:(y=t==null?void 0:t.customer)==null?void 0:y.name,address:(f=t==null?void 0:t.customer)==null?void 0:f.address,phone:(v=t==null?void 0:t.customer)==null?void 0:v.number,email:(w=t==null?void 0:t.customer)==null?void 0:w.email,code:(_=t==null?void 0:t.customer)==null?void 0:_.code},u=((k=t==null?void 0:t.table)==null?void 0:k.name)??((I=t==null?void 0:t.table)==null?void 0:I.label)??(t==null?void 0:t.table_name)??(t==null?void 0:t.order_type)??"",j=(t==null?void 0:t.order_slot)??null,g=(t==null?void 0:t.table_order_key)??(u&&j?`${u} #${j}`:null),N=O.map(e=>{var p,x;const i=n((e==null?void 0:e.qty)??(e==null?void 0:e.quantity)??1),l=n(e==null?void 0:e.price)||n(e==null?void 0:e.mrp_price)||n(e==null?void 0:e.tp_price)||0,m=n(e==null?void 0:e.total)||l*i;return{description:C(e),sku:((p=e==null?void 0:e.arribute)==null?void 0:p.sku)??((x=e==null?void 0:e.attribute)==null?void 0:x.sku)??(e==null?void 0:e.sku)??"",quantity:i,price:l,total:m}}),o={subtotal:n(t==null?void 0:t.total),discount:n(t==null?void 0:t.discount),discount_2nd:n(t==null?void 0:t.discount_second),after_discount:n(t==null?void 0:t.after_discount),total:n((t==null?void 0:t.grand_total)??(t==null?void 0:t.total)),previous_due:n(t==null?void 0:t.previous_due),payment:n(t==null?void 0:t.current_payment),order:(t==null?void 0:t.order_no)??"N/A",transition_location:((F=t==null?void 0:t.transition_location)==null?void 0:F.name)??"N/A"},E=(()=>{const e=W.toWords((n(o.total)||0).toFixed(2));return e?String(e).charAt(0).toUpperCase()+String(e).slice(1):""})();return r.jsxs("div",{className:"customer-slip-print print-2inch mx-auto break-after-avoid-page hidden print:!block print:bg-white print:relative",style:{width:"58mm",maxWidth:"58mm"},children:[r.jsx("style",{children:`
        @media print {
          @page { size: 58mm auto; margin: 0; padding: 0; }
          body { margin: 0; padding: 0; }
          .print-2inch { width: 220px !important; max-width: 220px !important; min-width: 220px !important; font-size: 13px !important; overflow: visible !important; color: #000 !important; }
          .print-2inch * { overflow: visible !important; color: inherit !important; }
          .print-2inch p, .print-2inch span, .print-2inch div { color: #000 !important; font-weight: 500 !important; }
          .print-2inch .font-semibold, .print-2inch .font-bold { font-weight: 700 !important; }
          .print-2inch .font-medium { font-weight: 600 !important; }
          .customer-slip-print { display: block !important; visibility: visible !important; }
        }
        @media print and (max-width: 768px) {
          .print-2inch { width: 220px !important; max-width: 220px !important; min-width: 220px !important; box-sizing: border-box !important; }
        }
      `}),r.jsxs("div",{className:"print-2inch text-center py-1.5 border-b-2 border-gray-800",children:[d.companyLogo&&r.jsx("img",{src:d.companyLogo||q,alt:"Logo",className:"w-10 h-10 mx-auto mb-1 object-contain"}),r.jsx("h2",{className:"text-[14px] font-bold uppercase tracking-wide leading-tight",children:c.name}),c.slogan&&r.jsx("p",{className:"text-[13px] text-gray-600 italic mt-0.5",children:c.slogan}),r.jsx("p",{className:"text-[13px] text-gray-700 leading-tight mt-0.5",children:c.address}),r.jsxs("p",{className:"text-[13px] text-gray-700 mt-0.5",children:["Ph: ",c.phone," | ",c.email]})]}),r.jsx("div",{className:"print-2inch text-center py-1.5 border-b-2 border-green-600 bg-green-50/80",children:r.jsx("h3",{className:"text-[13px] font-bold uppercase tracking-wider text-green-800",children:"CUSTOMER COPY"})}),r.jsxs("div",{className:"print-2inch text-center py-1 border-b border-gray-400",children:[r.jsx("h3",{className:"text-[13px] font-bold uppercase tracking-wider",children:"INVOICE"}),r.jsxs("div",{className:"text-[13px] mt-0.5 space-y-0.5",children:[r.jsxs("p",{children:[r.jsx("span",{className:"font-semibold",children:"Date:"})," ",P]}),b?r.jsxs("p",{children:[r.jsx("span",{className:"font-semibold",children:"Inv#:"})," ",b]}):null,g&&r.jsxs("p",{children:[r.jsx("span",{className:"font-semibold",children:"Slot No.:"})," ",g]}),((S=s==null?void 0:s.includes)==null?void 0:S.call(s,"sales_order_view"))&&o.order!=="N/A"&&r.jsxs("p",{children:[r.jsx("span",{className:"font-semibold",children:"Order#:"})," ",o.order]})]})]}),(a==null?void 0:a.name)&&r.jsxs("div",{className:"print-2inch py-1 border-b border-gray-300 text-[13px]",children:[r.jsxs("p",{className:"font-bold",children:["Customer: ",a.name]}),a.code&&r.jsxs("p",{children:["ID: ",a.code]}),a.phone&&r.jsxs("p",{children:["Ph: ",a.phone]}),a.address&&r.jsx("p",{className:"leading-tight",children:a.address})]}),r.jsxs("div",{className:"print-2inch py-1",children:[r.jsx("p",{className:"text-[12px] font-bold uppercase mb-0.5 border-b border-gray-400 pb-0.5",children:"Items"}),r.jsxs("div",{className:"text-[13px] font-semibold grid grid-cols-12 gap-0.5 py-0.5 border-b border-gray-400",children:[r.jsx("div",{className:"col-span-5",children:"Item"}),r.jsx("div",{className:"col-span-2 text-center",children:"Qty"}),r.jsx("div",{className:"col-span-2 text-center",children:"Pr"}),r.jsx("div",{className:"col-span-3 text-right",children:"Total"})]}),N.length===0?r.jsx("p",{className:"text-[12px] text-gray-500 py-1",children:"No items"}):N.map((e,i)=>r.jsx("div",{className:"border-b border-gray-200 py-0.5 text-[12px]",children:r.jsxs("div",{className:"grid grid-cols-12 gap-x-0.5 items-baseline",children:[r.jsxs("div",{className:"col-span-5 min-w-0 overflow-visible",children:[r.jsx("p",{className:"font-medium leading-tight break-words",children:e.description}),e.sku&&r.jsxs("p",{className:"text-[10px] text-gray-600",children:["SKU: ",e.sku]})]}),r.jsx("div",{className:"col-span-2 text-center",children:e.quantity}),r.jsx("div",{className:"col-span-2 text-center",children:n(e.price).toFixed(2)}),r.jsx("div",{className:"col-span-3 text-right font-semibold",children:n(e.total).toFixed(2)})]})},i))]}),r.jsx("div",{className:"print-2inch border-t-2 border-gray-600 pt-1 mt-1",children:r.jsxs("div",{className:"text-[12px] space-y-0.5",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Sub-Total:"}),r.jsx("span",{className:"font-semibold",children:n(o.subtotal).toFixed(2)})]}),(n(o.discount)||0)>0&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Discount:"}),r.jsx("span",{children:n(o.discount).toFixed(2)})]}),r.jsxs("div",{className:"flex justify-between border-t border-gray-400 pt-0.5 mt-0.5 font-bold text-[13px]",children:[r.jsx("span",{children:"Total:"}),r.jsx("span",{children:n(o.total).toFixed(2)})]}),((A=s==null?void 0:s.includes)==null?void 0:A.call(s,"sales_invoice_due_view"))&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex justify-between border-t border-gray-300 pt-0.5",children:[r.jsx("span",{children:"Payment:"}),r.jsx("span",{children:n(o.payment).toFixed(2)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Due:"}),r.jsx("span",{className:"font-semibold",children:(n(o.total)-n(o.payment)).toFixed(2)})]})]})]})}),r.jsx("div",{className:"print-2inch border-t border-gray-300 pt-1 mt-1",children:r.jsxs("p",{className:"text-[13px] leading-tight",children:[r.jsx("span",{className:"font-semibold",children:"In Words:"})," ",E]})}),T.footerNote&&r.jsx("div",{className:"print-2inch border-t border-gray-300 pt-1 mt-1",children:r.jsxs("p",{className:"text-[10px] text-gray-600 leading-tight text-center",children:[r.jsx("span",{className:"font-semibold",children:"NB:"})," ",T.footerNote]})}),r.jsxs("div",{className:"print-2inch text-center py-1.5 mt-1 border-t border-gray-300",children:[r.jsx("p",{className:"text-[13px] font-bold",children:"Thank You!"}),r.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:"Powered by DATA DSS LTD"})]})]})}export{V as default};
