mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	
		
			
	
	
		
			2 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			2 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|   | import{a as v,d as E,f as _}from"./get-51a7c3ed.js";import{l as P,a as S,b as T,c as L,d as k,e as A,f as h,g as x,s as D,h as O,i as B,j as F,k as y,m as w}from"./autocomplete-functions-3410a57d.js";import{o as g,i as d,q as z}from"./vendor-824d08a0.js";function M(e,n){let t=[];for(let r in e)if(e.hasOwnProperty(r)){const o=e[r];let i={};i.description=o.description,i.source_name=o.source_account.name,i.destination_name=o.destination_account.name,i.amount=o.amount,i.currency_code=o.currency_code,i.date=o.date,i.interest_date=o.interest_date,i.book_date=o.book_date,i.process_date=o.process_date,i.due_date=o.due_date,i.payment_date=o.payment_date,i.invoice_date=o.invoice_date,i.budget_id=o.budget_id,i.category_name=o.category_name,i.piggy_bank_id=o.piggy_bank_id,i.bill_id=o.bill_id,i.tags=o.tags,i.notes=o.notes,i.internal_reference=o.internal_reference,i.external_url=o.external_url,i.store_location=!1,o.hasLocation&&(i.store_location=!0,i.longitude=o.longitude.toString(),i.latitude=o.latitude.toString(),i.zoom_level=o.zoomLevel),typeof o.foreign_currency_code<"u"&&o.foreign_currency_code.toString()!==""&&(i.foreign_currency_code=o.foreign_currency_code,typeof o.foreign_amount<"u"&&o.foreign_amount.toString()!==""&&(i.foreign_amount=o.foreign_amount),(typeof o.foreign_amount>"u"||o.foreign_amount.toString()==="")&&(delete i.foreign_amount,delete i.foreign_currency_code)),typeof o.source_account.id<"u"&&o.source_account.id.toString()!==""&&(i.source_id=o.source_account.id),typeof o.destination_account.id<"u"&&o.destination_account.id.toString()!==""&&(i.destination_id=o.destination_account.id),i.type=n,t.push(i)}return t}let U=class{post(n){let t="/api/v2/transactions";return v.post(t,n)}};class I{post(n,t,r){let o="/api/v1/attachments";return v.post(o,{filename:n,attachable_type:t,attachable_id:r})}upload(n,t){let r="./api/v1/attachments/"+n+"/upload";return axios.post(r,t)}}let R=function(e){let n=e.length,t=0,r=!1;for(const o in e)if(e.hasOwnProperty(o)&&/^0$|^[1-9]\d*$/.test(o)&&o<=4294967294&&r===!1){let i=new I;i.post(e[o].name,"TransactionJournal",e[o].journal).then(s=>{let a=parseInt(s.data.data.id);i.upload(a,e[o].content).then(u=>{if(t++,t===n){const l=new CustomEvent("upload-success",{some:"details"});document.dispatchEvent(l)}}).catch(u=>{console.error("Could not upload"),console.error(u),t++;const l=new CustomEvent("upload-failed",{error:u});document.dispatchEvent(l),r=!0})}).catch(s=>{console.error("Could not create upload."),console.error(s),t++;const a=new CustomEvent("upload-failed",{error:s});document.dispatchEvent(a),r=!0})}};function N(e,n){n=n.reverse();let t=[],r=0,o=[],i=document.querySelectorAll('input[name="attachments[]"]');for(const s in i)if(i.hasOwnProperty(s)&&/^0$|^[1-9]\d*$/.test(s)&&s<=4294967294)for(const a in i[s].files)i[s].files.hasOwnProperty(a)&&/^0$|^[1-9]\d*$/.test(a)&&a<=4294967294&&(t.push({journal:n[s].transaction_journal_id,file:i[s].files[a]}),r++);for(const s in t)t.hasOwnProperty(s)&&/^0$|^[1-9]\d*$/.test(s)&&s<=4294967294&&function(a,u){let l=new FileReader;l.onloadend=function(m){m.target.readyState===FileReader.DONE&&(o.push({name:t[u].file.name,journal:t[u].journal,content:new Blob([m.target.result])}),o.length===r&&R(o))},l.readAsArrayBuffer(a.file)}(t[s],s);return r}function $(e,n,t){let r=[];for(let o in t)t.hasOwnProperty(o)&&r.push(t[o].replace(e,n));return r}function j(e,n,t){let r,o,i;for(const s in n)if(n.hasOwnProperty(s)){if(s==="group_title"){console.error("Cannot handle error in group title.");continue}if(r=parseInt(s.split(".")[1]),o=s.split(".")[2],i=$(s,o,n[s]),!t.hasOwnProperty(r)){console.error("Cannot handle errors in index #"+r);continue}switch(o){case"currency_code":case"foreign_currency_code":case"category_name":case"piggy_bank_id":case"notes":case"internal_reference":case"external_url":case"latitude":case"longitude":case"zoom_level":case"interest_date":case"book_date":case"process_date":case"due_date":case"payment_date":case"invoice_date":case"amount":case"date":case"budget_id":case"bill_id":case"description":case"tags":t[r].errors[o]=i;break;case"sou |