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

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. To create the challan return itself, use Save a Purchase Challan Return.

Known issue – this endpoint saves a purchase challan, not a purchase return. Today every request to this address (and to its older spelling) is processed exactly like Save a Purchase Challan: Challan_Code is ignored, a new purchase challan (goods receipt) is created for AccountCode with the items in LstItems, and those goods are added to stock – the opposite of a return. The request is checked against your API site's purchase challan settings and licence, and messages are those of Save a Purchase Challan. A successful answer carries the new challan's GRN number in LastSavedDocNo (for example TGRN-10040) and its internal number in LastSavedCode. Do not call this endpoint. Bill purchase challan returns in Logic ERP until this is corrected; if a request 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.

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. One challan return per request.

AccountCode

text

Yes

–

The supplier, by the party code shown in Logic ERP (User_Code in Get Party Master). The purchase return is posted to this account. Send the challan return's own supplier – see the known issue below.

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.

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

Checked to be a date and used as the default for Bill_Date and PartyBillDate. It does not set the document date – see the known issue below.

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_2, PU_Remarks_3

text

No

empty

Remarks 2 and 3. Always written – when you leave them out, the challan return's remarks 2 and 3 are not carried over (see the known issue below).

OrderNo

text

No

empty

Order number. Always written, like the remarks above.

GR_Number

text

No

empty

Transport GR (lorry receipt) number. Always written, like the remarks above.

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. Checked, but not saved – see the known issue below.

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, AdjustUnit, CreditDays

number

No

the challan return's values

Document-level discounts, charges 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).

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), PU_Remarks_1 (remarks 1 always comes from the challan return), Godown_Name (not used, but a name that does not exist still stops the request; leave it empty), SchemeRs (see the known issue below), 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 lines of the challan return in Challan_Code that still have an open (unbilled) quantity and whose item is in LstItems. Each line is billed for the quantity you sent for its item and lot, but never more than the line's open quantity. A larger quantity is not refused – only the open quantity is billed. Lines of items you did not list stay open. An item you list that has no open line on the challan return is skipped without a message.

  • 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 not cross-checked. Logic ERP does not check that the challan return belongs to the supplier in AccountCode or to the branch you send. Send its own supplier and branch.

  • 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 today (the server's date) and saved in the current financial year.

  • 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.

Known issue – a challan return with the same item in several lots. If the challan return has the item in more than one lot with open quantity, every one of those lots must be in LstItems; a lot left out makes the request fail with Invalid Item/Lot Present in Purchase Challan. To bill only some lots of such an item, bill it in Logic ERP.

Known issue – the same item and lot twice in LstItems. Only the first entry's quantity is used; later entries for the same item and lot are ignored. Send one entry per item and lot with the total quantity.

Known issue – two lines with the same item and lot. Each such line of the challan return is limited to your quantity on its own, so together they can bill more than you sent. Check the billed quantity in Logic ERP when the same item and lot is on more than one line.

Known issue – AccountCode is not checked against the challan return. The purchase return is posted to the account you send even when the challan return is for another supplier, while the supplier on the document stays the challan return's. Always send the challan return's own supplier code.

Known issue – Challan_Code is not checked to be a challan return. The number of a purchase challan (goods received) is accepted too, and its open lines are billed as a purchase return. Make sure you send the internal number of a purchase challan return.

Known issue – remarks 2 and 3, order number and GR number are cleared. PU_Remarks_2, PU_Remarks_3, OrderNo and GR_Number are always written, so leaving them out clears the values the challan return had. Send them again when you want to keep them.

Known issue – AgentName is not saved. The agent you send is checked (a name that is not found stops the request), but the purchase return is saved without an agent. Set the agent in Logic ERP if you need one.

Known issue – SchemeRs is saved as freight. A SchemeRs above 0 is written to the document's freight (unless Freight is also sent). Do not send SchemeRs.

Known issue – InvoiceDate does not set the document date. The purchase return is always dated today, whatever InvoiceDate you send. Send the request on the day the document should carry.

Example request

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

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.

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....

Today's date is outside the financial year Logic ERP opened.

Ask your Logic ERP team to check the financial years.

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.

Invalid Item/Lot Present in Purchase Challan. Item Code:… Lot_No : … Prod_Unit : … (followed by internal numbers)

A line of one of your items has a lot that is not in LstItems – or LotNo does not match exactly.

Send the lot numbers exactly as on the challan return, and every lot of that item (see the known issue).

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.

"Status": false with an empty Message

Saving stopped without a reason. Nothing was saved.

Check the challan return in Logic ERP; send the request_ID to support.

Last updated