Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Changes to expand VAT returns for non-FRS VAT #6

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c456f1b
Standard VAT related changes
pubmania Sep 3, 2019
8966ab4
user guidance on how to self host
pubmania Sep 5, 2019
59c78c4
guidance for Heroku Deployment
pubmania Sep 5, 2019
c91d733
Updated guidance to deploy
pubmania Sep 5, 2019
583539f
google sheets mysql guidance
pubmania Sep 5, 2019
f68b398
Guidance to connect googlesheets to mysql
pubmania Sep 5, 2019
0fe68a0
Updated to reflect Standard VAT related changes
pubmania Sep 5, 2019
2ce3c34
Update to reflect Standard VAT change
pubmania Sep 5, 2019
32bb1ce
Update tandc.html
pubmania Sep 5, 2019
9a6414e
Updated screenshot for Std VAT
pubmania Sep 5, 2019
2d9baee
Updated wordings
pubmania Sep 5, 2019
96d146f
Add files via upload
pubmania Sep 5, 2019
cd1bc76
added gif
pubmania Sep 5, 2019
8b7e4a9
Update README.md
pubmania Sep 5, 2019
ef24261
Update README.md
pubmania Sep 5, 2019
54382a8
Update README.md
pubmania Sep 5, 2019
6af259e
Error Handling
pubmania Sep 6, 2019
4aa19f3
Error Handling
pubmania Sep 6, 2019
162fa11
Error Handling
pubmania Sep 6, 2019
012e376
Error Handling
pubmania Sep 6, 2019
1c34bde
Update vatreturn.py
pubmania Sep 6, 2019
e7e2434
Error Handling - Pretify
pubmania Sep 6, 2019
098d690
Error Handling - Pretify
pubmania Sep 6, 2019
f2aed4d
Update preview_return.html
pubmania Sep 6, 2019
b528fb6
Update preview_return.html
pubmania Sep 6, 2019
12fa2e9
Update README.md
pubmania Sep 6, 2019
1ae74ab
Update preview_return.html
pubmania Sep 6, 2019
3dc1282
repositioned the csv submission box
pubmania Sep 6, 2019
8b18b84
Tabbed Home Page
pubmania Sep 6, 2019
c68fa89
Update index.html
pubmania Sep 6, 2019
fa494e2
Pertify Home Page
pubmania Sep 6, 2019
bd8dac9
Layout changes - reduce end user scrolling
pubmania Sep 6, 2019
e4318ae
Remove Scrolling
pubmania Sep 6, 2019
07ad6fc
Remove Scrolling
pubmania Sep 6, 2019
89470b0
restricting confirmation check to verification page
pubmania Sep 6, 2019
36bdff9
rolling back change
pubmania Sep 6, 2019
a8a335a
Changed Layout to reduce scrolling.
pubmania Sep 6, 2019
f29723c
Adjusted layout to remove scrolling
pubmania Sep 6, 2019
7ef2bbd
Changed Error box layout
pubmania Sep 6, 2019
1712026
Gif for updated frontend
pubmania Sep 7, 2019
4b1af04
Gif for updated frontend
pubmania Sep 7, 2019
3409f18
Error Handling
pubmania Sep 10, 2019
f5b6842
Error Handling
pubmania Sep 10, 2019
3f0803d
Error Handling
pubmania Sep 10, 2019
7643649
Update vatreturn.py
pubmania Sep 10, 2019
d91d114
Update send_return.html
pubmania Sep 10, 2019
f685b1d
Update send_return.html
pubmania Sep 10, 2019
81d2321
Corrected a typo
pubmania Sep 10, 2019
2441ffd
Update app.json
pubmania Sep 10, 2019
c897535
Update vatreturn.py
pubmania Sep 10, 2019
fe28e18
Update vatreturn.py
pubmania Sep 10, 2019
0cd9059
Update vatreturn.py
pubmania Sep 10, 2019
af9c444
Update obligations.html
pubmania Sep 10, 2019
52d307d
Update obligations.html
pubmania Sep 10, 2019
40a99e5
Update obligations.html
pubmania Sep 10, 2019
5d80993
Update obligations.html
pubmania Sep 10, 2019
8946a92
Update obligations.html
pubmania Sep 10, 2019
1e68ae3
Update obligations.html
pubmania Sep 10, 2019
992d2f9
Customised Page in case of Server Error
pubmania Sep 17, 2019
998e4cc
Add Customised Error Pages
pubmania Sep 17, 2019
dc43b9f
Add files via upload
pubmania Sep 17, 2019
25df6f4
Update 403.html
pubmania Sep 17, 2019
8e73ae5
Update 404.html
pubmania Sep 17, 2019
10628ef
Update 500.html
pubmania Sep 17, 2019
0e1019a
Update 500.html
pubmania Sep 17, 2019
cd74b95
Update 500.html
pubmania Sep 17, 2019
2667757
Update vatreturn.py
pubmania Sep 17, 2019
ef01551
Update vatreturn.py
pubmania Sep 17, 2019
956aed7
Add files via upload
pubmania Sep 17, 2019
cacd08e
Production Update
pubmania Sep 18, 2019
bddeb54
Update handlers.py
pubmania Sep 18, 2019
9a8dd23
Update vatreturn.py
pubmania Sep 18, 2019
072e3af
Custom CSS
pubmania Sep 18, 2019
9370bce
Merging style changes on base.html to one place
pubmania Sep 18, 2019
5c869f9
Update base.html
pubmania Sep 18, 2019
b17a285
Custom CSS changes
pubmania Sep 18, 2019
a1d522d
Update base.html
pubmania Sep 18, 2019
8214a09
Update base.html
pubmania Sep 18, 2019
98f97ea
Update base.html
pubmania Sep 18, 2019
d3b4b3d
Update main.css
pubmania Sep 18, 2019
bbcff48
Update index.html
pubmania Sep 18, 2019
c023247
Update main.css
pubmania Sep 18, 2019
e0f5b31
Update main.css
pubmania Sep 18, 2019
754a745
Update index.html
pubmania Sep 18, 2019
02580f1
Update preview_return.html
pubmania Sep 19, 2019
387ee58
Update preview_return.html
pubmania Sep 19, 2019
0439bdd
Make confirmation check on frontend
pubmania Sep 21, 2019
615dce8
Update README.md
pubmania Mar 17, 2020
762a896
corrected the bulleting
pubmania Apr 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 101 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
Free, Open Source software for submitting VAT returns to HMRC under their MTD (Making Tax Digital) scheme. Needs some work to support any kind of VAT return.
Free, Open Source software for submitting VAT returns to HMRC under their MTD (Making Tax Digital) scheme. ~~Needs some work to support any kind of VAT return.~~

# About

This software logs you into the HMRC VAT system, and then submits a spreadsheet (which must be in a particular format) as your VAT return. At the moment it only supports flat rate, because that's all I need.
This software logs you into the HMRC VAT system, and then submits a spreadsheet (which must be in a particular format) as your VAT return. This is modified version that supports submission of VAT returns of any kind as it just reads data from the csv for 7 of the 9 boxes, uses that data to compute the remaining two boxes on submission form and then submits the data as VAT return to HMRC.

You could deploy this to Heroku yourself for free (use the button below), or you can use my deployment at https://vatreturn.herokuapp.com - it doesn't store any data, so it's safe to use it from a security point of view. You'll either have to read the code or trust me that the calculations it submits are correct, though.
You could deploy this to Heroku yourself for free (use the button below), or you can use my deployment at https://standard-vat-return.herokuapp.com - it doesn't store any data, so it's safe to use it from a security point of view. You'll either have to read the code or trust me that the calculations it submits are correct, though.

Read more about the app at https://vatreturn.herokuapp.com
~~My deployment is still on HMRC sandbox environment so you will not be able to use it to submit your VAT returns and even if you do deploy your own version you will need to get it approved by HMRC before you can use it. I have submitted approval request for mine and will update here as soon as I have the approval.~~ The app is now approved by HMRC and hence is live on the URL and can be used by anyone for VAT submissions using a CSV file.

Read more about the app at https://standard-vat-return.herokuapp.com

<img src="https://github.com/pubmania/vatreturn/blob/master/img/VAT%20Return%20MTD%20Bridge%20V1.0.gif">


# Deploy
Expand All @@ -19,23 +23,105 @@ Nothing is stored in the app - the data is fetched from a CSV at a URL you defin
# Develop


* [Register application](https://developer.service.hmrc.gov.uk/developer/applications/) and note the `client_id` and `client_secret`
* Set up http://localhost:5000/ as a callback URL within the application registration section of the HMRC interface
* [Create test user](https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/api-platform-test-user/1.0) and note the login number, password, and vat number
* [Register application](https://developer.service.hmrc.gov.uk/developer/applications/)
<img src="https://github.com/pubmania/vatreturn/blob/master/img/App%20Registration%20Step%201.png" width="70%" height="70%">

* Note the `client_id` and `client_secret` - You will need to provide these while deploying on Heroku.
<img src="https://github.com/pubmania/vatreturn/blob/master/img/ClientID%20and%20Client%20Secret.png" width="70%" height="70%">

* Set up the heroku URL (or wherever you have hosted the tool) as a Redirect URL within the application registration section of the HMRC interface
<img src="https://github.com/pubmania/vatreturn/blob/master/img/Add%20Redirect%20URL.png" width="80%" height="80%">

Set environment variables, then:
* [Create test user](https://developer.service.hmrc.gov.uk/api-test-user) and note the login number, password, and vat number
<img src="https://github.com/pubmania/vatreturn/blob/master/img/Test%20User%20Creation.png" width="50%" height="50%">

OAUTHLIB_INSECURE_TRANSPORT=1LASK_DEBUG=1 FLASK_APP=vatreturn.py flask run

* Set environment variables on Heroku as per the image shown below:

- OAUTHLIB_INSECURE_TRANSPORT=1
- FLASK_DEBUG=1
- FLASK_APP=vatreturn.py flask run
- redirect_url = http://localhost:5000/
<img src="https://github.com/pubmania/vatreturn/blob/master/img/Heroku%20Configuration.png">


# Google Sheets format

The CSV you've prepared must match this format. The column headers matter (at the moment):
The CSV you've prepared must match this format. The column headers matter and must be named exactly as shown below:

VAT period SUM of Fee SUM of VAT VAT rate
2019-06-30 1800 360 16.5
2019-06-30 1400 290 16.5
2019-06-30 920 180 16.5
|VAT period |VAT Due Sales |VAT Due Acquisitions |VAT Reclaimed Curr Period |Total Value Sales Ex VAT |Total Value Purchases Ex VAT |Total Value Goods Supplied Ex VAT |Total Acquisitions Ex VAT |
| :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
| 2019-11-30 | 2000 | 0 | 10 | 10000 | 162 | 0 | 0 |
| 2019-08-31 | 4000 | 0 | 3000 | 20000 | 24000 | 0 | 0 |

For me this is a pivot table generated off my invoices spreadsheet,
For me this is a table generated using a mysql query on the google sheet scripts editor getting data from mariadb database,
and I share it using the Google Sheets "publish as CSV" functionality.

I am also providing some guidance on how to connect google sheets to a mysql database but ofcourse this can be a more involved process depending on set-up of your mysql server:

1. In a new googlesheet, open the script editor Tools -> Script Editor, as shown below:
<img src="https://github.com/pubmania/vatreturn/blob/master/img/GoogleSheets%20Step1.png">
2. Now give it a name, a function name and then create connection to your database as shown below:
<img src="https://github.com/pubmania/vatreturn/blob/master/img/Google%20Sheet%20database%20Connection.png">
3. A sample code is as shown below (YOU WILL NEED TO MAKE CHANGES TO CONN VARIABLE, rs2 VARIABLE AND TO doc VARIABLE FOR THIS TO WORK):

```javascript
function your_function_name() {

var conn = Jdbc.getConnection('jdbc:mysql://your.mysqlserver.com:3306/your_database_name', 'database_read_only_username', 'database_read_only_password'); // Change it as per your database credentials

var stmt = conn.createStatement();
var start = new Date(); // Get script starting time

//Create a string containing your query
//change query as per your database structure
var rs2 =
'select date_format(a.expense_date,\'%b-%Y\') as `Month-Year`, b.name as `Category`, sum(a.amount) as `Totals` from expenses a' +
' join expense_categories b on a.expense_category_id = b.id' +
' where a.is_deleted <> \'1\' ' +
' AND PERIOD_DIFF(DATE_FORMAT(CURDATE(),\'%Y%m\'),DATE_FORMAT(a.expense_date,\'%Y%m\'))<12' +
' group by date_format(a.expense_date,\'%b-%Y\'), b.name'

var rs = stmt.executeQuery(rs2);



var doc1 = SpreadsheetApp.getActiveSpreadsheet(); // Returns the currently active spreadsheet
var doc = doc1.getSheetByName('SheetName'); //Enter the sheetname you have given on google sheet

//delete current content on spreadsheet
var start_del, end_del;

start_del = 1;
end_del = doc.getLastRow() - 1;//Number of last row with content
if (end_del = -1) {end_del = 1;}
//blank rows after last row with content will not be deleted

doc.deleteRows(start_del, end_del);
//end delete

var cell = doc.getRange('a1');
var row = 0;
var getCount = rs.getMetaData().getColumnCount(); // Mysql table column name count.

for (var i = 0; i < getCount; i++){
cell.offset(row, i).setValue(rs.getMetaData().getColumnName(i+1)); // Mysql table column name will be fetched and added in spreadsheet.
}

var row = 1;
while (rs.next()) {
for (var col = 0; col < rs.getMetaData().getColumnCount(); col++) {
cell.offset(row, col).setValue(rs.getString(col + 1)); // Mysql table column data will be fetch and added in spreadsheet.
}
row++;
}


rs.close();
stmt.close();
conn.close();
var end = new Date(); // Get script ending time
Logger.log('Time elapsed: ' + (end.getTime() - start.getTime())); // To generate script log. To view log click on View -> Logs.
}
```

8 changes: 4 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "CSV to HMRC flat rate VAT return",
"description": "A simple system for submitting flat rate VAT returns",
"name": "CSV to HMRC VAT return",
"description": "A simple system for submitting VAT returns",
"keywords": [
"oauth"
],
"website": "https://github.com/sebbacon/vatreturn",
"repository": "https://github.com/sebbacon/vatreturn",
"website": "https://github.com/pubmania/vatreturn",
"repository": "https://github.com/pubmania/vatreturn",
"env": {
"HMRC_API_HOST": {
"description": "HMRC api host",
Expand Down
18 changes: 18 additions & 0 deletions handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask import Blueprint, render_template

errors = Blueprint('errors', __name__)


@errors.app_errorhandler(404)
def error_404(error):
return render_template('404.html'), 404


@errors.app_errorhandler(403)
def error_403(error):
return render_template('403.html'), 403


@errors.app_errorhandler(500)
def error_500(error):
return render_template('500.html'), 500
Binary file added img/Add Redirect URL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/App Registration Step 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/ClientID and Client Secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Google Sheet database Connection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/GoogleSheets Step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Heroku Configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Test User Creation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/VAT Return MTD Bridge V1.0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/VAT Return MTD Bridge.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/spreadsheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions static/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
body {
background: #fafafa;
color: #333333;
margin-top: 5rem;
padding-top: 5rem;
}

h1, h2, h3, h4, h5, h6 {
color: #444444;
}

.bg-steel {
background-color: #000000;
}

.navbar-dark .navbar-brand {
color: #f4bc0e;
}

.site-header .navbar-nav .nav-link {
color: #f4bc0e;
}

.btn-primary {
color: #f4bc0e;
background-color: #343a40;
border-color: #343a40
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open>.dropdown-toggle.btn-primary {
color: #fff;
background-color: #155724;
border-color: #155724;
}

.site-header .navbar-nav .nav-link:hover {
color: #ffffff;
}

.site-header .navbar-nav .nav-link.active {
font-weight: 500;
}

.content-section {
background: #ffffff;
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
margin-bottom: 20px;
}

.article-title {
color: #444444;
}

a.article-title:hover {
color: #428bca;
text-decoration: none;
}

.article-content {
white-space: pre-line;
}

.article-img {
height: 65px;
width: 65px;
margin-right: 16px;
}

.article-metadata {
padding-bottom: 1px;
margin-bottom: 4px;
border-bottom: 1px solid #e3e3e3
}

.article-metadata a:hover {
color: #333;
text-decoration: none;
}

.article-svg {
width: 25px;
height: 25px;
vertical-align: middle;
}

.account-img {
height: 125px;
width: 125px;
margin-right: 20px;
margin-bottom: 16px;
}

.account-heading {
font-size: 2.5rem;
}

.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
7 changes: 7 additions & 0 deletions templates/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<div class="content-section">
<h1>You don't have permission to do that (403)</h1>
<p>Please check your account and try again</p>
</div>
{% endblock content %}
7 changes: 7 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<div class="content-section">
<h1>Oops. Page Not Found (404)</h1>
<p>That page does not exist. Please try a different location</p>
</div>
{% endblock content %}
10 changes: 10 additions & 0 deletions templates/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'base.html' %}
{% block content %}
<div class="content-section">
<h1>Something went wrong!!! (500)</h1>
<p>
Please clear the cache of your browser and try again.
If this does not resolve the issue then we're experiencing some trouble on our end. Please try again in the near future.
</p>
</div>
{% endblock content %}
Loading