This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.ts
More file actions
36 lines (30 loc) · 1.23 KB
/
example.ts
File metadata and controls
36 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { TransactionImported } from "../utils/transaction.js";
import { Translator } from "./index.js";
import { convertStringCurrencyToNumber } from "../utils/money.js";
import { getFormattedDate } from "../utils/date.js";
// TODO: Change the const name here and import it in ../index.ts
export const exampleTranslator: Translator = {
// TODO: Change this to something useful
name: "Name that appears during import",
translate: (record: string[]): TransactionImported | null => {
// TODO: If the data comes with headers, figure out how to skip them
if (record[0] === "A header name") {
return null;
}
// TODO: Import or create a unique ID for each transaction
// TODO: See ./scu.ts for an example of creating one
const transactionId = record[0];
return {
// TODO: Change this to something short and clear
account: "Value that appears for each transaction record",
// TODO: Required, map incoming columns
id: transactionId,
datePosted: getFormattedDate(new Date(record[0])),
description: record[0],
amount: convertStringCurrencyToNumber(record[0]),
// TODO: Optional, map or remove
comments: record[0],
checkNumber: parseInt(record[0], 10),
};
},
};