Add support for LCL checks
This commit is contained in:
parent
43f1172ea6
commit
001116fa2c
6 changed files with 48 additions and 12 deletions
|
@ -9,11 +9,17 @@ from ofx_processor.utils.base_ofx import OfxBaseLine, OfxBaseProcessor
|
||||||
|
|
||||||
class LclLine(OfxBaseLine):
|
class LclLine(OfxBaseLine):
|
||||||
def _extract_payee_and_date(self):
|
def _extract_payee_and_date(self):
|
||||||
split = self.data.name.split()
|
|
||||||
default_date = (
|
default_date = (
|
||||||
self.data.dtposted.isoformat().split("T")[0] if self.data.dtposted else None
|
self.data.dtposted.isoformat().split("T")[0] if self.data.dtposted else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.data.trntype.lower() == "check":
|
||||||
|
return "CHQ", default_date
|
||||||
|
|
||||||
|
if not self.data.name:
|
||||||
|
return "", default_date
|
||||||
|
|
||||||
|
split = self.data.name.split()
|
||||||
if not split:
|
if not split:
|
||||||
return "", default_date
|
return "", default_date
|
||||||
|
|
||||||
|
@ -39,6 +45,11 @@ class LclLine(OfxBaseLine):
|
||||||
def get_date(self):
|
def get_date(self):
|
||||||
return self._extract_payee_and_date()[1]
|
return self._extract_payee_and_date()[1]
|
||||||
|
|
||||||
|
def get_memo(self):
|
||||||
|
if self.data.trntype.lower() == "check":
|
||||||
|
return f"CHQ {self.data.checknum}"
|
||||||
|
return super().get_memo()
|
||||||
|
|
||||||
|
|
||||||
class LclProcessor(OfxBaseProcessor):
|
class LclProcessor(OfxBaseProcessor):
|
||||||
line_class = LclLine
|
line_class = LclLine
|
||||||
|
|
|
@ -52,6 +52,13 @@ NEWFILEUID:NONE
|
||||||
<FITID>348 200720 -40045
|
<FITID>348 200720 -40045
|
||||||
<NAME> CB IKEA 17/07/20
|
<NAME> CB IKEA 17/07/20
|
||||||
</STMTTRN>
|
</STMTTRN>
|
||||||
|
<STMTTRN>
|
||||||
|
<TRNTYPE>CHECK
|
||||||
|
<DTPOSTED>20200721
|
||||||
|
<TRNAMT>-42.00
|
||||||
|
<FITID>003 1234567
|
||||||
|
<CHECKNUM>1234567
|
||||||
|
</STMTTRN>
|
||||||
</BANKTRANLIST>
|
</BANKTRANLIST>
|
||||||
<LEDGERBAL>
|
<LEDGERBAL>
|
||||||
<BALAMT>+1000.00
|
<BALAMT>+1000.00
|
||||||
|
|
|
@ -53,6 +53,13 @@ NEWFILEUID:NONE
|
||||||
<FITID>348 200720 -40045
|
<FITID>348 200720 -40045
|
||||||
<NAME> CB IKEA 17/07/20
|
<NAME> CB IKEA 17/07/20
|
||||||
</STMTTRN>
|
</STMTTRN>
|
||||||
|
<STMTTRN>
|
||||||
|
<TRNTYPE>CHECK
|
||||||
|
<DTPOSTED>20200721
|
||||||
|
<TRNAMT>-42.00
|
||||||
|
<FITID>003 1234567
|
||||||
|
<CHECKNUM>1234567
|
||||||
|
</STMTTRN>
|
||||||
</BANKTRANLIST>
|
</BANKTRANLIST>
|
||||||
<LEDGERBAL>
|
<LEDGERBAL>
|
||||||
<BALAMT>+1000.00
|
<BALAMT>+1000.00
|
||||||
|
|
|
@ -12,5 +12,12 @@
|
||||||
"payee_name": "CB IKEA",
|
"payee_name": "CB IKEA",
|
||||||
"memo": null,
|
"memo": null,
|
||||||
"import_id": "YNAB:-400450:2020-07-17:1"
|
"import_id": "YNAB:-400450:2020-07-17:1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"date": "2020-07-21",
|
||||||
|
"amount": -42000,
|
||||||
|
"payee_name": "CHQ",
|
||||||
|
"memo": "CHQ 1234567",
|
||||||
|
"import_id": "YNAB:-42000:2020-07-21:1"
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -15,6 +15,14 @@
|
||||||
"memo": null,
|
"memo": null,
|
||||||
"import_id": "YNAB:-400450:2020-07-17:1",
|
"import_id": "YNAB:-400450:2020-07-17:1",
|
||||||
"account_id": "<YOUR CE ACCOUNT ID>"
|
"account_id": "<YOUR CE ACCOUNT ID>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"date": "2020-07-21",
|
||||||
|
"amount": -42000,
|
||||||
|
"payee_name": "CHQ",
|
||||||
|
"memo": "CHQ 1234567",
|
||||||
|
"import_id": "YNAB:-42000:2020-07-21:1",
|
||||||
|
"account_id": "<YOUR CE ACCOUNT ID>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,19 +1,15 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class OfxTransaction:
|
class OfxTransaction:
|
||||||
"""
|
"""
|
||||||
Mimick what is retrieved via ofxtools when parsing the file
|
Mimick what is retrieved via ofxtools when parsing the file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
name: str = ""
|
||||||
self,
|
memo: str = ""
|
||||||
name: str = "",
|
dtposted: datetime.datetime = None
|
||||||
memo: str = "",
|
trnamt: float = 0
|
||||||
dtposted: datetime.datetime = None,
|
trntype: str = ""
|
||||||
trnamt: float = 0,
|
|
||||||
):
|
|
||||||
self.dtposted = dtposted
|
|
||||||
self.memo = memo
|
|
||||||
self.trnamt = trnamt
|
|
||||||
self.name = name
|
|
||||||
|
|
Loading…
Reference in a new issue