|
@@ -36,11 +36,14 @@ STORE_CODES = {
|
|
|
'THE FARM SHOP': 'GFS',
|
|
|
'Dreamview Cre': 'DV',
|
|
|
'new world': 'NW',
|
|
|
+ 'BIN INN': 'BI',
|
|
|
+ 'NEW SAVE': 'NS',
|
|
|
}
|
|
|
|
|
|
user = os.getenv('USER')
|
|
|
conn = psycopg.connect(f"{host} dbname=das user={user} {password}")
|
|
|
cur = conn.cursor()
|
|
|
+output = []
|
|
|
|
|
|
def get_record_from_database(date, store):
|
|
|
cur.execute(get_statement(date, store))
|
|
@@ -59,14 +62,14 @@ def get_store_code(store, value, user_data=dict()):
|
|
|
|
|
|
def _unwrap_list(root, blacklist):
|
|
|
for i in map(lambda x: [
|
|
|
- (':'.join([x[0], c.name]), True) for c in root.get_children()
|
|
|
+ (':'.join([x[0], c.name]), True) for c in root.get_children()
|
|
|
] if x[1] else [ x ], blacklist):
|
|
|
for j in i: yield j
|
|
|
|
|
|
def _accounts(root, path, blacklist, whitelist):
|
|
|
#print('blacklist1: {}'.format(blacklist))
|
|
|
#print(f'whitelist1 ({root.name}: {whitelist}')
|
|
|
-
|
|
|
+
|
|
|
if root.name in [ w[0] for w in whitelist ]:
|
|
|
if root.name not in [ b[0] for b in blacklist ]:
|
|
|
yield path, root
|
|
@@ -140,7 +143,7 @@ if __name__ == '__main__':
|
|
|
_from = int(parse_time(args[2]).timestamp())# 1554030000 # 1 April 2019 as seconds since epoch
|
|
|
_to = int(parse_time(args[3]).timestamp())
|
|
|
_interval = int(args[4])*60*60*24
|
|
|
-
|
|
|
+
|
|
|
ranges = dict([
|
|
|
[
|
|
|
el for el in map(lambda x: datetime.fromtimestamp(x), (i, i+_interval))
|
|
@@ -164,7 +167,9 @@ if __name__ == '__main__':
|
|
|
ts = ts - timedelta(days=1)
|
|
|
book = get_record_from_database(ts, store)
|
|
|
dbentry = f'{ts} {store:5s}' if book == int(value) else ''
|
|
|
- print(f'{d} {desc:35s} | {value/100:>6.2f} | {dbentry}')
|
|
|
-
|
|
|
+ output.append(f'{d} {desc:35s} | {value/100:>6.2f} | {dbentry}')
|
|
|
+
|
|
|
finally:
|
|
|
session.end()
|
|
|
+ for line in output:
|
|
|
+ print(line)
|