From 18e94f8c70d9619546ff94361928b44f1fb2d632 Mon Sep 17 00:00:00 2001 From: Eric Zinnikas <3394214+ericzinnikas@users.noreply.github.com> Date: Sat, 19 Aug 2023 12:25:34 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20set=20splitwise=20transaction=20?= =?UTF-8?q?date=20based=20on=20lunchmoney=20date=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/splitlunch/lunchmoney_splitwise.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lunchable/plugins/splitlunch/lunchmoney_splitwise.py b/lunchable/plugins/splitlunch/lunchmoney_splitwise.py index 740f22f..53502c2 100644 --- a/lunchable/plugins/splitlunch/lunchmoney_splitwise.py +++ b/lunchable/plugins/splitlunch/lunchmoney_splitwise.py @@ -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 @@ -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 @@ -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. @@ -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 @@ -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: @@ -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: