Skip to content

Commit

Permalink
bugfixed ignoring optional entries when processing subtransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbasta committed Mar 23, 2024
1 parent 3b13abf commit 1eae5b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ynabtransactionadjuster/models/subtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ class SubTransaction(BaseModel):
memo: Optional[str] = None

def as_dict(self) -> dict:
return dict(payee_id=self.payee.id,
payee_name=self.payee.name,
category_id=self.category.id,
amount=self.amount,
memo=self.memo)
instance_dict = dict(amount=self.amount)
if self.payee.name:
instance_dict['payee_name'] = self.payee.name
if self.payee.id:
instance_dict['payee_id'] = self.payee.id
if self.category.id:
instance_dict['category_id'] = self.category.id
if self.memo:
instance_dict['memo'] = self.memo
return instance_dict

@model_validator(mode='after')
def check_values(self):
Expand Down

0 comments on commit 1eae5b2

Please sign in to comment.