Skip to content

Commit

Permalink
🐛 set splitwise transaction date based on lunchmoney date (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzinnikas authored Aug 19, 2023
1 parent eadd9f2 commit 18e94f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lunchable/plugins/splitlunch/lunchmoney_splitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def split_a_transaction(cls, amount: Union[float, int]) -> Tuple[float, ...]:
return amounts_due

def create_self_paid_expense(
self, amount: float, description: str
self, amount: float, description: str, date: datetime.date
) -> SplitLunchExpense:
"""
Create and Submit a Splitwise Expense
Expand All @@ -291,6 +291,7 @@ def create_self_paid_expense(
# CREATE THE NEW EXPENSE OBJECT
new_expense = splitwise.Expense()
new_expense.setDescription(desc=description)
new_expense.setDate(date=date)
if self.financial_group:
new_expense.setGroupId(self.financial_group)
# GET AND SET AMOUNTS OWED
Expand Down Expand Up @@ -325,7 +326,7 @@ def create_self_paid_expense(
return pydantic_response

def create_expense_on_behalf_of_partner(
self, amount: float, description: str
self, amount: float, description: str, date: datetime.date
) -> SplitLunchExpense:
"""
Create and Submit a Splitwise Expense on behalf of your financial partner.
Expand All @@ -346,6 +347,7 @@ def create_expense_on_behalf_of_partner(
# CREATE THE NEW EXPENSE OBJECT
new_expense = splitwise.Expense()
new_expense.setDescription(desc=description)
new_expense.setDate(date=date)
if self.financial_group:
new_expense.setGroupId(self.financial_group)
# GET AND SET AMOUNTS OWED
Expand Down Expand Up @@ -863,7 +865,9 @@ def make_splitlunch_import(
if transaction.notes is not None:
description = f"{transaction.payee} - {transaction.notes}"
new_transaction = self.create_self_paid_expense(
amount=transaction.amount, description=description
amount=transaction.amount,
description=description,
date=transaction.date,
)
notes = f"Splitwise ID: {new_transaction.splitwise_id}"
if transaction.notes is not None:
Expand Down Expand Up @@ -946,7 +950,9 @@ def make_splitlunch_direct_import(
if transaction.notes is not None:
description = f"{transaction.payee} - {transaction.notes}"
new_transaction = self.create_expense_on_behalf_of_partner(
amount=transaction.amount, description=description
amount=transaction.amount,
description=description,
date=transaction.date,
)
notes = f"Splitwise ID: {new_transaction.splitwise_id}"
if transaction.notes is not None:
Expand Down

0 comments on commit 18e94f8

Please sign in to comment.