generated from felixm/defaultpy
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
import os.path
|
|
import csv
|
|
import logging
|
|
import src.utils
|
|
import src.process
|
|
from src.models import Transaction
|
|
from rich.logging import RichHandler
|
|
from typing import List
|
|
|
|
|
|
def write_mappings(unmatched_transactions: List[Transaction], mappings_directory: str):
|
|
""" Write mappings for unmatched expenses for update by the user. """
|
|
if not unmatched_transactions:
|
|
return
|
|
fn = os.path.join(mappings_directory, "unmatched.csv")
|
|
with open(fn, 'a') as f:
|
|
writer = csv.writer(f)
|
|
for t in unmatched_transactions:
|
|
e = ["expenses", t.description,
|
|
f"credit={t.credit};date={t.date}"]
|
|
writer.writerow(e)
|
|
|
|
|
|
def init_logging():
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(message)s",
|
|
datefmt="[%X]",
|
|
handlers=[RichHandler()],
|
|
)
|
|
|
|
|
|
def main():
|
|
init_logging()
|
|
config = src.utils.load_config()
|
|
src.utils.remove_if_exists(config.output_file)
|
|
src.utils.write_meta(config)
|
|
src.process.process_ldg_files(config)
|
|
src.process.process_csv_files(config)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|