Repository: redstreet/beancount_reds_importers (language: python)

Issue:
Payee / narration fields are possibly switched.
See #55 

I'd like to clean up the situation around payee/narration for good and do the right thing, whatever that is. It's fine to backward compatibility if needed for the benefit of getting this right for the longer run.

If at all you have the time and inclination figure out the full picture and submit a comprehensive solution, that would be great, and I'd rather accept that over the temporary fix of documenting it. If you're not inclined to, that's fine too: this needs to be documented and worked on at some point.

With that said, the things that come to mind are:
- [Beancount reference](https://beancount.github.io/docs/beancount_language_syntax.html#payee-narration)
- solving for the [comment here](https://github.com/redstreet/beancount_reds_importers/blob/64a2fde49424ac6147f2ac97640fb2524a7231e4/beancount_reds_importers/libtransactionbuilder/banking.py#L117)
- solving for the [investments transaction builder](https://github.com/redstreet/beancount_reds_importers/blob/64a2fde49424ac6147f2ac97640fb2524a7231e4/beancount_reds_importers/libtransactionbuilder/investments.py#L23)
- ensuring the current importers don't break (it's okay if they don't do the same thing as earlier, and do the right thing instead; however, they shouldn't crash)
- ensuring `smart_importer` works correctly with the solution
- documenting methods to fix backward compatibility for users
Payee / narration fields are possibly switched.
See #55 

I'd like to clean up the situation around payee/narration for good and do the right thing, whatever that is. It's fine to backward compatibility if needed for the benefit of getting this right for the longer run.

If at all you have the time and inclination figure out the full picture and submit a comprehensive solution, that would be great, and I'd rather accept that over the temporary fix of documenting it. If you're not inclined to, that's fine too: this needs to be documented and worked on at some point.

With that said, the things that come to mind are:
- [Beancount reference](https://beancount.github.io/docs/beancount_language_syntax.html#payee-narration)
- solving for the [comment here](https://github.com/redstreet/beancount_reds_importers/blob/64a2fde49424ac6147f2ac97640fb2524a7231e4/beancount_reds_importers/libtransactionbuilder/banking.py#L117)
- solving for the [investments transaction builder](https://github.com/redstreet/beancount_reds_importers/blob/64a2fde49424ac6147f2ac97640fb2524a7231e4/beancount_reds_importers/libtransactionbuilder/investments.py#L23)
- ensuring the current importers don't break (it's okay if they don't do the same thing as earlier, and do the right thing instead; however, they shouldn't crash)
- ensuring `smart_importer` works correctly with the solution
- documenting methods to fix backward compatibility for users


Discussion / hints:

Fix patch:
diff --git a/beancount_reds_importers/importers/capitalonebank/360Checking.qfx b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx
new file mode 100644
index 0000000..0a833c4
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx
@@ -0,0 +1,75 @@
+<?OFX OFXHEADER="200" VERSION="202" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>
+<OFX>
+  <SIGNONMSGSRSV1>
+    <SONRS>
+      <STATUS>
+        <CODE>0</CODE>
+        <SEVERITY>INFO</SEVERITY>
+      </STATUS>
+      <DTSERVER>20230310048208.398</DTSERVER>
+      <LANGUAGE>ENG</LANGUAGE>
+      <FI>
+        <ORG>Capital One Bank</ORG>
+        <FID>1001</FID>
+      </FI>
+      <INTU.BID>1236</INTU.BID>
+    </SONRS>
+  </SIGNONMSGSRSV1>
+  <BANKMSGSRSV1>
+    <STMTTRNRS>
+      <TRNUID>0</TRNUID>
+      <STATUS>
+        <CODE>0</CODE>
+        <SEVERITY>INFO</SEVERITY>
+      </STATUS>
+      <STMTRS>
+        <CURDEF>USD</CURDEF>
+        <BANKACCTFROM>
+          <BANKID>031176110</BANKID>
+          <ACCTID>9876</ACCTID>
+          <ACCTTYPE>CHECKING</ACCTTYPE>
+        </BANKACCTFROM>
+        <BANKTRANLIST>
+          <DTSTART>20230109050000.000</DTSTART>
+          <DTEND>20230309040000.000</DTEND>
+
+          <STMTTRN>
+            <TRNTYPE>CREDIT</TRNTYPE>
+            <DTPOSTED>20230228050000.000</DTPOSTED>
+            <TRNAMT>0.01</TRNAMT>
+            <FITID>202302283828</FITID>
+            <MEMO>Monthly Interest Paid</MEMO>
+          </STMTTRN>
+
+          <STMTTRN>
+            <TRNTYPE>CREDIT</TRNTYPE>
+            <DTPOSTED>20230119050000.000</DTPOSTED>
+            <TRNAMT>888.99</TRNAMT>
+            <FITID>202301191113</FITID>
+            <MEMO>Deposit from BEAN COUNTERS PAYROLL</MEMO>
+          </STMTTRN>
+
+          <STMTTRN>
+            <TRNTYPE>DEBIT</TRNTYPE>
+            <DTPOSTED>20230117050000.000</DTPOSTED>
+            <TRNAMT>-100</TRNAMT>
+            <FITID>202301171112</FITID>
+            <MEMO>Withdrawal from AMERICAN EXPRESS ACH PMT</MEMO>
+          </STMTTRN>
+          <STMTTRN>
+            <TRNTYPE>CREDIT</TRNTYPE>
+            <DTPOSTED>20230112050000.000</DTPOSTED>
+            <TRNAMT>444.55</TRNAMT>
+            <FITID>202301121111</FITID>
+            <MEMO>Deposit from BEAN COUNTERS PAYROLL</MEMO>
+          </STMTTRN>
+
+        </BANKTRANLIST>
+        <LEDGERBAL>
+          <BALAMT>4321.98</BALAMT>
+          <DTASOF>20230310048208.39</DTASOF>
+        </LEDGERBAL>
+      </STMTRS>
+    </STMTTRNRS>
+  </BANKMSGSRSV1>
+</OFX>
diff --git a/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.extract b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.extract
new file mode 100644
index 0000000..9a9fb4e
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.extract
@@ -0,0 +1,14 @@
+
+2023-01-12 * "Deposit from BEAN COUNTERS PAYROLL" ""
+  Assets:Banks:CapitalOne  444.55 USD
+
+2023-01-17 * "Withdrawal from AMERICAN EXPRESS ACH PMT" ""
+  Assets:Banks:CapitalOne  -100 USD
+
+2023-01-19 * "Deposit from BEAN COUNTERS PAYROLL" ""
+  Assets:Banks:CapitalOne  888.99 USD
+
+2023-02-28 * "Monthly Interest Paid" ""
+  Assets:Banks:CapitalOne  0.01 USD
+
+2023-03-01 balance Assets:Banks:CapitalOne                         4321.98 USD
diff --git a/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_account b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_account
new file mode 100644
index 0000000..b5120d7
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_account
@@ -0,0 +1,1 @@
+Assets:Banks:CapitalOne
diff --git a/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_date b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_date
new file mode 100644
index 0000000..07a2bd0
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_date
@@ -0,0 +1,1 @@
+2023-03-09T04:00:00
diff --git a/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_name b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_name
new file mode 100644
index 0000000..2bfe11d
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/360Checking.qfx.file_name
@@ -0,0 +1,1 @@
+360Checking.qfx


Test patch:
diff --git a/beancount_reds_importers/importers/capitalonebank/capitalone_test.py b/beancount_reds_importers/importers/capitalonebank/capitalone_test.py
new file mode 100644
index 0000000..6ca6ac9
--- /dev/null
+++ b/beancount_reds_importers/importers/capitalonebank/capitalone_test.py
@@ -0,0 +1,16 @@
+from os import path
+from beancount.ingest import regression_pytest as regtest
+from beancount_reds_importers.importers import capitalonebank
+
+
+@regtest.with_importer(
+    capitalonebank.Importer(
+        {
+            "account_number": "9876",
+            "main_account": "Assets:Banks:CapitalOne",
+        }
+    )
+)
+@regtest.with_testdir(path.dirname(__file__))
+class TestCapitalOne(regtest.ImporterTestBase):
+    pass