Cancel a Sale Order
Cancels the pending quantity of lines of a sale order that is already saved in Logic ERP – for example when your customer cancels some items before they are delivered. You point to the order by Logic ERP's internal number returned when it was saved, or by your party order number, and list the lines to cancel. Only the quantity that is still pending is cancelled: what has already been billed, delivered, reserved or ordered from a supplier stays on the order. Cancelled lines are kept on the order, marked as cancelled. A cancel cannot be undone through the API.
Endpoint
Address
https://your-server/api/CancelSaleOrder
Method
POST
Authorization
Basic Auth
The response and the common messages are explained in How Every API Call Works.
Send one order per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored.
Known issue – always send
ListItems. A request without lines inListItems– meant to cancel the whole order, or the items named inOrderItemCodes– always fails with a long technical message, and nothing is cancelled. List the lines to cancel inListItems. To cancel a whole order, list every item of the order, or cancel it in Logic ERP itself.
Request fields
Branch_Code
number
Yes (or BranchShortName)
0
The branch the order belongs to (Branch_Code in Get Branch Info). It is not checked on its own, but it must be the order's own branch, also when you send SaleOrderCode (see the known issue below).
BranchShortName
text
No
empty
The branch by its short name. Used only when Branch_Code is 0.
SaleOrderCode
number
One of the two ways
0
Logic ERP's internal number of the order – the LastSavedCode you received from Save a Sale Order. When it is above 0, PartyOrderNo is not used. Recommended.
PartyOrderNo
text
One of the two ways
empty
Your order number, as sent in Party_Order_No when the order was saved. Used when SaleOrderCode is 0.
ListItems
list
Yes (see the known issue above)
–
The lines to cancel. See the table below.
Cancel_Reason
text
No
empty
Why the lines are cancelled. Stored with the cancellation, together with the date and time and the note Cancelled From LOGIC Cancel Order API.
OrderItemCodes
text
No
empty
Item codes separated by commas, for example "KUR-BLU-M,KUR-RED-L", used only when ListItems is empty. Does not work – see the known issue above.
DisplayError
text
No
"0"
"1" = when the cancel fails, Message carries the full technical detail instead of the short reason.
Request fields – ListItems
ItemCode
text
Yes
–
The item's code in Logic ERP (LogicUser_Code in Get Item Master). When your Logic ERP works with additional item codes, an additional code (for example the EAN barcode) is also accepted.
Item_Order_ID
text
No
empty
The Item_Order_ID the line was saved with. When filled, only the order line with this ID is cancelled.
User_Col_2
text
No
empty
The User_Column_2 value the line was saved with. Used when Item_Order_ID is empty: only the order lines of the item with this value are cancelled.
CancelQty
number
No
–
Ignored. The whole pending quantity of each matching line is cancelled.
When neither Item_Order_ID nor User_Col_2 is filled, every line of that item in the order is cancelled.
Rules Logic ERP applies
Finding the order
With
SaleOrderCodeabove0, the order with that internal number is used.Otherwise the order with your
PartyOrderNoin the branchBranch_Codeis used. You must send at least one of the two.
Known issue – a
PartyOrderNoused more than once. Logic ERP does not check thatPartyOrderNomatches only one order. When the branch has several orders with that party order number – for example from different customers, or an order saved again – one of them is taken without any rule. If yourListItemsmatch lines of that order, those lines are cancelled – possibly on another customer's order (or, when that order is already cancelled as a whole, the request fails with Sale Order No.… is already Cancelled...); if they do not match, the request fails with Unable to found Item Code : …. SendSaleOrderCodeinstead.
Known issue –
SaleOrderCodeof another branch. The order is looked up bySaleOrderCodealone, but it is cancelled in the branch you send. WhenBranch_Codeis not the order's branch, the request usually fails with technical text containing This Order has been Deleted by another. When the branch you sent has an order with the same voucher number, the request can answerStatus: trueand Sale Order Cancelled Sucessfully... although nothing was cancelled – and if that other order was cancelled earlier, it can be made active again. Always send the order's ownBranch_Code.
Finding the lines
Each entry of
ListItemsmust match at least one line of the order, or nothing is cancelled and you get Unable to found Item Code : ….Only lines that still have a pending quantity and are not already cancelled are cancelled. When none of the matching lines is pending, nothing is cancelled and you get No Pending Item found in Sale Order for Cancel...Please Check. When some listed items have no pending line, nothing is cancelled and the message names them: Item Codes : … not exists in Order. Cannot allowed Sale Order Cancellation.
What blocks a cancel
Nothing is changed when any of these applies:
The whole order is already marked as cancelled in Logic ERP.
The order has no configuration linked to it.
The order was created from a branch order allocation.
The order date is on or before the lock date for changes in Logic ERP.
The order was changed by someone else while the cancel was running.
Approved orders can be cancelled.
What a cancel does
All of the following happen together, or none of them:
For each matching line, the quantity that is still free is cancelled. Free means: not yet billed or delivered, not reserved, not used for production or assembly, and not ordered from a supplier.
A line with nothing used is marked as cancelled as a whole.
A line partly used is split: the used part stays on the line, the free part becomes a separate cancelled line with its share of the discounts and taxes.
A line fully used is left as it is.
The order itself is not marked as cancelled, even when every line has been cancelled. In Logic ERP the order stays open, with its lines marked as cancelled.
The cancellation is recorded with
Cancel_Reason, the date and time, and an entry is written to the audit trail.The cancel runs as the Logic ERP user linked to your API site, so that user's rights and locks apply.
This endpoint does not read your API site's endpoint settings, so switching it off there has no effect on it.
Example request
By the internal number, cancelling one line by its ID and all pending lines of a second item:
By your party order number:
Response
Status
true / false
true when the lines were cancelled.
Message
text
"Sale Order Cancelled Sucessfully..." when cancelled; otherwise the reason.
LastSavedCode
number
Always 0.
request_ID
text
As described on the common page. null when the request failed before the order was found.
Example response
Messages you may see
Some refusals come back as technical text with the reason inside it; the table says which. The reason may be followed by technical detail – read the first line.
Please Define PartyOrderNo / SaleOrderCode to Continue...
Neither SaleOrderCode nor PartyOrderNo was sent.
Send one of them.
Unable to found Sale Order againts Party Order No. … and Branch Code : …
No order with that party order number in the branch.
Check PartyOrderNo and Branch_Code.
Unable to found Item Code : …
An entry of ListItems matches no line of the order – also when no order has that SaleOrderCode.
Check SaleOrderCode, ItemCode, Item_Order_ID and User_Col_2.
Unable to Retrive Sale Order for Cancel...Please Check
No order has that SaleOrderCode (only when ListItems is empty).
Check the number.
Sale Order No.… is already Cancelled...
The whole order is already cancelled in Logic ERP.
Nothing to do.
Configuration Not Linked againts Order...
The order has no configuration.
Cancel it in Logic ERP.
No Pending Item found in Sale Order for Cancel...Please Check
The matching lines have nothing pending, or are already cancelled.
Nothing to cancel.
Item Codes : … not exists in Order. Cannot allowed Sale Order Cancellation.
The named items have no pending line in the order.
Remove them from ListItems.
This order has been created from Branch Order Allocation.... Cannot allow Modification.
The order came from a branch order allocation.
Ask your Logic ERP team.
Technical text containing Modification rights not available for this date.....
The order date is on or before the lock date.
Ask your Logic ERP team.
Technical text containing This Order has been Deleted by another or This Order has been modified by another
Branch_Code is not the order's branch, or the order was changed while cancelling.
Send the order's branch and try again.
Technical text containing No Item Found With Pending Quantity
The order has nothing pending.
Nothing to cancel.
A long technical text about incorrect syntax
ListItems was empty. Nothing was cancelled.
Send the lines in ListItems (see the known issue at the top).
Last updated