mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
2 lines
2.1 KiB
JavaScript
2 lines
2.1 KiB
JavaScript
import{d as p,f as u}from"./format-money-e259f5e4.js";import{f as h,i as r}from"./vendor-fca45885.js";import{G as c}from"./get-3bb14de5.js";import{p as d}from"./parse-downloaded-splits-7d781ebe.js";import"./create-empty-split-fb5bda92.js";let l=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},groupProperties:{id:0,transactionType:"",transactionTypeTranslated:"",title:"",totalAmount:0,date:new Date},amounts:{},entries:[],pageProperties:{},formatMoney(e,o){return u(e,o)},format(e){return h(e,r.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_loading_data");const e=window.location.href.split("/"),o=parseInt(e[e.length-1]);new c().show(o,{}).then(t=>{const i=t.data.data;this.groupProperties.id=parseInt(i.id),this.groupProperties.transactionType=i.attributes.transactions[0].type,this.groupProperties.transactionTypeTranslated=r.t("firefly."+i.attributes.transactions[0].type),this.groupProperties.title=i.attributes.title??i.attributes.transactions[0].description,this.groupProperties.totalAmount=0,this.entries=d(i.attributes.transactions),this.notifications.wait.show=!1}).then(()=>{for(let t in this.entries)if(this.entries.hasOwnProperty(t)){const i=this.entries[t].currency_code,s=this.entries[t].foreign_currency_code;this.amounts[i]===void 0&&(this.amounts[i]=0,this.amounts[i]+=parseFloat(this.entries[t].amount)),s!==null&&s!==""&&this.amounts[s]===void 0&&(this.amounts[s]=0,this.amounts[s]+=parseFloat(this.entries[t].foreign_amount)),this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[t].amount),parseInt(t)===0&&(this.groupProperties.date=this.entries[t].date)}}).catch(t=>{this.notifications.error.show=!0,this.notifications.error.text=t.message})}}},n={show:l,dates:p};function a(){Object.keys(n).forEach(e=>{console.log(`Loading page component "${e}"`);let o=n[e]();Alpine.data(e,()=>o)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),a()});window.bootstrapped&&(console.log("Loaded through window variable."),a());
|