Save a Purchase Voucher Against a Purchase Challan
Bills goods that came in on a purchase challan that is already in Logic ERP. A purchase challan (goods receipt note) brings the goods into stock, but nothing is posted to the supplier's account yet. This endpoint takes the open lines of one challan for the items you list, prices and taxes them, and saves them as a purchase voucher posted to the supplier's account. You send the challan's internal number and the items and quantities you are billing; rates and taxes come from Logic ERP, not from your request.
To record a purchase without a challan, use Save a Purchase Voucher. To create the challan itself, use Save a Purchase Challan.
Endpoint
Address
https://your-server/api/SavePurchaseAgainstPUChallan
Method
POST
Authorization
Basic Auth
Also accepted: https://your-server/api/SavePurchaseAgaintPUChallan (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 Voucher, 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).
Challan_Code
number
Yes
0
Logic ERP's internal number of the purchase challan – the LastSavedCode you got from Save a Purchase Challan, or Vouch_Code in Get Purchase Challans. One challan per request.
AccountCode
text
Yes
–
The supplier, by the party code shown in Logic ERP (User_Code in Get Party Master). The voucher is posted to this account. Send the challan's own supplier – see the known issue below.
BranchCode
number
No – but always send it (or BranchShortName)
0
The branch the voucher is saved in (as explained in How Every API Call Works). Send the branch where the challan was saved.
BranchShortName
text
No
empty
The branch's short name, used only when BranchCode is 0.
Bill_No
text
No
the challan's supplier bill number
The supplier's bill (invoice) number.
Bill_Date
date
No
InvoiceDate, else today
The supplier's 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 voucher date – see the known issue below.
GRN_Prefix
text
No
GRN
Prefix of the goods receipt (GRN) number given to the voucher. The voucher gets the next GRN number for that prefix.
LstItems
list
Yes
empty list
The items and quantities to bill from the challan – 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 of the voucher. Always written – when you leave them out, the challan'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's values
Replace the challan'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's values
Replace the challan's values when sent (not empty).
DeliveryAt
text
No
empty
The delivery-at place. The challan'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'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'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's values
Document-level discounts, charges and credit days. Only values above 0 are used; they replace the challan'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
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 line – same capitals, no extra spaces. Without it the line does not match the challan and the request is refused.
Org_Production_Unit
text
No
empty
The lot's production unit. Used to match the challan 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 challan 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), Godown_Name (not used – the lines keep the challan's godowns – 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 in
Challan_Codethat still have an open (unbilled) quantity and whose item is inLstItems. 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 is skipped without a message.Billing in parts. The billed quantity is taken off the challan line's open quantity, so the rest can be billed later with another request. If the purchase series is set to bill only challan goods that have already been sold, unsold quantity is left out.
Matching lines. A challan line matches a
LstItemsentry by item andLotNo(and production unit, when that API setting is ticked). The lot number must match exactly, including capitals.Supplier, branch and challan are not cross-checked. Logic ERP does not check that the challan belongs to the supplier in
AccountCodeor to the branch you send. Send the challan's own supplier and branch.Rates. Your rates are not used. Each line's rate is the lot's basic rate, or the challan line's rate, depending on a setting of the purchase series. Sale rate, MRP and the other rates come from the lot. Rate formulas set on the purchase series are applied, as on Logic ERP's purchase screen.
Taxes. The tax region is the challan's tax region (not the supplier's current one). GST and other taxes are worked out item by item for that region and supplier, as on Logic ERP's purchase screen. A challan without a tax region is refused.
What comes from the challan. Supplier 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. The challan's agent, delivery-at place, currency and cost centre are not carried over.
Series and number. The voucher is saved in the purchase series chosen as Default Configuration for Purchase voucher against purchase challan in your API site's settings. There is no request field for the series. The voucher gets the series' next number.
Checks of the series. The purchase series' own checks apply – for example a mandatory MRP or purchase/sale rate, or refusing a supplier bill number that already exists for the supplier.
Date and financial year. The voucher is dated today (the server's date) and saved in the current financial year.
Approval. A challan that is waiting for 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. CheckStatusbefore you resend.All or nothing. The voucher and all its lines are saved together. If anything fails, nothing is saved.
Your Logic ERP licence must include the API for purchase vouchers against challans.
Known issue – a challan with the same item in several lots. If the challan 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 withInvalid 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 challan lines with the same item and lot. Each such line 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 a challan has the same item and lot on more than one line.
Known issue –
AccountCodeis not checked against the challan. The voucher is posted to the account you send even when the challan is from another supplier, while the supplier on the voucher stays the challan's. Always send the challan's own supplier code.
Known issue –
Challan_Codeis not checked to be a purchase challan. The number of a purchase challan return is accepted too, and its open lines are billed as a purchase. Make sure you send the internal number of a purchase challan.
Known issue – remarks 2 and 3, order number and GR number are cleared.
PU_Remarks_2,PU_Remarks_3,OrderNoandGR_Numberare always written to the voucher, so leaving them out clears the values the challan had. Send them again with the challan's values when you want to keep them.
Known issue –
AgentNameis not saved. The agent you send is checked (a name that is not found stops the request), but the voucher is saved without an agent. Set the agent on the voucher in Logic ERP if you need one.
Known issue –
SchemeRsis saved as freight. ASchemeRsabove0is written to the voucher's freight (unlessFreightis also sent). Do not sendSchemeRs.
Known issue –
InvoiceDatedoes not set the voucher date. The voucher is always dated today, whateverInvoiceDateyou send. Send the request on the day the voucher should carry, and useBill_Date/PartyBillDatefor the supplier's dates.
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's challan has already been billed, so sending it unchanged bills nothing more; save a new challan on its page first and put its LastSavedCode in Challan_Code.
Bills goods that came in on a purchase challan that is already in Logic ERP. A purchase challan (goods receipt note) brings the goods into stock, but nothing is posted to the supplier's account yet. This endpoint takes the open lines of one challan for the items you list, prices and taxes them, and saves them as a purchase voucher posted to the supplier's account. You send the challan's internal number and the items and quantities you are billing; rates and taxes come from Logic ERP, not from your request.
The user name and password of your API site.
Logic ERP's internal number of the purchase challan – the LastSavedCode you got from Save a Purchase Challan, or Vouch_Code in Get Purchase Challans. One challan per request.
The supplier, by the party code shown in Logic ERP (User_Code in Get Party Master). The voucher is posted to this account. Send the challan's own supplier – see the known issue below.
The branch the voucher is saved in (as explained in How Every API Call Works). Send the branch where the challan was saved.
The supplier's bill (invoice) number.
The supplier's bill date, yyyy-MM-dd.
The party bill date, yyyy-MM-dd.
Order number. Always written, like the remarks above.
Remarks 2 and 3 of the voucher. Always written – when you leave them out, the challan's remarks 2 and 3 are not carried over (see the known issue below).
Always HTTP 200. Check Status and Message.
The voucher's GRN number – prefix, a hyphen and the number with two decimals, for example GRN-13.00. Empty (null) when not saved.
true when the voucher was saved.
Empty when saved; the reason when not saved.
Logic ERP's internal number of the new purchase voucher; 0 when not saved.
The ID of this request – quote it to support.
No login was sent.
POST /api/SavePurchaseAgainstPUChallan HTTP/1.1
Host: demo.logicerp.com
Authorization: Basic username:password
Content-Type: application/json
Accept: */*
Content-Length: 273
{
"Challan_Code": 1423,
"AccountCode": "556",
"BranchCode": 2,
"Bill_No": "APITEST-PU-003",
"Bill_Date": "2026-10-30",
"PartyBillDate": "2026-10-30",
"OrderNo": "APITEST-PC-003",
"PU_Remarks_2": "API TEST",
"LstItems": [
{
"LogicUser_Code": "APITEST0001",
"ScannedQty": 4,
"LotNo": "APITESTLOT2"
}
]
}{
"LastSavedDocNo": "text",
"Status": true,
"Message": "text",
"LastSavedCode": 1,
"request_ID": "text"
}Response
Status
true / false
true when the voucher was saved.
Message
text
Empty when saved; the reason when not saved.
LastSavedCode
number
Logic ERP's internal number of the new purchase voucher; 0 when not saved.
LastSavedDocNo
text
The voucher's GRN number – prefix, a hyphen and the number with two decimals, for example GRN-13.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 voucher 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.
Default Configuration Not Defined..
No purchase series is chosen for purchase vouchers against purchase 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'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 is waiting for approval.
Approve it in Logic ERP first.
No Pending Item Present....
The challan 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 has no tax region.
Correct the challan in Logic ERP.
Invalid Item/Lot Present in Purchase Challan. Item Code:… Lot_No : … Prod_Unit : … (followed by internal numbers)
A challan 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, and every lot of that item (see the known issue).
No Item Present Purchase Challan.
None of the challan's lines could be billed.
Check the challan 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 purchase series needs an MRP and the lot has none.
Correct the lot or the series in Logic ERP.
Purchase Rate entry is mandatory.... Row No:… / Sale Rate entry is mandatory.... Row No:… *
The purchase series needs a rate and the line has none.
Correct the lot's rates in Logic ERP.
Unable to identify taxes of Item at Row No.:… *
No tax could be found for an item in the challan'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 supplier 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 supplier bill number already exists for this supplier and the purchase 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 in Logic ERP; send the request_ID to support.
Last updated