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

API Responses #10

Closed
c-myers1 opened this issue Nov 26, 2022 · 12 comments
Closed

API Responses #10

c-myers1 opened this issue Nov 26, 2022 · 12 comments

Comments

@c-myers1
Copy link

Testing some of the APIs, I note the responses are not as described in the docs. Specifically calling domain/add and currency/add gets a reply with only "time" in the response whilst the docs show a fuller response.

Do I have a wrong config somewhere?

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

The test cases return the right response, so something else is going on. Possibly an error of some sort where nothing is returned. Can you share the currency/add request details? I'll try to reproduce in a test environment and see what's going on.

@c-myers1
Copy link
Author

Full disclosure: this is the latest Laravel (PHP 8.2 I suppose). I just sailed up a fresh app and pulled down Abivia. Other weird stuff going on: it created domain, ledger and currency but whilst is responds with 200 to creation of account, no record is inserted in ledger_accounts table.

Also, after installing Abivia, I manually copied the routes under vendor/abivia/ledger/routes into the routes/api file (I thought publishing config would have taken care of all that). So that's what you need to do to reproduce this.

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

I see the problem and have reproduced it. You need to create the ledger first (via api/ledger/root/create), so it is a case of not reporting an error correctly. Fixing that now!

Thanks for the report.

@c-myers1
Copy link
Author

I created a domain and it created records in both ledger_domains and ledger_names. Is that a wrong way to go about it?

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

That should have returned an error too. Creating the ledger sets some critical rules, mostly related to ledger accounts. Without the ledger root, not much will work. Right now it's triggering an unexpected exception and no information is being returned because there's a risk of information disclosure. However details are recorded in the audit log.

I'm going to change the exception so it's handled differently. I'm also going to set it so that at the least an unexpected exception returns a message to say the request failed. I'll add a half dozen test cases to cover this too.

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

To answer your question more directly, creating the ledger root is the first thing you should do before doing anything else.

@c-myers1
Copy link
Author

I really need to understand the model better then. Since I can have multiple "domains" each having their own ledger root, I would have thought the domain comes first. Do I have things muddled up?

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

Domains share the same Chart of Accounts. Each domain is a separate partition in the Journal but they all use the same CoA. The ledger root is the (hidden) parent of all top level accounts, and embeds rules like what an account code can look like, whether or not transactions can be posted to category accounts, and so on.

So the process is to create the ledger. Then you can define accounts, currencies, and domains in any order.

@c-myers1
Copy link
Author

Oh ok, reading here again, that's actually clearly stated. But I first read that a long time ago.

So it means Abivia can't really be used to maintain accounts of multiple entities with different chart of accounts within the same Laravel application then. Correct?

@abivia
Copy link
Owner

abivia commented Nov 26, 2022

That's essentially correct. It's more designed for a single enterprise with multiple divisions/departments/etc. than a multi-tenant configuration.

Possibly the best approach for a multi-tenant application would be to use separate databases.

@c-myers1
Copy link
Author

Very true

@abivia
Copy link
Owner

abivia commented Nov 28, 2022

Fixed in 1.9.0.

@abivia abivia closed this as completed Nov 28, 2022
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

No branches or pull requests

2 participants