|
@@ -10,7 +10,7 @@
|
|
import sys
|
|
import sys
|
|
if sys.argv[1] == '-h':
|
|
if sys.argv[1] == '-h':
|
|
print("""
|
|
print("""
|
|
- usage: ./reconcile.py ~/gnucash/merged.gnucash 2024-02-01 2024-06-10 1 Alcohol Sundries CatFood Cleaning 2T
|
|
|
|
|
|
+ usage: ./reconcile.py ~/gnucash/merged.gnucash 2024-02-01 2024-06-10 1
|
|
""")
|
|
""")
|
|
sys.exit(0)
|
|
sys.exit(0)
|
|
|
|
|
|
@@ -23,11 +23,20 @@ import psycopg
|
|
from app.data.QueryManager import cursor_as_dict
|
|
from app.data.QueryManager import cursor_as_dict
|
|
from app.data.TransactionView import get_session_transactions_statement as get_statement
|
|
from app.data.TransactionView import get_session_transactions_statement as get_statement
|
|
|
|
|
|
-
|
|
|
|
|
|
+DEFAULT_TAGS =[
|
|
|
|
+ 'Alcohol',
|
|
|
|
+ 'Sundries',
|
|
|
|
+ 'CatFood',
|
|
|
|
+ 'Cleaning',
|
|
|
|
+ '2T',
|
|
|
|
+ 'Snack',
|
|
|
|
+ 'Travel',
|
|
|
|
+]
|
|
try:
|
|
try:
|
|
- from db_credentials import HOST, PASSWORD
|
|
|
|
|
|
+ from db_credentials import USER, HOST, PASSWORD
|
|
host = f'host={HOST}'
|
|
host = f'host={HOST}'
|
|
password = f'password={PASSWORD}'
|
|
password = f'password={PASSWORD}'
|
|
|
|
+ user = f'user={USER}'
|
|
except:
|
|
except:
|
|
host = ''
|
|
host = ''
|
|
password = ''
|
|
password = ''
|
|
@@ -43,7 +52,7 @@ STORE_CODES = {
|
|
'ORGANICFOOD': 'TOFS',
|
|
'ORGANICFOOD': 'TOFS',
|
|
'TOFS' : 'TOFS',
|
|
'TOFS' : 'TOFS',
|
|
'WHATAWHATA BERRY FARM': 'Farm',
|
|
'WHATAWHATA BERRY FARM': 'Farm',
|
|
- 'TAUPIRI DAIRY TAUPIRI': 'TD',
|
|
|
|
|
|
+ 'TAUPIRI DAIRY': 'TD',
|
|
'Dreamview Cre': 'DV',
|
|
'Dreamview Cre': 'DV',
|
|
'new world': 'NW',
|
|
'new world': 'NW',
|
|
'BIN INN': 'BI',
|
|
'BIN INN': 'BI',
|
|
@@ -63,8 +72,7 @@ STORE_CODES = {
|
|
'WWNZ' : 'CD',
|
|
'WWNZ' : 'CD',
|
|
}
|
|
}
|
|
|
|
|
|
-user = os.getenv('USER')
|
|
|
|
-conn = psycopg.connect(f"{host} dbname=grocery user={user} {password}")
|
|
|
|
|
|
+conn = psycopg.connect(f"{host} dbname=grocery {user} {password}")
|
|
cur = conn.cursor()
|
|
cur = conn.cursor()
|
|
output = []
|
|
output = []
|
|
|
|
|
|
@@ -155,7 +163,7 @@ def _iter(root, blacklist, whitelist, _from, _to):
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
args = sys.argv
|
|
args = sys.argv
|
|
session = gnucash.Session(args[1])
|
|
session = gnucash.Session(args[1])
|
|
- tags = set()
|
|
|
|
|
|
+ tags = set(DEFAULT_TAGS)
|
|
if len(args) > 5:
|
|
if len(args) > 5:
|
|
for arg in args[5:]:
|
|
for arg in args[5:]:
|
|
tags.add(arg)
|
|
tags.add(arg)
|