12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- '''Created 15 Jun 2023 Levi'''
- # from datetime import date
- import os
- from jinja2 import (Environment, PackageLoader)
- from pymt940 import (PaymentsProcessorOtp, private) # utils
- #
- # Always delete the end block that looks like (find a way for this):
- # "Data","Rulaj debitor","Rulaj creditor"
- # "20231201","0",".27"
- # "20231204","49.68","36444.51"
- # "20231205","3685.5","0"
- # "20231206","4259.79","0"
- # "20231215","25025","0"
- # "20231220","1007","0"
- # "20231221","1299","0"
- # "20231229","4.08","0"
- # "20240101","0",".62"
- #
- templates = Environment(loader=PackageLoader('pymt940', 'templates'))
- # body_template = 'body_incomes.txt'
- body_template = 'body_payments.txt'
- template = templates.get_template(body_template)
- home = os.path.expanduser('~')
- downloads_dir = os.path.join(home, 'Downloads', 'mentor', 'import', 'WEBS')
- currency = 'ron'
- # currency = 'eur'
- # currency = 'card'
- # currency = 'huf'
- acc_currency = 'accountron'
- # acc_currency = 'accounteur'
- # acc_currency = 'accountcard'
- # acc_currency = 'accounthuf'
- processor = PaymentsProcessorOtp(os.path.join(downloads_dir, private.WEBS[currency]), private.WEBS['name'],
- account_name=private.WEBS[acc_currency]['name'],
- account_number=private.WEBS[acc_currency]['number'],
- currency=private.WEBS[acc_currency]['currency'],
- account_location=private.WEBS['location'],
- account_agency=private.WEBS['agency'],
- account_symbol=private.WEBS['symbol'])
- if __name__ == '__main__':
- if 'incomes' in body_template:
- processor.process_income_data(day_slice=(6, 8))
- symbol = 411.01
- kind = 'TotalIncasari'
- output_file = os.path.join(downloads_dir, 'mentor_incasari.txt')
- else:
- processor.process_payment_data(day_slice=(6, 8))
- symbol = 401
- kind = 'TotalPlati'
- output_file = os.path.join(downloads_dir, 'mentor_plati.txt')
- data = processor.to_dict(kind=kind, month_back=1,
- std_client='_WEBS RO SRL', acc_symbol=symbol)
- output = template.render(data)
- print(output)
- with open(output_file, 'w') as text:
- text.write(output)
|