Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lunchable_splitlunch/lunchmoney_splitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,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, date: datetime.date
self, amount: float, currency_code: str, description: str, date: datetime.date
) -> SplitLunchExpense:
"""
Create and Submit a Splitwise Expense
Expand All @@ -230,6 +230,7 @@ def create_self_paid_expense(
amount=amount
)
new_expense.setCost(cost=amount)
new_expense.setCurrencyCode(currency_code=currency_code)
# CONFIGURE PRIMARY USER
primary_user = splitwise.user.ExpenseUser()
primary_user.setId(id=self.current_user.id)
Expand All @@ -255,7 +256,7 @@ def create_self_paid_expense(
return pydantic_response

def create_expense_on_behalf_of_partner(
self, amount: float, description: str, date: datetime.date
self, amount: float, currency_code: str, description: str, date: datetime.date
) -> SplitLunchExpense:
"""
Create and Submit a Splitwise Expense on behalf of your financial partner.
Expand All @@ -281,6 +282,7 @@ def create_expense_on_behalf_of_partner(
new_expense.setGroupId(self.financial_group)
# GET AND SET AMOUNTS OWED
new_expense.setCost(cost=amount)
new_expense.setCurrencyCode(currency_code=currency_code)
# CONFIGURE PRIMARY USER
primary_user = splitwise.user.ExpenseUser()
primary_user.setId(id=self.current_user.id)
Expand Down Expand Up @@ -450,6 +452,7 @@ def splitwise_to_pydantic(self, expense: splitwise.Expense) -> SplitLunchExpense
splitwise_id=expense.id,
original_amount=expense.cost,
financial_impact=financial_impact,
currency_code=expense.currency_code,
self_paid=self_paid,
description=expense.description,
category=expense.category.name,
Expand Down Expand Up @@ -795,6 +798,7 @@ def make_splitlunch_import(
description = f"{transaction.payee} - {transaction.notes}"
new_transaction = self.create_self_paid_expense(
amount=transaction.amount,
currency_code=transaction.currency.upper(),
description=description,
date=transaction.date,
)
Expand Down Expand Up @@ -881,6 +885,7 @@ def make_splitlunch_direct_import(
description = f"{transaction.payee} - {transaction.notes}"
new_transaction = self.create_expense_on_behalf_of_partner(
amount=transaction.amount,
currency_code=transaction.currency.upper(),
description=description,
date=transaction.date,
)
Expand Down Expand Up @@ -957,6 +962,7 @@ def splitwise_to_lunchmoney(
date=new_date,
payee=splitwise_transaction.description,
amount=splitwise_transaction.financial_impact,
currency=splitwise_transaction.currency_code.lower(),
asset_id=self.splitwise_asset.id,
external_id=str(splitwise_transaction.splitwise_id),
)
Expand Down
1 change: 1 addition & 0 deletions lunchable_splitlunch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SplitLunchExpense(LunchableModel):
original_amount: float
self_paid: bool
financial_impact: float
currency_code: str
description: str
category: str
details: Optional[str] = None
Expand Down
Loading