import{h as b,b as x,d as f}from"./bootstrap-BsWQM_6D.js";import{c as g,e as v}from"./components-DUSFgsKA.js";import{_ as D,n as w}from"./currency-Dtag6qPd.js";import{_ as k}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as C,o as n,c as a,a as e,f as p,t,F as c,b as m,i as F}from"./runtime-core.esm-bundler-VrNrzzXC.js";import"./chart-CAYz1qzV.js";import"./ns-prompt-popup-CwRKP6Ip.js";import"./ns-avatar-image-Pigdi04i.js";const Y={name:"ns-cash-flow",props:["storeLogo","storeName"],mounted(){this.loadReport()},components:{nsDatepicker:g,nsDateTimePicker:v},data(){return{startDateField:{value:b(ns.date.current).startOf("month").format("YYYY-MM-DD HH:mm:ss"),type:"datetimepicker"},endDateField:{value:b(ns.date.current).endOf("month").format("YYYY-MM-DD HH:mm:ss"),type:"datetimepicker"},report:new Object,ns:window.ns}},computed:{},methods:{__:D,nsCurrency:w,printSaleReport(){this.$htmlToPaper("report")},loadReport(){x.post("/api/reports/transactions",{startDate:this.startDateField.value,endDate:this.endDateField.value}).subscribe({next:l=>{this.report=l},error:l=>{f.error(l.message).subscribe()}})}}},R={id:"report-section",class:"px-4"},B={class:"flex -mx-2"},H={class:"px-2"},N={class:"px-2"},S={class:"px-2"},j={class:"ns-button"},L={class:"pl-2"},M={class:"px-2"},P={class:"ns-button"},T={class:"pl-2"},O={id:"report",class:"anim-duration-500 fade-in-entrance"},V={class:"flex w-full"},A={class:"my-4 flex justify-between w-full"},E={class:"text-primary"},q={class:"pb-1 border-b border-dashed"},z={class:"pb-1 border-b border-dashed"},G={class:"pb-1 border-b border-dashed"},I=["src","alt"],J={class:"shadow rounded my-4"},K={class:"ns-box"},Q={class:"ns-box-body"},U={class:"ns-table table w-full"},W={class:""},X={class:"border p-2 text-left"},Z={width:"150",class:"border border-error-secondary bg-error-primary p-2 text-right"},$={width:"150",class:"text-right border-success-secondary bg-success-primary border p-2"},ee={class:""},se={class:"p-2 bg-box-elevation-background border"},te={class:"p-2 border border-error-secondary bg-error-primary text-right"},re={class:"p-2 border text-right border-success-secondary bg-success-primary"},oe={class:"p-2 border"},de={class:"ml-4"},ne={class:"p-2 border border-error-secondary bg-error-primary text-right"},ae={class:"p-2 border text-right border-success-secondary bg-success-primary"},le={class:"p-2 border bg-box-elevation-background"},ie={class:"p-2 border text-right border-error-secondary bg-error-primary"},ce={class:"p-2 border text-right border-success-secondary bg-success-primary"};function _e(l,r,_,ue,o,s){const u=C("ns-field");return n(),a("div",R,[e("div",B,[e("div",H,[p(u,{field:o.startDateField},null,8,["field"])]),e("div",N,[p(u,{field:o.endDateField},null,8,["field"])]),e("div",S,[e("div",j,[e("button",{onClick:r[0]||(r[0]=d=>s.loadReport()),class:"rounded flex justify-between text-primary shadow py-1 items-center px-2"},[r[2]||(r[2]=e("i",{class:"las la-sync-alt text-xl"},null,-1)),e("span",L,t(s.__("Load")),1)])])]),e("div",M,[e("div",P,[e("button",{onClick:r[1]||(r[1]=d=>s.printSaleReport()),class:"rounded flex justify-between text-primary shadow py-1 items-center px-2"},[r[3]||(r[3]=e("i",{class:"las la-print text-xl"},null,-1)),e("span",T,t(s.__("Print")),1)])])])]),e("div",O,[e("div",V,[e("div",A,[e("div",E,[e("ul",null,[e("li",q,t(s.__("Range : {date1} — {date2}").replace("{date1}",o.startDateField.value).replace("{date2}",o.endDateField.value)),1),e("li",z,t(s.__("Document : Sale By Payment")),1),e("li",G,t(s.__("By : {user}").replace("{user}",o.ns.user.username)),1)])]),e("div",null,[e("img",{class:"w-24",src:_.storeLogo,alt:_.storeName},null,8,I)])])]),e("div",J,[e("div",K,[e("div",Q,[e("table",U,[e("thead",W,[e("tr",null,[e("th",X,t(s.__("Account")),1),e("th",Z,t(s.__("Debit")),1),e("th",$,t(s.__("Credit")),1)])]),e("tbody",ee,[(n(!0),a(c,null,m(o.report.accounts,(d,h)=>(n(),a(c,{key:h},[e("tr",null,[e("td",se,[r[4]||(r[4]=e("i",{class:"las la-arrow-right"},null,-1)),r[5]||(r[5]=F()),e("strong",null,t(d.name),1)]),e("td",te,t(s.nsCurrency(d.debits)),1),e("td",re,t(s.nsCurrency(d.credits)),1)]),(n(!0),a(c,null,m(d.transactions,(i,y)=>(n(),a("tr",{key:y},[e("td",oe,[e("span",de,t(i.name),1)]),e("td",ne,t(s.nsCurrency(i.debits)),1),e("td",ae,t(s.nsCurrency(i.credits)),1)]))),128))],64))),128))]),e("tbody",null,[e("tr",null,[e("td",le,[e("strong",null,t(s.__("Total")),1)]),e("td",ie,[e("strong",null,t(s.nsCurrency(o.report.debits)),1)]),e("td",ce,[e("strong",null,t(s.nsCurrency(o.report.credits)),1)])])])])])])])])])}const ve=k(Y,[["render",_e]]);export{ve as default};
