Skip to content

Command 43 — Create a ticket from a budgetrework

Same operation, new address: the budget id moves from the body to the path. The call itself is simple — but in V1 it was the whole sale, and in V2 it is only the first step of one.

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.

CallPermission
GET /budget/{budgetGID}Sales - Quotes → Edit
POST /invoice/{TicketGID}/payment/{paymethodID}Sales - Tickets → Add payment
PATCH /invoice/{TicketGID}Sales - Tickets → Close
POST /budget/125/sellSales - Quotes → Generate ticket
API V1
curl --location 'https://euapi.flowww.net/v1/fwa_external_get.asp?cmd=43&doctor=USER_LOGIN&pass=USER_PASS&country=ES&key=SYSTEM_KEY' \
--data-urlencode 'BudgetID=125'
API V2
curl --location --request POST 'https://api.flowww.net/v2/budget/125/sell?clinicID=1' \
--header 'Authorization: Bearer <api_key>'
→ { "TicketGID": "329" }

All the products of the budget are transferred to a new open ticket. It is not a sale yet: nothing is charged, the cash desk records nothing and the budget is not marked as sold.

From there, carry on with steps 4–7 of command 19: read the total, add the payments and close the ticket. Porting this command means porting that tail as well — it is the part V1 did for you.

The call creates an open ticket, so everything that applies to a sale applies here: an open ticket blocks the cash desk of the day, and the budget is not marked as sold until that ticket is closed.

Give up on it the same way as in a sale — remove its payments and lines, then delete the empty ticket: see Cleaning up. The budget is left untouched and can be sold again; what you must not do is call this command again “to retry”, because that creates a second ticket for the same budget.

TopicAPI V1API V2
ClinicTaken from the budget.The clinicID you send must be the budget’s clinic; otherwise the call fails.
The budget itselfLeft as it was.The call saves the budget again: its date becomes today, and its validity date, notes and doctor are cleared. Read the budget with GET /budget/{budgetGID} first if you need those values.
Payment and closingOne call: you sent the payment method and V1 charged the ticket and closed it.The call only creates the ticket. Reading the total, the payments (POST /invoice/{TicketGID}/payment/{paymethodID}) and the close (PATCH /invoice/{TicketGID}) are yours — steps 4–7 of command 19.
Budget status—The budget becomes Sold only when the ticket is closed. Until then it can be sold again, and a second call creates a second ticket.
A sale abandoned half-wayNothing was left behind.The open ticket stays, and it prevents closing the cash desk of the day. Remove its payments and lines before deleting it — see Cleaning up.
Rules of the saleMost were skipped.The rules of a normal sale apply: required client fields, cash desk of the day, stock traceability, single-use discounts already expired… See Settings that can block the sale in command 19.
AnswerMeaningWhat to do
400 “Could not create the ticket…”The sale was refused by one of the rules above. This answer carries no errorCode.Check that clinicID is the budget’s clinic, that the client has the required fields, and that the cash desk of the day is open.
409 “Invalid parameters…” (errorCode 16)The budget could not be read.Check the budgetGID.
400 (errorCode 15)The API user lacks Sales → Quotes → Generate ticket.Grant the permission.