Fixed bug with db collection, save the file based on the date and account name
This commit is contained in:
@@ -30,7 +30,7 @@ CONVERTED_DIR = 'Converted'
|
||||
MONGO_URL = os.environ['DB_HOST']
|
||||
MONGO_PORT = os.environ['DB_PORT']
|
||||
MONGO_DB = os.environ['DB_NAME']
|
||||
MONGO_COL = 'hsbc_converter'
|
||||
MONGO_COL = 'imported_transactions'
|
||||
ACCOUNT_COL = 'accounts'
|
||||
|
||||
MONGO_URL = "mongodb://{}:{}".format(MONGO_URL, MONGO_PORT)
|
||||
@@ -118,7 +118,7 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
|
||||
result = mongo_col.insert_one(line_d128)
|
||||
logging.info("New db entry stored: {}".format(result.inserted_id))
|
||||
|
||||
return statement
|
||||
return statement, account['name']
|
||||
|
||||
@staticmethod
|
||||
def unique_path(directory, name_pattern):
|
||||
@@ -153,7 +153,7 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
|
||||
with open(event.src_path, 'r') as file:
|
||||
|
||||
qfx = OfxParser.parse(file, fail_fast=False)
|
||||
statement = Handler.get_statement_from_qfx(qfx)
|
||||
statement, acct_name = Handler.get_statement_from_qfx(qfx)
|
||||
|
||||
path = Path(event.src_path)
|
||||
path.resolve()
|
||||
@@ -162,7 +162,7 @@ class Handler(watchdog.events.PatternMatchingEventHandler):
|
||||
if not converted_dir.exists():
|
||||
converted_dir.mkdir()
|
||||
|
||||
out_file = str(path.parent / CONVERTED_DIR / ('converted' + path.stem + '.csv'))
|
||||
out_file = str(path.parent / CONVERTED_DIR / (acct_name + '-' + qfx.signon.dtserver + '.csv'))
|
||||
Handler.write_csv(statement, out_file)
|
||||
|
||||
#Now move the input file to backup
|
||||
|
||||
Reference in New Issue
Block a user