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 route update invoice requires new document_number #3069

Closed
feeedback opened this issue Oct 13, 2023 · 2 comments
Closed

API route update invoice requires new document_number #3069

feeedback opened this issue Oct 13, 2023 · 2 comments
Labels
Milestone

Comments

@feeedback
Copy link

Akaunting version

3.0.17

PHP version

8.1.24

Operating system

Debian GNU/Linux 11

Steps to reproduce

API route PUT {{akaunting_url}}/documents/1?type=invoice&search=type:invoice&status=unpaid

https://www.postman.com/akaunting/workspace/akaunting/request/27090236-ca517d8e-c4b6-452b-b235-edd1d9ada799

Expected result

Invoice updated with same document_number

Actual result

422 Unprocessable Entity

{
    "message": "The document number has already been <strong>taken</strong>. (and 8 more errors)",
    "errors": {
        "document_number": [
            "The document number has already been <strong>taken</strong>."
        ],
        ...
}

Additional comments

I can't use the invoice update route (PUT) because of this validation error
and I can't use the partial invoice update (PATCH) route because such a route does not exist
Also, I can’t use the /:id/cancelled or /:id/unpaid route because they don’t exist either.

Relevant log output

No response

@vitis586
Copy link

Same applies to updating of a transaction. I think that it is by design. I am updating a transaction in one of my workflows and I update directly the db entry. If you have to use the API to update the invoice (or anything else in Akaunting I guess) I suggest you do the required update and change the document number to some high number. Then you update it again with the original number. It costs you two transactions but it is the only workaround so far.

@CihanSenturk
Copy link
Member

Hello,

The reason for this issue is that the update method is PUT. Try updating with PATCH.
In this PR, I fixed the issue in the PUT method. The problem will be solved in the new version.

Best Regards

@cuneytsenturk cuneytsenturk added this to the 3.1.5 milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants