> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-return-against-a-sale-challan-return.md).

# Save a Sale Return Against a Sale Challan Return

Turns a **sale challan return** that is already in Logic ERP into a billed document. A sale challan return brings goods back on a challan – stock comes back, but nothing is posted to the party's account yet. This endpoint takes the lines of that challan return that are not billed yet, prices and taxes them, and saves them as one document posted to the party's account. You send the challan return's internal number; you do not send the items.

To record goods coming back **without** a challan return, use [Save a Sale Return](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-return.md). To create the challan return itself, use [Save a Sale Challan Return](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-challan-return.md).

### **Endpoint**

| Name          | Detail                                                        |
| ------------- | ------------------------------------------------------------- |
| Address       | `https://your-server/api/SaveInvoiceAgainstSaleChallanReturn` |
| Method        | `POST`                                                        |
| Authorization | Basic Auth                                                    |

The response envelope, branches, dates, queueing and the common messages are explained in [How Every API Call Works](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/how-every-api-call-works.md).

### **Request fields**

The request has the same shape as [Save a Sale Invoice](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-invoice.md), but this endpoint reads only the fields below. Field names are not case-sensitive. Names are looked up without regard to capitals; spaces around them are not trimmed (only `Tax_Region` and `TransporterName` are trimmed). Spaces around the item codes (`LogicUserCode` / `AddlItemCode`) are removed before the item is looked up.

| Field                                                                                                                                                                                                                    | Type             | Required                                       | Default                             | Meaning                                                                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- | ---------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Doc_Code`                                                                                                                                                                                                               | number           | Yes                                            | `0`                                 | Logic ERP's internal number of the sale challan return – the `LastSavedCode` you got from Save a Sale Challan Return.                                                                                                                        |
| `BranchCode`                                                                                                                                                                                                             | number           | No – but always send it (or `BranchShortName`) | `0`                                 | The branch **where the challan return was saved**. The document itself is always saved in the challan return's branch; this field decides which branch's API settings and financial year are used – see the rules.                           |
| `BranchShortName`                                                                                                                                                                                                        | text             | No                                             | empty                               | The branch's short name, used only when `BranchCode` is `0`.                                                                                                                                                                                 |
| `Bill_Date`                                                                                                                                                                                                              | date             | No                                             | today                               | Date of the document, `yyyy-MM-dd`. It decides the financial year it is saved in. It does not have to match the challan return's date.                                                                                                       |
| `BillSeries`                                                                                                                                                                                                             | text             | No                                             | see rules                           | A **sale return** series of the branch, by name.                                                                                                                                                                                             |
| `Bill_Number`                                                                                                                                                                                                            | number           | No                                             | `0`                                 | `0` = next number of the series; above `0` = used as the number (needs `BillSeries`, must be free).                                                                                                                                          |
| `Ext_Bill_No`                                                                                                                                                                                                            | text             | No                                             | empty                               | Your own document number; kept as the displayed number and returned in `Invoice_No`.                                                                                                                                                         |
| `ActEntryPartyUserCode`                                                                                                                                                                                                  | text             | No                                             | the challan return's party          | A different account to post the document to in the accounts, by its code.                                                                                                                                                                    |
| `Tax_Region`                                                                                                                                                                                                             | text             | No                                             | the default of the series and party | The tax region, by name. `"AUTO"` is **not** supported here.                                                                                                                                                                                 |
| `GST_State_Code`                                                                                                                                                                                                         | text             | No                                             | Logic ERP's value                   | Place-of-supply state code. Used whenever sent (no API setting needed on this endpoint).                                                                                                                                                     |
| `PaymentMode`                                                                                                                                                                                                            | text             | No                                             | the series' setting                 | `"CASH"` or `"CREDIT"`, in capitals.                                                                                                                                                                                                         |
| `OrderNo`, `OrderDate`, `Order_Id`                                                                                                                                                                                       | text, date, text | No                                             | empty                               | Your references, kept on the document. No duplicate check is made.                                                                                                                                                                           |
| `AgentName`, `CostCenter`, `Tax_Form_Name`, `TransporterName`, `TransportMode`, `WayBillNo`, `CurrencyName`, `ExchangeRate`, `CreditDays`                                                                                |                  | No                                             |                                     | As on Save a Sale Invoice.                                                                                                                                                                                                                   |
| `CD_P`, `TD_P`, `SpCD_P`, `Freight`, `SpDiscountRs`, `Adjustment_Rs`, `Handling`                                                                                                                                         | number           | No                                             | `0`                                 | Document-level discounts and charges, applied over the challan return's lines. Only values above `0` are used.                                                                                                                               |
| `Ext_NetSale_Value`                                                                                                                                                                                                      | number           | No                                             | `0`                                 | When not `0`, the document is refused if Logic ERP's net amount differs.                                                                                                                                                                     |
| `Remarks1`, `Remarks2`, `Remarks3`, `DeliveryAt`, `DeliveryAdd1`, `DeliveryAdd2`, `Cases`, `Weight`, `PVTMark`, `GRNo`, `GRDate`, `Challan_No`, `Challan_Date`, `Insurance_Policy_No`, `Declaration_No`, `DeclarationNo` |                  | No                                             | empty                               | Kept on the document, as on Save a Sale Invoice.                                                                                                                                                                                             |
| `Sale_BillNo`, `Sale_Bill_Date`                                                                                                                                                                                          | text, date       | No                                             | empty                               | Read but not saved.                                                                                                                                                                                                                          |
| `LstItems`                                                                                                                                                                                                               | list             | No                                             | empty list                          | **Not used to choose lines** – every open line of the challan return is billed. If you send lines, each is still checked (item code, quantity above `0`, lot number exists for the item), and a wrong one stops the request. Leave it empty. |
| `Godown_Name`                                                                                                                                                                                                            | text             | No                                             | empty                               | Not used – the lines keep the challan return's godowns – but a name that does not exist still stops the request. Leave it empty.                                                                                                             |
| `TenderDetails`                                                                                                                                                                                                          | list             | No                                             | empty list                          | Not used. Send `[]` or leave it out – never `null`.                                                                                                                                                                                          |
| `RCU_First_Name`, `RCU_State`                                                                                                                                                                                            | text             | No                                             | empty                               | Used only in one case: without `RCU_Mobile_No` and `RCU_Email`, when both are the same word, the document is linked to the one retail customer with that first name in that state. Otherwise no retail customer is created or looked up.     |
| `Request_ID`                                                                                                                                                                                                             | text             | No                                             | empty                               | Used only when your API site keeps requests for later processing, as on Save a Sale Invoice.                                                                                                                                                 |
| `DisplayError`                                                                                                                                                                                                           | text             | No                                             | `"0"`                               | `"1"` = when the request fails, `Message` holds the full technical detail. Use only while testing.                                                                                                                                           |

**Ignored fields.** `PartyUserCode` (the party is always the challan return's party), `Doc_Type`, `Token_No`, `STBranchCode`, `InvoiceType`, `EntrySource`, `BillingAddress`, `ShippingAddress`, `Billing_Address1`, `Billing_Address2` and the other `RCU_…` fields are accepted but not used.

### **Rules Logic ERP applies**

* **What is billed.** Every line of the challan return in `Doc_Code` that is not billed yet, has a quantity and is approved – with the challan return's items, lots, quantities, rates, discounts and godowns. Filters set on the return series in Logic ERP (default companies, challan series, party item groups) can leave some lines out. The challan return itself must be approved. Lines that were taken back **against an earlier sale challan** (they reduce that challan rather than stand on their own) are not picked up. You cannot bill only part of a challan return.
* **Party.** The document is made out to the challan return's party; `PartyUserCode` is ignored. A party locked for billing is refused.
* **Branch.** The document is saved in the challan return's branch, and the series is looked up there. `BranchCode` only decides which branch's API settings, financial year and number check are used, so send the branch where the challan return was saved.
* **Series and number.** The series is, in this order: the series your Logic ERP team has linked to the challan return's series in the API site setup, else the `BillSeries` you send (a sale return series of the challan return's branch), else the sale return series linked to the party, else the API site's default series. A `BillSeries` that is not a sale return series of that branch is refused with `Bill Series : … Not found for Branch Code :… in API Parameter..`. The document gets the next number of that series in the year of `Bill_Date` unless you send `Bill_Number`.
* **Stock is not moved again.** The challan return already brought the goods back into stock; this document only bills those lines.
* **Tax and totals.** Logic ERP works out GST and other taxes on the challan return's lines for the tax region, applies the schemes set up in Logic ERP and rounds the total, as its own screens do.
* **No sale history link.** The lines are not linked to an original sale bill; no sale history is searched and `OrderNo` is only a reference.
* **No tenders, no retail customer.** `TenderDetails` and the retail customer fields are not used (except the first-name and state look-up above).
* **Duplicates.** A challan return line that has been billed is not billed again, so sending the same `Doc_Code` twice does not bill the lines twice; the second request finds nothing left to bill and saves nothing.
* **All or nothing.** The document and all its lines are saved together. If anything fails, nothing is saved.
* Your Logic ERP team can set the API site to save in the background or keep requests for later processing, as on Save a Sale Invoice.

> **Saved as a sale return.** The document is saved as a **sale return** in the return series, with positive amounts, the way Logic ERP's own screen saves a sale return against a challan return. Only the challan return's return lines are billed. It appears among sale returns, not among sale bills.

> **`Doc_Code` must be a sale challan return.** A `Doc_Code` of a challan that is not on a challan-return series is refused with `Doc_Code (Challan Code) : … is not a Sale Challan Return..Please Check...`. Send the internal number of a **sale challan return**.

> **Known issue – a switched-off endpoint answers `"Status": false`.** When your support team has switched this endpoint off for the branch, the answer is `"Status": false` with the message `Request cannot be processed. API Template is marked as In-Active in the configuration.`, not `"Status": true` as described in How Every API Call Works. Either way nothing is saved.

### **Example request**

```json
{
  "Doc_Code": 51234,
  "BranchCode": 2,
  "Bill_Date": "2026-10-29",
  "BillSeries": "ESR",
  "Bill_Number": 0,
  "OrderNo": "RET-2026-0412",
  "Remarks1": "Billing of challan return CRET-12",
  "LstItems": [],
  "TenderDetails": []
}
```

### **Test it**

Send a request to the Logic ERP **sandbox** (a test company) from this page: open the block below, enter the sandbox user name and password (ask your Logic ERP support team), change the request if you like, and press **Test it**. This really saves in the sandbox, so use test values like the example. The example's challan return has already been billed, so sending it unchanged answers that there is nothing left to bill; save a new challan return on its page first and put its `LastSavedCode` in `Doc_Code`.

## Save a Sale Return Against a Sale Challan Return

> Turns a sale challan return that is already in Logic ERP into a billed document. A sale challan return brings goods back on a challan – stock comes back, but nothing is posted to the party's account yet. This endpoint takes the lines of that challan return that are not billed yet, prices and taxes them, and saves them as one document posted to the party's account. You send the challan return's internal number; you do not send the items.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Sale - Push"}],"servers":[{"url":"https://demo.logicerp.com/api","description":"Logic ERP sandbox (test company)"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"The user name and password of your API site."}}},"paths":{"/SaveInvoiceAgainstSaleChallanReturn":{"post":{"tags":["Sale - Push"],"operationId":"SaveInvoiceAgainstSaleChallanReturn","summary":"Save a Sale Return Against a Sale Challan Return","description":"Turns a sale challan return that is already in Logic ERP into a billed document. A sale challan return brings goods back on a challan – stock comes back, but nothing is posted to the party's account yet. This endpoint takes the lines of that challan return that are not billed yet, prices and taxes them, and saves them as one document posted to the party's account. You send the challan return's internal number; you do not send the items.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"Doc_Code":{"type":"integer","description":"Logic ERP's internal number of the sale challan return – the `LastSavedCode` you got from Save a Sale Challan Return."},"BranchCode":{"type":"integer","description":"The branch where the challan return was saved. The document itself is always saved in the challan return's branch; this field decides which branch's API settings and financial year are used – see the rules."},"Bill_Date":{"type":"string","description":"Date of the document, `yyyy-MM-dd`. It decides the financial year it is saved in. It does not have to match the challan return's date."},"BillSeries":{"type":"string","description":"A sale return series of the branch, by name."},"Bill_Number":{"type":"integer","description":"`0` = next number of the series; above `0` = used as the number (needs `BillSeries`, must be free)."},"OrderNo":{"type":"string","description":"Your references, kept on the document. No duplicate check is made."},"Remarks1":{"type":"string","description":"Kept on the document, as on Save a Sale Invoice."},"Tax_Region":{"type":"string","description":"The tax region, by name. `\"AUTO\"` is not supported here."},"LstItems":{"type":"array","items":{"type":"object"},"description":"Not used to choose lines – every open line of the challan return is billed. If you send lines, each is still checked (item code, quantity above `0`, lot number exists for the item), and a wrong one stops the request. Leave it empty."},"TenderDetails":{"type":"array","items":{"type":"object"},"description":"Not used. Send `[]` or leave it out – never `null`."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"PrintFile":{"type":"string","description":"Always empty."},"Invoice_No":{"type":"string","description":"The new document's number, or your `Ext_Bill_No`. For a series with its own number format this is the formatted number (for example `26-27/2/ESR-35`); otherwise series and number (for example `ESR-9`)."},"Order_No":{"type":"string","description":"The challan return's document number as Logic ERP stores it internally, for example `CHCRET12`."},"PartyOrderNo":{"type":"string","description":"The `OrderNo` you sent."},"Status":{"type":"boolean","description":"`true` when the document was saved."},"Message":{"type":"string","description":"Empty when saved, unless your Logic ERP shows the document number after saving. When automatic export is set up for your company, a note from that step can follow in the same text even though the document was saved – for example `Export Virtual Txns : No Suppliers Linked With Current Branch, Can Not Export in Auto Mode ...`. Go by `Status`. The reason when not saved."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal number of the new document; `0` when not saved."},"request_ID":{"type":"string","description":"The ID of this request – quote it to support."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field           | Type         | Meaning                                                                                                                                                                                                                                                                                                                                                                           |
| --------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`        | true / false | `true` when the document was saved.                                                                                                                                                                                                                                                                                                                                               |
| `Message`       | text         | Empty when saved, unless your Logic ERP shows the document number after saving. When automatic export is set up for your company, a note from that step can follow in the same text even though the document was saved – for example `Export Virtual Txns : No Suppliers Linked With Current Branch, Can Not Export in Auto Mode ...`. Go by `Status`. The reason when not saved. |
| `LastSavedCode` | number       | Logic ERP's internal number of the new document; `0` when not saved.                                                                                                                                                                                                                                                                                                              |
| `request_ID`    | text         | The ID of this request – quote it to support.                                                                                                                                                                                                                                                                                                                                     |
| `Invoice_No`    | text         | The new document's number, or your `Ext_Bill_No`. For a series with its own number format this is the formatted number (for example `26-27/2/ESR-35`); otherwise series and number (for example `ESR-9`).                                                                                                                                                                         |
| `Order_No`      | text         | The challan return's document number as Logic ERP stores it internally, for example `CHCRET12`.                                                                                                                                                                                                                                                                                   |
| `PartyOrderNo`  | text         | The `OrderNo` you sent.                                                                                                                                                                                                                                                                                                                                                           |
| `PrintFile`     | text         | Always empty.                                                                                                                                                                                                                                                                                                                                                                     |

### **Example response**

```json
{
  "PrintFile": "",
  "Invoice_No": "ESR-9",
  "Order_No": "CHCRET12",
  "PartyOrderNo": "RET-2026-0412",
  "Status": true,
  "Message": "",
  "LastSavedCode": 40896,
  "request_ID": "7b1e4c20-58d2-4f0a-9c1b-3e6d2a9f0c11"
}
```

### **Messages you may see**

Messages from Logic ERP's own checks also come back in `Message`. Where the code adds technical detail, the reason may be followed by technical detail – read the first line.

| Message                                                                                                                                                                                                        | Meaning                                                                                                   | What to do                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `Unable to Sale Challan...`                                                                                                                                                                                    | `Doc_Code` is `0` or missing.                                                                             | Send the challan return's internal number.                               |
| `Doc_Code (Challan Code) : … not exists..Please Check...`                                                                                                                                                      | No challan has that number.                                                                               | Check `Doc_Code`.                                                        |
| `Doc_Code (Challan Code) : … is not a Sale Challan Return..Please Check...`                                                                                                                                    | `Doc_Code` is a challan, but not a sale challan return.                                                   | Send the `LastSavedCode` of Save a Sale Challan Return.                  |
| `Error Occured While Retriving Sale Challan.Please Check...`                                                                                                                                                   | The challan return's lines could not be read.                                                             | Check the challan return in Logic ERP.                                   |
| `"Status": false` with `No Items present....`, another message from Logic ERP, or an empty `Message`                                                                                                           | Nothing is left to bill – the lines are billed already, or the challan return is not approved.            | Check the challan return in Logic ERP.                                   |
| `Bill Series : … Not found for Branch Code :… in API Parameter..` / `Default Bill Series Not Set for Branch Code :…`                                                                                           | The `BillSeries` sent is not a sale return series of the challan return's branch, or no series was found. | Send a return series of the branch, or ask for a series link or default. |
| `Cannot allow Bill Saving If Bill Number defined without Bill Series....`                                                                                                                                      | `Bill_Number` without `BillSeries`.                                                                       | Send both, or neither.                                                   |
| `Bill No. […] against Branch Code : … already exists...Please Check..`                                                                                                                                         | That number is used.                                                                                      | Send another number, or `0`.                                             |
| `Unable to Retrieve Accounts...`                                                                                                                                                                               | The challan return's party could not be found.                                                            | Check the challan return in Logic ERP.                                   |
| `Sale Bill Locked against Party(Setup New Accounts)`                                                                                                                                                           | The party is locked for billing.                                                                          | Ask your Logic ERP team.                                                 |
| `Unable to found Tax Region : …`                                                                                                                                                                               | The tax region does not exist (`AUTO` is not supported here).                                             | Use a region name from Logic ERP.                                        |
| `Invalid LogicUserCode / EANCode : …`, `Invalid Item Qty : …`, `Unable to found LotNo : … againts EAN/Item Code : …`                                                                                           | A line in `LstItems` is wrong.                                                                            | Leave `LstItems` empty.                                                  |
| `Invalid Godown Name […]. Please Check...`                                                                                                                                                                     | `Godown_Name` does not exist.                                                                             | Leave `Godown_Name` empty.                                               |
| `Currency Name : … not found...Please Check...`, `Exchange Rate not Defined for Currency Name :…...Please Check...`                                                                                            | The currency is unknown, or sent without an exchange rate above `0`.                                      | Fix `CurrencyName` / `ExchangeRate`.                                     |
| `Net Value cannot match with External Net Value...`                                                                                                                                                            | `Ext_NetSale_Value` differs from Logic ERP's net amount.                                                  | Check the challan return and the discounts sent.                         |
| `Date not Within Financial Year`                                                                                                                                                                               | `Bill_Date` is outside the financial year.                                                                | Check the date.                                                          |
| `No financial year covers the date ….`                                                                                                                                                                         | No financial year in Logic ERP covers `Bill_Date`.                                                        | Check the date, or ask your Logic ERP team to create the year.           |
| `Unable to found A/E Party : …`, `Invalid Agent […] .Please Check`, `Unable to found Cost Center […] .Please Check`, `Invalid Tax Form […] .Please Check`, `Transporter Name [ … ] not found. Please Check...` | A code or name was not found.                                                                             | Send it exactly as in Logic ERP.                                         |
| A technical error naming a save step                                                                                                                                                                           | Saving failed inside Logic ERP; nothing was saved.                                                        | Retry once; if it repeats, send the `request_ID` to support.             |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-return-against-a-sale-challan-return.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
