mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
refactor(folio-spec): use keyedBy for ledger row identity
This commit is contained in:
1 parent
6b50f2dbeb
commit
7b7d051edd
1 file changed
+5
-6
@@ -5,6 +5,7 @@ import {
|
|||||||
always,
|
always,
|
||||||
extract,
|
extract,
|
||||||
from,
|
from,
|
||||||
|
keyedBy,
|
||||||
next,
|
next,
|
||||||
now,
|
now,
|
||||||
weighted,
|
weighted,
|
||||||
@@ -48,12 +49,10 @@ const accounts = extract<Account[]>(s =>
|
|||||||
|
|
||||||
// Ledger rows: identity composed from the row's stable testTag'd cells.
|
// Ledger rows: identity composed from the row's stable testTag'd cells.
|
||||||
const ledgerRows = extract<LedgerRow[]>(s =>
|
const ledgerRows = extract<LedgerRow[]>(s =>
|
||||||
s.ax.findAll([{ testTag: "LedgerScreen" }, { testTag: "LedgerRow" }]).map(row => {
|
s.ax.findAll([{ testTag: "LedgerScreen" }, { testTag: "LedgerRow" }]).map(row => ({
|
||||||
const note = row.find({ testTag: "TxnNote" })?.text ?? "";
|
key: keyedBy(row, ["TxnDate", "TxnNote", "TxnAmount"]),
|
||||||
const date = row.find({ testTag: "TxnDate" })?.text ?? "";
|
signed: parseDollarCents(row.find({ testTag: "TxnAmount" })?.text),
|
||||||
const amount = row.find({ testTag: "TxnAmount" })?.text ?? "";
|
})));
|
||||||
return { key: `${date}|${note}|${amount}`, signed: parseDollarCents(amount) };
|
|
||||||
}));
|
|
||||||
|
|
||||||
const ledgerBalance = extract(s =>
|
const ledgerBalance = extract(s =>
|
||||||
parseDollarCents(s.ax.find({ testTag: "LedgerBalance" })?.text));
|
parseDollarCents(s.ax.find({ testTag: "LedgerBalance" })?.text));
|
||||||
|
|||||||
Reference in new issue
Block a user