From: Dustin Walde Date: Mon, 13 Nov 2023 01:17:51 +0000 (-0800) Subject: Fix repeated txn to not share meta/postings dicts X-Git-Url: https://git.walde.dev/?a=commitdiff_plain;h=c14f46eb2b2c6ed68366e4ddc9f73142c9688c20;p=beanbeanbean Fix repeated txn to not share meta/postings dicts --- diff --git a/src/beanbeanbean/recurring.py b/src/beanbeanbean/recurring.py index 2206112..adca9e6 100644 --- a/src/beanbeanbean/recurring.py +++ b/src/beanbeanbean/recurring.py @@ -113,6 +113,7 @@ def handle_recurring_transaction(txn: Transaction, format_token: str) -> Union[L balances = {} for j, posting in enumerate(txn.postings): post_dict = posting._asdict() + post_dict["meta"] = dict(posting.meta) remaining = post_vals[j] amortized_cost = None @@ -158,16 +159,18 @@ def handle_recurring_transaction(txn: Transaction, format_token: str) -> Union[L post['units'] = amount.sub(post['units'], remainder) break - for pd in new_txn_dict["postings"]: + for j, pd in enumerate(new_txn_dict["postings"]): if pd['cost'] is not None: pd['cost'] = position.Cost(pd['cost'].number, pd['cost'].currency, txn.date, 'amortized') for k, v in pd["meta"].items(): if type(v) is str: pd["meta"][k] = new_txn_dict["date"].strftime(v) - new_txn_dict["postings"].append(Posting(**pd)) + new_txn_dict["postings"][j] = Posting(**pd) else: for posting in txn.postings: - new_txn_dict["postings"].append(posting) + pd = posting._asdict() + pd["meta"] = dict(posting.meta) + new_txn_dict["postings"].append(Posting(**pd)) new_date = new_txn_dict["date"] new_meta = new_txn_dict["meta"]