fix ofx lcl

This commit is contained in:
Gabriel Augendre 2024-10-14 23:08:13 +02:00
parent c7acfcd099
commit 8f1662a861
2 changed files with 17 additions and 7 deletions

View file

@ -1,5 +1,6 @@
import sys import sys
from datetime import datetime from datetime import datetime
from operator import truediv
import click import click
import dateparser import dateparser
@ -67,19 +68,27 @@ class LclProcessor(OfxBaseProcessor):
click.secho("Couldn't find ofx file", fg="red") click.secho("Couldn't find ofx file", fg="red")
sys.exit(1) sys.exit(1)
if "Content-Type:" in data[0]: new_lines = [line for line in data if is_valid_line(line)]
with open(self.filename, "w") as temp_file:
temp_file.writelines(data[1:]) with open(self.filename, "w") as temp_file:
temp_file.writelines(new_lines)
ofx = super()._parse_file() ofx = super()._parse_file()
if "Content-Type:" in data[0]: with open(self.filename, "w") as temp_file:
with open(self.filename, "w") as temp_file: temp_file.writelines(data)
temp_file.writelines(data)
return ofx return ofx
def is_valid_line(line):
if "Content-Type:" in line:
return False
if "MKTGINFO" in line:
return False
return True
def main(filename, keep, download, send_method, push_to_ynab): def main(filename, keep, download, send_method, push_to_ynab):
"""Import LCL bank statement (OFX file).""" """Import LCL bank statement (OFX file)."""
if download: if download:
@ -91,6 +100,7 @@ def main(filename, keep, download, send_method, push_to_ynab):
) )
filename = LclDownloader().download() filename = LclDownloader().download()
processor = LclProcessor(filename) processor = LclProcessor(filename)
processor.parse_file()
if send_method: if send_method:
processor.send_reconciled_amount(send_method) processor.send_reconciled_amount(send_method)
if push_to_ynab: if push_to_ynab:

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "ofx-processor" name = "ofx-processor"
version = "4.5.1" version = "4.5.2"
description = "Personal ofx processor" description = "Personal ofx processor"
readme = "README.md" readme = "README.md"
authors = ["Gabriel Augendre <gabriel@augendre.info>"] authors = ["Gabriel Augendre <gabriel@augendre.info>"]