For the complete documentation index, see llms.txt. This page is also available as Markdown.

Cancel a Sale Invoice

Cancels a sale invoice that is already saved in Logic ERP. The invoice is not removed: it stays in Logic ERP marked as cancelled, its number stays used, and everything it had put in place is reversed — the stock comes back, its accounting entries are removed, and loyalty points, discount coupons and gift vouchers linked to it are released. You can point to the invoice by its bill series and number, by your party order number, or by Logic ERP's internal number returned when it was saved. A cancel cannot be undone.

Endpoint

Name
Detail

Address

https://your-server/api/CancelSaleBill

Method

POST

Authorization

Basic Auth

The response and the common messages are explained in How Every API Call Works.

Send one invoice per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored.

Request fields

Field
Type
Required
Default
Meaning

Branch_Code

number

Yes (in practice)

0

The branch the invoice belongs to (Branch_Code in Get Branch Info). The invoice is looked for in this branch only, so with 0 it is never found. A branch short name is not accepted here.

DocCode

number

One of the three ways

0

Logic ERP's internal number of the invoice – the LastSavedCode you received when you saved it with Save a Sale Invoice. When it is above 0, BillSeries, Bill_No and PartyOrderNo are not used.

BillSeries

text

One of the three ways

empty

The bill series of the invoice as shown in Logic ERP, for example "WSL". Must be a sale series of the branch. Use it together with Bill_No.

Bill_No

number

With BillSeries

0

The invoice number within the series, for example 59. Send a number only, not text such as "WSL-59".

PartyOrderNo

text

One of the three ways

empty

Your own order number that was sent as the party order number when the invoice was saved. Used when DocCode is 0 and the invoice was not found by series and number.

Cancel_Reason

text

Yes

–

Why the invoice is cancelled. Stored with the cancellation, together with the Logic ERP user, date and time.

DisplayError

text

No

"0"

"1" = when the cancel fails, Message carries the full technical detail instead of the short reason. Useful when the short message does not say why (see the known issue below).

Rules Logic ERP applies

Finding the invoice

  • The invoice must belong to the branch in Branch_Code and to the current financial year – the year that contains today's date on the server. An invoice of an earlier year is not found; cancel it in Logic ERP itself.

  • With DocCode above 0, the invoice with that internal number is used.

  • Otherwise BillSeries + Bill_No are tried first. The series must exist in the branch as a sale series, or the request fails with Unable to Retrive Bill Series : …. If no invoice has that number, Logic ERP then looks for the PartyOrderNo.

  • PartyOrderNo must match exactly one invoice of the branch in the current year. If more than one invoice carries it, nothing is cancelled and you get Duplicate Bill exists againts Party Order No. ….

  • You must send at least DocCode, or BillSeries with Bill_No, or PartyOrderNo.

Known issue – a wrong bill number with an empty PartyOrderNo. If the series exists but no invoice has the Bill_No you sent, and PartyOrderNo is empty, Logic ERP looks for an invoice whose party order number is blank. Usually there are many and the request fails with Duplicate Bill exists againts Party Order No. …; but if the branch has exactly one invoice with a blank party order number in the current year, that invoice is cancelled instead. Check the bill number before you send it, or send DocCode, or fill PartyOrderNo.

Known issue – a DocCode that is not found. If no invoice of the branch and the current year has the DocCode you sent, the request does not answer Unable to found Document…; it fails with a short technical database error in Message. Nothing is cancelled. Check the DocCode, the Branch_Code and the year.

Known issue – DocCode of a sale return. DocCode is not checked to be a sale invoice. If it belongs to a sale return of the same branch and year, that return is cancelled. Send only the LastSavedCode of a sale invoice.

What blocks a cancel

Nothing is changed when any of these applies:

  • The invoice is already cancelled.

  • Cancel_Reason is empty.

  • A GST e-invoice (IRN) has been generated for it.

  • It has been marked as posted in Logic ERP's document posting.

  • It was transferred to head office, exported to another branch or imported from another branch, when the user rights of your API user stop changes to such documents.

  • The invoice date is in a period that is locked for entry or modification, is on or before the lock date for modifications, or is on or before the last physical stock entry date (when that lock is switched on).

  • It has been approved, when approved documents may not be changed.

  • Payments or receipts have been adjusted against it, when bills with payments are locked in the user rights. When they are not locked, the cancel goes ahead and those adjustments are removed from the invoice.

  • A GST advance receipt has been adjusted against it, it is in an excise register, it is linked to a retail customer discount package (when discount packages are switched on), or it was changed by someone else while the cancel was running.

  • Cancelling would make the stock of a lot negative, when negative stock is not allowed.

  • The invoice was used to calculate a customer bonus.

Known issue – invoices made from goods sent on approval. For an invoice that is linked to a sale-on-approval document and contains approval lots, the request answers Status: true and Success, but nothing is cancelled. Check such invoices in Logic ERP and cancel them there.

What a cancel does

All of the following happen together, or none of them (a failure part-way undoes everything):

  • The invoice and its lines are marked as cancelled and kept. Its number is not freed for re-use.

  • Stock of the lines sold directly comes back to the godown it was sold from. Lines that were billed from a sale challan or a packing slip go back to that document instead (see the next point), and lines that do not affect stock are left as they are.

  • Quantities taken from sale orders, sale challans, delivery orders and packing slips become pending again on those documents.

  • Its accounting entries are removed, including TDS and TCS entries, and receipts adjusted against it are unlinked.

  • Loyalty points earned or redeemed on the invoice are removed from the customer's points ledger.

  • Discount coupons used on the invoice are released for use again, and gift vouchers linked to it are unlinked from it.

  • Employee-discount ledger entries, scheme and free-item records, customer discount card entries, retail customer ledger entries, warranty, home delivery, alteration and appointment links of the invoice are removed.

  • The reason, the Logic ERP user and the date and time are recorded, and an entry is written to the audit trail.

After the cancel

  • A cancelled invoice cannot be cancelled again (Document has already been cancelled...), and there is no endpoint that un-cancels it.

  • The cancel runs as the Logic ERP user linked to your API site, so that user's rights and locks apply.

Known issue – the reason is sometimes missing from Message. When the cancel is refused by one of the final checks (for example the lock date, adjusted payments, approval, insufficient stock), Message holds a short technical text instead of the reason. Some other refusals (for example the customer-bonus check) come back as The operation was canceled. In both cases nothing was cancelled. To see the reason, repeat the request with "DisplayError": "1": the reason appears inside the technical detail, after the short technical text. The operation was canceled. stays without a reason even then.

Example request

By series and number:

By the internal number returned when the invoice was saved:

Response

Field
Type
Meaning

Status

true / false

true when the invoice was cancelled.

Message

text

"Success" when cancelled; otherwise the reason.

LastSavedCode

number

Logic ERP's internal number of the cancelled invoice. 0 when the request failed.

LastSavedDocNo

text

The invoice number: the printed invoice number when the series uses one, otherwise Logic ERP's internal form of series and number (for example "SLWSL 59"). null when the request failed.

request_ID

text

As described on the common page. null when the request failed before the invoice was found.

Example response

Messages you may see

Message
Meaning
What to do

Please Define Bill No. Or PartyOrderNo to Continue...

None of DocCode, BillSeries or PartyOrderNo was sent.

Send one of them.

Bill No. not defined against Bill Series : …

BillSeries sent with Bill_No 0 or missing.

Send the invoice number.

Unable to Retrive Bill Series : …

No sale series with that name in the branch.

Check the series and Branch_Code.

Duplicate Bill exists againts Party Order No. : … in Branch Code : …

More than one invoice matched.

Send DocCode or the series and number.

Unable to found Document againts Party Order No. … and Branch Code : …

No invoice matched in that branch and the current financial year (the message names the party order number even when you sent a series and number). A DocCode that is not found gives a technical error instead – see the known issue.

Check the branch, the number and the year.

Document has already been cancelled...

The invoice is already cancelled.

Nothing to do.

Please Enter Cancel Remarks to Continue...

Cancel_Reason is empty.

Send a reason.

GST eInvoice has been Generated. Cannot allow Cancellation.

An e-invoice exists for this invoice.

Cancel the e-invoice and the invoice in Logic ERP.

Cannot allow cancellation.... This document has been posted.....

The invoice is marked as posted.

Ask your Logic ERP team.

This document has been transferred to H.O. Modification not allowed......, This document has been Exported to other Branches. Modification not allowed......, This document has been imported from other Branches. Modification not allowed......

The invoice was transferred between branches.

Cancel it where it was created, or ask your Logic ERP team.

Entry/Modification is locked for this period....

The invoice date is in a locked period.

Ask your Logic ERP team.

The operation was canceled.

Refused by a check that does not return its reason (for example the customer-bonus check). Nothing was cancelled.

Check the invoice in Logic ERP, or ask your Logic ERP team.

Last updated