mt940-mbank-ts/public/bundle.js.map

8 lines
13 KiB
Plaintext
Raw Normal View History

2023-12-10 15:15:13 +01:00
{
"version": 3,
"sources": ["../src/utils.ts", "../src/index.ts", "../src/browser.ts"],
"sourcesContent": ["export function chunks(s: string, chunkSize: number): string[] {\n\tconst result = [];\n\tfor (let i = 0; i < s.length; i += chunkSize) {\n\t\tconst chunk = s.slice(i, i + chunkSize);\n\t\tresult.push(chunk);\n\t}\n\treturn result;\n}\n\nexport function fillWithEmpty(array: string[], target_length: number) {\n\tconst a = [...array];\n\twhile (a.length < target_length) {\n\t\ta.push(\"\");\n\t}\n\treturn a;\n}\n\nexport function addLineNumbers(\n\ts: string[],\n\tstart_num: number,\n\tprefix = \"~\"\n): string[] {\n\treturn s.map((l, i) => `${prefix}${start_num + i}${l}`);\n}\n\nexport function removeRepeatingSpace(s: string) {\n\treturn s.replace(/ +/g, \" \");\n}\n", "import {\n\taddLineNumbers,\n\tchunks,\n\tfillWithEmpty,\n\tremoveRepeatingSpace,\n} from \"./utils\";\n\nclass Account {\n\tconstructor(\n\t\tpublic number: string,\n\t\tpublic initial_balance: number,\n\t\tpublic closing_balance: number,\n\t\tpublic currency: string\n\t) {}\n}\n\nclass Transaction {\n\tconstructor(\n\t\tpublic acc_date: Date,\n\t\tpublic op_date: Date,\n\t\tpublic description: string,\n\t\tpublic title: string,\n\t\tpublic person: string,\n\t\tpublic account_number: string,\n\t\tpublic amount: number,\n\t\tpublic balance_after: number\n\t) {}\n\n\tpublic static counter = (function* () {\n\t\tlet c = 1;\n\t\twhile (true) {\n\t\t\tyield c.toString().padStart(11, \"0\");\n\t\t\tc++;\n\t\t}\n\t})();\n\n\tformatTitle() {\n\t\treturn addLineNumbers(\n\t\t\tfillWithEmpty(chunks(this.title.trim(), 27), 9),\n\t\t\t20\n\t\t).join(\"\\n\");\n\t}\n\n\tformatPerson() {\n\t\treturn addLineNumbers(\n\t\t\tfillWithEmpty(\n\t\t\t\tchunks(removeRepeatingSpace(this.person).trim(), 27),\n\t\t\t\t2\n\t\t\t).slice(0, 2),\n\t\t\t32\n\t\t).join(\"\\n\");\n\t}\n\n\ttoMT940() {\n\t\tconst prefixes = { incoming: \"150\", outcoming: \"169\" };\n\t\tconst prefix = this.amount > 0 ? prefixes.incoming : prefixes.outcoming;\n\t\treturn `:61:${mtDate(this.acc_date)}${mtDate(this.op_date).slice(\n\t\t\t2\n\t\t)}C${mtAmount(this.amount)}S${prefix}${Transaction.counter.next().value}\n:86:${prefix}\n:86:${prefix}~00B${prefix}${this.description.slice(0, 23)}\n${this.formatTitle()}\n~29${this.account_number}\n~30${this.account_number.slice(2, 10)}\n~31${this.account_number.slice(10)}\n${this.formatPerson()}\n~34${prefix}\n~38PL${this.account_number}\n~62\n~63`;\n\t}\n}\n\nclass Range {\n\tconstructor(public date_start: Date, public date_end: Date) {}\n}\n\nabstract class CSVParser {\n\tabstract read_csv(content_utf8: string): {\n\t\taccount: Account;\n\t\trange: Range;\n\t\ttransactions: Transaction[];\n\t};\n}\n\nclass mBankParser extends CSVParser {\n\tread_csv(content_utf8: string): {\n\t\taccount: Account;\n\t\trange: Range;\n\t\ttransactions: Transaction[];\n\t} {\n\t\tconst lines = content_utf8.split(\"\\r\\n\").map((line) => line.split(\";\"));\n\t\tlet last = 0;\n\t\twhile (!lines[last][0].startsWith(\"Niniejszy dokument sporz\u0105dzono\")) {\n\t\t\tlast++;\n\t\t}\n\t\tconst account = new Account(\n\t\t\tlines[20][0],\n\t\t\tthis.parseAmount(lines[35][1]),\n\t\t\tthis.parseAmount(lines[last - 2][7]),\n\t\t\tlines[18][0]\n\t\t);\n\t\tconst range = new Range(\n\t\t\tthis.parseDate(lines[14][0]),\n\t\t\tthis.parseDate(lines[14][1])\n\t\t);\n\t\tconst transactions = [];\n\t\tfor (let i = 38; i <= last - 5; i++) {\n\t\t\tconst line = lines[i];\n\t\t\tif (line.length != 9) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Wrong amount of columns! maybe a semicolon got stuck in a transaction description?\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst date_acc = new Date(line[0]);\n\t\t\tconst date_op = new Date(line[1]);\n\t\t\tconst [description, title, person, account_number] = line\n\t\t\t\t.slice(2)\n\t\t\t\t.map(this.trimString);\n\t\t\tconst [amount, balance_after] = line\n\t\t\t\t.slice(6)\n\t\t\t\t.map((s) => this.parseAmount(s));\n\t\t\ttransactions.push(\n\t\t\t\tnew Transaction(\n\t\t\t\t\tdate_acc,\n\t\t\t\t\tdate_op,\n\t\t\t\t\tdescription,\n\t\t\t\t\ttitle,\n\t\t\t\t\tperson,\n\t\t\t\t\taccount_number,\n\t\t\t\t\tamount,\n\t\t\t\t\tbalance_after\n\t\t\t\t)
"mappings": "MAAO,SAASA,EAAOC,EAAWC,EAA6B,CAC9D,IAAMC,EAAS,CAAC,EAChB,QAASC,EAAI,EAAGA,EAAIH,EAAE,OAAQG,GAAKF,EAAW,CAC7C,IAAMG,EAAQJ,EAAE,MAAMG,EAAGA,EAAIF,CAAS,EACtCC,EAAO,KAAKE,CAAK,CAClB,CACA,OAAOF,CACR,CAEO,SAASG,EAAcC,EAAiBC,EAAuB,CACrE,IAAMC,EAAI,CAAC,GAAGF,CAAK,EACnB,KAAOE,EAAE,OAASD,GACjBC,EAAE,KAAK,EAAE,EAEV,OAAOA,CACR,CAEO,SAASC,EACfT,EACAU,EACAC,EAAS,IACE,CACX,OAAOX,EAAE,IAAI,CAACY,EAAGT,IAAM,GAAGQ,CAAM,GAAGD,EAAYP,CAAC,GAAGS,CAAC,EAAE,CACvD,CAEO,SAASC,EAAqBb,EAAW,CAC/C,OAAOA,EAAE,QAAQ,OAAQ,GAAG,CAC7B,CCpBA,IAAMc,EAAN,KAAc,CACb,YACQC,EACAC,EACAC,EACAC,EACN,CAJM,YAAAH,EACA,qBAAAC,EACA,qBAAAC,EACA,cAAAC,CACL,CACJ,EAEMC,EAAN,MAAMC,CAAY,CACjB,YACQC,EACAC,EACAC,EACAC,EACAC,EACAC,E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M,QAAQ,CAAC,GAAGD,EAAQ,QAAQ,GAAGV,EAClDU,EAAQ,eACT,CAAC,GACwB,MAAAC,CAAM,CAChC,CCvLA,SAASe,EAASC,EAAcC,EAAkBC,EAAc,CAC/D,IAAIC,EAAO,IAAI,KAAK,CAACH,CAAI,EAAG,CAAE,KAAME,CAAK,CAAC,EACtCE,EAAI,SAAS,cAAc,GAAG,EACjCC,EAAM,IAAI,gBAAgBF
"names": ["chunks", "s", "chunkSize", "result", "i", "chunk", "fillWithEmpty", "array", "target_length", "a", "addLineNumbers", "start_num", "prefix", "l", "removeRepeatingSpace", "Account", "number", "initial_balance", "closing_balance", "currency", "Transaction", "_Transaction", "acc_date", "op_date", "description", "title", "person", "account_number", "amount", "balance_after", "c", "addLineNumbers", "fillWithEmpty", "chunks", "removeRepeatingSpace", "prefixes", "prefix", "mtDate", "mtAmount", "Range", "date_start", "date_end", "CSVParser", "mBankParser", "content_utf8", "lines", "line", "last", "account", "range", "transactions", "i", "date_acc", "date_op", "s", "day", "month", "year", "d", "n", "convert", "csv_utf8", "result", "t", "download", "data", "filename", "type", "file", "a", "url", "handle", "csv_input", "fileName", "files", "buffer", "string", "result", "convert"]
}