Skip to content

Commit

Permalink
Formatted Responses and Direct Import Bugfix (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin authored Jan 6, 2022
1 parent 513f4ea commit d72b3e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lunchable/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

__lunchable__ = "lunchable"
__version__ = "0.1.6"
__version__ = "0.1.7"
22 changes: 19 additions & 3 deletions lunchable/plugins/splitlunch/lunchmoney_splitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,15 @@ def make_splitlunch_import(self, tag_transactions: bool = False) -> List[Dict[st
update_response = self.lunchable.update_transaction(transaction_id=transaction.id,
split=[split_object,
reimbursement_object])
update_responses.append(update_response)
formatted_update_response = dict(original_id=transaction.id,
payee=transaction.payee,
amount=transaction.amount,
reimbursement_amount=reimbursement_object.amount,
notes=transaction.notes,
splitwise_id=new_transaction.splitwise_id,
updated=update_response["updated"],
split=update_response["split"])
update_responses.append(formatted_update_response)
# Tag each of the new transactions generated
for split_transaction_id in update_response["split"]:
update_tags = transaction.tags or []
Expand Down Expand Up @@ -874,7 +882,7 @@ def make_splitlunch_direct_import(self, tag_transactions: bool = False) -> List[
notes = f"{transaction.notes} || {notes}"
existing_tags = transaction.tags or []
tags = [tag.name for tag in existing_tags if
tag.name.lower() != self.splitlunch_import_tag.name.lower()]
tag.name.lower() != self.splitlunch_direct_import_tag.name.lower()]
if self.splitwise_tag.name not in tags and tag_transactions is True:
self._raise_nonexistent_tag_error(tags=[SplitLunchConfig.splitwise_tag])
tags.append(self.splitwise_tag.name)
Expand All @@ -883,7 +891,15 @@ def make_splitlunch_direct_import(self, tag_transactions: bool = False) -> List[
notes=notes)
response = self.lunchable.update_transaction(transaction_id=transaction.id,
transaction=update)
update_responses.append(response)
formatted_update_response = dict(original_id=transaction.id,
payee=transaction.payee,
amount=transaction.amount,
reimbursement_amount=transaction.amount,
notes=transaction.notes,
splitwise_id=new_transaction.splitwise_id,
updated=response["updated"],
split=None)
update_responses.append(formatted_update_response)
return update_responses

def splitwise_to_lunchmoney(self, expenses: List[SplitLunchExpense]) -> List[int]:
Expand Down

0 comments on commit d72b3e8

Please sign in to comment.