Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature] - Add new Bank Sync Functionality #25

Closed
latetedemelon opened this issue Jun 3, 2024 · 2 comments · Fixed by #27
Closed

[New Feature] - Add new Bank Sync Functionality #25

latetedemelon opened this issue Jun 3, 2024 · 2 comments · Fixed by #27

Comments

@latetedemelon
Copy link

Thanks for all the hard work putting this together. Please consider this request to add the new bank sync functionality:

actualbudget/actual#2683

@bvanelli
Copy link
Owner

bvanelli commented Jun 3, 2024

Hello @latetedemelon , thanks for your interest in the project! I was planning to integrate such functionality. I mapped the API calls from the

I think this info is for now enough for the API models, but the resolution of the transactions is unfortunatelly not that straight forward (at least I know by lookimg at actual source code that you also have to resolve edge cases, like transactions added manually, ending balance that does not match, etc). Since this is a bigger issue I'll focus first on getting the pip release ready (#14) and then try to implement this functionality.

For reference, here is the flow for Simplefin (since they have a beta token easily available):

  • Frontend registers by posting to /secret using the body {"name": "simplefin_token", "value": "raw token"}. Response is {"status": "ok"}
  • There is a post request to figure out which syncronization methods are already configured (for some reason, this is a POST with empty dict): /gocardless/status and /simplefin/status. Response is {"status":"ok","data":{"configured":true}}
  • You can then query, in this case, which account you want to syncronize. For Simplefin, POST to /simplefin/accounts with empty dict. The response somehow seems to contain exactly (a very arbitrary number of) 57 of the oldest transactions. The response is something like:
{
   "status":"ok",
   "data":{
      "accounts":[
         {
            "org":{
               "domain":"example.com",
               "sfin-url":"https://beta-bridge.simplefin.org/simplefin"
            },
            "id":"Demo Savings",
            "name":"SimpleFIN Savings",
            "currency":"USD",
            "balance":"115524.49",
            "available-balance":"115524.49",
            "balance-date":1719792000,
            "transactions":[
               {
                  "id":"1717315200",
                  "posted":1717315200,
                  "amount":"-10.00",
                  "description":"Fishing bait",
                  "payee":"John's Fishin Shack",
                  "memo":"JOHNS FISHIN SHACK BAIT"
               }
            ],
            "holdings":[
               {
                  "id":"25bc4910-4cb4-437b-9924-ee98003651c5",
                  "created":345427200,
                  "cost_basis":"55.00",
                  "currency":"USD",
                  "description":"Shares of Apple",
                  "market_value":"105884.8",
                  "purchase_price":"0.10",
                  "shares":"550.0",
                  "symbol":"AAPL"
               }
            ]
         },
         {
            "org":{
               "domain":"example.com",
               "sfin-url":"https://beta-bridge.simplefin.org/simplefin"
            },
            "id":"Demo Checking",
            "name":"SimpleFIN Checking",
            "currency":"USD",
            "balance":"26134.41",
            "available-balance":"26134.41",
            "balance-date":1719792000,
            "transactions":[
               {
                  "id":"1717315200",
                  "posted":1717315200,
                  "amount":"-13.31",
                  "description":"Fishing bait",
                  "payee":"John's Fishin Shack",
                  "memo":"JOHNS FISHIN SHACK BAIT"
               }
            ],
            "holdings":[
               
            ]
         }
      ]
   }
}
  • Apparently we can also query the transactions via the endpoint /simplefin/transactions with POST data {"accountId":"Demo Checking","startDate":"2024-03-05"}. The second call used start date as 2024-04-03 that was the latest date from the previous sync. The response for the first call was:
{
   "status":"ok",
   "data":{
      "balances":[
         {
            "balanceAmount":{
               "amount":"26134.41",
               "currency":"USD"
            },
            "balanceType":"expected",
            "referenceDate":"2024-07-01"
         },
         {
            "balanceAmount":{
               "amount":"26134.41",
               "currency":"USD"
            },
            "balanceType":"interimAvailable",
            "referenceDate":"2024-07-01"
         }
      ],
      "startingBalance":2613441,
      "transactions":{
         "all":[
            {
               "booked":true,
               "bookingDate":"2024-04-03",
               "date":"2024-04-03",
               "debtorName":"John's Fishin Shack",
               "remittanceInformationUnstructured":"Fishing bait",
               "transactionAmount":{
                  "amount":"-19.96",
                  "currency":"USD"
               },
               "transactionId":"1712131200",
               "valueDate":"2024-04-03"
            },
            {
               "booked":true,
               "bookingDate":"2024-04-03",
               "date":"2024-04-03",
               "debtorName":"Grocery store",
               "remittanceInformationUnstructured":"Grocery store",
               "transactionAmount":{
                  "amount":"-163.36",
                  "currency":"USD"
               },
               "transactionId":"1712160000",
               "valueDate":"2024-04-03"
            },
         ],
         "booked":[
            {
               "booked":true,
               "bookingDate":"2024-04-03",
               "date":"2024-04-03",
               "debtorName":"John's Fishin Shack",
               "remittanceInformationUnstructured":"Fishing bait",
               "transactionAmount":{
                  "amount":"-19.96",
                  "currency":"USD"
               },
               "transactionId":"1712131200",
               "valueDate":"2024-04-03"
            },
            {
               "booked":true,
               "bookingDate":"2024-04-03",
               "date":"2024-04-03",
               "debtorName":"Grocery store",
               "remittanceInformationUnstructured":"Grocery store",
               "transactionAmount":{
                  "amount":"-163.36",
                  "currency":"USD"
               },
               "transactionId":"1712160000",
               "valueDate":"2024-04-03"
            }
         ],
         "pending":[
            
         ]
      }
   }
}

@JaxOfDiamonds
Copy link

I literally came here to ask the same! But thinking about it - I wonder if integrating with SimpleFin directly and then adding the transactions with the API would give extra control. Though that is likely beyond the scope of this project.t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants