ownledger 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/engine/actions.js +22 -7
- package/dist/node/statement-rows.js +3 -1
- package/dist/worker/version.d.ts +1 -1
- package/dist/worker/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.1 (2026-11-23)
|
|
4
|
+
|
|
5
|
+
- **Fix: editing only the amount of a 0-amount row** booked it as income (the kind came from the sign of 0), so the
|
|
6
|
+
account went up instead of down. The kind now comes from the category's side (income or expense; expense for system
|
|
7
|
+
categories), and a 0 transfer keeps its lines' order.
|
|
8
|
+
- **Fix: `statements reconcile` read a statement's period line as a row** ("21/06/2025 - 20/07/2025 100,000", the
|
|
9
|
+
dates and the minimum due on MSB), giving a false "missing" row each month, sometimes matched to another account.
|
|
10
|
+
Lines holding a date range are skipped.
|
|
11
|
+
|
|
3
12
|
## 2.3.0 (2026-11-23)
|
|
4
13
|
|
|
5
14
|
- **`batch` saves bank statement amounts too:** op `statement_amount` (`account`, `statement_date`, `amount`; 0
|
package/dist/engine/actions.js
CHANGED
|
@@ -110,28 +110,43 @@ function buildEdit(files, id, patch, meta) {
|
|
|
110
110
|
next[k] = patch[k];
|
|
111
111
|
}
|
|
112
112
|
if (patch.lines || patch.amount || patch.kind || patch.account || patch.category || patch.to_account) {
|
|
113
|
-
next.lines = linesOf({ ...simpleOf(old), ...patch });
|
|
113
|
+
next.lines = linesOf({ ...simpleOf(old, files), ...patch });
|
|
114
114
|
}
|
|
115
115
|
if (!isDate(next.date))
|
|
116
116
|
throw new ActionError("date must be yyyy-mm-dd");
|
|
117
117
|
const done = trailed(next, "edit", meta);
|
|
118
118
|
return { change: { replaceTransactions: [done] }, message: withMeta(`Edit: ${next.date} ${next.note ?? ""}`.trim(), meta), tx: done, old };
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
121
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Best-effort simple view of a transaction (to let an edit change just one field).
|
|
122
|
+
* A 0 amount has no sign, so the kind comes from the category's side (income/expense),
|
|
123
|
+
* and a 0 transfer keeps its lines' order (first line is the source).
|
|
124
|
+
*/
|
|
125
|
+
function simpleOf(t, files) {
|
|
122
126
|
const acc = t.lines.filter((l) => l.account);
|
|
123
127
|
const cat = t.lines.filter((l) => l.category);
|
|
124
128
|
if (t.lines.length === 2 && acc.length === 1 && cat.length === 1) {
|
|
125
129
|
const a = acc[0];
|
|
126
|
-
|
|
130
|
+
const category = cat[0].category;
|
|
131
|
+
const kind = a.amount < 0 ? "expense" : a.amount > 0 ? "income" : categoryKindOf(files, category);
|
|
132
|
+
return { kind, amount: Math.abs(a.amount), account: a.account, category };
|
|
127
133
|
}
|
|
128
134
|
if (t.lines.length === 2 && acc.length === 2) {
|
|
129
|
-
const from = acc.find((l) => l.amount < 0);
|
|
130
|
-
const to = acc.find((l) => l
|
|
131
|
-
return { kind: "transfer", amount: to.amount, account: from.account, to_account: to.account };
|
|
135
|
+
const from = acc.find((l) => l.amount < 0) ?? acc[0];
|
|
136
|
+
const to = acc.find((l) => l !== from);
|
|
137
|
+
return { kind: "transfer", amount: Math.abs(to.amount), account: from.account, to_account: to.account };
|
|
132
138
|
}
|
|
133
139
|
return { lines: t.lines };
|
|
134
140
|
}
|
|
141
|
+
/** A category's side from data/categories.yaml; expense when unknown (system categories, a missing file). */
|
|
142
|
+
function categoryKindOf(files, path) {
|
|
143
|
+
try {
|
|
144
|
+
return flattenCategories(readCats(files)).map.get(path)?.kind === "income" ? "income" : "expense";
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return "expense";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
135
150
|
export function voidTransaction(files, id, reason, meta) {
|
|
136
151
|
const b = buildVoid(files, id, reason, meta);
|
|
137
152
|
return plan(files, b.change, b.message);
|
|
@@ -124,6 +124,8 @@ export function amountOf(text) {
|
|
|
124
124
|
}
|
|
125
125
|
/** A cell that starts with a date. */
|
|
126
126
|
const STARTS_WITH_DATE = /^(\d{1,2}[/.-]\d{1,2}([/.-](\d{4}|\d{2}))?|\d{4}[/.-]\d{1,2}[/.-]\d{1,2})(?![\d])/;
|
|
127
|
+
/** A period line ("21/06/2025 - 20/07/2025", "01/06/2025 đến 30/06/2025"): a statement's header, never a row. */
|
|
128
|
+
const DATE_RANGE_RE = /\d{1,2}[/.]\d{1,2}[/.]\d{2,4}\s*(?:-|–|~|to|den)\s*\d{1,2}[/.]\d{1,2}[/.]\d{2,4}/;
|
|
127
129
|
const hasWord = (text, words) => {
|
|
128
130
|
const p = plain(text);
|
|
129
131
|
return words.some((w) => {
|
|
@@ -200,7 +202,7 @@ export function parseStatement(lines, period, layout = {}, base) {
|
|
|
200
202
|
if (!date || date < lo || date > hi)
|
|
201
203
|
return;
|
|
202
204
|
const text = l.map((c) => c.text).join(" ");
|
|
203
|
-
if (hasWord(text, skips))
|
|
205
|
+
if (hasWord(text, skips) || DATE_RANGE_RE.test(plain(text)))
|
|
204
206
|
return;
|
|
205
207
|
const amounts = [];
|
|
206
208
|
const desc = [];
|
package/dist/worker/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.3.
|
|
1
|
+
export declare const VERSION = "2.3.1";
|
package/dist/worker/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by scripts/version.mjs
|
|
2
|
-
export const VERSION = "2.3.
|
|
2
|
+
export const VERSION = "2.3.1";
|
package/package.json
CHANGED