summaryrefslogtreecommitdiff
path: root/fracture/invoice.py
diff options
context:
space:
mode:
Diffstat (limited to 'fracture/invoice.py')
-rw-r--r--fracture/invoice.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/fracture/invoice.py b/fracture/invoice.py
index e973b8a..e56a44f 100644
--- a/fracture/invoice.py
+++ b/fracture/invoice.py
@@ -180,7 +180,20 @@ class Invoice:
@classmethod
- def load(cls, id, series, type):
+ def load_by_idrepr(cls, id_repr, type="sent"):
+ with sqlite3.connect(cls.DB_FILE) as conn:
+ conn.row_factory = sqlite3.Row
+
+ c = conn.cursor()
+ c.execute("""SELECT id, series, type FROM invoices
+ WHERE id_repr = ? AND type = ?""", (id_repr, type))
+ res = c.fetchone()
+ if res is None:
+ return None
+ return cls.load(res["id"], res["series"], type)
+
+ @classmethod
+ def load(cls, id, series, type="sent"):
with sqlite3.connect(cls.DB_FILE) as conn:
conn.row_factory = sqlite3.Row
@@ -291,15 +304,17 @@ class Invoice:
type,
series,
id,
+ id_repr,
date,
notes,
customer_id,
customer_name,
customer_address
- ) VALUES (?,?,?,?,?,?,?,?)""", (
+ ) VALUES (?,?,?,?,?,?,?,?,?)""", (
self.type,
self.series,
self.id,
+ self.format_id(),
self.date.strftime("%Y-%m-%d"),
self.notes,
self.customer.id,