CSVLoaderBtrl.py 2.0 KB

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