Ports "گزارش" end to end (D24), the last missing app page.
In the reference this feature computes nothing: Customer\TahesabController
proxies an external accounting system (hesab.henzagold.com and a bare IP at
31.7.68.147:3030) with TLS verification disabled, a bearer token hardcoded in
the source and a URL-embedded secret, keyed on Customer.mcode. The target has
no such system and no mcode, so per the owner's option الف this is built on our
own ledger with no external connection.
API — customer/me/report{,/detail,/balances,/:id}
- one row per CONFIRMED ledger entry with the running gold and rial balance
after it, newest first as the reference displayed it
- only confirmed entries count, the same rule the cached
Customer.goldDebtGrams/fiatDebtRial follow, so the statement's closing
balance agrees with the figure shown everywhere else in the app
- fields the target has no source for (foreign currency, نام کارساخته,
جنس فلز, the external system's internal ids) are null/zero and the UI OMITS
the row rather than rendering a fabricated value (REP-01)
SEC-16, NOT ported: the reference's detail($id) took the factor code from the
URL and performed no ownership check at all — it never consults auth() — so any
signed-in customer could read any other customer's document by guessing a code.
Here the id is only a filter on top of a customerId scope from the token.
Tested in both directions.
Apps (both, template+script byte-identical, per-app styling only)
- ReportView with the reference's two tabs, its card rows and its «جزئیات»
modal; ReportDocument for one document
- routes /report and /report/detail, the latter opening the second tab
- dashboard entry (v1 tile, v2 row), shown to every signed-in customer since
the reference's hasMCode() gate has no target equivalent
Verified: build 5/5 · jest 45/45 · report 40/40 (new) ·
complete-profile 38/38 · apps smoke 43/43 · typecheck clean on all four apps.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 lines
8.6 KiB
JavaScript
2 lines
8.6 KiB
JavaScript
import{d as A,i as n,c as a,b as t,E as N,t as i,u as $,f as r,_ as K,g as u,o as Q,a as W,k as m,s as y,K as X,q as I,e as D,F as w,r as B,I as M,v as Y,x as O}from"./index-BrtROTwT.js";import{P as Z}from"./PageBar-Dh4JEEwN.js";import{a as U}from"./Spinner.vue_vue_type_style_index_0_lang-DTTCd0cJ.js";import{j as S,p as q}from"./filters-CLL9nGZ2.js";import{D as tt}from"./index-DixO0OJ3.js";import{P as et}from"./index-DPfyaKOl.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./classCallCheck-DE78qYAT.js";const st={class:"doc"},lt={class:"doc__head"},nt={class:"doc__rows"},at={class:"doc__row"},ot={class:"doc__row"},it={dir:"ltr"},rt={key:0,class:"doc__row"},dt={dir:"ltr"},ut={key:1,class:"doc__row"},_t={dir:"ltr"},ct={key:2,class:"doc__row"},vt={key:3,class:"doc__row"},mt={dir:"ltr"},ft={key:4,class:"doc__row"},pt={dir:"ltr"},yt={key:5,class:"doc__row"},kt={dir:"ltr"},bt={key:6,class:"doc__row"},gt={key:7,class:"doc__row"},ht={key:8,class:"doc__row"},wt={key:9,class:"doc__row"},$t={key:10,class:"doc__row"},Ct={class:"doc__gold"},xt={class:"doc__stack"},Rt={dir:"ltr",class:"is-in"},Dt={dir:"ltr",class:"is-out"},Nt=A({__name:"ReportDocument",props:{item:{}},setup(l){function C(c){const e=parseFloat(c);if(!Number.isFinite(e))return c;const v=Math.trunc(Math.abs(e)).toString();return(e<0?"-":"")+q(v)}return(c,e)=>(n(),a("article",st,[t("header",lt,[t("span",null,[e[0]||(e[0]=t("span",{class:"doc__muted"},"شماره سند:",-1)),N(" "+i(l.item.sh_factor),1)]),t("span",null,[e[1]||(e[1]=t("span",{class:"doc__muted"},"تاریخ:",-1)),N(" "+i($(S)(l.item.tarikh)),1)])]),t("dl",nt,[t("div",at,[e[2]||(e[2]=t("dt",null,"نوع سند",-1)),t("dd",null,i(l.item.no),1)]),t("div",ot,[e[3]||(e[3]=t("dt",null,"وزن خالص",-1)),t("dd",it,i(l.item.vazn),1)]),l.item.ayar!==null?(n(),a("div",rt,[e[4]||(e[4]=t("dt",null,"عیار",-1)),t("dd",dt,i(l.item.ayar),1)])):r("",!0),l.item.sh_sharti?(n(),a("div",ut,[e[5]||(e[5]=t("dt",null,"شماره انگ",-1)),t("dd",_t,i(l.item.sh_sharti),1)])):r("",!0),l.item.name_az?(n(),a("div",ct,[e[6]||(e[6]=t("dt",null,"نام آزمایشگاه",-1)),t("dd",null,i(l.item.name_az),1)])):r("",!0),l.item.Darsad_Talayee?(n(),a("div",vt,[e[7]||(e[7]=t("dt",null,"اجرت (گرم)",-1)),t("dd",mt,i(l.item.Darsad_Talayee),1)])):r("",!0),l.item.fi?(n(),a("div",ft,[e[8]||(e[8]=t("dt",null,"قیمت هر گرم",-1)),t("dd",pt,i(C(l.item.fi)),1)])):r("",!0),l.item.fiF?(n(),a("div",yt,[e[9]||(e[9]=t("dt",null,"مبلغ سند",-1)),t("dd",kt,i(C(l.item.fiF)),1)])):r("",!0),l.item.bankName?(n(),a("div",bt,[e[10]||(e[10]=t("dt",null,"بانک",-1)),t("dd",null,i(l.item.bankName),1)])):r("",!0),l.item.accountName?(n(),a("div",gt,[e[11]||(e[11]=t("dt",null,"نام حساب",-1)),t("dd",null,i(l.item.accountName),1)])):r("",!0),l.item.transferTo?(n(),a("div",ht,[e[12]||(e[12]=t("dt",null,"مقصد حواله",-1)),t("dd",null,i(l.item.transferTo),1)])):r("",!0),l.item.receivedAt?(n(),a("div",wt,[e[13]||(e[13]=t("dt",null,"تاریخ دریافت",-1)),t("dd",null,i($(S)(l.item.receivedAt)),1)])):r("",!0),l.item.note?(n(),a("div",$t,[e[14]||(e[14]=t("dt",null,"توضیحات",-1)),t("dd",null,i(l.item.note),1)])):r("",!0)]),t("div",Ct,[e[15]||(e[15]=t("span",null,"طلا",-1)),t("div",xt,[t("span",Rt,i(l.item.tabdil750_v),1),t("span",Dt,i(l.item.tabdil750_kh),1)])])]))}}),j=K(Nt,[["__scopeId","data-v-f58a45b8"]]),Ft={class:"rep"},Vt={class:"rep__tabs"},Pt={key:0,class:"rep__list"},Tt={class:"rep__head"},zt={class:"rep__pair"},It={class:"rep__stack"},Bt={dir:"ltr",class:"is-in"},Mt={dir:"ltr",class:"is-out"},St={class:"rep__pair is-balance"},Et={class:"rep__pair"},Lt={class:"rep__stack"},Ot={dir:"ltr",class:"is-in"},Ut={dir:"ltr",class:"is-out"},jt={class:"rep__pair is-balance"},At=["onClick"],Kt={key:1,class:"rep__empty"},qt={key:0,class:"rep__list"},Gt={key:1,class:"rep__empty"},Ht={key:2,class:"rep__empty"},Jt={key:3,class:"rep__more"},Qt={class:"rep__modal"},Wt={key:0,class:"rep__modalEmpty"},Xt=A({__name:"ReportView",setup(l){const C=X(),c=u(C.name==="reportDetail"?"2":"1"),e=u([]),v=u([]),k=u(1),b=u(!0),f=u(!1),F=u(!1),p=u(!1),x=u(!1),R=u(!1),g=u([]);function V(d){const s=parseFloat(d);if(!Number.isFinite(s))return d;const _=Math.trunc(Math.abs(s)).toString();return(s<0?"-":"")+q(_)}function E(d){return parseFloat(d)<0?"is-out":"is-in"}async function P(){var d,s;if(!(f.value||!b.value)){f.value=!0,p.value=!1;try{if(c.value==="1"){const _=await I.getReport(k.value);e.value=[...e.value,..._.result??[]],(((d=_.result)==null?void 0:d.length)??0)<(_.limit??50)?b.value=!1:k.value+=1}else{const _=await I.getReportDetailList(k.value);v.value=[...v.value,..._.result??[]],(((s=_.result)==null?void 0:s.length)??0)<(_.limit??50)?b.value=!1:k.value+=1}}catch{p.value=!0,b.value=!1}finally{f.value=!1}}}function G(){e.value=[],v.value=[],k.value=1,b.value=!0,p.value=!1}async function T(){G(),await P()}async function L(d){c.value!==d&&(c.value=d,await T())}async function H(){await T(),F.value=!1}async function J(d){x.value=!0,R.value=!0,g.value=[];try{const s=await I.getReportDocument(d.factor_Code);g.value=s.result??[]}catch{g.value=[]}finally{R.value=!1}}const z=u(null);let h=null;return Q(async()=>{await P(),typeof IntersectionObserver<"u"&&(h=new IntersectionObserver(d=>{d.some(s=>s.isIntersecting)&&P()}),z.value&&h.observe(z.value))}),W(()=>h==null?void 0:h.disconnect()),(d,s)=>{const _=Y("container");return n(),a("div",Ft,[m(Z,{title:"گزارش","back-to":"userPage::hasSubRoute"},{below:y(()=>[t("div",Vt,[t("button",{type:"button",class:D(["rep__tab",{"is-on":c.value==="1"}]),onClick:s[0]||(s[0]=o=>L("1"))}," کلیات حساب ",2),t("button",{type:"button",class:D(["rep__tab",{"is-on":c.value==="2"}]),onClick:s[1]||(s[1]=o=>L("2"))}," جزئیات حساب ",2)])]),_:1}),m(U,{spinning:f.value&&!e.value.length&&!v.value.length,tip:"درحال دریافت اطلاعات"},{default:y(()=>[m($(et),{modelValue:F.value,"onUpdate:modelValue":s[2]||(s[2]=o=>F.value=o),onRefresh:H},{default:y(()=>[m(_,{class:"rep__body"},{default:y(()=>[c.value==="1"?(n(),a(w,{key:0},[e.value.length?(n(),a("div",Pt,[(n(!0),a(w,null,B(e.value,o=>(n(),a("article",{key:o.factor_Code,class:"rep__card"},[t("header",Tt,[t("span",null,[s[5]||(s[5]=t("span",{class:"rep__muted"},"شماره سند:",-1)),N(" "+i(o.sh_factor),1)]),t("span",null,[s[6]||(s[6]=t("span",{class:"rep__muted"},"تاریخ:",-1)),N(" "+i($(S)(o.tarikh)),1)])]),t("div",zt,[s[7]||(s[7]=t("span",null,"طلا",-1)),t("div",It,[t("span",Bt,i(o.geram_v),1),t("span",Mt,i(o.geram_kh),1)])]),t("div",St,[s[8]||(s[8]=t("span",null,"مانده طلا:",-1)),t("span",{dir:"ltr",class:D(E(o.tahesab_T))},i(o.tahesab_T),3)]),t("div",Et,[s[9]||(s[9]=t("span",null,"ریال",-1)),t("div",Lt,[t("span",Ot,i(V(o.rial_v)),1),t("span",Ut,i(V(o.rial_kh)),1)])]),t("div",jt,[s[10]||(s[10]=t("span",null,"مانده ریال:",-1)),t("span",{dir:"ltr",class:D(E(o.tahesab_P))},i(V(o.tahesab_P)),3)]),t("button",{type:"button",class:"rep__more",onClick:Yt=>J(o)},"جزئیات",8,At)]))),128))])):!f.value&&!p.value?(n(),a("section",Kt,[m(M,{icon:"vuesax-linear:receipt-text",size:"26"}),s[11]||(s[11]=t("p",null,"هنوز سندی برای حساب شما ثبت نشده است.",-1))])):r("",!0)],64)):(n(),a(w,{key:1},[v.value.length?(n(),a("div",qt,[(n(!0),a(w,null,B(v.value,o=>(n(),O(j,{key:o.factor_Code,item:o},null,8,["item"]))),128))])):!f.value&&!p.value?(n(),a("section",Gt,[m(M,{icon:"vuesax-linear:receipt-text",size:"26"}),s[12]||(s[12]=t("p",null,"هنوز سندی برای حساب شما ثبت نشده است.",-1))])):r("",!0)],64)),p.value?(n(),a("section",Ht,[m(M,{icon:"vuesax-linear:danger",size:"26"}),s[13]||(s[13]=t("p",null,"دریافت اطلاعات با خطا روبهرو شد.",-1)),t("button",{type:"button",class:"rep__retry",onClick:T},"تلاش دوباره")])):r("",!0),f.value&&(e.value.length||v.value.length)?(n(),a("div",Jt,"در حال دریافت…")):r("",!0),t("div",{ref_key:"sentinel",ref:z,class:"rep__sentinel"},null,512)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["spinning"]),m($(tt),{open:x.value,"onUpdate:open":s[4]||(s[4]=o=>x.value=o),placement:"bottom",height:"auto",closable:!1,"body-style":{padding:"0"}},{default:y(()=>[t("div",Qt,[m(U,{spinning:R.value,tip:"درحال دریافت اطلاعات"},{default:y(()=>[(n(!0),a(w,null,B(g.value,o=>(n(),O(j,{key:o.factor_Code,item:o},null,8,["item"]))),128)),!R.value&&!g.value.length?(n(),a("p",Wt," جزئیاتی برای این سند ثبت نشده است. ")):r("",!0)]),_:1},8,["spinning"]),t("button",{type:"button",class:"rep__close",onClick:s[3]||(s[3]=o=>x.value=!1)},"بازگشت")])]),_:1},8,["open"])])}}}),ie=K(Xt,[["__scopeId","data-v-857bd503"]]);export{ie as default};
|