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

Save a Sale Invoice Against a Sale Order

Bills a sale order that is already in Logic ERP. You name the order and, usually, the items and quantities you are delivering now; Logic ERP takes the order's pending lines for those items, with the order's customer, rates and discounts, takes the stock from the branch, works out GST and other taxes, and saves a sale invoice linked to the order. The order's pending quantity goes down by what was billed, so an order can be billed in parts. The answer tells you the invoice number and Logic ERP's internal number of the invoice.

To bill goods without an order, use Save a Sale Invoice. To bill a delivery order or packing slip, use Save a Sale Invoice Against a Delivery Order.

Endpoint

Name
Detail

Address

https://your-server/api/SaveInvoiceAgainstSO

Method

POST

Authorization

Basic Auth

The response envelope, branches, dates, queueing and the common messages are explained in How Every API Call Works. The order is created with Save a Sale Order; the saved invoice can be read back with Get Sale Invoices.

Request fields

The request has the same shape as Save a Sale Invoice, and most header fields mean the same (see that page). This table lists only what is different for an order. Field names are not case-sensitive. Names are looked up without regard to capitals; spaces around them are not trimmed (only Tax_Region and TransporterName are trimmed).

Field
Type
Required
Default
Meaning

Doc_Code

number

Yes (or OrderNo)

0

Logic ERP's internal number of the sale order – the LastSavedCode you got from Save a Sale Order.

OrderNo

text

No

empty

With Doc_Code 0: the order is looked up by the party order number (Party_Order_No sent with Save a Sale Order) – see the known issue. It is also kept on the invoice as its order number, as on Save a Sale Invoice.

BranchCode

number

No – ignored when Doc_Code is sent (standard routine); required on the newer routine

0

The invoice is always saved in the order's branch, with that branch's API settings. Used only for the look-up by OrderNo.

BranchShortName

text

No

empty

Branch short name. With Doc_Code 0 it is the only branch field that works for the look-up by OrderNo.

Bill_Date

date

No

today

Date of the invoice, yyyy-MM-dd; decides the financial year. It does not have to match the order's date.

BillSeries

text

No

see rules

A sale series (not a stock transfer series) of the order's branch, by name. A series linked to the order's series takes priority – see the rules.

Bill_Number, Ext_Bill_No

number, text

No

0, empty

As on Save a Sale Invoice.

LstItems

list

No

empty list

What to bill now – see the next table. Leave it empty to bill every pending line of the order in full. Send [] or leave it out – never null.

InvoiceType

text

No

empty

"B2B" = when the order was taken as a B2B (drop-ship) order, the invoice is made out to the order's other customer and normally posted in the accounts to the order's customer. Any other value: the order's customer.

GST_State_Code

text

No

Logic ERP's value

Place-of-supply state code. Used whenever sent – no API setting is needed on this endpoint.

Tax_Region

text

No

the default of the series and party

The tax region, by name. "AUTO" is not supported.

ActEntryPartyUserCode

text

No

the order's customer

A different account to post the invoice to in the accounts, by its code.

AgentName, CostCenter, Tax_Form_Name, TransporterName, TransportMode, WayBillNo, CurrencyName, ExchangeRate, CreditDays, PaymentMode

No

As on Save a Sale Invoice.

CD_P, TD_P, SpCD_P, Freight, SpDiscountRs, Adjustment_Rs, Handling, Ext_NetSale_Value

number

No

0

Invoice-level discounts, charges and the net amount check, as on Save a Sale Invoice. Applied over the order's lines.

Remarks1–Remarks3, DeliveryAt, DeliveryAdd1, DeliveryAdd2, Cases, Weight, PVTMark, GRNo, GRDate, Challan_No, Challan_Date, Insurance_Policy_No, Declaration_No, DeclarationNo, OrderDate

No

empty

Kept on the invoice, as on Save a Sale Invoice.

Order_Id

text

No

empty

Kept on the invoice – but when the order carries an external order ID, that ID replaces yours.

TenderDetails

list

No

empty list

How the bill was paid, as on Save a Sale Invoice. Send [] or leave it out – never null.

Godown_Name

text

No

empty

Not used to choose stock, but a name that does not exist still stops the request. Leave it empty.

RCU_First_Name, RCU_State

text

No

empty

Used only when the order has no retail customer: without RCU_Mobile_No and RCU_Email, when both are the same word, the invoice is linked to the one retail customer with that first name in that state.

Request_ID, DisplayError

text

No

empty, "0"

As on Save a Sale Invoice.

Ignored fields. PartyUserCode (the invoice is made out to the order's customer), Doc_Type, Token_No, STBranchCode, EntrySource, BillingAddress, ShippingAddress (the order's billing and shipping addresses are used), Billing_Address1, Billing_Address2, Sale_BillNo, Sale_Bill_Date (read but not saved) and the other RCU_… fields (the order's retail customer is used) are accepted but not used.

LstItems – one entry per item to bill

Field
Type
Required
Default
Meaning

LogicUserCode / AddlItemCode

text

Yes (one of them)

empty

The item, as on Save a Sale Invoice. It must be on the order with a pending quantity.

Quantity

number

Yes

–

Quantity to bill now, above 0. Lines of the same item are added together.

Mrp

number

No

0

Above 0: take the stock only from lots with this MRP.

Lot_No

text

No

empty

Must exist for the item. It decides the lot only when your API site requires a lot number for this endpoint – see the rules.

Rate, CD_P, TD_P, SPCD_P, Scheme_Rs, SchemePerUnit, AdjustItem_Rs, AdjustmentRs, AdjustmentPerUnit, LabourPerUnit, ItemDescription, GodownName, Production_Unit, SaleOrSR

No

Not used – rates and discounts come from the order (see the rules). Rate only appears in a message.

Rules Logic ERP applies

  • Which order. With Doc_Code, that order; it does not have to belong to the branch you send. Without Doc_Code, the order of the branch whose party order number equals OrderNo; if several orders of the branch have the same number, any one of them may be taken. The order must be approved and not cancelled.

  • Customer and branch come from the order. The invoice is made out to the order's customer (or, with "InvoiceType": "B2B" on a B2B order, to its other customer) and saved in the order's branch. A customer locked for billing, or over its credit limit when Logic ERP stops bills over the limit, is refused.

  • What is billed. Only order lines with a pending quantity, not cancelled and not linked to another line. With LstItems, each item's quantity is spread over the order's pending lines for that item, never more than a line's pending quantity. Every item you send must be on the order, and the quantity billed for each item must come out exactly as you sent it – if the order does not have that much pending (over-billing) or – when the series checks stock – the branch does not have the stock, the whole request is refused. Without LstItems, every pending line is billed in full.

  • Partial billing. Billing less than the pending quantity leaves the rest of the order open; send another request later for the rest. The order is not closed or cancelled after billing.

  • Rates and discounts come from the order's lines and Logic ERP's settings for the series (the order rate is taken when the series is set to pick rates from the sale order; otherwise the rate Logic ERP's sale bill screen would take). Invoice-level discounts you send are added on top; the schemes set up in Logic ERP are applied, taxes are worked out for the tax region, TCS is added when the customer is set up for it, and the total is rounded, as on the sale bill screen.

  • Stock. Stock reserved for the order line is used first; otherwise the stock is taken from the branch's lots as Logic ERP's sale bill screen takes it for an order. With Mrp, only lots with that MRP. When your API site requires a lot number for this endpoint, only lots with stock are used, limited to the order line's own lot number, or else to the Lot_No values you send for that item.

  • Series and number. The series is, in this order: the sale series your Logic ERP team has linked to the order's series in the API site setup, else the BillSeries you send, else the series linked to the customer for sale bills, else the API site's default series for this endpoint. A BillSeries that is not found is skipped without a message. The invoice gets the next number of that series in the year of Bill_Date unless you send Bill_Number.

  • Taken over from the order: the retail customer, billing and shipping addresses, delivery address, the order's external order ID, a credit note adjusted on the order and the advance received against it.

  • API site settings. This endpoint has its own settings (default series, series links, duplicate order number check, saving in the background or later), separate from Save a Sale Invoice. They are read for the order's branch.

  • Duplicates. Logic ERP does not stop you billing the same quantities twice as long as the order still has them pending. If your Logic ERP team switches on "do not allow duplicate order number" for this endpoint, OrderNo becomes required and a second invoice with the same OrderNo for the same branch and customer in the year is refused – which also stops a second partial invoice that repeats the order number.

  • All or nothing. The invoice, its lines and the reduction of the order's pending quantities are saved together.

  • Your Logic ERP team can set the API site to save in the background or keep requests for later processing, as on Save a Sale Invoice. Do not use an apostrophe (') in codes, names or order numbers.

  • Newer save routine. Some sites are switched by support to a newer routine for this endpoint. On those sites BranchCode (or BranchShortName), PartyUserCode and LstItems are required: without a branch the request is refused with Default Bill Series Not Set for Branch Code : 0, even when you send BillSeries, and without PartyUserCode with Party_User_Code cannot be blank.... The invoice is made out to PartyUserCode and saved in the branch you send (the order's customer and branch are not checked), the series is BillSeries or the API site's default only, the financial year follows Sale_Bill_Date, and Order_No comes back empty. Ask your Logic ERP team which routine your site uses – do not assume the standard one. Sending BranchCode and PartyUserCode (the order's own branch and customer) works on both.

Known issue – the look-up by OrderNo does not use BranchCode. When Doc_Code is 0, the branch you send in BranchCode is dropped before the order is looked up, so Logic ERP looks for the order outside your branch; normally it is not found and the answer is Unable to Retrieve Sale Order.... Send Doc_Code; or, to look up by OrderNo, send the branch in BranchShortName.

Known issue – without LstItems, missing stock is not reported. When stock is checked and LstItems is empty, an order line the branch cannot fully supply is billed for the quantity in stock, or left out, without a message. Send LstItems if you need every quantity confirmed.

Known issue – a customer marked for stock transfer gets a stock transfer. If the order's customer is set up in Logic ERP as a stock-transfer party, the document is saved as a stock transfer, not a sale invoice. Check Invoice_No and the document in Logic ERP for such customers.

Known issue – a wrong BillSeries is not refused. A series name that does not exist for the order's branch is skipped and the invoice is saved in another series without a message. Check Invoice_No in the response.

Known issue – WayBillNo is not linked. As on Save a Sale Invoice: a way bill that is not finalized is refused as already Finalized, and a finalized one is accepted but not linked. Leave WayBillNo empty.

Known issue – a switched-off endpoint answers "Status": false with technical text. When your Logic ERP team has switched this endpoint off for the order's branch, nothing is saved and Message holds technical detail around Request cannot be processed. API Template is marked as In-Active in the configuration. Sites on the newer routine answer "Status": true with just that sentence. Treat it as "not saved" either way.

Example request

Bill 2 of the 5 shirts and the 1 pair of trousers still pending on sale order 48213:

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. The example's test order may already be fully billed, and is then refused – first save a test order with Save a Sale Order and send its internal number in Doc_Code. The sandbox uses the newer save routine, so keep BranchCode and PartyUserCode.

Save a Sale Invoice Against a Sale Order

post

Bills a sale order that is already in Logic ERP. You name the order and, usually, the items and quantities you are delivering now; Logic ERP takes the order's pending lines for those items, with the order's customer, rates and discounts, takes the stock from the branch, works out GST and other taxes, and saves a sale invoice linked to the order. The order's pending quantity goes down by what was billed, so an order can be billed in parts. The answer tells you the invoice number and Logic ERP's internal number of the invoice.

Authorizations
AuthorizationstringRequired

The user name and password of your API site.

Body
Doc_CodeintegerOptional

Logic ERP's internal number of the sale order – the LastSavedCode you got from Save a Sale Order.

BranchCodeintegerOptional

The invoice is always saved in the order's branch, with that branch's API settings. Used only for the look-up by OrderNo.

PartyUserCodestringOptional

One party code as shown in Logic ERP (User_Code in the response), for example "C1045". Returns that party whether or not it changed recently; the bookmark and period are ignored.

OrderNostringOptional

With Doc_Code 0: the order is looked up by the party order number (Party_Order_No sent with Save a Sale Order) – see the known issue. It is also kept on the invoice as its order number, as on Save a Sale Invoice.

Bill_DatestringOptional

Date of the invoice, yyyy-MM-dd; decides the financial year. It does not have to match the order's date.

BillSeriesstringOptional

A sale series (not a stock transfer series) of the order's branch, by name. A series linked to the order's series takes priority – see the rules.

Bill_NumberintegerOptional

As on Save a Sale Invoice.

Remarks1stringOptional

Kept on the invoice, as on Save a Sale Invoice.

TenderDetailsobject[]Optional

How the bill was paid, as on Save a Sale Invoice. Send [] or leave it out – never null.

Responses
200

Always HTTP 200. Check Status and Message.

application/json
PrintFilestringOptional

Always empty.

Invoice_NostringOptional

The invoice number given (for a series with its own number format, the formatted number such as 26-27/WSL-1290), or your Ext_Bill_No.

Order_NostringOptional

The sale order's number as Logic ERP shows it – order prefix and number, for example SO-3554. Empty when not saved, and always on the newer routine.

PartyOrderNostringOptional

The OrderNo you sent (also when not saved).

StatusbooleanOptional

true when the invoice was saved.

MessagestringOptional

Empty when saved, unless your Logic ERP shows the document number after saving. The reason when not saved.

LastSavedCodeintegerOptional

Logic ERP's internal number of the new invoice; 0 when not saved.

request_IDstringOptional

Filled once Logic ERP has started on the request, also when it then fails.

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

{
  "Doc_Code": 487069,
  "BranchCode": 2,
  "PartyUserCode": "APITESTC01",
  "OrderNo": "APITEST-SO-002",
  "Bill_Date": "2026-10-30",
  "BillSeries": "WSL",
  "Bill_Number": 0,
  "Remarks1": "API TEST",
  "LstItems": [
    {
      "LogicUserCode": "APITEST0001",
      "Quantity": 1
    }
  ],
  "TenderDetails": []
}
{
  "PrintFile": "text",
  "Invoice_No": "text",
  "Order_No": "text",
  "PartyOrderNo": "text",
  "Status": true,
  "Message": "text",
  "LastSavedCode": 1,
  "request_ID": "text"
}

Response

Field
Meaning for this endpoint

Status

true when the invoice was saved.

Message

Empty when saved, unless your Logic ERP shows the document number after saving. The reason when not saved.

LastSavedCode

Logic ERP's internal number of the new invoice; 0 when not saved.

Invoice_No

The invoice number given (for a series with its own number format, the formatted number such as 26-27/WSL-1290), or your Ext_Bill_No.

Order_No

The sale order's number as Logic ERP shows it – order prefix and number, for example SO-3554. Empty when not saved, and always on the newer routine.

PartyOrderNo

The OrderNo you sent (also when not saved).

PrintFile

Always empty.

request_ID

Filled once Logic ERP has started on the request, also when it then fails.

Example response

Messages you may see

All with Status: false. When your API site logs requests, or with "DisplayError": "1", the reason may be followed by technical detail – read the first line.

Message
Meaning
What to do

Unable to Retrieve Sale Order...

No Doc_Code, and no order was found for OrderNo (see the known issue).

Send Doc_Code.

Default Bill Series Not Set for Branch Code : 0

Newer routine: no BranchCode was sent.

Send BranchCode.

Party_User_Code cannot be blank...

Newer routine: no PartyUserCode was sent.

Send the order's customer code.

Doc_Code (Sale Order Code) : … not exists..Please Check...

No sale order has that internal number.

Check Doc_Code.

Sale Order Is marked as Un Approved. Cannot allow Bill Creation :…

The order is not approved yet.

Approve the order in Logic ERP first.

No Pending Item Present against Sale Order..

Nothing is pending on the order – it is fully billed or cancelled – or none of the items you sent is on it.

Check the order and the item codes.

A message starting Unable to found Item Code : … and Rate : …

An item you sent is not pending on the order (the rate shown is only what you sent).

Remove the item, or bill it with Save a Sale Invoice.

Unable to Create Bill for Item : … with Quantity : … Order Qty : …

The quantity you sent for that item could not be billed in full – more than is pending on the order, or not enough stock. The last number is the quantity that could be billed.

Send at most the pending quantity, or check the stock.

Unable to Create Bill for Item : … Quantity : … Billing Qty : …

The same check when you bill the whole pending quantity of the order.

As above.

Unable to Create Bill because stock not available Item Code : …

No stock of that item could be taken.

Check the stock at the order's branch.

A message starting Stock not available for Item : (followed by the item's name and codes, and the MRP when you sent one)

No lot of the item has stock at the branch – with that MRP, or among the lot numbers allowed.

Check Mrp / Lot_No and the stock.

A message starting Duplicate Entry found for Item :

You sent an Mrp for an item that appears on more order lines than the MRPs you sent.

Send one LstItems entry per MRP, or leave Mrp at 0.

Unable to Retrive Sale Order Item Count : …

No line could be brought in from the order.

Check the order and the stock in Logic ERP.

Unable to found LotNo : … againts EAN/Item Code : …

A Lot_No does not exist for the item.

Correct or remove Lot_No.

LogicUserCode Or EAN Code Cannot Blank!!, Invalid LogicUserCode / EANCode : …, Invalid Item Qty : … for Item Code : … EAN Code : …

A line in LstItems has no item code, an unknown one, or a quantity of 0 or less.

Correct the line.

Invalid Godown Name […]. Please Check...

Godown_Name does not exist.

Leave Godown_Name empty.

Bill Series : … Not found for Branch Code :… in API Parameter.. / Default Bill Series Not Set for Branch Code :…

No series was found for the order's branch.

Send a sale series of that branch, or ask for a series link or default for this endpoint.

Cannot allow Bill Saving If Bill Number defined without Bill Series...., Bill No. […] against Branch Code : … already exists...Please Check..

As on Save a Sale Invoice.

Send both or neither; use a free number.

Order No. Cannot be blank.... / Order No. already exists for same Customer.Please Check

The duplicate order number check is on for this endpoint.

Send OrderNo; for a second partial invoice use a new OrderNo with Doc_Code.

Sale Bill Locked against Party(Setup New Accounts) / The Above Customer has crossed the Credit Limit....Cannot Continue

The order's customer is locked for billing or over its credit limit.

Ask your Logic ERP team.

Unable to found Tax Region : …, Unable to found A/E Party : …, Invalid Agent […] .Please Check, Unable to found Cost Center […] .Please Check, Invalid Tax Form […] .Please Check, Transporter Name [ … ] not found. Please Check..., Currency Name : … not found...Please Check..., Exchange Rate not Defined for Currency Name :…...Please Check..., Card Name [ … ] not found. Please Check...

A name or code was not found, as on Save a Sale Invoice.

Send it exactly as in Logic ERP.

Net Value cannot match with External Net Value...

Logic ERP's net amount differs from Ext_NetSale_Value.

Compare with the order's rates; send 0 to skip the check.

A message from Logic ERP's sale bill checks, for example Sale Rate is equal to or greater than MRP at Row No.: 1 are same... Cannot allow or Day not open for Addition/Modification.........

The bill breaks a rule set up in Logic ERP for sale bills.

Correct the order or ask your Logic ERP team.

Request is pending for processing...

Your API site keeps requests for later processing.

Keep the request_ID.

Last updated