CSVLoaderBrd.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. '''Created 15 Jun 2023 Levi'''
  2. # from datetime import date
  3. import os
  4. from jinja2 import (Environment, PackageLoader)
  5. from pymt940 import (PaymentsProcessorBrd, private) # utils
  6. templates = Environment(loader=PackageLoader('pymt940', 'templates'))
  7. # body_template = 'body_incomes.txt'
  8. body_template = 'body_payments.txt'
  9. template = templates.get_template(body_template)
  10. home = os.path.expanduser('~')
  11. downloads_dir = os.path.join(home, 'Downloads', 'mentor', 'import', 'KINVEST')
  12. currency = 'ron'
  13. # currency = 'eur'
  14. # currency = 'usd'
  15. # currency = 'huf'
  16. acc_currency = 'accountron'
  17. # acc_currency = 'accounteur'
  18. # acc_currency = 'accountusd'
  19. # acc_currency = 'accounthuf'
  20. processor = PaymentsProcessorBrd(os.path.join(downloads_dir, private.KKINV[currency]), private.KKINV['name'],
  21. account_name=private.KKINV[acc_currency]['name'],
  22. account_number=private.KKINV[acc_currency]['number'],
  23. currency=private.KKINV[acc_currency]['currency'],
  24. account_location=private.KKINV['location'],
  25. account_agency=private.KKINV['agency'],
  26. account_symbol=private.KKINV['symbol'])
  27. if __name__ == '__main__':
  28. if 'incomes' in body_template:
  29. processor.process_income_data(day_slice=(0, 2))
  30. symbol = 411.01
  31. kind = 'TotalIncasari'
  32. output_file = os.path.join(downloads_dir, 'mentor_incasari.txt')
  33. else:
  34. processor.process_payment_data(day_slice=(0, 2))
  35. symbol = 401
  36. kind = 'TotalPlati'
  37. output_file = os.path.join(downloads_dir, 'mentor_plati.txt')
  38. data = processor.to_dict(kind=kind, month_back=1,
  39. std_client='_KK INVESTMENT SRL', acc_symbol=symbol)
  40. output = template.render(data)
  41. print(output)
  42. with open(output_file, 'w') as text:
  43. text.write(output)