Skip to content

Commit

Permalink
#82 ALL endpoint for GeneralLedger accountregister (#83)
Browse files Browse the repository at this point in the history
* add endpoint ALL AccountRegister

* added test for new added endpoint

* testing for new endpoint

* add accountingProperties end point

* flake8 failure, missing space in inline comment

* test failure, needed to put lines in correct order
  • Loading branch information
timrichardson authored Sep 10, 2023
1 parent cb2af59 commit dc3aea3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ cred = PartnerCredentials(
```

Cache `cred.state` somewhere. You'll use this to rebuild the `PartnerCredentials` instance later.
This object includes a datetime object, so if your cache does not serialise datetime objects, you'll need to find an alternative, such as pickling and saving to a binary database column.

Redirect the user to `cred.url`. There, they will need to log in to MYOB and authorise partnership with your app<sup id="a1">[1](#f1)</sup>. Once they do, they'll be redirected to the Redirect Uri you supplied.

At the url they're redirected to, rebuild the `PartnerCredentials` then pick the verifier out of the request and use it to verify the credentials.
Expand Down Expand Up @@ -79,6 +81,7 @@ comp.id # Company Id
comp.name # Company Name
comp.data # Remaining data as a raw dict.
```
Tip: the companyfiles object specifies all supported managers (that is, endpoints).

Render a dropdown for your user to let them select which of the company files they wish to use. Usually there will only be one against their account, but best to check.
If additional authentication against the company file is needed (ie when the company file account isn't tied via SSO to a my.myob account), prompt them for the username and password for that company file and save this as follows:
Expand Down
4 changes: 3 additions & 1 deletion myob/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .utils import pluralise

ALL = 'ALL'
GET = 'GET'
GET = 'GET' # this method expects a UID as a keyword
POST = 'POST'
PUT = 'PUT'
DELETE = 'DELETE'
Expand Down Expand Up @@ -70,6 +70,8 @@
(CRUD, 'Job/', 'job'),
(ALL, 'JournalTransaction/', 'transaction journal'),
(GET, 'JournalTransaction/', 'transaction journal'),
(ALL, 'AccountRegister/', 'account register'),
(ALL, 'AccountingProperties/', 'accounting property setting'),
]
},
'Inventory/': {
Expand Down
4 changes: 4 additions & 0 deletions tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def test_general_ledger(self):
self.assertEqual(repr(self.companyfile.general_ledger), (
"GeneralLedgerManager:\n"
" account() - Return all accounts for an AccountRight company file.\n"
" accountingproperties() - Return all accounting property settings for an AccountRight company file.\n"
" accountregister() - Return all account registers for an AccountRight company file.\n"
" category() - Return all cost center tracking categories for an AccountRight company file.\n"
" delete_account(uid) - Delete selected account.\n"
" delete_category(uid) - Delete selected cost center tracking category.\n"
Expand Down Expand Up @@ -346,6 +348,8 @@ def test_general_ledger(self):
self.assertEndpointReached(self.companyfile.general_ledger.post_category, {'data': DATA}, 'POST', f'/{CID}/GeneralLedger/Category/')
self.assertEndpointReached(self.companyfile.general_ledger.delete_category, {'uid': UID}, 'DELETE', f'/{CID}/GeneralLedger/Category/{UID}/')
self.assertEndpointReached(self.companyfile.general_ledger.journaltransaction, {}, 'GET', f'/{CID}/GeneralLedger/JournalTransaction/')
self.assertEndpointReached(self.companyfile.general_ledger.accountregister, {}, 'GET', f'/{CID}/GeneralLedger/AccountRegister/')
self.assertEndpointReached(self.companyfile.general_ledger.accountingproperties, {}, 'GET', f'/{CID}/GeneralLedger/AccountingProperties/')

def test_inventory(self):
self.assertEqual(repr(self.companyfile.inventory), (
Expand Down

0 comments on commit dc3aea3

Please sign in to comment.