usawa

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | Submodules | LICENSE

commit 7d87306f7050dbcbc9674f1f507bfe49d2b6b8c2
parent 6d49f6267dab5e223b53e5d4cbe89e9e150552d2
Author: lash <dev@holbrook.no>
Date:   Sat, 17 Jan 2026 15:32:20 +0000

Remove rencode from sub serializations

Diffstat:
Mdummy/doc/accounts.texi | 15++++++++++++++-
Mdummy/usawa/crypto.py | 7++++++-
Mdummy/usawa/entry.py | 2+-
Mdummy/usawa/ledger.py | 17++++++++++++-----
Mdummy/usawa/unit.py | 8++++++--
5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/dummy/doc/accounts.texi b/dummy/doc/accounts.texi @@ -1,4 +1,17 @@ @chapter Accounts +Accounts are made up of two parts, @emph{type} and @emph{path}. + @anchor{account_type} -@anchor{account_path} +There are four account types: + +@itemize +@item @strong{income}, representing funds moving into the ledger. +@item @strong{expense}, representing funds moving out of the ledger. +@item @strong{asset}, representing value stored in the ledger. +@item @strong{liability}, representing value owed in the ledger. +@end itemize + +Under each type, a path-like identifier may be freely chosen to subdivide the context under each type. This context can in turn be used to obtain granular balances and totals. + +For example, @code{rents/Apartment A} could subdivide an @code{income} account type to separate it from @code{rents/Apartment B} diff --git a/dummy/usawa/crypto.py b/dummy/usawa/crypto.py @@ -248,11 +248,16 @@ class ACL: return r - def serialize(self): + def to_list(self): keys = list(self.rev.keys()) keys.sort() r = [] for k in keys: v = self.axx[self.rev[k]][1] r.append((k, v,)) + return r + + + def serialize(self): + r = self.to_list() return rencode.dumps(r) diff --git a/dummy/usawa/entry.py b/dummy/usawa/entry.py @@ -61,7 +61,7 @@ class EntryPart: account = tree.find('account', namespaces=nsmap()).text return EntryPart(unit, typ, account, amount, debit=debit) - + """Commit the object state to XML. :returns: Same object. diff --git a/dummy/usawa/ledger.py b/dummy/usawa/ledger.py @@ -123,7 +123,7 @@ class RunningTotal: """ """ - def serialize(self): + def to_list(self): d = [ self.sym, varints.leb128s.encode(self.income), @@ -131,8 +131,12 @@ class RunningTotal: varints.leb128s.encode(self.asset), varints.leb128s.encode(self.liability), ] - return rencode.dumps(d) + return d + + def serialize(self): + d = self.to_list() + return rencode.dumps(d) def __str__(self): @@ -677,10 +681,13 @@ class Ledger: def serialize(self): ts = int(self.dt.timestamp()) ts_bytes = ts.to_bytes(4, byteorder='big') - units = self.uidx.serialize() - identities = self.acl.serialize() + #units = self.uidx.serialize() + units = self.uidx.to_list() + #identities = self.acl.serialize() + identities = self.acl.to_list() totals = [] - v = self.running[self.uidx.base].serialize() + #v = self.running[self.uidx.base].serialize() + v = self.running[self.uidx.base].to_list() totals.append(v) for k in self.running.keys(): if k == self.uidx.base: diff --git a/dummy/usawa/unit.py b/dummy/usawa/unit.py @@ -196,8 +196,7 @@ class UnitIndex: r *= -1 return int(r) - - def serialize(self): + def to_list(self): syms = list(self.detail.keys()) syms.sort() units = [] @@ -209,6 +208,11 @@ class UnitIndex: self.base, units, ] + return d + + + def serialize(self): + d = self.to_list() return rencode.dumps(d)