-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test-fraud command to unit-test.sh. Added setup.sh.
- Loading branch information
Showing
12 changed files
with
378 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# HACKY WINDOWS GIT BASH CONSOLE ONLY: Check for Admin privs using the help output from an admin-only windows command | ||
if [[ $(sfc 2>&1 | tr -d '\0') =~ SCANNOW ]]; then | ||
if [[ -f $(dirname $(which python))/scripts/gnucash-uk-vat ]]; then | ||
echo "Update gnucash-uk-vat" | ||
# python -m pip install --upgrade --force-reinstall . 2>&1 | tee setup.log | ||
python -m pip install --upgrade . 2>&1 | tee setup.log | ||
else | ||
echo "Install gnucash-uk-vat" | ||
python -m pip install . 2>&1 | tee setup.log | ||
fi | ||
else | ||
echo "ERROR: setup.sh must be run in a console with Administrator priviledges" | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Test Suite to run tests against HMRC sandbox. | ||
|
||
|
||
Open a console (Git Bash for Windows) in the 'test' directory. | ||
|
||
# Help | ||
Display the help using: | ||
./unit-test.sh help | ||
|
||
Create a config file to allow access to HMRC. | ||
./unit-test.sh config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"accounts": { | ||
"kind": "piecash", | ||
"file": "hmrc-test.sqlite3.gnucash", | ||
"vatDueSales": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :[email protected]%:0000-05", | ||
"vatDueAcquisitions": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"totalVatDue": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :[email protected]%:0000-05", | ||
"vatReclaimedCurrPeriod": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"netVatDue": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :[email protected]%:0000-05", | ||
"totalValueSalesExVAT": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :FRV Turnover:0000-05", | ||
"totalValuePurchasesExVAT": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"totalValueGoodsSuppliedExVAT": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"totalAcquisitionsExVAT": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"liabilities": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount", | ||
"bills": "Retained Earnings Transfer Account:[AC435=AC36] :[AC32=CP44] :[AC26] :[AC16=CP14=CP39] :[AC12=CP7] :ZeroVatAccount" | ||
}, | ||
"application": { | ||
"profile": "test", | ||
"client-id": "<CLIENT_ID>", | ||
"client-secret": "<CLIENT-SECRET>", | ||
"terms-and-conditions-url": "http://example.com/terms_and_conditions/" | ||
}, | ||
"identity": { | ||
"vrn": "<VRN>", | ||
"device": { | ||
"os-family": "Windows", | ||
"os-version": "8.1", | ||
"device-manufacturer": "ASUSTeK COMPUTER INC.", | ||
"device-model": "G751JY", | ||
"id": "12345678-1234-1234-1234-1234567890" | ||
}, | ||
"user": "account_name", | ||
"local-ip": "192.168.0.100", | ||
"mac-address": "12:34:56:78:90:12", | ||
"time": "2023-01-16T16:33:01.953Z" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# This calls the Fraud API test endpoint on sandbox. Only useful for developers. | ||
import asyncio | ||
import sys | ||
import types | ||
import json | ||
import argparse | ||
|
||
import gnucash_uk_vat.hmrc as hmrc | ||
from gnucash_uk_vat.config import Config | ||
from gnucash_uk_vat.auth import Auth | ||
|
||
# Command-line argument parser | ||
parser = argparse.ArgumentParser(description="Gnucash to HMRC VAT API") | ||
parser.add_argument('--config', '-c', | ||
default='gnucash-uk-vat-test.json', | ||
help='Configuration file (default: gnucash-uk-vat-test.json)') | ||
|
||
# Parse arguments | ||
args = parser.parse_args(sys.argv[1:]) | ||
|
||
|
||
# Loads default config, user and auth | ||
config = Config(args.config) | ||
u = Config() | ||
a = Auth() | ||
|
||
# Use the sandbox service | ||
svc = hmrc.VatTest(config, a, u) | ||
|
||
# Call fraud API and dump out results. This is gonna be a fail on lack of | ||
# gov-vendor-license-ids and gov-lient-multi-factor headers. | ||
|
||
def asyncrun(coro): | ||
# Prevent "RuntimeError: Event loop is closed" on Windows | ||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) | ||
|
||
# asyncio.run introduced in Python 3.7, just use that. | ||
if sys.version_info >= (3, 7): | ||
return asyncio.run(coro) | ||
|
||
# Emulate asyncio.run() | ||
|
||
# asyncio.run() requires a coro, so require it here as well | ||
if not isinstance(coro, types.CoroutineType): | ||
raise TypeError("run() requires a coroutine object") | ||
|
||
loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(loop) | ||
try: | ||
return loop.run_until_complete(coro) | ||
finally: | ||
loop.close() | ||
asyncio.set_event_loop(None) | ||
|
||
try: | ||
resp = asyncrun(svc.test_fraud_headers()) | ||
print(json.dumps(resp, indent=4)) | ||
except Exception as e: | ||
sys.stderr.write("Exception: %s\n" % e) | ||
sys.exit(1) |
Oops, something went wrong.