mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
1 line
4.6 KiB
JavaScript
Vendored
1 line
4.6 KiB
JavaScript
Vendored
"use strict";(self["webpackChunkfirefly_iii"]=self["webpackChunkfirefly_iii"]||[]).push([[379],{379:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var s=n(9835),u=n(6970);const r={class:"q-mx-sm"},i=["title"],o=(0,s.Uk)(": "),a=["title"],d={key:0},l=(0,s._)("br",null,null,-1),m=["title"],c=["title"],p={key:0};function g(e,t,n,g,h,f){const v=(0,s.up)("q-item-label"),_=(0,s.up)("q-item-section"),w=(0,s.up)("q-item"),b=(0,s.up)("q-separator"),y=(0,s.up)("q-circular-progress"),A=(0,s.up)("q-card-section"),k=(0,s.up)("q-card");return(0,s.wg)(),(0,s.iD)("div",r,[(0,s.Wm)(k,{bordered:""},{default:(0,s.w5)((()=>[(0,s.Wm)(w,null,{default:(0,s.w5)((()=>[(0,s.Wm)(_,null,{default:(0,s.w5)((()=>[(0,s.Wm)(v,null,{default:(0,s.w5)((()=>[(0,s._)("strong",null,(0,u.zw)(e.$t("firefly.left_to_spend")),1)])),_:1})])),_:1})])),_:1}),(0,s.Wm)(b),(0,s.Wm)(A,{horizontal:""},{default:(0,s.w5)((()=>[(0,s.Wm)(A,null,{default:(0,s.w5)((()=>[(0,s.Wm)(y,{value:f.percentage,size:"50px",thickness:.22,color:"negative","track-color":"positive"},null,8,["value","thickness"])])),_:1}),(0,s.Wm)(b,{vertical:""}),0===h.budgeted.length&&0===h.spent.length?((0,s.wg)(),(0,s.j4)(A,{key:0},{default:(0,s.w5)((()=>[(0,s.Uk)((0,u.zw)(e.$t("firefly.no_budget")),1)])),_:1})):(0,s.kq)("",!0),h.budgeted.length>0||h.spent.length>0?((0,s.wg)(),(0,s.j4)(A,{key:1},{default:(0,s.w5)((()=>[(0,s._)("span",{title:f.formatAmount(this.currency,this.budgetedAmount)},(0,u.zw)(e.$t("firefly.budgeted")),9,i),o,((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(h.budgeted,((e,t)=>((0,s.wg)(),(0,s.iD)("span",null,[(0,s._)("span",{title:f.formatAmount(e.native_code,e.native_sum)},(0,u.zw)(f.formatAmount(e.code,e.sum)),9,a),t+1!==h.budgeted.length?((0,s.wg)(),(0,s.iD)("span",d," + ")):(0,s.kq)("",!0)])))),256)),l,h.spent.length>0?((0,s.wg)(),(0,s.iD)("span",{key:0,title:f.formatAmount(this.currency,this.spentAmount)},(0,u.zw)(e.$t("firefly.spent"))+": ",9,m)):(0,s.kq)("",!0),((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(h.spent,((e,t)=>((0,s.wg)(),(0,s.iD)("span",null,[(0,s._)("span",{title:f.formatAmount(e.native_code,e.native_sum)},(0,u.zw)(f.formatAmount(e.code,e.sum)),9,c),t+1!==h.spent.length?((0,s.wg)(),(0,s.iD)("span",p," + ")):(0,s.kq)("",!0)])))),256))])),_:1})):(0,s.kq)("",!0)])),_:1})])),_:1})])}var h=n(3555),f=n(1569),v=n(8898);class _{budgeted(e,t){let n="api/v2/budgets/sum/budgeted",s=(0,v.Z)(e,"y-MM-dd"),u=(0,v.Z)(t,"y-MM-dd");return f.api.get(n,{params:{start:s,end:u}})}spent(e,t){let n="api/v2/budgets/sum/spent",s=(0,v.Z)(e,"y-MM-dd"),u=(0,v.Z)(t,"y-MM-dd");return f.api.get(n,{params:{start:s,end:u}})}}const w={data(){return{store:null,budgeted:[],spent:[],currency:"EUR",budgetedAmount:0,spentAmount:0}},name:"SpendInsightBox",computed:{percentage:function(){if(0===this.budgetedAmount)return 100;if(0===this.spentAmount)return 0;const e=this.spentAmount/this.budgetedAmount*100;return e>100?100:e}},mounted(){this.store=(0,h.S)(),this.store.$onAction((({name:e,$store:t,args:n,after:s,onError:u})=>{s((t=>{"setRange"===e&&this.triggerUpdate()}))})),this.triggerUpdate()},methods:{triggerUpdate:function(){if(null!==this.store.getRange.start&&null!==this.store.getRange.end){this.budgeted=[];const e=new Date(this.store.getRange.start),t=new Date(this.store.getRange.end),n=new _;this.currency=this.store.getCurrencyCode,n.budgeted(e,t).then((e=>this.parseBudgetedResponse(e.data))),n.spent(e,t).then((e=>this.parseSpentResponse(e.data)))}},formatAmount:function(e,t){return Intl.NumberFormat(this.store.getLocale,{style:"currency",currency:e}).format(t)},parseBudgetedResponse:function(e){for(let t in e)if(e.hasOwnProperty(t)){const n=e[t],s=n.converted&&n.native_id!==n.id&&0!==parseFloat(n.native_sum);this.budgeted.push({sum:n.sum,code:n.code,native_sum:n.converted?n.native_sum:n.sum,native_code:n.converted?n.native_code:n.code,native:s}),n.converted&&(s||n.native_id===n.id)&&(this.budgetedAmount=this.budgetedAmount+parseFloat(n.native_sum)),n.converted||(this.budgetedAmount=this.budgetedAmount+parseFloat(n.sum))}},parseSpentResponse:function(e){for(let t in e)if(e.hasOwnProperty(t)){const n=e[t],s=n.converted&&n.native_id!==n.id&&0!==parseFloat(n.native_sum);this.spent.push({sum:n.sum,code:n.code,native_sum:n.converted?n.native_sum:n.sum,native_code:n.converted?n.native_code:n.code,native:s}),n.converted&&(s||n.native_id===n.id)&&(this.spentAmount=this.spentAmount+-1*parseFloat(n.native_sum)),n.converted||(this.spentAmount=this.spentAmount+-1*parseFloat(n.sum))}}}};var b=n(1639),y=n(4458),A=n(490),k=n(1233),q=n(3115),Z=n(926),D=n(3190),R=n(3302),W=n(9984),z=n.n(W);const M=(0,b.Z)(w,[["render",g]]),C=M;z()(w,"components",{QCard:y.Z,QItem:A.Z,QItemSection:k.Z,QItemLabel:q.Z,QSeparator:Z.Z,QCardSection:D.Z,QCircularProgress:R.Z})}}]); |