X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/edit?a=blobdiff_plain;f=ledger.py;h=22e36a38dc095af1c6ca986f53ad03274ef9a623;hb=bd32647c67dd9a4979a39efaf31bfe63c82c72d0;hp=817def60ea1f2f29feeb4a4436496b1f1d2158ad;hpb=4aa69f1601319ceeef640a4c56f9d2b1eb25cd6b;p=misc
diff --git a/ledger.py b/ledger.py
index 817def6..22e36a3 100755
--- a/ledger.py
+++ b/ledger.py
@@ -65,6 +65,10 @@ add_structured_html = """
+
+
+
+
@@ -355,7 +359,6 @@ class LedgerDB(PlomDB):
self.write_text_to_db(text)
def insert_at_date(self, lines, date):
- print("DEBUG insert_at_date")
start_at = 0
if len(self.bookings) > 0:
if date >= self.bookings[-1].date_string:
@@ -371,7 +374,6 @@ class LedgerDB(PlomDB):
return self.write_lines_in_total_lines_at(self.real_lines, start_at, lines)
def update(self, start, end, lines, date):
- print("DEBUG update")
total_lines = self.real_lines[:start] + self.real_lines[end:]
n_original_lines = end - start
start_at = len(total_lines)
@@ -520,6 +522,14 @@ class LedgerDB(PlomDB):
ret += [f' {acc_buffer} {-final_minus} ⬠; assume as to earn in year: {acc_buffer} + {12 - months_passed - 1} * this = {year_needed}']
return ret
+ def add_mirror(self, lines):
+ ret = []
+ bookings, _ = parse_lines(lines)
+ booking = bookings[0]
+ for line in booking.lines[1:]:
+ ret += [f'? {-line[1]} {line[2]}']
+ return ret
+
def ledger_as_html(self):
booking_tmpl = jinja2.Template(booking_html)
single_c_tmpl = jinja2.Template('
') ##
@@ -715,10 +725,15 @@ class LedgerDB(PlomDB):
lines += [f'Assets {amount:.2f} {currency}']
except PlomException:
pass
- if 'add_taxes' in postvars.keys():
+ elif 'add_taxes' in postvars.keys():
lines += self.add_taxes(lines, finish=False)
elif 'add_taxes2' in postvars.keys():
lines += self.add_taxes(lines, finish=True)
+ elif 'replace' in postvars.keys():
+ for i, line in enumerate(lines):
+ lines[i] = line.replace(postvars['replace_from'][0], postvars['replace_to'][0])
+ elif 'add_mirror' in postvars.keys():
+ lines += self.add_mirror(lines)
return lines, add_empty_line