2021-03-26 06:14:35 +01:00
|
|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{331:function(t,e,a){t.exports=a(457)},457:function(t,e,a){"use strict";a.r(e);var n=a(10),r=a.n(n),s=a(14);function c(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}function i(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?c(Object(a),!0).forEach((function(e){o(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):c(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function o(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}var l={name:"Index",props:{accountTypes:String},data:function(){return{accounts:[],type:"all",loading:!0,ready:!1,fields:[],currentPage:1,perPage:5,total:0}},watch:{datesReady:function(t){!0===t&&this.getAccountList()}},computed:i(i(i({},Object(s.d)("",["listPageSize"])),Object(s.d)("dashboard/index",["start","end"])),{},{datesReady:function(){return null!==this.start&&null!==this.end&&this.ready},cardTitle:function(){return this.$t("firefly."+this.type+"_accounts")}}),created:function(){var t=window.location.pathname.split("/");this.type=t[t.length-1];var e=new URLSearchParams(window.location.search);this.currentPage=e.get("page")?parseInt(e.get("page")):1,this.fields=[{key:"title",label:this.$t("list.name"),sortable:!0}],"asset"===this.type&&this.fields.push({key:"role",label:this.$t("list.role"),sortable:!0}),this.fields.push({key:"number",label:this.$t("list.iban"),sortable:!1}),this.fields.push({key:"current_balance",label:this.$t("list.currentBalance"),sortable:!0}),this.fields.push({key:"menu",label:" ",sortable:!1}),this.ready=!0},methods:{getAccountList:function(){this.accounts=[],this.downloadAccountList(1)},downloadAccountList:function(t){var e=this;console.log("Downloading page "+t),axios.get("./api/v1/accounts?type="+this.type+"&page="+t).then((function(t){var a=parseInt(t.data.meta.pagination.current_page),n=parseInt(t.data.meta.pagination.total_pages);if(e.total=parseInt(t.data.meta.pagination.total),e.parseAccounts(t.data.data),a<n){var r=a+1;e.downloadAccountList(r)}}))},roleTranslate:function(t){return null===t?"":this.$t("firefly.account_role_"+t)},parsePages:function(t){this.total=parseInt(t.pagination.total)},parseAccounts:function(t){for(var e in t)if(t.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294){var a=t[e],n={};n.id=a.id,n.title=a.attributes.name,n.role=this.roleTranslate(a.attributes.account_role),n.iban=a.attributes.iban,n.account_number=a.attributes.account_number,n.current_balance=a.attributes.current_balance,n.currency_code=a.attributes.currency_code,n.balance_diff="loading",this.accounts.push(n),"asset"===this.type&&this.getAccountBalanceDifference(this.accounts.length-1,a)}},getAccountBalanceDifference:function(t,e){var a=this,n=[];n.push(new Promise((function(a){a({account:e,index:t})}))),n.push(axios.get("./api/v1/accounts/"+e.id+"?date="+this.start.toISOString().split("T")[0])),n.push(axios.get("./api/v1/accounts/"+e.id+"?date="+this.end.toISOString().split("T")[0])),Promise.all(n).then((function(t){var e=t[0].index,n=parseFloat(t[1].data.data.attributes.current_balance),r=parseFloat(t[2].data.data.attributes.current_balance);a.accounts[e].balance_diff=r-n}))},loadAccounts:function(t){for(var e in t)if(t.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294){var a=t[e];this.accounts.push(a)}}}},u=a(4),d=Object(u.a)(l,(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"row"},[a("div",{staticClass:"col-lg-12 col-md-12 col-sm-12 col-xs-12"},[a("b-pagination",{attrs:{"total-rows":t.total,"per-page":t.perPage,"aria-controls":"my-table"},model:{value:t.currentPage,callback:function(e){t.currentPage=e},expression:"currentPage"}})],1)]),t._v(" "),a("div",{staticClass:"row"},[a("div",{stati
|