Skip to content

Commit c3d9d63

Browse files
committed
chore: move prettier config and run
1 parent 69a16e0 commit c3d9d63

File tree

7 files changed

+28
-54
lines changed

7 files changed

+28
-54
lines changed

.prettierrc.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 85,
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"singleQuote": false,
7+
"quoteProps": "consistent"
8+
}

package.json

-7
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,5 @@
2626
"dependencies": {
2727
"csv": "^6.2.5",
2828
"inquirer": "^9.1.4"
29-
},
30-
"prettier": {
31-
"trailingComma": "es5",
32-
"tabWidth": 2,
33-
"semi": true,
34-
"singleQuote": false,
35-
"quoteProps": "consistent"
3629
}
3730
}

src/scripts/import.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import {
1717
promptConfirm,
1818
promptTransaction,
1919
} from "../utils/prompt.js";
20-
import {
21-
convertStringCurrencyToNumber,
22-
roundCurrency,
23-
} from "../utils/money.js";
20+
import { convertStringCurrencyToNumber, roundCurrency } from "../utils/money.js";
2421
import { statSync } from "fs";
2522

2623
const config = getConfiguration();
@@ -158,9 +155,7 @@ const run = async (): Promise<void> => {
158155
let originalAmountToSplit = Math.abs(originalAmount);
159156

160157
while (originalAmountToSplit) {
161-
console.log(
162-
`🔪 Split #${splitCount}, $${originalAmountToSplit} remaining`
163-
);
158+
console.log(`🔪 Split #${splitCount}, $${originalAmountToSplit} remaining`);
164159
const splitAmount = convertStringCurrencyToNumber(await promptAmount());
165160
const splitPrompt = await promptTransaction(true);
166161
const splitTransaction = {
@@ -169,9 +164,7 @@ const run = async (): Promise<void> => {
169164
};
170165
db.saveRow(mapTransaction(splitTransaction, splitPrompt, splitCount));
171166
splitCount++;
172-
originalAmountToSplit = roundCurrency(
173-
originalAmountToSplit - splitAmount
174-
);
167+
originalAmountToSplit = roundCurrency(originalAmountToSplit - splitAmount);
175168
}
176169
}
177170
}

src/scripts/report.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { DB } from "../utils/storage.js";
22
import { Allowance, getConfiguration } from "../utils/config.js";
33
import { hardNo } from "../utils/index.js";
4-
import {
5-
convertStringCurrencyToNumber,
6-
formatCurrency,
7-
} from "../utils/money.js";
4+
import { convertStringCurrencyToNumber, formatCurrency } from "../utils/money.js";
85

96
////
107
/// Types
@@ -105,9 +102,7 @@ const percentNeed = Math.round(
105102
const percentWant = Math.round(
106103
(aggregateData.want / aggregateData.income._total) * -100
107104
);
108-
const percentSaved = Math.round(
109-
(amountSaved / aggregateData.income._total) * 100
110-
);
105+
const percentSaved = Math.round((amountSaved / aggregateData.income._total) * 100);
111106

112107
console.log(`
113108
@@ -146,9 +141,7 @@ allowanceTotalsKeys.forEach((subCategory: string) => {
146141
allowanceOutput +=
147142
"\n " + formatCurrency(aggregateData.expense[subCategory]) + " spent";
148143
if ("Annual" === reportType) {
149-
const monthsCompleted: number = reportIsYtd
150-
? new Date().getMonth() + 1
151-
: 12;
144+
const monthsCompleted: number = reportIsYtd ? new Date().getMonth() + 1 : 12;
152145
const allowanceAllowed = allowance * monthsCompleted;
153146
allowanceOutput += `\n ${formatCurrency(allowanceAllowed)} allowed`;
154147
allowanceOutput += `\n ${formatCurrency(carryover)} carryover`;

src/scripts/transactions.ts

+11-18
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ const datePostedRegex = new RegExp(`^${dateRange}`, "g");
3939
const transactions = db
4040
.getByTerms(reportCategory, reportSubCategory)
4141
.filter((transaction: string[]): boolean => {
42-
const matchedDateRange = !!(transaction[2].match(datePostedRegex) || [])
43-
.length;
42+
const matchedDateRange = !!(transaction[2].match(datePostedRegex) || []).length;
4443
return (
45-
transaction[9] !== "omit" &&
46-
transaction[9] !== "split" &&
47-
matchedDateRange
44+
transaction[9] !== "omit" && transaction[9] !== "split" && matchedDateRange
4845
);
4946
});
5047

@@ -59,19 +56,15 @@ console.log(
5956
console.log("================");
6057

6158
let runningTotal = 0;
62-
transactions
63-
.sort(sortTransactionsByDate)
64-
.forEach((transaction: string[]): void => {
65-
const [, , date, amount, description, , , , , , , , notes] = transaction;
66-
const parsedAmount = parseFloat(amount);
67-
const displayNotes = notes || "<No notes>";
68-
console.log(
69-
`${date}, ${formatCurrency(
70-
parsedAmount
71-
)}, ${description}, ${displayNotes}`
72-
);
73-
runningTotal += parsedAmount;
74-
});
59+
transactions.sort(sortTransactionsByDate).forEach((transaction: string[]): void => {
60+
const [, , date, amount, description, , , , , , , , notes] = transaction;
61+
const parsedAmount = parseFloat(amount);
62+
const displayNotes = notes || "<No notes>";
63+
console.log(
64+
`${date}, ${formatCurrency(parsedAmount)}, ${description}, ${displayNotes}`
65+
);
66+
runningTotal += parsedAmount;
67+
});
7568

7669
console.log("----------------");
7770
console.log(formatCurrency(runningTotal));

src/translators/index.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
import {
2-
TransactionComplete,
3-
TransactionImported,
4-
} from "../utils/transaction.js";
1+
import { TransactionComplete, TransactionImported } from "../utils/transaction.js";
52
import { boaTranslator } from "./boa.js";
63
import { transactionCompleteTranslator } from "./transaction-complete.js";
74
import { nordstromsTranslator } from "./nordstroms.js";
85
import { scuTranslator } from "./scu.js";
96

107
export interface Translator {
118
name: string;
12-
translate: (
13-
record: string[]
14-
) => TransactionImported | TransactionComplete | null;
9+
translate: (record: string[]) => TransactionImported | TransactionComplete | null;
1510
importCompleted?: boolean;
1611
transformFileData?: (data: string) => string;
1712
}

src/utils/storage.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ export class DB {
4343

4444
public hasTransaction = (account: string, id: string): boolean => {
4545
return (
46-
!!this.transactionIds[account] &&
47-
this.transactionIds[account].includes(id)
46+
!!this.transactionIds[account] && this.transactionIds[account].includes(id)
4847
);
4948
};
5049

0 commit comments

Comments
 (0)