"use strict";(self["webpackChunkfirefly_iii"]=self["webpackChunkfirefly_iii"]||[]).push([[7221],{7221:(t,n,a)=>{a.r(n),a.d(n,{default:()=>L});var e=a(9835),r=a(6970);const o={key:0},i=(0,e._)("thead",null,[(0,e._)("tr",null,[(0,e._)("th",{class:"text-left"},"Description"),(0,e._)("th",{class:"text-right"},"Opposing account"),(0,e._)("th",{class:"text-right"},"Amount")])],-1),s={class:"text-left"},c={key:0},u=(0,e._)("br",null,null,-1),l={key:0},d=(0,e._)("br",null,null,-1),_={class:"text-right"},p={key:0},g=(0,e._)("br",null,null,-1),h=[g],m={key:0},f={class:"text-right"},w={key:0},y=(0,e._)("br",null,null,-1),k=[y],v={key:0},b=["title"],D={key:2},q={key:0},A=["title"],I={key:3};function T(t,n,a,g,y,T){const C=(0,e.up)("q-item-label"),G=(0,e.up)("q-item-section"),W=(0,e.up)("q-item"),z=(0,e.up)("q-separator"),Z=(0,e.up)("router-link"),x=(0,e.up)("q-markup-table"),j=(0,e.up)("q-card");return(0,e.wg)(),(0,e.iD)("div",null,[(0,e.Wm)(j,{bordered:""},{default:(0,e.w5)((()=>[(0,e.Wm)(W,null,{default:(0,e.w5)((()=>[(0,e.Wm)(G,null,{default:(0,e.w5)((()=>[(0,e.Wm)(C,null,{default:(0,e.w5)((()=>[(0,e._)("strong",null,(0,r.zw)(y.accountName),1),""!==y.accountCurrencyCode?((0,e.wg)(),(0,e.iD)("span",o," ("+(0,r.zw)(T.formatAmount(y.accountCurrencyCode,y.accountBalance))+") ",1)):(0,e.kq)("",!0)])),_:1})])),_:1})])),_:1}),(0,e.Wm)(z),(0,e.Wm)(x,null,{default:(0,e.w5)((()=>[i,(0,e._)("tbody",null,[((0,e.wg)(!0),(0,e.iD)(e.HY,null,(0,e.Ko)(y.transactions,(t=>((0,e.wg)(),(0,e.iD)("tr",null,[(0,e._)("td",s,[(0,e.Wm)(Z,{to:{name:"transactions.show",params:{id:t.transactionGroupId}}},{default:(0,e.w5)((()=>[t.transactions.length>1?((0,e.wg)(),(0,e.iD)("strong",c,[(0,e.Uk)((0,r.zw)(t.transactionGroupTitle),1),u])):(0,e.kq)("",!0)])),_:2},1032,["to"]),((0,e.wg)(!0),(0,e.iD)(e.HY,null,(0,e.Ko)(t.transactions,(n=>((0,e.wg)(),(0,e.iD)("span",null,[t.transactions.length>1?((0,e.wg)(),(0,e.iD)("span",l,[(0,e.Uk)((0,r.zw)(n.description)+" ",1),d])):(0,e.kq)("",!0),1===t.transactions.length?((0,e.wg)(),(0,e.j4)(Z,{key:1,to:{name:"transactions.show",params:{id:t.transactionGroupId}}},{default:(0,e.w5)((()=>[(0,e.Uk)((0,r.zw)(n.description),1)])),_:2},1032,["to"])):(0,e.kq)("",!0)])))),256))]),(0,e._)("td",_,[t.transactions.length>1?((0,e.wg)(),(0,e.iD)("span",p,h)):(0,e.kq)("",!0),((0,e.wg)(!0),(0,e.iD)(e.HY,null,(0,e.Ko)(t.transactions,(n=>((0,e.wg)(),(0,e.iD)("span",null,[(0,e.Wm)(Z,{to:{name:"accounts.show",params:{id:n.destination_id}}},{default:(0,e.w5)((()=>[(0,e.Uk)((0,r.zw)(n.destination_name),1)])),_:2},1032,["to"]),t.transactions.length>1?((0,e.wg)(),(0,e.iD)("br",m)):(0,e.kq)("",!0)])))),256))]),(0,e._)("td",f,[t.transactions.length>1?((0,e.wg)(),(0,e.iD)("span",w,k)):(0,e.kq)("",!0),((0,e.wg)(!0),(0,e.iD)(e.HY,null,(0,e.Ko)(t.transactions,(n=>((0,e.wg)(),(0,e.iD)("span",null,[!1===n.native_currency_converted?((0,e.wg)(),(0,e.iD)("span",v,(0,r.zw)(T.formatAmount(n.currency_code,n.amount)),1)):(0,e.kq)("",!0),!0===n.native_currency_converted?((0,e.wg)(),(0,e.iD)("span",{key:1,title:T.formatAmount(n.currency_code,n.amount)},(0,r.zw)(T.formatAmount(n.native_currency_code,n.native_amount)),9,b)):(0,e.kq)("",!0),null!==n.foreign_amount?((0,e.wg)(),(0,e.iD)("span",D,[!1===n.foreign_currency_converted?((0,e.wg)(),(0,e.iD)("span",q," ("+(0,r.zw)(T.formatAmount(n.foreign_currency_code,n.foreign_amount))+")",1)):(0,e.kq)("",!0),!0===n.foreign_currency_converted?((0,e.wg)(),(0,e.iD)("span",{key:1,title:T.formatAmount(n.foreign_currency_code,n.foreign_amount)}," ("+(0,r.zw)(T.formatAmount(n.native_currency_code,n.native_foreign_amount))+")",9,A)):(0,e.kq)("",!0)])):(0,e.kq)("",!0),t.transactions.length>1?((0,e.wg)(),(0,e.iD)("br",I)):(0,e.kq)("",!0)])))),256))])])))),256))])])),_:1})])),_:1})])}var C=a(5148),G=a.n(C),W=a(1569);class z{constructor(t){G()(this,"root","/api/v2/"),G()(this,"path",""),this.path=t}apiPath(){return this.root+this.path}apiPathWithObject(t){return this.root+this.path+"/"+t}apiGet(t,n){let a=this.apiPathWithObject(t);return n?W.api.get(a,{params:n}):W.api.get(a)}apiGetTransactions(t,n){let a=this.apiPathWithObject(t)+"/transactions";return n?W.api.get(a,{params:n}):W.api.get(a)}}class Z extends z{constructor(){super("accounts")}get(t,n){let a={date:n};return n?this.apiGet(t,a):this.apiGet(t)}transactions(t,n){return n?this.apiGetTransactions(t,n):this.apiGetTransactions(t)}}var x=a(3555),j=a(8898);const O={name:"TransactionList",props:{accountId:0},data(){return{store:null,accountName:"",transactions:[],accountCurrencyCode:"",accountBalance:0}},mounted(){this.store=(0,x.S)(),0!==this.accountId&&(this.getAccount(),this.store.$onAction((({name:t,$store:n,args:a,after:e,onError:r})=>{e((n=>{"setRange"===t&&this.getTransactions()}))})),this.getTransactions())},methods:{getAccount:function(){(new Z).get(this.accountId).then((t=>this.parseAccount(t.data)))},parseAccount:function(t){console.log(t.data.attributes),this.accountName=t.data.attributes.name,this.accountBalance=t.data.attributes.current_balance,this.accountCurrencyCode=t.data.attributes.currency_code},getTransactions:function(){if(null!==this.store.getRange.start&&null!==this.store.getRange.end){const t=new Date(this.store.getRange.start),n=new Date(this.store.getRange.end);let a=(0,j.Z)(t,"y-MM-dd"),e=(0,j.Z)(n,"y-MM-dd");(new Z).transactions(this.accountId,{start:a,end:e,limit:10}).then((t=>this.parseTransactions(t.data)))}},formatAmount:function(t,n){return Intl.NumberFormat(this.store.getLocale,{style:"currency",currency:t}).format(n)},parseTransactions:function(t){for(let n in t.data)if(t.data.hasOwnProperty(n)){let a=t.data[n],e={transactionGroupId:a.id,transactionGroupTitle:a.attributes.group_title,transactions:[]};for(let t in a.attributes.transactions)if(a.attributes.transactions.hasOwnProperty(t)){let n=a.attributes.transactions[t],r={journalId:n.transaction_journal_id,description:n.description,destination_name:n.destination_name,destination_id:n.destination_id,type:n.type,amount:n.amount,native_amount:n.native_amount,foreign_amount:n.foreign_amount,native_foreign_amount:n.native_foreign_amount,currency_code:n.currency_code,native_currency_code:n.native_currency_code,foreign_currency_code:n.foreign_currency_code,native_currency_converted:n.native_currency_converted,foreign_currency_converted:n.foreign_currency_converted};e.transactions.push(r)}this.transactions.push(e)}}}};var P=a(1639),Q=a(4458),M=a(490),R=a(1233),H=a(3115),K=a(926),N=a(6933),U=a(9984),Y=a.n(U);const B=(0,P.Z)(O,[["render",T]]),L=B;Y()(O,"components",{QCard:Q.Z,QItem:M.Z,QItemSection:R.Z,QItemLabel:H.Z,QSeparator:K.Z,QMarkupTable:N.Z})}}]);