Save a Purchase Return
Records goods you send back to a supplier: Logic ERP saves a purchase return for the supplier, takes the items out of stock from lots that still hold them, and works out the value and tax of the goods returned. Use it when your warehouse or store app returns damaged, excess or wrong goods to a supplier. The request has the same shape as Save a Purchase Voucher; this page lists every field the return reads and explains where a return behaves differently.
Endpoint
Address
https://your-server/api/SavePurchaseReturn
Method
POST
Authorization
Basic Auth
The response envelope, branches, dates, queueing and the common messages are explained in How Every API Call Works.
This endpoint always uses Logic ERP's purchase import engine. Unlike Save a Purchase Voucher, no setting switches it to the screen engine.
How a return is linked to the original purchase
There is no field for the original purchase voucher – no voucher number, GRN number or internal code. A return is tied to earlier purchases only through the lot (batch) the goods are taken from:
LotNo– the lot number. Logic ERP looks only at lots of that item with that number.Lot_Bill_No– the supplier bill number the lot was purchased on (theBill_Nosent with the purchase). Send it to take the goods only from lots bought on that bill.Production_Unit– the lot's production unit, when your lots carry one.
Logic ERP does not check that the lot was bought from the supplier you are returning to, and the return is not recorded against the purchase voucher. If you need the original purchase on the return, put its number in PU_Remarks_2 or OrderNo.
Request fields
One return per request. Field names are not case-sensitive. Codes and names are matched without regard to upper and lower case, and spaces at the start are not trimmed – except LotNo, which must match the lot number exactly (see its row). Where a field works as on Save a Purchase Voucher, the meaning below is short; see that page for details.
Return header
BranchCode
number
No – but always send it (or BranchShortName)
0
Logic ERP's number of the branch sending the goods back (Branch_Code in Get Branch Info). Stock is taken from this branch.
BranchShortName
text
No
empty
The branch's short name, used only when BranchCode is 0.
AccountCode
text
Yes
–
The supplier account the return is made out to, by its code in Logic ERP (User_Code in Get Party Master). It must exist. Its tax region, payment terms and default discounts are used.
SupplierCode
text
No
AccountCode
A different supplier account, by its code, when the party on the return differs from the account posted to. When sent, it must exist.
Bill_No
text
No*
empty
The return's reference number – usually the debit-note or gate-pass number you give the supplier. *Required when your API site checks duplicate supplier bill numbers – see Duplicates.
InvoiceDate
date
No
today
The return date, yyyy-MM-dd. See Financial year and dates.
Bill_Date
date
No
InvoiceDate
Date of the reference in Bill_No.
PartyBillDate
date
No
InvoiceDate
The supplier's document date.
Godown_Name
text
No
none
Take stock only from this godown, by name. It must exist. See Stock.
GRN_Prefix
text
No
the series' first GRN prefix, else GRN
Prefix of the return's GRN number, for example "PR". Logic ERP gives the next number of that prefix.
Series_Code
number
No
the API site's series
Logic ERP's internal code of the purchase-return series. Used only when your API site has no default series for this endpoint; otherwise ignored.
GR_Number, GR_Date
text, date
No
empty
The transporter's GR (lorry receipt) number and date.
GRDate
date
No
–
Also the GR date; when both are sent, GRDate wins.
OrderNo, OrderDate
text, date
No
empty
Your reference number and date. OrderNo is also kept as the request's reference in Logic ERP's API log.
PU_Remarks_1
text
No
–
See the known issue – not saved.
PU_Remarks_2, PU_Remarks_3
text
No
empty
Remarks, for example the reason for the return.
AgentName
text
No
none
Agent, by name. Must exist.
CostCenter
text
No
none
Cost centre, by name. Must exist.
TransporterName
text
No
the supplier's transporter
Transporter, by name. Must exist.
CurrencyName, ExchangeRate
text, number
No
none, 1
Foreign currency by name (must exist) and its rate. Only an ExchangeRate above 0 is used.
CreditDays
number
No
the supplier's payment terms
Only a value above 0 is used.
CD_P, TD_P, SP_CD
number
No
the supplier's defaults
Cash discount %, trade discount % and special CD %. Only values above 0 are used.
Freight, Adjustment_Rs, SpDiscountRs, AdjustUnit, SchemeRs
number
No
0
Freight, adjustment, special discount, adjustment per unit and scheme amount in ₹. Only values above 0 are used.
ChallanNo, ChallanDate, Cases, Weight, TransportMode, VehicleNo, DeliveryAt, DeliveryAdd1, DeliveryAdd2, PVTMark, Insurance_Policy_No, Declaration_No
No
empty
Kept on the return, as on Save a Purchase Voucher.
GPN_No, GPN_Date
text, date
No
empty
Gate pass number and date. GPN_Date must be a valid date when GPN_No is sent.
Doc_Type
text
No
"PU"
Leave it out. Only with "PU" or "PR" does the return take the reverse charge mark from its tax region; any other value leaves it off. It does not change the document type.
LstItems
list
Yes
–
The items going back – see below. Send at least one line, never null.
DisplayError
text
No
"0"
"1" = when the request fails, Message holds the full technical detail. Use only while testing.
Ignored fields. DNO_Code, Challan_Code, PO_Code, EntrySource, Request_ID and Sup_Code are accepted but not used. GRN_Number, shown in older examples, does not exist – the GRN number is always the next number of the prefix.
LstItems – one entry per line
LogicUser_Code
text
Yes (or AddlItemCode)
empty
The item code shown as Item Code in Logic ERP (UserCode in Get Item Master).
AddlItemCode
text
Yes (or LogicUser_Code)
empty
The item's barcode / EAN, used when LogicUser_Code is empty or not found. With LogicUser_Code empty, the item's extra barcodes are also accepted.
ScannedQty
number
Yes
–
Quantity returned, above 0.
LotNo
text
No
empty
Take the goods only from lots with this number. Empty = any lot of the item. Send it exactly as the lot number is stored – same upper and lower case, no extra spaces; a lot number that differs only in case is not matched and the request fails with Insufficient Stock.
Lot_Bill_No
text
No*
empty
Take the goods only from lots bought on this supplier bill number. *Required when your API site filters return lots by bill number.
Production_Unit
text
No
empty
Take the goods only from lots of this production unit.
BasicRate
number
No
0
Rate per unit returned. The line amount is BasicRate × quantity, unless the supplier's price list is applied (see Rates and tax).
Lot_Mrp, PurRate, SaleRate, SP_Rate_1 … SP_Rate_5
number
No
0
Passed with the line. They do not choose the lot and are not used for the amount.
ItemDescription
text
No
empty
A description kept with the line.
Expiry_Date, MFG_Date
date
No
none
Passed with the line when they are valid dates; they do not choose the lot.
LotCode, Godown_Code and Org_Production_Unit are accepted but not used for a return – Logic ERP chooses the lot and godown itself (see Stock).
Rules Logic ERP applies
Branch. The return belongs to the branch in
BranchCode(orBranchShortName). A request with neither is not refused up front, so always send one of them.Financial year and dates. The return is saved in the financial year of the day the request arrives, not of
InvoiceDate. AnInvoiceDatebefore the start of that year is moved to the first day of the year without a message (see the known issue); one after its end is refused. When your Logic ERP does not allow post-dated purchase returns, anInvoiceDateafter today is refused, and lock periods set for purchase returns apply.Series. The return is saved in the default series set for this endpoint in your API site (one of the purchase-return series). With no default there,
Series_Codeis used; with neither, the request fails. Logic ERP does not check that aSeries_Codeyou send is a return series.What must already exist. The account (and
SupplierCode), every item, every lot you return from, and every name you send (godown, agent, cost centre, transporter, currency). Nothing is created – no lot, no item.Stock. The returned quantity is taken out of stock. For every line, Logic ERP collects the lots of the item that have stock in this branch in the current financial year, oldest purchase first, keeping only:
lots with the number in
LotNo, the bill number inLot_Bill_Noand the production unit inProduction_Unit– each only when sent;the godown in
Godown_Name, when sent;the default godown of this endpoint in your API site, when one is set (on top of
Godown_Name– see the known issue).
The quantity is taken from the first lot, then the next, until it is covered, so one line can become several return lines (one per lot and godown). Lines for the same item with the same
LotNoshare what is left (see the known issue on mixed lines). If the lots do not hold enough for a line, the whole request is refused withInsufficient Stock for Item Code : … Lot_No: …. When the return series is limited to certain godowns, stock found in other godowns makes the request fail with Lot not found for this item.API site lot filters. When your API site filters return lots by lot bill number,
Lot_Bill_Nois required on every line. When it filters by production unit, the lot taken must have a production unit, otherwise the request fails with Invalid Production Unit for Item.Rates and tax. You do not send tax amounts. Logic ERP works out GST and other taxes on each line from the item's tax setup and the return's tax region, which comes only from the supplier: the tax region linked to the
AccountCodeaccount for this branch, else that account's own tax region; when you send a differentSupplierCodeand that account has a tax region linked for this branch, that one is used. An account with neither is refused withDefault Tax Region not Set.Please Check..... When your API site applies party-wise price lists to returns and the account has a price list, the price-list rate replacesBasicRate.Stock-transfer accounts. When the account is a stock-transfer account (an account standing for another branch), the return is marked as a stock transfer to that account's branch.
Duplicates. Logic ERP does not check whether you sent the same return before; sending it twice saves two returns and takes the stock out twice. When your API site is set to validate duplicate supplier bills,
Bill_Nois required and a purchase return with the sameBill_Noin the current financial year is refused – for the same supplier and branch, or for the same supplier in any branch, depending on that setting. Only purchase returns are compared.All or nothing. The return and all its lines are saved together. If any line fails, nothing is saved.
Do not use an apostrophe (
') in codes, names, lot numbers or bill numbers – the request fails.
How it differs from Save a Purchase Voucher
Stock
Added; lots created or topped up
Taken out of existing lots that have stock
LotNo
Required (import engine)
Optional – narrows the lots searched
Lot_Bill_No, Production_Unit
Kept on new lots
Narrow the lots searched
LotCode, Godown_Code on a line
Line godown used
Ignored – Logic ERP picks lot and godown
One request line
One voucher line
Can become several lines (one per lot / godown)
Engine
Import engine or screen engine (API setting)
Always the import engine
Party price list
Not applied
Applied when switched on for the API site
Duplicate supplier bill check
Against purchase vouchers
Against purchase returns
Known issue – the return date can be moved into the current financial year. The return is always saved in the financial year of the day the request arrives. An
InvoiceDatefrom an earlier financial year is not refused: the return is saved dated the first day of the current year. Until this is fixed, send returns for an earlier year through the Purchase Return screen, and check the date on returns sent just after the year changes.
Known issue –
Godown_Nameand the API site's default godown are both applied. When your API site has a default godown for this endpoint, stock is searched only in lots that are in that godown and inGodown_Name. If the two differ, no stock is found and the request fails with Insufficient Stock. Until this is fixed, sendGodown_Nameonly when it is the default godown, or ask your Logic ERP team to clear the default godown for this endpoint.
Known issue – mixed lines for the same item can return more than a lot holds. Stock is counted separately for each different
LotNoyou send. A line for an item with an emptyLotNodoes not see what another line naming one of that item's lots has already taken, so together they can take more than the lot holds. Until this is fixed, send all lines for one item either with the lot number or without it, not both.
Known issue – accounts with no stock-transfer branch recorded fail. Some accounts – usually system or default accounts created with the company – have no stock-transfer branch recorded at all (not even "none"). A return to such an account fails with a technical error. Until this is fixed, use a regular supplier account, or ask your Logic ERP team to set that account's stock-transfer branch to none.
Known issue – "append production unit to lot number" makes returns fail. When this setting is switched on for this endpoint in your API site and the lot taken has a production unit, Logic ERP looks for a lot numbered
LotNo|production unit– which is not the lot it found – and the request fails with Lot not found for this item. Until this is fixed, ask your Logic ERP team to keep that setting off for purchase returns.
Known issue –
PU_Remarks_1is not saved. The first remark is dropped, so the return's first remark stays empty. Send remarks inPU_Remarks_2andPU_Remarks_3.
Example request
Two shirts of lot L2610-118 (bought on supplier bill INV-4471) going back to supplier SUP014 from the main godown of branch 2:
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 return.
Records goods you send back to a supplier: Logic ERP saves a purchase return for the supplier, takes the items out of stock from lots that still hold them, and works out the value and tax of the goods returned. Use it when your warehouse or store app returns damaged, excess or wrong goods to a supplier. The request has the same shape as Save a Purchase Voucher; this page lists every field the return reads and explains where a return behaves differently.
The user name and password of your API site.
Logic ERP's number of the branch sending the goods back (Branch_Code in Get Branch Info). Stock is taken from this branch.
The supplier account the return is made out to, by its code in Logic ERP (User_Code in Get Party Master). It must exist. Its tax region, payment terms and default discounts are used.
The return's reference number – usually the debit-note or gate-pass number you give the supplier. *Required when your API site checks duplicate supplier bill numbers – see Duplicates.
The return date, yyyy-MM-dd. See Financial year and dates.
Date of the reference in Bill_No.
The supplier's document date.
Take stock only from this godown, by name. It must exist. See Stock.
Your reference number and date. OrderNo is also kept as the request's reference in Logic ERP's API log.
Remarks, for example the reason for the return.
Always HTTP 200. Check Status and Message.
The return's GRN number as prefix and number, for example PR-37. null when not saved.
true when the return was saved.
Empty when saved; the reason when not saved.
Logic ERP's internal number of the return; 0 when not saved.
The ID of this request – quote it to support.
No login was sent.
POST /api/SavePurchaseReturn HTTP/1.1
Host: demo.logicerp.com
Authorization: Basic username:password
Content-Type: application/json
Accept: */*
Content-Length: 364
{
"BranchCode": 2,
"AccountCode": "556",
"Bill_No": "APITEST-PR-001",
"InvoiceDate": "2026-10-30",
"Bill_Date": "2026-10-30",
"PartyBillDate": "2026-10-30",
"Godown_Name": "MAIN",
"OrderNo": "APITEST-PR-001",
"PU_Remarks_2": "API TEST",
"LstItems": [
{
"LogicUser_Code": "APITEST0001",
"AddlItemCode": "",
"ScannedQty": 1,
"LotNo": "APITESTLOT2",
"BasicRate": 100,
"ItemDescription": "API TEST"
}
]
}{
"LastSavedDocNo": "text",
"Status": true,
"Message": "text",
"LastSavedCode": 1,
"request_ID": "text"
}Response
Status
true / false
true when the return was saved.
Message
text
Empty when saved; the reason when not saved.
LastSavedCode
number
Logic ERP's internal number of the return; 0 when not saved.
LastSavedDocNo
text
The return's GRN number as prefix and number, for example PR-37. null when not saved.
request_ID
text
The ID of this request – quote it to support.
Example response
Messages you may see
Messages marked technical text arrive wrapped in technical detail: look for the quoted reason inside Message (the first line starts with technical words). The others are the whole Message, unless you send "DisplayError": "1".
Default Configuration Not Defined in API Template
No series: your API site has no default series for this endpoint and no Series_Code was sent.
Ask your Logic ERP team to set the default series.
Request cannot be processed. API Template is marked as In-Active in the configuration.
This endpoint is switched off for your API site. Nothing is saved, but Status is true and LastSavedCode is 0 – look for this sentence.
Ask your Logic ERP team.
Account Code Not Defined...
AccountCode is empty.
Send the supplier's code.
Invalid Account User Code...
No account has that AccountCode.
Check it with Get Party Master.
Invalid Supplier Code Defined...
SupplierCode was sent but not found.
Check it, or leave it out.
Invalid Invoice Date Defined..., Invalid Bill Date..., Invalid Party Bill Date...
A date could not be read.
Send dates as yyyy-MM-dd.
Invalid Godown Name […]. Please Check...
Godown_Name was not found.
Send the godown name as in Logic ERP.
Bill No can't be blank...
Your API site checks duplicate supplier bills and Bill_No is empty.
Send Bill_No.
Bill No:… already exists for current supplier and current Branch / Bill No:… already exists for current supplier..
A purchase return with this Bill_No already exists (see Duplicates).
Do not resend the same return; use a new reference.
Post Dated enteries are not allowed.......
InvoiceDate is after today and post-dated returns are not allowed.
Send today's date or earlier.
Entry/Modification is locked for this period....
InvoiceDate is in a locked period.
Ask your Logic ERP team.
Logic User Code/Additional Item Code Not Defined for Item No : …
Line number … has neither LogicUser_Code nor AddlItemCode.
Send the item code or barcode.
Invalid LogicUserCode / EANCode : …
The item was not found; … is the barcode you sent, else the item code, in capitals.
Check the code with Get Item Master.
Quantity Not Defined For : '' Item No : …
Line number … has a quantity of 0 or less.
Send a positive ScannedQty.
Insufficient Stock for Item Code : … Lot_No: …
The lots that match the line do not hold the quantity (see Stock and the godown known issue).
Check stock with your Logic ERP team; check LotNo, Lot_Bill_No, Production_Unit and Godown_Name.
Unable to Retrive Item Details...
The item's master record is incomplete.
Ask your Logic ERP team.
Invoice Date Date not within financial year.Please Check....
InvoiceDate is after the end of the current financial year.
Check the date.
Default Tax Region not Set.Please Check....
The supplier has no tax region for this branch and none of its own.
Set the tax region on the supplier in Logic ERP.
Invalid Agent […] .Please Check
AgentName was not found.
Send the agent name as in Logic ERP.
Technical text containing Lot not found for this item : …
The lot found could not be used – the return series is limited to other godowns, or the production-unit setting above is on.
Ask your Logic ERP team.
Technical text containing Invalid Bill No. Please Check..
Your API site filters lots by bill number and Lot_Bill_No is empty.
Send Lot_Bill_No.
Technical text containing Invalid Production Unit for Item : …
Your API site filters lots by production unit and the lot has none.
Ask your Logic ERP team.
Technical text containing Unable to found Cost Center […] .Please Check, Transporter Name [ … ] not found. Please Check..., Currency Name [ … ] not found. Please Check... or Invalid GPN_Date .Please Check
A name was not found, or GPN_No was sent without a valid GPN_Date.
Send names exactly as in Logic ERP; send GPN_Date as yyyy-MM-dd.
Technical text containing Unable to Find Items for Import...
LstItems is empty.
Send at least one line.
Technical text containing Purchase / Tax Details not found for all Items. Check Row No.: … or Please set Default Tax Type before import this document.......
The item's tax for this tax region, or the series' default tax type, is not set up.
Ask your Logic ERP team.
Any other technical error
Saving failed inside Logic ERP; nothing was saved.
Retry once; if it repeats, send the request_ID to support.
Last updated