import{n as e}from"./chunk-qMK8H_w0.js";import{$ as t,$t as n,An as r,Nn as i,Q as a,Qt as o,Rt as s,Ut as ee,_n as c,an as l,at as u,bn as te,en as d,et as f,it as p,mn as ne,nn as m,nt as h,on as re,ot as g,rn as _,vn as v}from"./app-4kCgdoJR.js";var y=e({default:()=>X}),ie={class:`border-b border-gray-200 p-4 sm:px-6 dark:border-gray-700 print:hidden`},b={class:`absolute end-0 top-0 flex items-center gap-3 pe-4 pt-4`},x={class:`sr-only`},S={class:`sr-only`},C={class:`text-base leading-6 font-semibold text-gray-900 dark:text-gray-100`},w={key:0,class:`m-6 flex flex-col gap-4`},T={class:`text-center`},E=[`src`],D={key:1,class:`text-center text-lg font-bold`},O={key:2},k={key:3},A={key:4},j={class:`text-center text-lg font-bold`},M={key:0},N={key:1},P={class:`-mx-2`},F={class:`w-full divide-y divide-gray-200 dark:divide-gray-700 print:divide-gray-400 dark:print:divide-gray-400`},I={class:`px-2 py-0.5 text-start`},L={class:`w-10 px-2 py-0.5 text-center`},R={class:`w-10 px-2 py-0.5 text-center`},z={class:`w-10 px-2 py-0.5 text-center`},B={class:`px-2 py-0.5 text-start`},V={key:0,class:`pb-1 text-xs`},H={class:`px-2 py-0.5 text-start`},U={class:`w-10 px-2 py-0.5 text-center`},ae={class:`w-10 px-2 py-0.5 text-end`},W={class:`p</template>y-0.5 w-10 px-2 text-end`},G={class:`px-2 py-0.5 text-start`},K={key:0,class:`pb-1 text-xs`},q={class:`w-10 px-2 py-0.5 text-center`},J={class:`w-10 px-2 py-0.5 text-end`},oe={class:`w-10 px-2 py-0.5 text-end`},se={colspan:`3`,class:`px-2 py-0.5 text-end`},ce={class:`w-10 px-2 py-0.5 text-end whitespace-nowrap`},le={key:0},Y={colspan:`3`,class:`px-2 py-0.5 text-end`},ue={class:`w-10 px-2 py-0.5 text-end whitespace-nowrap`},de={colspan:`3`,class:`px-2 py-0.5 text-end`},fe={class:`w-10 px-2 py-0.5 text-end whitespace-nowrap`},pe={colspan:`3`,class:`px-2 py-0.5 text-end`},me={class:`w-10 px-2 py-0.5 text-end whitespace-nowrap`},he={class:`mt-3 text-center text-sm`},ge={key:1,class:`m-6 flex flex-col gap-4 text-yellow-600`},X={__name:`PrintBill`,props:[`form`,`show`,`sendPrint`,`halls`],emits:[`close`],setup(e,{emit:y}){let X=ee(),{t:Z}=s({}),_e=y,Q=e,ve=n(()=>Q.halls.find(e=>e.id===Q.form.selectedHallId)?.tables||[]);ne(()=>{X.props.settings?.print_dialog==1&&setTimeout($,250)});function $(){if(X.props.settings?.pos_server==1){let e={type:`print-json-bill`,data:{}};e.data.logo=X.props.opened_register.store.logo||X.props.settings?.logo||``,e.data.heading=X.props.settings?.name,e.data.store_heading=X.props.opened_register.store.name||``,e.data.store_details={},e.data.store_details.name=X.props.opened_register.store.name||``,e.data.store_details.email=X.props.opened_register.store.phone||``,e.data.store_details.phone=X.props.opened_register.store.email||``,e.data.store_details.address=X.props.opened_register.store?.address||``,e.data.store_details.state=X.props.opened_register.store?.state?.name||``,e.data.store_details.country=X.props.opened_register.store?.country?.name||``,e.data.type=Z(`Bill`),e.data.headers=null,e.data.info=[[Z(`Id`),Q.form.id||``],[Z(`Ref`),Q.form.reference],[Z(`Order No.`),Q.form.number],[Z(`Customer`),Q.form.customer?.company||Q.form.customer?.name||``],[Z(`Date`),Q.form.created_at?t(Q.form.created_at):t(new Date().toISOString(),null,null,!0)],[Z(`Created by`),Q.form.user?.name||X.props.auth?.user?.name||``],[Z(`Created at`),Q.form.created_at?f(Q.form.created_at):f(new Date().toISOString(),null,null,!0)],[Z(`Printed at`),f(new Date().toISOString(),null,null,!0)]],e.data.table_headers=[{label:Z(`Description`)},{label:Z(`Price`)},{label:Z(`Qty`)},{label:Z(`Subtotal`)}];let n=Q.form.items.map(e=>{if(e.variations&&e.variations.length){let t=e.variations.map(e=>({type:`item`,name:p(e.meta),qty:g(e.quantity),price:u(e.price),subtotal:u(e.total)}));return{variations:[{type:`text`,text:e.name+(e.comment?`
`+e.comment:``)},...t]}}else return{type:`item`,name:e.name+(e.comment?`
`+e.comment:``),qty:h(e.quantity),price:u(e.price),subtotal:u(e.total)}}),r=n.filter(e=>e.variations).map(e=>e.variations),i=n.filter(e=>!e.variations);n=[...r.flat(),...i],e.data.items=[n],e.data.totals=[{label:Z(`Total`),value:a(Q.form.items.reduce((e,t)=>Number(t.subtotal)+e,0))},{label:Z(`Discount`),value:a(Q.form.items.reduce((e,t)=>Number(t.total_discount_amount)+e,0))},{label:Z(`Tax`),value:a(Q.form.items.reduce((e,t)=>Number(t.total_tax_amount)+e,0))},{label:Z(`Grand Total`),value:a(Q.form.items.reduce((e,t)=>Number(t.total)+e,0))}],e.data.footers=null,e.data.notice=Z(`This is not receipt but the bill to collect payment.`)+`
`+Z(`Official receipt will be issued after receiving payment.`),Q.sendPrint(e)}else window.print()}return(t,n)=>{let s=te(`Icon`);return c(),_(`div`,null,[d(`div`,ie,[d(`div`,b,[d(`button`,{type:`button`,onClick:n[0]||=e=>$(),class:`focus relative rounded-md text-gray-400 hover:text-gray-500`},[n[2]||=d(`span`,{class:`absolute -inset-2.5`},null,-1),d(`span`,x,i(t.$t(`Print`)),1),re(s,{name:`print-o`,className:`size-6`})]),d(`button`,{type:`button`,onClick:n[1]||=e=>_e(`close`),class:`rounded-md text-gray-400 hover:text-gray-500 focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:outline-hidden`},[d(`span`,S,i(t.$t(`Close`)),1),n[3]||=d(`svg`,{class:`h-6 w-6`,fill:`none`,viewBox:`0 0 24 24`,"stroke-width":`1.5`,stroke:`currentColor`,"aria-hidden":`true`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M6 18L18 6M6 6l12 12`})],-1)])]),d(`div`,null,[d(`h3`,C,i(t.$t(`Print Bill`)),1)])]),e.form.items&&e.form.items.length?(c(),_(`div`,w,[d(`div`,T,[r(X).props.opened_register.store.logo?(c(),_(`img`,{key:0,class:`h-8 max-w-[200pc]`,src:r(X).props.opened_register.store.logo,alt:`Logo`},null,8,E)):(c(),_(`h2`,D,i(r(X).props.opened_register.store.name||t.settings.name),1)),r(X).props.opened_register.store?.address?(c(),_(`div`,O,i(r(X).props.opened_register.store.address||``),1)):m(``,!0),r(X).props.opened_register.store?.phone?(c(),_(`div`,k,i(t.$t(`Phone`))+`: `+i(r(X).props.opened_register.store.phone||``),1)):m(``,!0),r(X).props.opened_register.store?.email?(c(),_(`div`,A,i(t.$t(`Email`))+`: `+i(r(X).props.opened_register.store.email||``),1)):m(``,!0)]),d(`h2`,j,i(t.$t(`Bill`)),1),d(`div`,null,[e.form.id?(c(),_(`div`,M,i(t.$t(`Id`))+`: `+i(e.form.id),1)):m(``,!0),d(`div`,null,i(t.$t(`Customer`))+`: `+i(e.form.customer?.company||e.form.customer?.name||``),1),d(`div`,null,i(t.$t(`Order Ref`))+`: `+i(e.form.reference),1),d(`div`,null,i(t.$t(`Order Number`))+`: `+i(e.form.number),1),e.form.table?(c(),_(`div`,N,i(t.$t(`Table`))+`: `+i(e.form.table?.name||ve.value.find(t=>t.id===e.form.selectedTableId)?.name||``)+` (`+i(e.form.table?.hall?.name||e.halls.find(t=>t.id===e.form.selectedHallId)?.name||`Main`)+`) `,1)):m(``,!0),d(`div`,null,i(t.$t(`Created at`))+`: `+i(e.form.created_at?r(f)(e.form.created_at):r(f)(new Date().toISOString(),null,null,!0)),1),d(`div`,null,i(t.$t(`Created  by`))+`: `+i(e.form.user?.name||r(X).props.auth?.user?.name||``),1)]),d(`div`,P,[d(`table`,F,[d(`thead`,null,[d(`tr`,null,[d(`th`,I,i(t.$t(`Description`)),1),d(`th`,L,i(t.$t(`Qty`)),1),d(`th`,R,i(t.$t(`Price`)),1),d(`th`,z,i(t.$t(`Total`)),1)])]),(c(!0),_(o,null,v(e.form.items,e=>(c(),_(o,null,[e.variations&&e.variations.length?(c(),_(`tbody`,{key:e.id},[d(`tr`,null,[d(`td`,B,[l(i(e.name)+` `,1),e.comment?(c(),_(`div`,V,i(e.comment),1)):m(``,!0)]),n[4]||=d(`td`,{class:`w-10 px-2 py-0.5 text-center`},null,-1),n[5]||=d(`td`,{class:`w-10 px-2 py-0.5 text-end`},null,-1),n[6]||=d(`td`,{class:`w-10 px-2 py-0.5 text-end`},null,-1)]),(c(!0),_(o,null,v(e.variations,e=>(c(),_(`tr`,{key:e.id},[d(`td`,H,i(r(p)(e.meta)),1),d(`td`,U,i(r(g)(e.quantity)),1),d(`td`,ae,i(r(u)(e.price)),1),d(`td`,W,i(r(u)(e.total)),1)]))),128))])):(c(),_(`tbody`,{key:e.id+`_`},[d(`tr`,null,[d(`td`,G,[l(i(e.name)+` `,1),e.comment?(c(),_(`div`,K,i(e.comment),1)):m(``,!0)]),d(`td`,q,i(r(h)(e.quantity)),1),d(`td`,J,i(r(u)(e.price)),1),d(`td`,oe,i(r(u)(e.total)),1)])]))],64))),256)),d(`tfoot`,null,[d(`tr`,null,[d(`th`,se,i(t.$t(`Total`)),1),d(`th`,ce,i(r(a)(e.form.items.reduce((e,t)=>Number(t.subtotal)+e,0))),1)]),e.form.items.reduce((e,t)=>Number(t.total_discount_amount)+e,0)>0?(c(),_(`tr`,le,[d(`th`,Y,i(t.$t(`Discount`)),1),d(`th`,ue,i(r(a)(e.form.items.reduce((e,t)=>Number(t.total_discount_amount)+e,0))),1)])):m(``,!0),d(`tr`,null,[d(`th`,de,i(t.$t(`Tax`)),1),d(`th`,fe,i(r(a)(e.form.items.reduce((e,t)=>Number(t.total_tax_amount)+e,0))),1)]),d(`tr`,null,[d(`th`,pe,i(t.$t(`Grand Total`)),1),d(`th`,me,i(r(a)(e.form.items.reduce((e,t)=>Number(t.total)+e,0))),1)])])])]),d(`div`,null,[d(`div`,null,i(t.$t(`Printed at`))+`: `+i(r(f)(new Date().toISOString(),null,null,!0)),1),d(`div`,null,i(t.$t(`Printed by`))+`: `+i(r(X).props.auth?.user?.name||``),1),d(`div`,he,[d(`div`,null,i(t.$t(`This is not receipt but the bill to collect payment.`)),1),d(`div`,null,i(t.$t(`Official receipt will be issued after receiving payment.`)),1)])])])):(c(),_(`div`,ge,i(t.$t(`Please add at least one item to form.`)),1))])}}};export{X as n,y as t};