Remove compiled
This commit is contained in:
parent
94f82ea82d
commit
5efc239fff
@ -1,22 +0,0 @@
|
|||||||
(()=>{function l(e,n){let t=[];for(let o=0;o<e.length;o+=n){let r=e.slice(o,o+n);t.push(r)}return t}function p(e,n){let t=[...e];for(;t.length<n;)t.push("");return t}function m(e,n,t="~"){return e.map((o,r)=>`${t}${n+r}${o}`)}function _(e){return e.replace(/ +/g," ")}var g=class{constructor(n,t,o,r){this.number=n;this.initial_balance=t;this.closing_balance=o;this.currency=r}},d=class e{constructor(n,t,o,r,s,i,c,a){this.acc_date=n;this.op_date=t;this.description=o;this.title=r;this.person=s;this.account_number=i;this.amount=c;this.balance_after=a}static{this.counter=function*(){let n=1;for(;;)yield n.toString().padStart(11,"0"),n++}()}formatTitle(){return m(p(l(this.title.trim(),27),9),20).join(`
|
|
||||||
`)}formatPerson(){return m(p(l(_(this.person).trim(),27),2).slice(0,2),32).join(`
|
|
||||||
`)}toMT940(){let n={incoming:"150",outcoming:"169"},t=this.amount>0?n.incoming:n.outcoming;return`:61:${u(this.acc_date)}${u(this.op_date).slice(2)}C${$(this.amount)}S${t}${e.counter.next().value}
|
|
||||||
:86:${t}
|
|
||||||
:86:${t}~00B${t}${this.description.slice(0,23)}
|
|
||||||
${this.formatTitle()}
|
|
||||||
~29${this.account_number}
|
|
||||||
~30${this.account_number.slice(2,10)}
|
|
||||||
~31${this.account_number.slice(10)}
|
|
||||||
${this.formatPerson()}
|
|
||||||
~34${t}
|
|
||||||
~38PL${this.account_number}
|
|
||||||
~62
|
|
||||||
~63`}},b=class{constructor(n,t){this.date_start=n;this.date_end=t}},h=class{},f=class extends h{read_csv(n){let t=n.split(`\r
|
|
||||||
`).map(c=>c.split(";")),o=0;for(;!t[o][0].startsWith("Niniejszy dokument sporz\u0105dzono");)o++;let r=new g(t[20][0],this.parseAmount(t[35][1]),this.parseAmount(t[o-2][7]),t[18][0]),s=new b(this.parseDate(t[14][0]),this.parseDate(t[14][1])),i=[];for(let c=38;c<=o-5;c++){let a=t[c];if(a.length!=9)throw new Error("Wrong amount of columns! maybe a semicolon got stuck in a transaction description?");let v=new Date(a[0]),y=new Date(a[1]),[D,S,x,L]=a.slice(2).map(this.trimString),[M,E]=a.slice(6).map(T=>this.parseAmount(T));i.push(new d(v,y,D,S,x,L,M,E))}return{account:r,range:s,transactions:i}}parseAmount(n){return parseFloat(n.replace(/[^0-9,-]/g,"").replace(",","."))}parseDate(n){let[t,o,r]=n.split(".").map(i=>parseInt(i)),s=new Date;return s.setHours(0),s.setMinutes(0),s.setSeconds(0),s.setMilliseconds(0),s.setDate(t),s.setMonth(o-1),s.setFullYear(r),s}trimString(n){return n.replaceAll(/(^["']|["']$)/g,"")}};function u(e){return`${e.getFullYear()-2e3}${(e.getMonth()+1).toString().padStart(2,"0")}${e.getDate().toString().padStart(2,"0")}`}function $(e){return Math.abs(e).toString().replace(".",",")}function w(e){let n=new f().read_csv(e),{account:t,transactions:o,range:r}=n;return{output:`:20:MT940
|
|
||||||
:25:/PL${t.number.replaceAll(/[^0-9]/g,"")}
|
|
||||||
:28C:${u(r.date_start)}
|
|
||||||
:60F:D${u(r.date_start)}${t.currency}${$(t.initial_balance)}
|
|
||||||
${o.map(i=>i.toMT940()).join(`
|
|
||||||
`)}
|
|
||||||
:62F:D${u(r.date_end)}${t.currency}${$(t.closing_balance)}`,range:r}}function A(e,n,t){var o=new Blob([e],{type:t}),r=document.createElement("a"),s=URL.createObjectURL(o);r.href=s,r.download=n,document.body.appendChild(r),r.click(),setTimeout(function(){document.body.removeChild(r),window.URL.revokeObjectURL(s)},0)}async function R(){console.log("browser.ts:2");let e=document.getElementById("csv");if(!e||!(e instanceof HTMLInputElement))throw console.log("browser.ts:5"),new Error("coudl not find the csv input");var n=e.value.replace("C:\\fakepath\\","");let t=e.files;if(!t)throw new Error("no files in the input");let o=await t[0].arrayBuffer(),r=new TextDecoder("windows-1250").decode(o),s=w(r);A(s.output,`raport-${s.range.date_start.getFullYear()}-${(s.range.date_start.getMonth()+1).toString().padStart(2,"0")}.mt940`,"text")}document.querySelector("#submit")?.addEventListener("click",R);console.log("added handler to",document.querySelector("#submit"));})();
|
|
||||||
//# sourceMappingURL=bundle.js.map
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user