|
@@ -222,10 +222,6 @@ cols = [
|
|
]
|
|
]
|
|
|
|
|
|
#cols.remove(None)
|
|
#cols.remove(None)
|
|
-NON_AUTOFILL_COLUMNS = [
|
|
|
|
- 'ts',
|
|
|
|
- 'store',
|
|
|
|
-]
|
|
|
|
|
|
|
|
NON_IDENTIFIER_COLUMNS = [
|
|
NON_IDENTIFIER_COLUMNS = [
|
|
'ts',
|
|
'ts',
|
|
@@ -236,13 +232,6 @@ NON_IDENTIFIER_COLUMNS = [
|
|
'organic',
|
|
'organic',
|
|
]
|
|
]
|
|
|
|
|
|
-IGNORE_MATCH_COLUMNS = [
|
|
|
|
- 'organic',
|
|
|
|
- 'quantity',
|
|
|
|
- 'price',
|
|
|
|
- 'unit',
|
|
|
|
-]
|
|
|
|
-
|
|
|
|
display_map = {
|
|
display_map = {
|
|
'ts': lambda x: f"{time.strftime('%Y-%m-%d %H:%M', (x.year, x.month, x.day, x.hour, x.minute, 0, 0, 0, 0))}",
|
|
'ts': lambda x: f"{time.strftime('%Y-%m-%d %H:%M', (x.year, x.month, x.day, x.hour, x.minute, 0, 0, 0, 0))}",
|
|
'price': lambda x: f"{x:.2f}",
|
|
'price': lambda x: f"{x:.2f}",
|
|
@@ -263,14 +252,11 @@ def records(cursor, col_idx_map):
|
|
cur.execute("SELECT * FROM transaction_view;")
|
|
cur.execute("SELECT * FROM transaction_view;")
|
|
|
|
|
|
|
|
|
|
-def record_matches(record, ignore_match=IGNORE_MATCH_COLUMNS, strict=None, **kwargs):
|
|
|
|
|
|
+def record_matches(record, strict=None, **kwargs):
|
|
strict = strict or []
|
|
strict = strict or []
|
|
for k,v in kwargs.items():
|
|
for k,v in kwargs.items():
|
|
if not v:
|
|
if not v:
|
|
continue
|
|
continue
|
|
-
|
|
|
|
- if k in ignore_match:
|
|
|
|
- continue
|
|
|
|
|
|
|
|
if k in strict and v.lower() != record[k].lower():
|
|
if k in strict and v.lower() != record[k].lower():
|
|
return False
|
|
return False
|
|
@@ -296,7 +282,7 @@ def suggestions(name, exclude=NON_IDENTIFIER_COLUMNS, **kwargs):
|
|
)
|
|
)
|
|
[ kwargs.pop(k) for k in exclude if k in kwargs]
|
|
[ kwargs.pop(k) for k in exclude if k in kwargs]
|
|
yield from filter(lambda x: record_matches(
|
|
yield from filter(lambda x: record_matches(
|
|
- x, ignore_match=IGNORE_MATCH_COLUMNS, strict=[ k for k in kwargs if k != name ], _print=(name == 'organic' and False), **kwargs
|
|
|
|
|
|
+ x, strict=[ k for k in kwargs if k != name ], **kwargs
|
|
), records(cur, col_idx_map))
|
|
), records(cur, col_idx_map))
|
|
|
|
|
|
def show_or_exit(key):
|
|
def show_or_exit(key):
|
|
@@ -534,7 +520,7 @@ class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
name: value,
|
|
name: value,
|
|
})
|
|
})
|
|
for k,v in self.data.items():
|
|
for k,v in self.data.items():
|
|
- if k in NON_AUTOFILL_COLUMNS or k == name:
|
|
|
|
|
|
+ if k == name or v:
|
|
continue
|
|
continue
|
|
options = unique_suggestions(k, **self.data)
|
|
options = unique_suggestions(k, **self.data)
|
|
if len(options) == 1 and k != 'ts':
|
|
if len(options) == 1 and k != 'ts':
|