CSVLoaderOtp.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. '''Created 15 Jun 2023 Levi'''
  2. # from datetime import date
  3. import os
  4. from jinja2 import (Environment, PackageLoader)
  5. from pymt940 import (PaymentsProcessorOtp, private) # utils
  6. #
  7. # Always delete the end block that looks like (find a way for this):
  8. # "Data","Rulaj debitor","Rulaj creditor"
  9. # "20231201","0",".27"
  10. # "20231204","49.68","36444.51"
  11. # "20231205","3685.5","0"
  12. # "20231206","4259.79","0"
  13. # "20231215","25025","0"
  14. # "20231220","1007","0"
  15. # "20231221","1299","0"
  16. # "20231229","4.08","0"
  17. # "20240101","0",".62"
  18. #
  19. templates = Environment(loader=PackageLoader('pymt940', 'templates'))
  20. # body_template = 'body_incomes.txt'
  21. body_template = 'body_payments.txt'
  22. template = templates.get_template(body_template)
  23. home = os.path.expanduser('~')
  24. downloads_dir = os.path.join(home, 'Downloads', 'mentor', 'import', 'WEBS')
  25. currency = 'ron'
  26. # currency = 'eur'
  27. # currency = 'card'
  28. # currency = 'huf'
  29. acc_currency = 'accountron'
  30. # acc_currency = 'accounteur'
  31. # acc_currency = 'accountcard'
  32. # acc_currency = 'accounthuf'
  33. processor = PaymentsProcessorOtp(os.path.join(downloads_dir, private.WEBS[currency]), private.WEBS['name'],
  34. account_name=private.WEBS[acc_currency]['name'],
  35. account_number=private.WEBS[acc_currency]['number'],
  36. currency=private.WEBS[acc_currency]['currency'],
  37. account_location=private.WEBS['location'],
  38. account_agency=private.WEBS['agency'],
  39. account_symbol=private.WEBS['symbol'])
  40. if __name__ == '__main__':
  41. if 'incomes' in body_template:
  42. processor.process_income_data(day_slice=(6, 8))
  43. symbol = 411.01
  44. kind = 'TotalIncasari'
  45. output_file = os.path.join(downloads_dir, 'mentor_incasari.txt')
  46. else:
  47. processor.process_payment_data(day_slice=(6, 8))
  48. symbol = 401
  49. kind = 'TotalPlati'
  50. output_file = os.path.join(downloads_dir, 'mentor_plati.txt')
  51. data = processor.to_dict(kind=kind, month_back=1,
  52. std_client='_WEBS RO SRL', acc_symbol=symbol)
  53. output = template.render(data)
  54. print(output)
  55. with open(output_file, 'w') as text:
  56. text.write(output)