Update CE processing
This commit is contained in:
parent
0354b25bce
commit
40331a39bc
2 changed files with 37 additions and 19 deletions
|
@ -7,22 +7,6 @@ from ofxtools import OFXTree
|
||||||
from ofx_processor.utils.processor import Processor, Line
|
from ofx_processor.utils.processor import Processor, Line
|
||||||
|
|
||||||
|
|
||||||
def _process_name_and_memo(name, memo):
|
|
||||||
if "CB****" in name:
|
|
||||||
conversion = re.compile(r"\d+,\d{2}[a-zA-Z]{3}")
|
|
||||||
match = conversion.search(memo)
|
|
||||||
if match:
|
|
||||||
res_name = memo[: match.start() - 1]
|
|
||||||
res_memo = name + memo[match.start() - 1 :]
|
|
||||||
else:
|
|
||||||
res_name = memo
|
|
||||||
res_memo = name
|
|
||||||
|
|
||||||
return res_name, res_memo
|
|
||||||
|
|
||||||
return name, memo
|
|
||||||
|
|
||||||
|
|
||||||
class BpvfLine(Line):
|
class BpvfLine(Line):
|
||||||
def __init__(self, data=None):
|
def __init__(self, data=None):
|
||||||
super(BpvfLine, self).__init__(data)
|
super(BpvfLine, self).__init__(data)
|
||||||
|
@ -34,10 +18,26 @@ class BpvfLine(Line):
|
||||||
return int(self.data.trnamt * 1000)
|
return int(self.data.trnamt * 1000)
|
||||||
|
|
||||||
def get_memo(self):
|
def get_memo(self):
|
||||||
return _process_name_and_memo(self.data.name, self.data.memo)[1]
|
return self._process_name_and_memo(self.data.name, self.data.memo)[1]
|
||||||
|
|
||||||
def get_payee(self):
|
def get_payee(self):
|
||||||
return _process_name_and_memo(self.data.name, self.data.memo)[0]
|
return self._process_name_and_memo(self.data.name, self.data.memo)[0]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _process_name_and_memo(name: str, memo: str):
|
||||||
|
if "CB****" in name:
|
||||||
|
conversion = re.compile(r"\d+,\d{2}[a-zA-Z]{3}")
|
||||||
|
match = conversion.search(memo)
|
||||||
|
if match:
|
||||||
|
res_name = memo[: match.start() - 1]
|
||||||
|
res_memo = name + memo[match.start() - 1 :]
|
||||||
|
else:
|
||||||
|
res_name = memo
|
||||||
|
res_memo = name
|
||||||
|
|
||||||
|
return res_name, res_memo
|
||||||
|
|
||||||
|
return name, memo
|
||||||
|
|
||||||
|
|
||||||
class BpvfProcessor(Processor):
|
class BpvfProcessor(Processor):
|
||||||
|
|
|
@ -1,10 +1,28 @@
|
||||||
|
import re
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from ofx_processor.processors.bpvf import BpvfProcessor
|
from ofx_processor.processors.bpvf import BpvfProcessor, BpvfLine
|
||||||
|
|
||||||
|
|
||||||
|
class CeLine(BpvfLine):
|
||||||
|
@staticmethod
|
||||||
|
def _process_name_and_memo(name: str, memo: str):
|
||||||
|
name = name.strip()
|
||||||
|
cb_format = re.compile(r"FACT \d{6}$")
|
||||||
|
match = cb_format.search(name)
|
||||||
|
if match:
|
||||||
|
res_name = name[: match.start() - 1].strip()
|
||||||
|
res_memo = name[match.start() - 1 :].strip()
|
||||||
|
else:
|
||||||
|
res_name = name
|
||||||
|
res_memo = memo
|
||||||
|
return res_name, res_memo
|
||||||
|
|
||||||
|
|
||||||
class CeProcessor(BpvfProcessor):
|
class CeProcessor(BpvfProcessor):
|
||||||
account_name = "ce"
|
account_name = "ce"
|
||||||
|
line_class = CeLine
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@click.command("ce", help="Process CE bank statement (OFX)")
|
@click.command("ce", help="Process CE bank statement (OFX)")
|
||||||
|
|
Loading…
Reference in a new issue