Files
firefly-iii/public/build/assets/create-5a2ad8a8.js

2 lines
21 KiB
JavaScript
Raw Normal View History

2024-01-02 20:19:09 +01:00
import{a as h,d as b,g as w,l as S,f as v,b as k,G as T}from"./get-10f2a251.js";import{f as C,k as g,I as x,l as I,m as p}from"./vendor-5ec3da0f.js";function m(){return{id:"",name:"",alpine_name:""}}function L(){let t=C(new Date,"yyyy-MM-dd HH:mm");return{description:"",amount:"",currency_code:"EUR",foreign_amount:"",foreign_currency_code:"",source_account:m(),destination_account:m(),budget_id:null,category_name:"",piggy_bank_id:null,bill_id:null,tags:[],notes:"",internal_reference:"",external_url:"",hasLocation:!1,map:null,latitude:null,longitude:null,zoomLevel:null,marker:null,date:t,interest_date:"",book_date:"",process_date:"",due_date:"",payment_date:"",invoice_date:"",errors:{amount:[],foreign_amount:[],budget_id:[],category_name:[],piggy_bank_id:[]}}}function A(e,t){let o=[];for(let a in e)if(e.hasOwnProperty(a)){const n=e[a];let r={};r.description=n.description,r.source_name=n.source_account.name,r.destination_name=n.destination_account.name,r.amount=n.amount,r.currency_code=n.currency_code,r.date=n.date,r.interest_date=n.interest_date,r.book_date=n.book_date,r.process_date=n.process_date,r.due_date=n.due_date,r.payment_date=n.payment_date,r.invoice_date=n.invoice_date,r.budget_id=n.budget_id,r.category_name=n.category_name,r.piggy_bank_id=n.piggy_bank_id,n.hasLocation&&(r.longitude=n.longitude.toString(),r.latitude=n.latitude.toString(),r.zoom_level=n.zoomLevel),typeof n.foreign_currency_code<"u"&&n.foreign_currency_code.toString()!==""&&(r.foreign_currency_code=n.foreign_currency_code,typeof n.foreign_amount<"u"&&n.foreign_amount.toString()!==""&&(r.foreign_amount=n.foreign_amount),(typeof n.foreign_amount>"u"||n.foreign_amount.toString()==="")&&(delete r.foreign_amount,delete r.foreign_currency_code)),typeof n.source_account.id<"u"&&n.source_account.id.toString()!==""&&(r.source_id=n.source_account.id),typeof n.destination_account.id<"u"&&n.destination_account.id.toString()!==""&&(r.destination_id=n.destination_account.id),r.type=t,o.push(r)}return o}let O=class{post(t){let o="/api/v2/transactions";return h.post(o,t)}};class E{post(t,o,a){let n="/api/v1/attachments";return h.post(n,{filename:t,attachable_type:o,attachable_id:a})}upload(t,o){let a="./api/v1/attachments/"+t+"/upload";return axios.post(a,o)}}let q=class{list(t){return h.get("/api/v2/currencies",{params:t})}};class ${list(t){return h.get("/api/v2/budgets",{params:t})}}let l;const d={description:"/api/v2/autocomplete/transaction-descriptions",account:"/api/v2/autocomplete/accounts",category:"/api/v2/autocomplete/categories",tag:"/api/v2/autocomplete/tags"};let B=function(e,t){console.log("Now in uploadAttachments"),t=t.reverse();let o=[],a=0,n=[],r=document.querySelectorAll('input[name="attachments[]"]');console.log(r);for(const s in r)if(r.hasOwnProperty(s)&&/^0$|^[1-9]\d*$/.test(s)&&s<=4294967294){console.log("Now at attachment #"+s);for(const i in r[s].files)r[s].files.hasOwnProperty(i)&&/^0$|^[1-9]\d*$/.test(i)&&i<=4294967294&&(console.log("Will upload #"+i+" from attachment #"+s+" to transaction #"+t[s].transaction_journal_id),o.push({journal:t[s].transaction_journal_id,file:r[s].files[i]}),a++)}console.log("Found "+a+" attachments.");for(const s in o)o.hasOwnProperty(s)&&/^0$|^[1-9]\d*$/.test(s)&&s<=4294967294&&(console.log("Create file reader for file #"+s),function(i,c){let u=new FileReader;u.onloadend=function(f){f.target.readyState===FileReader.DONE&&(console.log("Done reading file #"+c),n.push({name:o[c].file.name,journal:o[c].journal,content:new Blob([f.target.result])}),n.length===a&&(console.log("Done reading file #"+c),P(n,e)))},u.readAsArrayBuffer(i.file)}(o[s],s));return a},P=function(e,t){let o=e.length,a=0;console.log("Will now upload "+o+" file(s) to journal with id #"+t);for(const n in e)if(e.hasOwnProperty(n)&&/^0$|^[1-9]\d*$/.test(n)&&n<=4294967294){console.log("Creating attachment #"+n);let r=new E;r.post(e[n].name,"TransactionJournal",e[n].journal).then(s=>{let i=parseInt(s.data.data.id);console.log("Created attachment #"+i+" for key #"+n),console.log("Uploading attachment #"+n),r.upload(i,e[n].content).then(c=>{if(a++,a=