Command 41 — Update budgetsmulti-step
Same building blocks as command 40, applied to an existing BudgetGID. The field mapping of command 40 holds.
Permissions
Section titled “Permissions”V2 checks an app permission on every call — V1 checked none — and a call whose permission is missing answers 400 with errorCode 15, the same status as an invalid payload (see 4.4). Grant these to the API user before porting the command; the names are the ones of the permission tree in flowww.
| Call | Permission |
|---|---|
PUT /budget/{budgetGID} | Sales - Quotes → Save |
POST /budget/{budgetGID}/detail/product/{productID} | Sales - Quotes → Add product |
PUT /budget/{budgetGID}/detail/{budgetID} | Sales - Quotes → Edit price |
PUT /budget/{budgetGID}/detail/{budgetID}/comment | Sales - Quotes → Edit comments on a quote |
DELETE /budget/{budgetGID}/detail/{budgetID} | Sales - Quotes → Delete Product |
DELETE /budget/{budgetGID} | Sales - Quotes → Delete |
GET /budget/{budgetGID} | Sales - Quotes → Edit |
The flow
Section titled “The flow”An update is not one call either. The order is always the same: read it, change it, save the header whole.
- 1
GET /budget/{budgetGID}
Read it before touching anything: the header comes back whole — you have to resend it whole — and each line inDetails[]carries itsBudgetID
No V1 equivalent - 2
POST /budget/{budgetGID}/detail/product/{productID}
Lines, one call each: add here, change the price withPUT …/detail/{budgetID}, remove withDELETE …/detail/{budgetID}
Products[]ofBudgetdata - 3
PUT /budget/{budgetGID}
The header, always whole and withoutBudgetGStatus: date, validity, notes, salesperson, doctor
The rest ofBudgetdata - 4
PUT /budget/{budgetGID}
The status travels alone,{"BudgetGStatus": n}, never with the header
Undocumented command41b
Every change, call by call:
What to call for each change
Section titled “What to call for each change”| What you want to change | API V2 call |
|---|---|
| Date, validity, notes, salesperson, doctor | PUT /budget/{budgetGID} with the whole header (without BudgetGStatus) |
| Status only | PUT /budget/{budgetGID} with {"BudgetGStatus": n} |
| Add a line | POST /budget/{budgetGID}/detail/product/{productID} |
| Change the price of a line | PUT /budget/{budgetGID}/detail/{budgetID} with {"BudgetPrice": …} (VAT included) |
| Change the units of a line | Delete the line and add it again with the new units. |
| Change the comment of a line | PUT /budget/{budgetGID}/detail/{budgetID}/comment |
| Remove a line | DELETE /budget/{budgetGID}/detail/{budgetID} |
| Delete the whole budget | DELETE /budget/{budgetGID} |
Cleaning up after a failure
Section titled “Cleaning up after a failure”An update leaves nothing orphaned — the budget was already there — but it is not atomic either: each call is saved on its own, so a run that dies half-way leaves the budget half changed, with the lines you had already touched and a header still holding its old values.
There is nothing to delete: read it again with GET /budget/{budgetGID}, compare it with what you meant to leave, and finish the calls that are missing. A line you added and no longer want goes with DELETE /budget/{budgetGID}/detail/{budgetID}.
Retrying the whole update from the start is safe for the header — it is replaced whole — but not for the lines: adding them again adds them twice. Diff before you retry.
What changes compared with V1
Section titled “What changes compared with V1”| Topic | API V1 | API V2 |
|---|---|---|
| Budget id | A new one on every update. | The same one. |
| Sold or accepted budgets | The old budget could not be deleted, so a duplicate was left. | The header and the lines can still be edited, except when the budget has advances. Check the status (GET /budget/{budgetGID}) before editing a budget the client has already accepted. |
| Expired budgets | — | Saving an expired budget sets it back to Pending. |
| Status only | Undocumented command 41b, with no checks. | PUT with BudgetGStatus. Refused if the budget is sold or has advances. |
Errors
Section titled “Errors”| Call | Answer | Meaning |
|---|---|---|
PUT /budget/{id} | 404 168 | BudgetGDate missing, budget sold, or not found. |
PUT /budget/{id} | 404 493 | The budget has advances and can no longer be changed. |
DELETE …/detail/{budgetID} | 404 | Line not found, budget from another clinic (send its clinicID), budget with advances, or a treatment line that cannot be removed. |
DELETE /budget/{id} | 400 513 / 493 | The budget is accepted or sold / has advances. |
Deleting a budget that is already used in a ticket hides it instead of deleting it.