From 6fcea8e2b3714b57432c19359de2f0bd28225905 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sun, 9 Sep 2018 04:12:11 +0200 Subject: [PATCH] Added fallback handling for transactions with unknown dates. --- matemat/db/facade.py | 4 +++- matemat/db/primitives/Transaction.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/matemat/db/facade.py b/matemat/db/facade.py index 2251427..ec44ac9 100644 --- a/matemat/db/facade.py +++ b/matemat/db/facade.py @@ -619,7 +619,9 @@ class MatematDatabase(object): fromdate, min_id = row created: datetime = datetime.fromtimestamp(fromdate) cursor.execute(''' - SELECT t.ta_id, t.value, t.old_balance, t.date, c.ta_id, d.ta_id, m.ta_id, c.product, m.agent, m.reason + SELECT + t.ta_id, t.value, t.old_balance, COALESCE(t.date, 0), + c.ta_id, d.ta_id, m.ta_id, c.product, m.agent, m.reason FROM transactions AS t LEFT JOIN consumptions AS c ON t.ta_id = c.ta_id diff --git a/matemat/db/primitives/Transaction.py b/matemat/db/primitives/Transaction.py index 63e9cf8..964b835 100644 --- a/matemat/db/primitives/Transaction.py +++ b/matemat/db/primitives/Transaction.py @@ -19,6 +19,8 @@ class Transaction: @property def receipt_date(self) -> str: + if self.date == datetime.fromtimestamp(0): + return ' ' date: str = self.date.strftime('%d.%m.%Y, %H:%M') return date