Exporting Financial Transactions for import into an accounting platform
Not really a typical TFS/VSTS blog post but at least this time I used VSTS for my own benefit and to end up with a fully automated process without any manual intervention.
About a year ago I discovered Revolut, a #fintech digital banking alternative that started in 2015 and since my early experiences I have become a big fan of their platform and how they run their business. It’s all BUT the traditional and painful banking experience we have somehow become familiar with. Finally a bank with a true “customer first” digital culture, without filling and signing a zillion of paper documents from all different parties to get started. First I used Revolut for personal banking and a few months ago I opened a business account for the private company running Techorama.
Older people sit down and ask, ‘What is it?’ but the boy asks, ‘What can I do with it?’. — Steve Jobs
One of the (many) interesting features of Revolut for Business is the Open API to integrate Revolut into your existing business processes. A very frustrating process in the old world (before Revolut) has been to process our credit card transactions (VISA) into our accounting system. Once a month these transactions were sent by post to my home address after which I scanned the documents to pdf files to finally send these to our accountant. Staff members of the accounting firm had to manually input every transaction into the system and validate the various currency transactions with cryptic payment messages. Not quite a smooth process to perform the full matching with the actual invoices and there was always too much delay in getting this done.
My plan was to try the Revolut API and dump all transactions (wire transfer, top-up, credit card payments) for a specific account into a CSV file which can be automatically processed by our accounting platform Yuki.
When doing similar proof of concepts, I like to take the challenge and use some new tools/technology. I haven’t been using Visual Studio Code a lot in the past and wanted to explore a bit more the possibilities with developing/debugging PowerShell scripts inside Visual Studio Code. PowerShell Core 6 was also on my list for exploration and after some tweaking, Visual Studio Code was configured to be my development environment for this exercise.
API call to fetch all accounts and transactions:
$urlAccounts = "https://b2b.revolut.com/api/1.0/accounts"
$urlTransactions = "https://b2b.revolut.com/api/1.0/transactions"Invoke-RestMethod $urlAccounts -Method Get -Authentication Bearer -Token $secureKey
Invoke-RestMethod $urlTransactions -Method Get -Authentication Bearer -Token $secureKey
The $secureKey variable contains the Revolut Api key which can be generated from the settings in your business account.
For dumping the transaction details to a CSV file I’m using the simple Add-Content method. In the end of the script I’m sending the file as attachment to an email address with Send-MailMessage. This result file must of course map with the expected format of your accounting software to be processed automatically without any manual intervention.
Send-MailMessage -To $toEmail -From "email@example.com" -Subject "Export Revolut Transactions BE" -SmtpServer "smtp.gmail.com" -Credential $mycreds -Port 587 -UseSsl -Attachments $exportFileBE
Schedule Export with VSTS
Once the script was working fine, I created a build pipeline in VSTS to call my PowerShell script with a weekly trigger
Because I’m using PowerShell Core 6 which is cross-platform (Windows, macOS and Linux), I can now also choose to run my build in a Hosted Linux Preview agent pool.
This simple automation to export our financial transactions will pay off in the future and lots of manual processing will now be avoided by different parties. It’s a clear win for everyone and we won’t be playing the traditional catch-up game anymore. More time for us to focus on our core business.
Using the right tools offer so many opportunities to integrate and automate boring and repetitive manual tasks. Time is so precious for us at Techorama that we invest a lot in tasks and actions that can be automated. We have become a software company ourselves, relying on a number of critical tools to run our business. Revolut, due to its Open API, has become an important asset in our portfolio of software tools.