mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 03:29:33 +00:00
2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
|
|
import{a as p,d as f,f as c}from"./format-money-43e05102.js";import{G as g}from"./get-a29f6df7.js";import{p as m}from"./parse-downloaded-splits-4afea167.js";import{p as w,d as y,e as a,f as b,g as S,h as P,i as v,l as A,a as C,b as _,c as E,s as D,j as x,k as l,m as u}from"./splice-errors-into-transactions-9c9b99c0.js";import{i as r,m as B}from"./vendor-fca45885.js";import{d as T}from"./create-empty-split-fb5bda92.js";import"./get-94678769.js";class L{put(s,o){let e="/api/v2/transactions/"+parseInt(o.id);return p.put(e,s)}}const n=x();let U=function(){return{entries:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"edit",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},submitTransaction(){this.notifications.error.show=!1,this.notifications.success.show=!1,this.notifications.wait.show=!1;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.entries[e].errors=T());this.formStates.isSubmitting=!0;let t=w(this.entries,this.groupProperties.transactionType),s={group_title:this.groupProperties.title,fire_webhooks:this.formStates.webhooksButton,apply_rules:this.formStates.rulesButton,transactions:t};this.groupProperties.title===null&&t.length>1&&(s.group_title=t[0].description);let o=new L;console.log(s),o.put(s,{id:this.groupProperties.id}).then(e=>{const i=e.data.data;if(this.groupProperties.id=parseInt(i.id),this.groupProperties.title=i.attributes.group_title??i.attributes.transactions[0].description,y(this.groupProperties.id,i.attributes.transactions)>0){this.notifications.wait.show=!0,this.notifications.wait.text=r.t("firefly.wait_attachments");return}this.showMessageOrRedirectUser()}).catch(e=>{this.submitting=!1,console.log(e),typeof e.response<"u"&&this.parseErrors(e.response.data)})},filters:{source:[],destination:[]},addedSplit(){setTimeout(()=>{const t=function(s,o,e){return s.name_with_balance+'<br><small class="text-muted">'+r.t("firefly.account_type_"+s.type)+"</small>"};a({selector:"input.ac-source",serverUrl:n.account,filters:this.filters.source,onRenderItem:t,onChange:b,onSelectItem:S}),console.log("ok"),console.log(this.entries[0].source_account.alpine_name),a({selector:"input.ac-dest",serverUrl:n.account,filters:this.filters.destination,onRenderItem:t,onChange:P,onSelectItem:v}),a({selector:"input.ac-category",serverUrl:n.category,valueField:"id",labelField:"name",onChange:l,onSelectItem:l}),a({selector:"input.ac-description",serverUrl:n.description,valueField:"id",labelField:"description",onChange:u,onSelectItem:u})},250)},changedDateTime(t){console.warn("changedDateTime, event is not used")},changedDescription(t){console.warn("changedDescription, event is not used")},changedDestinationAccount(t){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(t){console.warn("changedSourceAccount, event is not used")},formattedTotalAmount(){return this.entries.length===0?c(this.groupProperties.totalAmount,"EUR"):c(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},getTags(t){return console.log("at get tags "+t),console.log(this.entries[t].tags),this.entries[t].tags??[]},getTransactionGroup(){this.entries=[];const t=window.location.href.split("/"),s=parseInt(t[t.length-1]);new g().show(s,{}).then(e=>{const i=e.data.data;this.groupProperties.id=parseInt(i.id),this.groupProperties.transactionType=i.attributes.transactions[0].type,this.groupProperties.title=i.attributes.title??i.attributes.transactions[0].description,this.entries=m(i.attributes.transactions),this.notifications.wait.show=!1}).then(()=>{this.groupProperties.totalAmount=0;for(let e in this.entries)this.entries.hasOwnProperty(e)&&(this.g
|