Skip to content

Commit c5f2d72

Browse files
committed
fix: fix invoice creation (unbound to session error due to logging)
1 parent ca674d8 commit c5f2d72

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

app/core/abstractions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def query_the_only(self, entity_type: Type[sqlmodel.SQLModel]) -> sqlmodel.SQLMo
259259

260260
def store(self, entity: sqlmodel.SQLModel):
261261
"""Stores the given entity in the database"""
262-
logger.debug(f"storing {entity}")
262+
# logger.debug(f"storing {entity}")
263263
with self.create_session() as session:
264264
session.add(entity)
265265
session.commit()

app/invoicing/data_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import datetime
44

5+
from loguru import logger
6+
57
from core.abstractions import SQLModelDataSourceMixin
68
from core.intent_result import IntentResult
79

@@ -72,6 +74,7 @@ def save_invoice(
7274
invoice: Invoice,
7375
):
7476
"""Creates or updates an invoice with given invoice and project info"""
77+
logger.info(f"Saving invoice {invoice}")
7578
self.store(invoice)
7679

7780
def save_timesheet(self, timesheet: Timesheet):

tuttle/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ class Invoice(SQLModel, table=True):
593593
description="Whether the invoice has been rendered as a PDF.",
594594
)
595595

596+
def __repr__(self):
597+
return f"Invoice(id={self.id}, number={self.number}, date={self.date})"
598+
596599
#
597600
@property
598601
def sum(self) -> Decimal:

0 commit comments

Comments
 (0)