feat: added remaining after budget
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { format } from 'date-fns';
|
||||
import chalk from 'chalk';
|
||||
|
||||
import { checkEnv } from './lib/env.js';
|
||||
import { formatAmount, formatSchedule } from './lib/format.js';
|
||||
import * as actual from './lib/actual.js';
|
||||
import { addFromFrequency } from './lib/dates.js';
|
||||
import chalk from 'chalk';
|
||||
|
||||
checkEnv([
|
||||
'BUDGET_INCOME_NAME',
|
||||
@@ -21,24 +22,7 @@ if (process.env.DRY_RUN) {
|
||||
|
||||
const [month = format(new Date(), 'yyyy-MM')] = process.argv.slice(2);
|
||||
|
||||
const amountFormatter = new Intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' });
|
||||
function formatAmount(amount) {
|
||||
return chalk.bold(amountFormatter.format(Math.abs(amount / 100)));
|
||||
}
|
||||
|
||||
function formatSchedule(s, c) {
|
||||
const operator = s._amountOp === 'isapprox' ? '~ ' : '';
|
||||
let meta = formatAmount(s._amount);
|
||||
if (s._date.frequency) {
|
||||
meta += ` - ${s._date.frequency}`;
|
||||
}
|
||||
if (c?.name) {
|
||||
meta += ` - ${c.name}`;
|
||||
}
|
||||
return `${chalk.underline(s.name)} (${operator}${meta})`;
|
||||
}
|
||||
|
||||
const schedules = await actual.getSchedules();
|
||||
const schedules = await actual.getSchedulesSQL();
|
||||
const categoriesTotal = new Map();
|
||||
let totalOutcome = 0;
|
||||
let totalIncome = 0;
|
||||
@@ -109,4 +93,4 @@ for (const [id, total] of categoriesTotal) {
|
||||
|
||||
console.log();
|
||||
|
||||
await actual.shutdown();
|
||||
await actual.shutdown();
|
||||
|
||||
Reference in New Issue
Block a user