import{b as l}from"./app-DTeOhhdM.js";const b={title:"Sales Details",breadcrumb:"Home - Sales View",backRoute:"sales.index",getNumber:e=>e.invoice_no,getDate:e=>e.created_at,getTotalAmount:e=>Number(e.grand_total||0),getStatusBadge:()=>null,getApprovalStatusBadge:()=>null,summaryFields:[{label:"Invoice No",value:e=>e.invoice_no||"N/A"},{label:"Date",value:e=>e.created_at?new Date(e.created_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A"},{label:"Customer",value:e=>{var t;return((t=e.customer)==null?void 0:t.name)||"N/A"}},{label:"Grand Total",value:e=>`৳${Number(e.grand_total||0).toFixed(2)}`}],infoCards:[{title:"Sales Info",fields:[{label:"Invoice No",getValue:e=>e.invoice_no||"N/A"},{label:"Created By",getValue:e=>{var t,r;return((t=e.user)==null?void 0:t.name)||((r=e.User)==null?void 0:r.name)||"N/A"}},{label:"Sales Person",getValue:e=>{var t,r,o;return((t=e.transition_location)==null?void 0:t.name)||((r=e.transitionLocation)==null?void 0:r.name)||((o=e.sales_person)==null?void 0:o.name)||"N/A"}},{label:"Order/Note",getValue:e=>e.order_no||"N/A"}]},{title:"Customer Info",fields:[{label:"Name",getValue:e=>{var t;return((t=e.customer)==null?void 0:t.name)||"N/A"}},{label:"Code",getValue:e=>{var t;return((t=e.customer)==null?void 0:t.code)||"N/A"}},{label:"Phone",getValue:e=>{var t;return((t=e.customer)==null?void 0:t.number)||"N/A"}},{label:"Email",getValue:e=>{var t;return((t=e.customer)==null?void 0:t.email)||"N/A"}}]},{title:"Payment Info",fields:[{label:"Subtotal",getValue:e=>Number(e.total||0).toFixed(2)},{label:"Discount",getValue:e=>Number(e.after_discount||0).toFixed(2)},{label:"VAT",getValue:e=>Number(e.vat||0).toFixed(2)},{label:"Previous Due",getValue:e=>Number(e.previous_due||0).toFixed(2)},{label:"Payment",getValue:e=>Number(e.current_payment||0).toFixed(2)}]}],itemsField:"details",itemsLabel:"Sales Items",getTableColumns:e=>{var i,u,c;const t=(i=e.details)==null?void 0:i.some(a=>a.warranty_code),r=(u=e.details)==null?void 0:u.some(a=>Number(a.fqty||0)>0),o=(c=e.details)==null?void 0:c.some(a=>Number(a.after_discount||0)>0),s=[{header:"Product",field:"product",sortable:!0,render:a=>{var n,d;return l.jsxs("div",{children:[l.jsx("div",{className:"text-sm font-medium text-gray-900",children:((n=a.product)==null?void 0:n.name)||a.product_name||"Unknown Product"}),((d=a.arribute)==null?void 0:d.sku)&&l.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:["SKU: ",a.arribute.sku]})]})}},{header:"Qty",field:"qty",align:"center",sortable:!0,render:a=>{var n,d;return l.jsxs("div",{children:[l.jsx("span",{className:"font-medium text-gray-900",children:parseFloat(a.qty||0).toFixed(2)}),((d=(n=a.arribute)==null?void 0:n.unit)==null?void 0:d.name)&&l.jsx("span",{className:"text-gray-500 ml-1 text-xs",children:a.arribute.unit.name})]})}}];return r&&s.push({header:"FQ",field:"fqty",align:"center",sortable:!0,render:a=>parseFloat(a.fqty||0).toFixed(2)}),s.push({header:"Price",field:"price",align:"right",sortable:!0,render:a=>parseFloat(a.price||0).toFixed(2)},{header:"Total",field:"total",align:"right",sortable:!0,render:a=>parseFloat(a.total||0).toFixed(2)}),o&&s.splice(s.length-1,0,{header:"Discount",field:"after_discount",align:"right",sortable:!0,render:a=>parseFloat(a.after_discount||0).toFixed(2)}),t&&s.push({header:"Warranty",field:"warranty_code",sortable:!0,render:a=>a.warranty_code||"-"}),s},getSortValue:(e,t)=>{var r;switch(t){case"product":return((r=e.product)==null?void 0:r.name)||e.product_name||"";case"qty":return parseFloat(e.qty||0);case"fqty":return parseFloat(e.fqty||0);case"price":return parseFloat(e.price||0);case"after_discount":return parseFloat(e.after_discount||0);case"total":return parseFloat(e.total||0);case"warranty_code":return e.warranty_code||"";default:return""}},renderTableFooter:(e,t,r)=>{var s;const o=((s=e.details)==null?void 0:s.length)||0;return l.jsxs("tr",{className:"bg-gray-50",children:[l.jsxs("td",{colSpan:2,className:"px-4 py-3 text-sm font-semibold text-gray-700",children:["Total Items:"," ",l.jsx("span",{className:"text-gray-900",children:o})]}),l.jsx("td",{colSpan:3,className:"px-4 py-3 text-sm font-semibold text-gray-700 text-right",children:"Grand Total:"}),l.jsx("td",{className:"px-4 py-3 text-sm font-bold text-gray-900 text-right",children:Number(r||0).toFixed(2)})]})}};export{b as salesSingleViewConfig};
