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

Save a Purchase Challan Return

Creates a purchase challan return in Logic ERP: goods you send back to a supplier that were received on a purchase challan and have not been billed yet – for example damaged pieces or excess quantity found when the goods were checked. The goods leave your branch's stock at once. Like the challan, the return is not a purchase document: no purchase return or debit note is raised by it.

Endpoint

Name
Detail

Address

https://your-server/api/SavePurchaseChallanReturn

Method

POST

Authorization

Basic Auth

The response envelope, branches, dates and the common messages are explained in How Every API Call Works.

Send one return per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored. Do not send null for LstItems.

  • This endpoint takes no reference to the original challan – Challan_Code is ignored. The return is tied to the supplier and to the lots the goods are taken from, not to a challan.

  • The goods are taken from lots of the item that have stock in the branch in the current financial year. To return the goods of a particular challan, send the lot number used on that challan in LotNo, and – if the same lot number was used on other challans – that challan's Bill_No in Lot_Bill_No (a lot carries the bill number of the last challan or purchase that received goods into it).

  • The lot's supplier is not checked: a lot received from another supplier is accepted. Send lot numbers that belong to this supplier.

  • The return gets its own GRN number and internal number. Saved returns are returned by Get Purchase Challan Returns.

How it differs from Save a Purchase Voucher

The request has the same fields as Save a Purchase Voucher. The differences:

  • Stock goes out instead of coming in, and no lot is created: every line must find stock in existing lots.

  • The document is a challan return, kept with the purchase challans, not a purchase bill or purchase return.

  • This endpoint always uses Logic ERP's import save routine, with its own API site settings (default series, default godown, lot filters, duplicate bill-number check).

  • LotNo is optional and, when sent, chooses the lot instead of naming a new one.

Request fields

Field
Type
Required
Default
Meaning

AccountCode

text

Yes

–

The supplier's party code (User_Code in Get Party Master). Must already exist. The tax region, credit days, transporter and default discounts are taken from this account.

SupplierCode

text

No

AccountCode

A different party code for the supplier, when the account is someone else. Must exist. Usually left out.

BranchCode

number

No

0

The branch sending the goods back, by Logic ERP's branch number (Branch_Code in Get Branch Info).

BranchShortName

text

No

empty

The branch by its short name; used only when BranchCode is 0. With neither, Logic ERP falls back to a default branch – always send one.

Bill_No

text

No*

empty

Your return reference, for example your return note number. *Required when your API site checks duplicate supplier bills. See the known issue – it cannot be the challan's bill number.

InvoiceDate

date

No

today

Date of the return, yyyy-MM-dd. Same rules as on a challan.

Bill_Date, PartyBillDate

date

No

InvoiceDate

Reference dates stored on the return.

Godown_Name

text

No

none

Only lots in this godown are used. Must exist.

GRN_Prefix

text

No

the series' GRN prefix, else GRN

Prefix of the return's GRN number.

GR_Number, GR_Date (or GRDate), GPN_No, GPN_Date, OrderNo, OrderDate, ChallanNo, ChallanDate, PU_Remarks_2, PU_Remarks_3, AgentName, TransporterName, CostCenter, CurrencyName, ExchangeRate, CreditDays, Freight, Adjustment_Rs, SpDiscountRs, TransportMode, VehicleNo, Cases, Weight, PVTMark, Insurance_Policy_No, Declaration_No, DeliveryAt, DeliveryAdd1, DeliveryAdd2, Series_Code, DisplayError, Doc_Type

–

No

–

As on Save a Purchase Challan. Series_Code is used only when your API site has no default series for challan returns.

PU_Remarks_1, CD_P, TD_P, SP_CD, SchemeRs, AdjustUnit

–

No

–

See the known issues on Save a Purchase Challan – the first remark is not saved and the bill-level discounts do not change the amounts.

LstItems

list

Yes

–

The goods returned. See below. ListItems is accepted as another name.

Request_ID, EntrySource, DNO_Code, Challan_Code, PO_Code

–

No

–

Ignored by this endpoint.

LstItems

Field
Type
Required
Default
Meaning

LogicUser_Code

text

Yes, or AddlItemCode

empty

The item code shown in Logic ERP (UserCode in Get Item Master).

AddlItemCode

text

Yes, or LogicUser_Code

empty

The item's additional code / barcode; used when LogicUser_Code is empty or not found.

ScannedQty

number

Yes

–

Quantity returned; more than 0. There must be at least this much stock in the matching lots.

LotNo

text

No

any lot

Lot number to take the goods from. Empty = any lot of the item with stock. See the known issue on capitals.

Lot_Bill_No

text

No*

empty

Only lots with this bill number are used (for a lot received on a challan, the challan's Bill_No). *Required when your API site filters return lots by lot bill number.

Production_Unit

text

No

empty

Only lots of this production unit are used.

BasicRate

number

No

0

Rate per unit in ₹ for the line amount. Send the rate of the goods returned.

ItemDescription

text

No

empty

Description for the line.

PurRate, SaleRate, Lot_Mrp, SP_Rate_1 … SP_Rate_5, Expiry_Date, MFG_Date

–

No

0 / empty

Optional line values; the goods come from an existing lot.

LotCode, Godown_Code, Org_Production_Unit

–

No

–

Ignored by this endpoint; the lot and its godown are found by Logic ERP.

Rules Logic ERP applies

Supplier, branch, series and dates

  • As on Save a Purchase Challan: the supplier is found by its party code (any account code is accepted), the series is your API site's default series for purchase challan returns (else Series_Code), the return is saved in the financial year of the day the request arrives, and the tax region comes only from the supplier.

Choosing the lots

  • For each line Logic ERP looks for lots of the item with stock above 0 in the branch in the current financial year, and keeps only those that match what you sent: LotNo, Lot_Bill_No, Production_Unit, the godown of Godown_Name, and your API site's default godown for this endpoint if one is set. When both a default godown and Godown_Name are set, the lot must be in both – send the same godown.

  • The quantity is taken from the oldest lot first (by purchase date). If one lot does not have enough, the rest is taken from the next one, and the line becomes one return line per lot. Several lines for the same item and lot share that lot's stock.

  • If the matching lots together hold less than the quantity, the request fails with Insufficient Stock for Item Code : …. Nothing is returned from stock that is not there, even if your Logic ERP set-up allows negative stock.

  • While saving, Logic ERP checks the chosen lot again: it must be in one of the series' default godowns (when the series has any), and, if your API site filters return lots by lot bill number or production unit, Lot_Bill_No must be sent and the lot must have a production unit.

Duplicates

  • The same checks as a challan: your API site's duplicate supplier-bill check, and Logic ERP's own refusal of a Bill_No already used on a purchase challan or purchase challan return of the same supplier in the same branch. Challans and challan returns are checked together.

Saving

  • The return is saved in one step; on any failure nothing is saved.

Known issue – the return's Bill_No cannot be the challan's. Purchase challans and purchase challan returns share one bill-number check, so a return sent with the bill number of the challan it returns is refused with Bill No:… already exists for this supplier... Cannot Continue. Give the return its own number (for example your return note number) and put the challan's bill number in Lot_Bill_No or ChallanNo.

Known issue – lot numbers must match capitals. A LotNo is found in Logic ERP without regard to capitals, but then has to match the lot's number exactly, including capitals and spaces. dc5521-01 for the lot DC5521-01 fails with Insufficient Stock for Item Code : …. Send lot numbers exactly as Logic ERP shows them.

Known issue – no API route raises the purchase return for a challan return. The route meant for a purchase return against a purchase challan return (Save a Purchase Return Against a Purchase Challan Return) currently saves a new purchase challan (goods coming in) instead. Do not use it until it is fixed; raise the purchase return in Logic ERP.

Known issue – production unit added to lot numbers. If your API site is set to add the production unit to lot numbers, a return line taken from a lot that has a production unit fails with Lot not found for this item : …: the production unit is added to the lot number a second time while saving. Return such goods in Logic ERP until this is fixed.

Known issue – an apostrophe in a code or name. Codes and names you send (party codes, item codes, lot number, lot bill number, production unit, godown, agent, transporter, cost centre, currency, bill number) are looked up exactly as typed. An apostrophe (') in any of them makes the request fail with a database error. Leave apostrophes out of codes and names you send.

Example request

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 returns one pair of the test item APITEST0001; each send creates one more test challan return.

Save a Purchase Challan Return

post

Creates a purchase challan return in Logic ERP: goods you send back to a supplier that were received on a purchase challan and have not been billed yet – for example damaged pieces or excess quantity found when the goods were checked. The goods leave your branch's stock at once. Like the challan, the return is not a purchase document: no purchase return or debit note is raised by it.

Authorizations
AuthorizationstringRequired

The user name and password of your API site.

Body
BranchCodeintegerOptional

The branch sending the goods back, by Logic ERP's branch number (Branch_Code in Get Branch Info).

AccountCodestringOptional

The supplier's party code (User_Code in Get Party Master). Must already exist. The tax region, credit days, transporter and default discounts are taken from this account.

Bill_NostringOptional

Your return reference, for example your return note number. *Required when your API site checks duplicate supplier bills. See the known issue – it cannot be the challan's bill number.

Bill_DatestringOptional

Reference dates stored on the return.

PartyBillDatestringOptional

Reference dates stored on the return.

InvoiceDatestringOptional

Date of the return, yyyy-MM-dd. Same rules as on a challan.

Godown_NamestringOptional

Only lots in this godown are used. Must exist.

ChallanNostringOptional

As on Save a Purchase Challan. Series_Code is used only when your API site has no default series for challan returns.

PU_Remarks_2stringOptional

As on Save a Purchase Challan. Series_Code is used only when your API site has no default series for challan returns.

Responses
200

Always HTTP 200. Check Status and Message.

application/json
LastSavedDocNostringOptional

The return's GRN number, GRN prefix and number joined by -, for example RGRN-311. null when nothing was saved.

StatusbooleanOptional

true = the return was saved.

MessagestringOptional

Why it failed; empty on success.

LastSavedCodeintegerOptional

Logic ERP's internal number of the challan return. Use it in Doc_Codes to read it back.

request_IDstringOptional

The ID of this request – quote it to support.

post/SavePurchaseChallanReturn
POST /api/SavePurchaseChallanReturn HTTP/1.1
Host: demo.logicerp.com
Authorization: Basic username:password
Content-Type: application/json
Accept: */*
Content-Length: 380

{
  "BranchCode": 2,
  "AccountCode": "556",
  "Bill_No": "APITEST-PCR-001",
  "Bill_Date": "2026-10-30",
  "PartyBillDate": "2026-10-30",
  "InvoiceDate": "2026-10-30",
  "Godown_Name": "MAIN",
  "ChallanNo": "APITEST-PC-003",
  "PU_Remarks_2": "API TEST",
  "LstItems": [
    {
      "LogicUser_Code": "APITEST0001",
      "ScannedQty": 1,
      "BasicRate": 100,
      "LotNo": "APITESTLOT2",
      "Lot_Bill_No": "APITEST-PC-003",
      "ItemDescription": "API TEST"
    }
  ]
}
{
  "LastSavedDocNo": "text",
  "Status": true,
  "Message": "text",
  "LastSavedCode": 1,
  "request_ID": "text"
}

Response

Field
Type
Meaning

Status

true / false

true = the return was saved.

Message

text

Why it failed; empty on success.

LastSavedCode

number

Logic ERP's internal number of the challan return. Use it in Doc_Codes to read it back.

LastSavedDocNo

text

The return's GRN number, GRN prefix and number joined by -, for example RGRN-311. null when nothing was saved.

request_ID

text

The ID of this request – quote it to support.

Example response

Messages you may see

All with Status: false. Text in … is replaced by the value concerned. Messages marked † come with technical text before and after the reason – look for the sentence. With "DisplayError": "1" every message carries technical detail – read the first line.

Specific to returns

Message
Meaning
What to do

Insufficient Stock for Item Code : … Lot_No: …

The matching lots hold less than the quantity (or no lot matched – check the capitals of LotNo).

Check the stock with Get Stock In Hand, the lot number, Lot_Bill_No, Production_Unit and the godown.

Lot not found for this item : … †

The chosen lot is not in one of the series' default godowns (or see the known issue on production units).

Return the goods from a godown the series allows, or ask your Logic ERP team.

Invalid Bill No. Please Check.. †

Your API site filters return lots by lot bill number and Lot_Bill_No is empty.

Send Lot_Bill_No.

Invalid Production Unit for Item : … †

Your API site filters return lots by production unit and the lot has none.

Ask your Logic ERP team.

Unable to Retrive Item Details...

The item could not be read while looking for stock.

Contact support with the request_ID.

Same as on a challan

Default Configuration Not Defined in API Template, Account Code Not Defined..., Invalid Account User Code..., Invalid Supplier Code Defined..., the date messages, Bill No can't be blank..., the Bill No:… already exists… messages, Logic User Code/Additional Item Code Not Defined for Item No : …, Invalid LogicUserCode / EANCode : …, Quantity Not Defined For : '' Item No : …, Unable to Find Items for Import... †, Invalid Godown Name […]. Please Check..., Default Tax Region not Set.Please Check...., the GST messages †, the name-not-found messages and Error while saving voucher † – see Save a Purchase Challan for their meaning.