updated and cleaned
This commit is contained in:
@@ -16,7 +16,7 @@ def collect_parsed_data_from_mongo_database(mongo_provider) -> list:
|
||||
|
||||
|
||||
def write_parsed_data_to_account_records(
|
||||
file: str, data_dict: dict, collection_name: str, mongo_provider
|
||||
file: str, data_dict: dict, collection_name: str, mongo_provider
|
||||
):
|
||||
db_session = AccountRecords.new_session()
|
||||
data_dict["bank_balance"] = data_dict.pop("balance")
|
||||
@@ -28,7 +28,9 @@ def write_parsed_data_to_account_records(
|
||||
data_dict["bank_date_d"] = bank_date.day
|
||||
data_dict["bank_date_y"] = bank_date.year
|
||||
data_dict["bank_date"] = str(bank_date)
|
||||
if build_iban := BuildIbans.filter_by_one(iban=data_dict["iban"], db=db_session).data:
|
||||
if build_iban := BuildIbans.filter_by_one(
|
||||
iban=data_dict["iban"], db=db_session
|
||||
).data:
|
||||
data_dict.update(
|
||||
{
|
||||
"build_id": build_iban.build_id,
|
||||
@@ -36,7 +38,7 @@ def write_parsed_data_to_account_records(
|
||||
}
|
||||
)
|
||||
if found_record := AccountRecords.filter_one(
|
||||
AccountRecords.bank_date == data_dict["bank_date"],
|
||||
AccountRecords.bank_date == data_dict["bank_date"],
|
||||
AccountRecords.iban == data_dict["iban"],
|
||||
AccountRecords.bank_reference_code == data_dict["bank_reference_code"],
|
||||
AccountRecords.bank_balance == data_dict["bank_balance"],
|
||||
@@ -48,12 +50,13 @@ def write_parsed_data_to_account_records(
|
||||
new_account_record.is_confirmed = True
|
||||
new_account_record.save(db=db_session)
|
||||
mongo_provider.update_one(
|
||||
filter_query={"filename": file}, update_data={"$set": {"stage": "written"}},
|
||||
filter_query={"filename": file},
|
||||
update_data={"$set": {"stage": "written"}},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print('Writer Service is running')
|
||||
print("Writer Service is running")
|
||||
while True:
|
||||
with MongoProvider.mongo_client() as mongo_client:
|
||||
provider = MongoProvider(
|
||||
@@ -71,6 +74,6 @@ if __name__ == "__main__":
|
||||
data_dict=parsed_data,
|
||||
collection_name=provider.collection.name,
|
||||
mongo_provider=provider,
|
||||
file=file_name
|
||||
file=file_name,
|
||||
)
|
||||
time.sleep(60)
|
||||
|
||||
@@ -15,4 +15,3 @@ class BankReceive(BaseModel):
|
||||
process_type: str
|
||||
process_comment: str
|
||||
bank_reference_code: str
|
||||
|
||||
|
||||
Reference in New Issue
Block a user