> 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/purchase/push/save-a-purchase-return-against-a-purchase-challan-return.md).

# Save a Purchase Return Against a Purchase Challan Return

Bills goods that went back to a supplier on a **purchase challan return** that is already in Logic ERP. A purchase challan return sends goods back on a challan, but nothing is posted to the supplier's account yet. This endpoint is meant to take the open lines of one challan return for the items you list, price and tax them, and save them as a **purchase return** posted to the supplier's account. You send the challan return's internal number and the items and quantities; rates and taxes come from Logic ERP, not from your request.

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

> **Known issue – this endpoint does not save a purchase return yet.** Today every request to this address (and to its older spelling) is processed like [Save a Purchase Challan](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-challan.md). A request with `Challan_Code` above `0` is refused with `Challan_Code is not supported on this route. A purchase return against a challan return is not supported here..Please Check...` and nothing is saved. A request without `Challan_Code` (or with `0`) still creates a **new purchase challan** (goods receipt) for `AccountCode` with the items in `LstItems`, and those goods are **added** to stock – the opposite of a return. **Do not call this endpoint.** Bill purchase challan returns in Logic ERP until this is corrected; if a request without `Challan_Code` has already been sent, find the purchase challan it created in Logic ERP and delete it. The rest of this page describes how the endpoint processes a request once this is corrected.

### **Endpoint**

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

Also accepted: `https://your-server/api/SavePurchaseReturnAgaintPUChallanReturn` (older spelling – works exactly the same).

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 Purchase Return, but this endpoint reads only the fields below. Field names are not case-sensitive. Codes and names are matched as you send them – spaces around them are not trimmed (only `TransporterName` and `CurrencyName` are trimmed).

| Field                                                                                                                     | Type                   | Required                                       | Default                           | Meaning                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ---------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Challan_Code`                                                                                                            | number                 | Yes                                            | `0`                               | Logic ERP's internal number of the purchase challan return – the `LastSavedCode` you got from Save a Purchase Challan Return, or `Vouch_Code` in [Get Purchase Challan Returns](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/pull/get-purchase-challan-returns.md). One challan return per request. |
| `AccountCode`                                                                                                             | text                   | No                                             | the challan return's supplier     | The supplier, by the party code shown in Logic ERP (`User_Code` in [Get Party Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-party-master.md)). The purchase return is posted to this account. When sent, it must be the challan return's own supplier; another code is refused.      |
| `BranchCode`                                                                                                              | number                 | No – but always send it (or `BranchShortName`) | `0`                               | The branch the purchase return is saved in (as explained in How Every API Call Works). Send the branch where the challan return was saved; a challan return of another branch is refused.                                                                                                                                                                     |
| `BranchShortName`                                                                                                         | text                   | No                                             | empty                             | The branch's short name, used only when `BranchCode` is `0`.                                                                                                                                                                                                                                                                                                  |
| `Bill_No`                                                                                                                 | text                   | No                                             | the challan return's bill number  | The supplier bill number kept on the purchase return.                                                                                                                                                                                                                                                                                                         |
| `Bill_Date`                                                                                                               | date                   | No                                             | `InvoiceDate`, else today         | The bill date, `yyyy-MM-dd`.                                                                                                                                                                                                                                                                                                                                  |
| `PartyBillDate`                                                                                                           | date                   | No                                             | `InvoiceDate`, else today         | The party bill date, `yyyy-MM-dd`.                                                                                                                                                                                                                                                                                                                            |
| `InvoiceDate`                                                                                                             | date                   | No                                             | today                             | The document date, `yyyy-MM-dd`. Also the default for `Bill_Date` and `PartyBillDate`. It must fall in the current financial year.                                                                                                                                                                                                                            |
| `GRN_Prefix`                                                                                                              | text                   | No                                             | `GRN`                             | Prefix of the GRN number given to the purchase return. It gets the next number for that prefix.                                                                                                                                                                                                                                                               |
| `LstItems`                                                                                                                | list                   | Yes                                            | empty list                        | The items and quantities to bill from the challan return – see below. `ListItems` is accepted as another name for the same list.                                                                                                                                                                                                                              |
| `PU_Remarks_1`, `PU_Remarks_2`, `PU_Remarks_3`                                                                            | text                   | No                                             | the challan return's remarks      | Remarks 1, 2 and 3. Replace the challan return's remarks when sent (not empty).                                                                                                                                                                                                                                                                               |
| `OrderNo`                                                                                                                 | text                   | No                                             | the challan return's order number | Order number. Replaces the challan return's value when sent (not empty).                                                                                                                                                                                                                                                                                      |
| `GR_Number`                                                                                                               | text                   | No                                             | the challan return's GR number    | Transport GR (lorry receipt) number. Replaces the challan return's value when sent (not empty).                                                                                                                                                                                                                                                               |
| `GRDate`, `OrderDate`, `ChallanNo`, `ChallanDate`                                                                         | date, date, text, date | No                                             | the challan return's values       | Replace the challan return's values when sent. Dates `yyyy-MM-dd`; a date that cannot be read is ignored.                                                                                                                                                                                                                                                     |
| `PVTMark`, `Insurance_Policy_No`, `Declaration_No`, `Cases`, `TransportMode`, `DeliveryAdd1`, `DeliveryAdd2`, `VehicleNo` | text                   | No                                             | the challan return's values       | Replace the challan return's values when sent (not empty).                                                                                                                                                                                                                                                                                                    |
| `DeliveryAt`                                                                                                              | text                   | No                                             | empty                             | The delivery-at place. The challan return's value is not carried over.                                                                                                                                                                                                                                                                                        |
| `AgentName`                                                                                                               | text                   | No                                             | none                              | An agent / broker, by name exactly as in Logic ERP. Must exist.                                                                                                                                                                                                                                                                                               |
| `CostCenter`                                                                                                              | text                   | No                                             | none                              | A cost centre, by name exactly as in Logic ERP.                                                                                                                                                                                                                                                                                                               |
| `TransporterName`                                                                                                         | text                   | No                                             | the challan return's transporter  | A transporter, by name as in Logic ERP.                                                                                                                                                                                                                                                                                                                       |
| `CurrencyName`, `ExchangeRate`                                                                                            | text, number           | No                                             | none, `1`                         | A currency by name, and its exchange rate (used only when above `0`). The challan return's currency and exchange rate are not carried over.                                                                                                                                                                                                                   |
| `CD_P`, `TD_P`, `SP_CD`, `Freight`, `Adjustment_Rs`, `SpDiscountRs`, `SchemeRs`, `AdjustUnit`, `CreditDays`               | number                 | No                                             | the challan return's values       | Document-level discounts, charges (`SchemeRs` is the scheme amount) and credit days. Only values above `0` are used; they replace the challan return's value.                                                                                                                                                                                                 |
| `DisplayError`                                                                                                            | text                   | No                                             | `"0"`                             | `"1"` = when the request fails, `Message` holds the full technical detail. Use only while testing.                                                                                                                                                                                                                                                            |

**`LstItems` – one entry per item and lot to bill**

| Field                     | Type   | Required         | Default   | Meaning                                                                                                                                                                                            |
| ------------------------- | ------ | ---------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `LogicUser_Code`          | text   | One of the two   | empty     | The item code shown in Logic ERP (`UserCode` in [Get Item Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-item-master.md)). |
| `AddlItemCode`            | text   | One of the two   | empty     | The additional item code / barcode (`AddlItemCode` in Get Item Master). Used only when `LogicUser_Code` is empty.                                                                                  |
| `ScannedQty`              | number | Yes              | `0`       | Quantity to bill. Must be above `0`.                                                                                                                                                               |
| `LotNo`                   | text   | Yes, in practice | empty     | The lot number **exactly as on the challan return line** – same capitals, no extra spaces. Without it the line does not match and the request is refused.                                          |
| `Org_Production_Unit`     | text   | No               | empty     | The lot's production unit. Used to match the line only when your API site has **Filter Lots On Basis Of Production Unit for Purchase Return** ticked.                                              |
| `Lot_Bill_No`             | text   | No               | empty     | Used only together with the next three fields: they are applied to a line only when `LotNo`, `Org_Production_Unit` and `Lot_Bill_No` all equal the lot's values.                                   |
| `Expiry_Date`, `MFG_Date` | date   | No               | the lot's | Expiry and manufacturing date for the line (see `Lot_Bill_No`).                                                                                                                                    |
| `Production_Unit`         | text   | No               | the lot's | Production unit for the line (see `Lot_Bill_No`). When the line matches as described there, the value you send is used even when it is empty.                                                      |

**Ignored fields.** `SupplierCode` (checked to exist when sent, then not used), `Godown_Name` (not used, but a name that does not exist still stops the request; leave it empty), `GR_Date`, `GPN_No`, `GPN_Date`, `Weight`, `Series_Code`, `DNO_Code`, `PO_Code`, `EntrySource`, and in `LstItems`: `BasicRate`, `PurRate`, `SaleRate`, `Lot_Mrp`, `SP_Rate_1` to `SP_Rate_5`, `ItemDescription`, `LotCode`, `Godown_Code`. Leave `Doc_Type` out (it defaults to `PU`; any value other than `PU` or `PR` stops the reverse-charge setting being taken from the tax region).

### **Rules Logic ERP applies**

* **What is billed.** The open (unbilled) lines of the challan return in `Challan_Code` whose item and lot are in `LstItems`. Entries for the same item and lot are added together, and the total is billed from the matching lines in turn, never more than you sent. A total above the open quantity of the item and lot is refused with `Requested quantity is more than the quantity pending in Purchase Challan.`, and an item and lot with no open line is refused with `Item/Lot not pending in Purchase Challan.` Lines of items or lots you did not list stay open.
* **Billing in parts.** The billed quantity is taken off the challan return line's open quantity, so the rest can be billed later with another request.
* **Matching lines.** A line matches a `LstItems` entry by item and `LotNo` (and production unit, when that API setting is ticked). The lot number must match exactly, including capitals.
* **Supplier, branch and challan return are checked.** `Challan_Code` must be a purchase challan return (not a purchase challan) of the branch you send. `AccountCode`, when sent, must be the challan return's supplier; left out, its supplier is used.
* **Rates.** Your rates are not used. Each line keeps the challan return line's rate; sale rate, MRP and the other rates come from the lot. Rate formulas set on the series are applied, as on Logic ERP's purchase return screen.
* **Taxes.** The tax region is the **challan return's** tax region. GST and other taxes are worked out item by item for that region and supplier. A challan return without a tax region is refused.
* **What comes from the challan return.** Bill number, discounts, freight and other charges, credit days, remarks 1, transporter, delivery address and transport details – unless you send a value as listed in the table. Its agent, delivery-at place, currency and cost centre are not carried over.
* **Series and number.** The purchase return is saved in the series chosen as **Default Configuration** for *Purchase return against purchase return challan* in your API site's settings. There is no request field for the series. It gets the series' next number.
* **Checks of the series.** The series' own checks apply – for example a mandatory MRP, or refusing a bill number that already exists for the supplier.
* **Date and financial year.** The purchase return is dated `InvoiceDate` (today when it is left out) and saved in the current financial year. An `InvoiceDate` outside the current financial year is refused.
* **Approval.** A challan return that is waiting for purchase challan approval is refused.
* **Duplicates.** There is no duplicate check on the request. A billed quantity is no longer open, so a repeat finds less to bill: when the first request billed all the open quantity of the items, the repeat is refused with `No Pending Item Present....`; when it billed only part, the repeat bills again from what is left. Check `Status` before you resend.
* **All or nothing.** The purchase return and all its lines are saved together. If anything fails, nothing is saved.
* Your Logic ERP licence must include the API for purchase returns against challan returns.

### **Example request**

```json
{
  "Challan_Code": 1587,
  "AccountCode": "S0412",
  "BranchCode": 2,
  "Bill_No": "DN/26-27/0093",
  "Bill_Date": "2026-10-29",
  "GRN_Prefix": "",
  "PU_Remarks_2": "Damaged in transit",
  "LstItems": [
    { "LogicUser_Code": "SHT1042", "ScannedQty": 2, "LotNo": "L2610A" }
  ]
}
```

### **Response**

| Field            | Type         | Meaning                                                                                                                                       |
| ---------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`         | true / false | `true` when the purchase return was saved.                                                                                                    |
| `Message`        | text         | Empty when saved; the reason when not saved.                                                                                                  |
| `LastSavedCode`  | number       | Logic ERP's internal number of the new purchase return; `0` when not saved.                                                                   |
| `LastSavedDocNo` | text         | The purchase return's GRN number – prefix, a hyphen and the number with two decimals, for example `GRN-14.00`. Empty (`null`) when not saved. |
| `request_ID`     | text         | The ID of this request – quote it to support.                                                                                                 |

### **Example response**

```json
{
  "LastSavedDocNo": "GRN-14.00",
  "Status": true,
  "Message": "",
  "LastSavedCode": 291,
  "request_ID": "8d41b2e0-6a3c-4f17-b9e2-5c0a7d1e2f34"
}
```

### **Messages you may see**

Messages from checks made while the document is being saved (marked \*) come back with technical text before the reason and technical detail after it – look for the reason in the first line.

| Message                                                                                                                                                                                   | Meaning                                                                                                                                                                                                           | What to do                                                                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `Default Configuration Not Defined..`                                                                                                                                                     | No series is chosen for purchase returns against purchase return challans in your API site's settings.                                                                                                            | Ask your Logic ERP team to choose the Default Configuration.                                |
| `Account Code Not Defined...` / `Invalid Account User Code...`                                                                                                                            | `AccountCode` is missing or not found.                                                                                                                                                                            | Send the supplier's party code.                                                             |
| `Invalid Supplier Code Defined...`                                                                                                                                                        | `SupplierCode` was sent but not found.                                                                                                                                                                            | Leave `SupplierCode` out.                                                                   |
| `Invalid Godown Name […]. Please Check...`                                                                                                                                                | `Godown_Name` does not exist.                                                                                                                                                                                     | Leave `Godown_Name` empty.                                                                  |
| `Invalid Invoice Date Defined...` / `Invalid Bill Date...` / `Invalid Party Bill Date...`                                                                                                 | A date could not be read.                                                                                                                                                                                         | Send dates as `yyyy-MM-dd`.                                                                 |
| `Invalid Challan Code...`                                                                                                                                                                 | `Challan_Code` is `0` or missing.                                                                                                                                                                                 | Send the challan return's internal number.                                                  |
| `Invalid Challan Code […]...`                                                                                                                                                             | No challan has that number.                                                                                                                                                                                       | Check `Challan_Code`.                                                                       |
| `Challan Code […] is not a Purchase Challan Return...`                                                                                                                                    | The number belongs to another kind of challan, for example a purchase challan.                                                                                                                                    | Send the internal number of a purchase challan return.                                      |
| `Challan Code […] belongs to another branch...`                                                                                                                                           | The challan return was saved in another branch than the one you sent.                                                                                                                                             | Send its own branch.                                                                        |
| `Account Code […] is not the account of Challan Code […]...`                                                                                                                              | `AccountCode` is not the challan return's supplier.                                                                                                                                                               | Send its supplier, or leave `AccountCode` out.                                              |
| `Logic User Code/Additional Item Code Not Defined for Item No : …`                                                                                                                        | An entry in `LstItems` has neither code.                                                                                                                                                                          | Send `LogicUser_Code` or `AddlItemCode`.                                                    |
| `Invalid Logic User Code : '…' Defined for Item No : …` / `Invalid Additional Item Code : '…' Defined for Item No : …`                                                                    | The item code is not found.                                                                                                                                                                                       | Send the code exactly as in Logic ERP.                                                      |
| `Quantity Not Defined For : '…' Item No : …`                                                                                                                                              | `ScannedQty` is `0` or less.                                                                                                                                                                                      | Send a quantity above `0`.                                                                  |
| `Invoice Date Date not Within Financial Year.Please Check....`                                                                                                                            | `InvoiceDate` (today when left out) is outside the current financial year.                                                                                                                                        | Send a date in the current financial year.                                                  |
| `Challan No.… is Pending for approval. Cannot Retrieve.`                                                                                                                                  | The challan return is waiting for approval.                                                                                                                                                                       | Approve it in Logic ERP first.                                                              |
| `No Pending Item Present....`                                                                                                                                                             | The challan return has no open line for the items you sent – it is billed already, the number is wrong, or the items are not on it.                                                                               | Check `Challan_Code` and the items.                                                         |
| `Default Tax Region not Set.Please Check....`                                                                                                                                             | The challan return has no tax region.                                                                                                                                                                             | Correct it in Logic ERP.                                                                    |
| `Item/Lot not pending in Purchase Challan. Key : …`                                                                                                                                       | An item and lot you sent has no open line on the challan return – or `LotNo` does not match exactly. The key is Logic ERP's internal item number and the lot number.                                              | Send the lot numbers exactly as on the challan return.                                      |
| `Requested quantity is more than the quantity pending in Purchase Challan. Key : … Short by : …`                                                                                          | The quantity sent for an item and lot is more than is still open; `Short by` is the excess.                                                                                                                       | Send at most the open quantity.                                                             |
| `No Item Present Purchase Challan.`                                                                                                                                                       | None of the lines could be billed.                                                                                                                                                                                | Check the challan return in Logic ERP.                                                      |
| `Invalid Agent […] .Please Check`, `Unable to found Cost Center […] .Please Check`, `Transporter Name [ … ] not found. Please Check...`, `Currency Name [ … ] not found. Please Check...` | A name was not found.                                                                                                                                                                                             | Send it exactly as in Logic ERP.                                                            |
| `M.R.P. Entry is mandatory......Row No: …` \*                                                                                                                                             | The series needs an MRP and the lot has none.                                                                                                                                                                     | Correct the lot or the series in Logic ERP.                                                 |
| `Unable to identify taxes of Item at Row No.:…` \*                                                                                                                                        | No tax could be found for an item in the challan return's tax region.                                                                                                                                             | Check the item's tax set-up in Logic ERP.                                                   |
| `Bill No:… already exists for this supplier... Cannot Continue.` \*                                                                                                                       | The series refuses a bill number that is already used for this supplier.                                                                                                                                          | Send the correct `Bill_No`.                                                                 |
| `Error while saving voucher` \*                                                                                                                                                           | Saving was stopped inside Logic ERP; nothing was saved. One known cause: the bill number already exists for this supplier and the series is set to ask before accepting it – the API cannot answer that question. | Check `Bill_No`; otherwise retry once and, if it repeats, send the `request_ID` to support. |
| Another technical error \*                                                                                                                                                                | Saving failed inside Logic ERP; nothing was saved.                                                                                                                                                                | Retry once; if it repeats, send the `request_ID` to support.                                |
| `Voucher not saved. The challan may be pending approval, or the item-wise amounts could not be calculated.`                                                                               | Saving stopped without a reason. Nothing was saved.                                                                                                                                                               | Check the challan return in Logic ERP; 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/purchase/push/save-a-purchase-return-against-a-purchase-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.
