> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-invoice.md).

# Save a Sale Invoice

Creates a **sale invoice** (sale bill) in Logic ERP from your shop, website or POS: the customer account, the items and quantities, and optionally rates, discounts, a retail customer, how the bill was paid and your own order number. Logic ERP does the rest the way its own sale bill screen does: it takes the stock from the branch's lots, picks the rate where you send none, works out **GST and other taxes**, applies the schemes set up in Logic ERP, rounds the total and gives the invoice its number. The answer tells you the invoice number and Logic ERP's internal number of the invoice.

### **Endpoint**

| Name          | Detail                                    |
| ------------- | ----------------------------------------- |
| Address       | `https://your-server/api/SaveSaleInvoice` |
| Method        | `POST`                                    |
| Authorization | Basic Auth                                |

The response and the common messages are explained in [How Every API Call Works](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/how-every-api-call-works.md). You can read the saved invoice back with [Get Sale Invoices](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/pull/get-sale-invoices.md) and cancel it with [Cancel a Sale Invoice](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/cancel-a-sale-invoice.md). The same request can also be sent to [Save a Sale Document by Type](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-document-by-type.md) with `"Doc_Type": "SL"`.

### **Request fields**

One invoice per request. Field names are not case-sensitive. Codes and names you send are looked up in Logic ERP without regard to capitals. Send them exactly as they appear in Logic ERP: a space at the start of a code or name makes the lookup fail. Only the item codes (`LogicUserCode` / `AddlItemCode`) are an exception: spaces around them are removed before the item is looked up. Lengths given below are the space Logic ERP keeps for the value; a longer value makes the save fail.

**Invoice header**

| Field                                        | Type       | Required                   | Default                                                                               | Meaning                                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------- | ---------- | -------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `BranchCode`                                 | number     | Yes (or `BranchShortName`) | `0`                                                                                   | Logic ERP's number of the branch that sells (`Branch_Code` in [Get Branch Info](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-branch-info.md)). The stock is taken from this branch, and the API settings of this branch are used.                            |
| `BranchShortName`                            | text       | No                         | empty                                                                                 | The branch's short name, used only when `BranchCode` is `0` or less.                                                                                                                                                                                                                                                           |
| `PartyUserCode`                              | text       | Yes                        | –                                                                                     | The account the bill is made out to: the code shown as the account's code in Logic ERP (`User_Code` in [Get Party Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-party-master.md)). It must already exist. See **Cash and credit bills** in the rules. |
| `Bill_Date`                                  | date       | No                         | today                                                                                 | The invoice date, `yyyy-MM-dd`. It also decides the **financial year** the invoice is saved in.                                                                                                                                                                                                                                |
| `BillSeries`                                 | text       | No                         | see rules                                                                             | The name of the sale bill series, for example `"WSL"`. It must be a sale series of this branch (not a stock transfer series). See **Series and invoice number**.                                                                                                                                                               |
| `Bill_Number`                                | number     | No                         | `0`                                                                                   | `0` = Logic ERP gives the next number of the series. A number above `0` is used as the invoice number; it needs `BillSeries` and must not be used yet in that series and year.                                                                                                                                                 |
| `Ext_Bill_No`                                | text       | No                         | empty                                                                                 | Your own invoice number, up to 26 characters. Kept on the invoice as its displayed invoice number and returned in `Invoice_No`.                                                                                                                                                                                                |
| `OrderNo`                                    | text       | No\*                       | empty                                                                                 | Your order or reference number, up to 100 characters. \*Required when your API site does not allow a duplicate order number – see **Duplicates**.                                                                                                                                                                              |
| `OrderDate`                                  | date       | No                         | none                                                                                  | Date of your order, `yyyy-MM-dd`. A value that is not a date is ignored.                                                                                                                                                                                                                                                       |
| `Order_Id`                                   | text       | No                         | empty                                                                                 | A second reference, up to 50 characters. Your Logic ERP team can set the API site to copy `OrderNo` into it.                                                                                                                                                                                                                   |
| `PaymentMode`                                | text       | No                         | the series' setting                                                                   | `"CASH"` or `"CREDIT"`, in capitals. Any other value is ignored. See **Cash and credit bills**.                                                                                                                                                                                                                                |
| `Tax_Region`                                 | text       | No                         | the default of the series and party                                                   | The name of the tax region as set up in Logic ERP. It decides which taxes apply and whether rates include GST.                                                                                                                                                                                                                 |
| `GST_State_Code`                             | text       | No                         | Logic ERP's value                                                                     | The GST state code (place of supply), up to 20 characters. Used only when your Logic ERP team has switched on "accept GST state code" for the API site; otherwise ignored.                                                                                                                                                     |
| `Tax_Form_Name`                              | text       | No                         | none                                                                                  | A tax form, by its name in Logic ERP.                                                                                                                                                                                                                                                                                          |
| `Godown_Name`                                | text       | No                         | all godowns allowed                                                                   | Sell only from this godown (store location), by name. Applies to every line that has no `GodownName` of its own.                                                                                                                                                                                                               |
| `AgentName`                                  | text       | No                         | Logic ERP's default                                                                   | Agent or salesman, by name as set up in Logic ERP.                                                                                                                                                                                                                                                                             |
| `CostCenter`                                 | text       | No                         | none                                                                                  | A cost centre, by name.                                                                                                                                                                                                                                                                                                        |
| `TransporterName`                            | text       | No                         | the party's transporter                                                               | Transporter, by name.                                                                                                                                                                                                                                                                                                          |
| `TransportMode`                              | text       | No                         | empty                                                                                 | Mode of transport, up to 25 characters.                                                                                                                                                                                                                                                                                        |
| `WayBillNo`                                  | text       | No                         | none                                                                                  | A way bill of this branch that is not finalized; it is linked to the invoice. A finalized way bill is refused.                                                                                                                                                                                                                 |
| `CurrencyName`                               | text       | No                         | none                                                                                  | A foreign currency, by name. Needs `ExchangeRate`.                                                                                                                                                                                                                                                                             |
| `ExchangeRate`                               | number     | With `CurrencyName`        | `0`                                                                                   | Exchange rate of that currency.                                                                                                                                                                                                                                                                                                |
| `ActEntryPartyUserCode`                      | text       | No                         | the account linked to the party for accounts entry in Logic ERP, else `PartyUserCode` | A different account to post the bill amount to in the accounts, by its code.                                                                                                                                                                                                                                                   |
| `CreditDays`                                 | number     | No                         | Logic ERP's default                                                                   | Credit days for this bill. `0` keeps Logic ERP's default.                                                                                                                                                                                                                                                                      |
| `CD_P`, `TD_P`, `SpCD_P`                     | number     | No                         | `0`                                                                                   | Bill-level CD %, TD % and special CD %. Used for every line that has no percentage of its own. Only values above `0` are used.                                                                                                                                                                                                 |
| `Freight`                                    | number     | No                         | `0`                                                                                   | Freight in ₹. Only a value above `0` is used.                                                                                                                                                                                                                                                                                  |
| `SpDiscountRs`                               | number     | No                         | `0`                                                                                   | Special discount for the whole bill in ₹. Only a value above `0` is used.                                                                                                                                                                                                                                                      |
| `Adjustment_Rs`                              | number     | No                         | `0`                                                                                   | Adjustment for the whole bill in ₹. Only a value above `0` is used – a negative adjustment cannot be sent.                                                                                                                                                                                                                     |
| `Handling`                                   | number     | No                         | `0`                                                                                   | Handling charges in ₹. Only a value above `0` is used.                                                                                                                                                                                                                                                                         |
| `Ext_NetSale_Value`                          | number     | No                         | `0`                                                                                   | The net bill amount in your system. When it is not `0`, Logic ERP refuses the bill if its own calculated net amount is different (to the paisa).                                                                                                                                                                               |
| `Remarks1`, `Remarks2`, `Remarks3`           | text       | No                         | the series' default remarks                                                           | Remarks, up to 150 characters each.                                                                                                                                                                                                                                                                                            |
| `DeliveryAt`, `DeliveryAdd1`, `DeliveryAdd2` | text       | No                         | empty                                                                                 | Delivery place and address lines, up to 100 characters each.                                                                                                                                                                                                                                                                   |
| `Cases`                                      | text       | No                         | empty                                                                                 | Number of cases, up to 6 characters.                                                                                                                                                                                                                                                                                           |
| `Weight`                                     | text       | No                         | empty                                                                                 | Weight, up to 10 characters.                                                                                                                                                                                                                                                                                                   |
| `PVTMark`                                    | text       | No                         | empty                                                                                 | Private mark, up to 50 characters.                                                                                                                                                                                                                                                                                             |
| `GRNo`, `GRDate`                             | text, date | No                         | empty                                                                                 | Goods receipt (GR / LR) number, up to 25 characters, and its date.                                                                                                                                                                                                                                                             |
| `Challan_No`, `Challan_Date`                 | text, date | No                         | empty                                                                                 | A challan number, up to 50 characters, and its date, kept on the invoice.                                                                                                                                                                                                                                                      |
| `Insurance_Policy_No`                        | text       | No                         | empty                                                                                 | Insurance policy number, up to 25 characters.                                                                                                                                                                                                                                                                                  |
| `Declaration_No`                             | text       | No                         | empty                                                                                 | Declaration number, up to 25 characters. `DeclarationNo` does the same; when both are sent, `Declaration_No` is kept.                                                                                                                                                                                                          |
| `Sale_BillNo`, `Sale_Bill_Date`              | text, date | No                         | empty                                                                                 | A reference bill number and date kept on the invoice header.                                                                                                                                                                                                                                                                   |
| `RCU_…` fields                               |            | No                         |                                                                                       | The retail customer (shopper) – see the next table.                                                                                                                                                                                                                                                                            |
| `Billing_Address1`, `Billing_Address2`       | text       | No                         | empty                                                                                 | Address lines for a retail customer that Logic ERP **creates** with this bill. Not stored on the invoice – use `BillingAddress` for that.                                                                                                                                                                                      |
| `BillingAddress`, `ShippingAddress`          | object     | No                         | none                                                                                  | Billing and shipping address of this bill – see the table below.                                                                                                                                                                                                                                                               |
| `LstItems`                                   | list       | Yes                        | –                                                                                     | The items – see below.                                                                                                                                                                                                                                                                                                         |
| `TenderDetails`                              | list       | No                         | empty list                                                                            | How the bill was paid – see below. Send `[]` (not `null`) when there are none.                                                                                                                                                                                                                                                 |
| `Request_ID`                                 | text       | No                         | empty                                                                                 | Used only when your API site is set to keep requests for later processing – see **Saving later**.                                                                                                                                                                                                                              |
| `DisplayError`                               | text       | No                         | `"0"`                                                                                 | `"1"` = when the request fails, `Message` holds the full technical detail. Use only while testing.                                                                                                                                                                                                                             |

**Ignored fields.** `Doc_Type` (this endpoint always saves a sale invoice), `Doc_Code`, `STBranchCode`, `InvoiceType`, `EntrySource` and `Token_No` are accepted but not used for a sale invoice.

**Retail customer (`RCU_…` fields)**

Fill these to link the bill to a retail customer (shopper). Leave all of them empty for a bill without one.

| Field                                                                                             | Type   | Required                                                           | Default | Meaning                                                                                                                  |
| ------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `RCU_Mem_Prefix`                                                                                  | text   | Yes, when `RCU_Mem_Number`, `RCU_Mobile_No` or `RCU_Email` is sent | empty   | Membership series, for example `"RCU"`.                                                                                  |
| `RCU_Mem_Number`                                                                                  | number | No                                                                 | `0`     | Membership number within the series. Above `0` = the customer is looked up by series and number; `0` = by mobile number. |
| `RCU_Mobile_No`                                                                                   | text   | Yes, when `RCU_Mem_Number` or `RCU_Email` is sent                  | empty   | Mobile number.                                                                                                           |
| `RCU_First_Name`                                                                                  | text   | Yes, when `RCU_Mem_Number`, `RCU_Mobile_No` or `RCU_Email` is sent | empty   | First name.                                                                                                              |
| `RCU_Last_Name`, `RCU_Email`, `RCU_City`, `RCU_State`, `RCU_Country`, `RCU_PinCode`, `RCU_GST_No` | text   | No                                                                 | empty   | Used only when Logic ERP creates a new customer.                                                                         |

**`BillingAddress` and `ShippingAddress`**

| Field                                                                  | Type | Meaning                                                                                                             |
| ---------------------------------------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------- |
| `Contact_Person_Name`, `Company_Name`                                  | text | Name of the contact and the company.                                                                                |
| `Address_1`, `Address_2`                                               | text | Address lines.                                                                                                      |
| `Location_Name`, `City_Name`, `State_Name`, `Country_Name`, `Pin_Code` | text | Area, city, state, country and PIN code. When the state is known in Logic ERP, the country is taken from the state. |
| `Mobile_No`, `Phone_Number`, `Email_Id`                                | text | Contact numbers and e-mail.                                                                                         |

An address in which name, company, address lines, area, city, state, country and mobile are all empty is not saved. Both addresses are optional; leave out an address you do not have.

**`LstItems` – one entry per line**

| Field                                                | Type   | Required                 | Default          | Meaning                                                                                                                                                                                                         |
| ---------------------------------------------------- | ------ | ------------------------ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `LogicUserCode`                                      | text   | Yes (or `AddlItemCode`)  | empty            | The item code shown as Item Code in Logic ERP (`UserCode` in [Get Item Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-item-master.md)). |
| `AddlItemCode`                                       | text   | Yes (or `LogicUserCode`) | empty            | The item's barcode / EAN (additional item code), used when `LogicUserCode` is empty or not found. When `LogicUserCode` is empty, the extra barcodes linked to an item are also searched.                        |
| `Quantity`                                           | number | Yes                      | –                | Quantity sold, above `0`.                                                                                                                                                                                       |
| `Rate`                                               | number | No                       | Logic ERP's rate | Rate per unit. `0` = Logic ERP takes the rate the sale bill screen would take (price list of the series or party, item or lot rate). Whether the rate includes GST follows the bill's tax region.               |
| `Mrp`                                                | number | No                       | the lot's MRP    | MRP per unit. Only a value above `0` is used.                                                                                                                                                                   |
| `CD_P`, `TD_P`, `SPCD_P`                             | number | No                       | bill-level value | CD %, TD % and special CD % for this line. Only values above `0` are used.                                                                                                                                      |
| `Scheme_Rs`, `SchemePerUnit`                         | number | No                       | `0`              | Scheme discount for the line in ₹, or per unit.                                                                                                                                                                 |
| `AdjustItem_Rs`, `AdjustmentRs`, `AdjustmentPerUnit` | number | No                       | `0`              | Adjustment amounts for the line in ₹, or per unit.                                                                                                                                                              |
| `LabourPerUnit`                                      | number | No                       | `0`              | Labour charge per unit.                                                                                                                                                                                         |
| `ItemDescription`                                    | text   | No                       | empty            | A description printed with the line.                                                                                                                                                                            |
| `GodownName`                                         | text   | No                       | `Godown_Name`    | Sell this line only from this godown, by name.                                                                                                                                                                  |
| `Lot_No`                                             | text   | No                       | empty            | A lot (batch) number of the item. It is only checked – see the known issue.                                                                                                                                     |

For each line, numbers above `0` replace the value Logic ERP would have used; `0` keeps Logic ERP's value. Branch + party + item defaults set up in Logic ERP are applied first. `Production_Unit` and `SaleOrSR` are accepted but not used.

**`TenderDetails` – one entry per payment**

| Field           | Type   | Required     | Default    | Meaning                                                                                             |
| --------------- | ------ | ------------ | ---------- | --------------------------------------------------------------------------------------------------- |
| `TenderType`    | text   | No           | `"CREDIT"` | `"CASH"`, `"CREDIT"`, `"CARD"` or `"GV"` (gift voucher), in any capitals. Other values are ignored. |
| `Amount`        | number | No           | `0`        | Amount paid this way, in ₹. Not used for `"GV"` – the gift voucher's own value is used.             |
| `CardName`      | text   | For `"CARD"` | empty      | The card type or bank as set up in Logic ERP's card list, for example `"HDFC VISA"`.                |
| `CardNo`        | text   | For `"CARD"` | empty      | The card number. If your Logic ERP checks card numbers, it must be 16 characters.                   |
| `GiftVoucherNo` | text   | For `"GV"`   | empty      | The gift voucher number to redeem.                                                                  |

### **Rules Logic ERP applies**

* **Branch and financial year.** The invoice belongs to the branch in `BranchCode` (or `BranchShortName`). `Bill_Date` decides the financial year; send a date inside a financial year that exists in Logic ERP. With no `Bill_Date`, the invoice is dated today. Always send `BranchCode` or `BranchShortName`: with neither, the request is not tied to any of your real branches.
* **What must already exist.** The account in `PartyUserCode`, every item, and every name you send (series, godown, agent, transporter, cost centre, tax region, tax form, currency, card name, gift voucher) must already exist in Logic ERP; an unknown one stops the request. The account in `PartyUserCode` must be a customer, supplier or cash account; any other kind of account is refused. Nothing in this list is created by the endpoint.
* **What is created.** Besides the invoice: a **retail customer** when the `RCU_…` details do not match an existing one, and a card number record the first time a card number is used. Both are saved before the invoice and are kept even if the invoice then fails.
* **Series and invoice number.** The series is chosen in this order: the `BillSeries` you send, else the series linked to the party in Logic ERP, else the default sale series set for the API site and branch. A `BillSeries` that is not a sale series of the branch is refused – it is never replaced by another series. The invoice gets the next number of that series in that financial year, unless you send `Bill_Number`. `Invoice_No` in the response shows the number given.
* **Stock.** For each line Logic ERP takes the quantity from the item's lots in the branch, in the order the lots were created (oldest first), in the godowns the series and the API user may use (or only `Godown_Name` / `GodownName`). When the series or Logic ERP's settings do not allow negative stock, only lots with stock are used, and if the branch does not have the full quantity of any item the whole invoice is refused with `Stock not available for Item Code : …`. Items marked in Logic ERP as not affecting stock are always allowed. One line can become several lines on the invoice when the quantity comes from more than one lot.
* **Taxes are worked out by Logic ERP.** You do not send tax amounts. GST and any other taxes are calculated from each item's tax setup for the bill's tax region, exactly as on the sale bill screen. TCS is added when the party is set up for TCS.
* **Discounts and schemes.** The discounts you send are applied first; then the **schemes** set up in Logic ERP that apply to this bill are applied automatically, without prompting.
* **Round-off and totals** are calculated by Logic ERP according to the series' settings. Use `Ext_NetSale_Value` if you want the invoice refused when Logic ERP's net amount differs from yours.
* **Cash and credit bills.** By default the bill is a credit bill made out to `PartyUserCode`. On a series set up for cash bills, `PartyUserCode` is the customer and the money goes to the series' cash account. `"PaymentMode": "CASH"` on a credit series makes a cash bill in which `PartyUserCode` is the cash account and the customer is the series' default customer.
* **Tenders.** With `TenderDetails`, the amounts are recorded as the bill's payment split; two or more tender types, or any card, make it a multi-payment bill, and a card payment also posts the bill to the series' cash account. The endpoint itself does not compare the amounts with the bill total.
* **Retail customer.** When any of `RCU_Mem_Number`, `RCU_Mobile_No` or `RCU_Email` is filled, `RCU_Mem_Prefix`, `RCU_Mobile_No` and `RCU_First_Name` are all required. The customer is looked up by series and membership number (`RCU_Mem_Number` above `0`) or by mobile number; if none is found, a new customer is created from the `RCU_…` fields and `Billing_Address1`/`Billing_Address2`. An existing customer is not changed. Without mobile and e-mail, if `RCU_First_Name` and `RCU_State` are the same word (for example both `"PUNJAB"`), the bill is linked to the one customer with that first name in that state, if exactly one exists.
* **Duplicates.** Logic ERP does **not** check whether you sent the same bill before: sending a request twice creates two invoices. If your Logic ERP team switches on "do not allow duplicate order number" for the API site, `OrderNo` becomes required and a second bill with the same `OrderNo` for the same branch and customer in the same financial year is refused. Use that setting, or keep the `request_ID` / `LastSavedCode` of each saved bill, before you retry after a timeout.
* **Customer checks.** A party locked for billing (on a cash-bill series, the series' cash account is the one checked), or over its credit limit when Logic ERP stops bills over the limit, is refused. All other checks of the sale bill screen also apply (day open, rate above MRP, branch licence and so on); their message comes back in `Message`.
* **All or nothing.** The invoice and all its lines are saved together. If anything fails, no invoice is saved (only a new retail customer or card number, see above).
* **Saving later.** Your Logic ERP team can set the API site to save sale invoices **in the background** – the answer then comes at once with `"Status": false`, an empty `Message` and a `request_ID`; ask for the result later with the request status endpoint (`TokenStatus`, sending that `request_ID`). Or to **keep requests for later processing** – the answer is `Request is pending for processing...`; sending the same request again with that ID in `Request_ID` processes it, or returns the stored answer if it was already processed.
* **Lines with item code `-1`** are skipped when your Logic ERP team has switched on "ignore invalid item" for the API site. Any other unknown item code stops the request.
* Do not use an apostrophe (`'`) in codes, names, order numbers or lot numbers – the request fails with a database error.
* Some Logic ERP sites are switched by support to a newer save routine for this endpoint. It takes the same request; some messages differ from the ones below.

> **Known issue – `Lot_No` does not choose the lot.** The lot number is only checked to exist for the item; the stock is still taken from the oldest lots with stock. If the lot number does not exist for the item, the request is refused with `Unable to found LotNo : … againts EAN/Item Code : …`. Until this is fixed, leave `Lot_No` empty for sale invoices.

> **Known issue – a switched-off endpoint answers `"Status": false`.** When your Logic ERP team has switched this endpoint off for the branch, nothing is saved and the answer is `"Status": false` with an empty `request_ID` and the `Message` `Request cannot be processed. API Template is marked as In-Active in the configuration.` Sites switched to the newer save routine answer `"Status": true` with the same sentence instead. Whatever `Status` says, treat this message as "not saved" and ask your Logic ERP team.

### **Example request**

A credit bill with two lines, a retail customer and a card payment:

```json
{
  "BranchCode": 2,
  "PartyUserCode": "C1045",
  "Bill_Date": "2026-10-28",
  "BillSeries": "WSL",
  "Bill_Number": 0,
  "OrderNo": "WEB-100245",
  "OrderDate": "2026-10-27",
  "Remarks1": "Online order",
  "RCU_Mem_Prefix": "RCU",
  "RCU_Mem_Number": 0,
  "RCU_Mobile_No": "9812345670",
  "RCU_First_Name": "Neha",
  "RCU_Last_Name": "Arora",
  "RCU_City": "LUDHIANA",
  "RCU_State": "PUNJAB",
  "BillingAddress": {
    "Contact_Person_Name": "Neha Arora",
    "Address_1": "217, Model Town",
    "City_Name": "LUDHIANA",
    "State_Name": "PUNJAB",
    "Pin_Code": "141002",
    "Mobile_No": "9812345670"
  },
  "LstItems": [
    {
      "LogicUserCode": "SH-1021-BLK-9",
      "Quantity": 1,
      "Rate": 2499
    },
    {
      "LogicUserCode": "",
      "AddlItemCode": "8901234567895",
      "Quantity": 2,
      "Rate": 0,
      "CD_P": 5
    }
  ],
  "TenderDetails": [
    {
      "TenderType": "CARD",
      "CardName": "HDFC VISA",
      "CardNo": "4111111111111111",
      "Amount": 3398
    }
  ]
}
```

### **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 sells one pair of the sandbox's test item `APITEST0001` from branch 2; each send creates one more test invoice.

## Save a Sale Invoice

> Creates a sale invoice (sale bill) in Logic ERP from your shop, website or POS: the customer account, the items and quantities, and optionally rates, discounts, a retail customer, how the bill was paid and your own order number. Logic ERP does the rest the way its own sale bill screen does: it takes the stock from the branch's lots, picks the rate where you send none, works out GST and other taxes, applies the schemes set up in Logic ERP, rounds the total and gives the invoice its number. The answer tells you the invoice number and Logic ERP's internal number of the invoice.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Sale - Push"}],"servers":[{"url":"https://demo.logicerp.com/api","description":"Logic ERP sandbox (test company)"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"The user name and password of your API site."}}},"paths":{"/SaveSaleInvoice":{"post":{"tags":["Sale - Push"],"operationId":"SaveSaleInvoice","summary":"Save a Sale Invoice","description":"Creates a sale invoice (sale bill) in Logic ERP from your shop, website or POS: the customer account, the items and quantities, and optionally rates, discounts, a retail customer, how the bill was paid and your own order number. Logic ERP does the rest the way its own sale bill screen does: it takes the stock from the branch's lots, picks the rate where you send none, works out GST and other taxes, applies the schemes set up in Logic ERP, rounds the total and gives the invoice its number. The answer tells you the invoice number and Logic ERP's internal number of the invoice.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"BranchCode":{"type":"integer","description":"Logic ERP's number of the branch that sells (`Branch_Code` in Get Branch Info). The stock is taken from this branch, and the API settings of this branch are used."},"PartyUserCode":{"type":"string","description":"The account the bill is made out to: the code shown as the account's code in Logic ERP (`User_Code` in Get Party Master). It must already exist. See Cash and credit bills in the rules."},"Bill_Date":{"type":"string","description":"The invoice date, `yyyy-MM-dd`. It also decides the financial year the invoice is saved in."},"BillSeries":{"type":"string","description":"The name of the sale bill series, for example `\"WSL\"`. It must be a sale series of this branch (not a stock transfer series). See Series and invoice number."},"Bill_Number":{"type":"integer","description":"`0` = Logic ERP gives the next number of the series. A number above `0` is used as the invoice number; it needs `BillSeries` and must not be used yet in that series and year."},"OrderNo":{"type":"string","description":"Your order or reference number, up to 100 characters. *Required when your API site does not allow a duplicate order number – see Duplicates."},"Remarks1":{"type":"string","description":"Remarks, up to 150 characters each."},"LstItems":{"type":"array","items":{"type":"object","properties":{"LogicUserCode":{"type":"string","description":"The item code shown as Item Code in Logic ERP (`UserCode` in Get Item Master)."},"Quantity":{"type":"integer","description":"Quantity sold, above `0`."},"Rate":{"type":"integer","description":"Rate per unit. `0` = Logic ERP takes the rate the sale bill screen would take (price list of the series or party, item or lot rate). Whether the rate includes GST follows the bill's tax region."}}},"description":"The items – see below."},"TenderDetails":{"type":"array","items":{"type":"object"},"description":"How the bill was paid – see below. Send `[]` (not `null`) when there are none."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"PrintFile":{"type":"string","description":"Always empty for this endpoint."},"Invoice_No":{"type":"string","description":"The invoice number given, for example `\"WSL-1288\"`, or your `Ext_Bill_No` when you sent one. Empty when nothing was saved."},"Order_No":{"type":"string","description":"Always empty for a sale invoice."},"PartyOrderNo":{"type":"string","description":"The `OrderNo` you sent. On sites switched to the newer save routine, it is empty when nothing was saved."},"Status":{"type":"boolean","description":"`true` when the invoice was saved."},"Message":{"type":"string","description":"Usually empty when saved – or, if the API user's Logic ERP settings show the document number after saving, text such as `Saved Doc No. - WSL-1288` with the date. When the request failed, the reason."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal number of the new invoice (as in Get Sale Invoices). `0` when nothing was saved."},"request_ID":{"type":"string","description":"Filled once Logic ERP has started on the request, also when it then fails; empty when the request was refused before that (for example an unknown branch or financial year, or the endpoint is switched off for the branch)."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field           | Meaning for this endpoint                                                                                                                                                                                                    |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`        | `true` when the invoice was saved.                                                                                                                                                                                           |
| `Message`       | Usually empty when saved – or, if the API user's Logic ERP settings show the document number after saving, text such as `Saved Doc No. - WSL-1288` with the date. When the request failed, the reason.                       |
| `LastSavedCode` | Logic ERP's internal number of the new invoice (as in Get Sale Invoices). `0` when nothing was saved.                                                                                                                        |
| `Invoice_No`    | The invoice number given, for example `"WSL-1288"`, or your `Ext_Bill_No` when you sent one. Empty when nothing was saved.                                                                                                   |
| `PartyOrderNo`  | The `OrderNo` you sent. On sites switched to the newer save routine, it is empty when nothing was saved.                                                                                                                     |
| `Order_No`      | Always empty for a sale invoice.                                                                                                                                                                                             |
| `PrintFile`     | Always empty for this endpoint.                                                                                                                                                                                              |
| `request_ID`    | Filled once Logic ERP has started on the request, also when it then fails; empty when the request was refused before that (for example an unknown branch or financial year, or the endpoint is switched off for the branch). |

### **Example response**

```json
{
  "PrintFile": "",
  "Invoice_No": "WSL-1288",
  "Order_No": "",
  "PartyOrderNo": "WEB-100245",
  "Status": true,
  "Message": "",
  "LastSavedCode": 48213,
  "request_ID": "9c2f7b4e-1a3d-4e8b-b6f0-5d2c8a7e1f43"
}
```

### **Messages you may see**

All with `Status: false`. With `"DisplayError": "1"`, or when the reason comes from an error inside Logic ERP, the reason may be followed by technical detail – read the first line.

| Message                                                                                                                                                                                                                                                              | Meaning                                                                                                       | What to do                                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| A message containing `Branch not found` or `Branch_Short_Name : … not exists.`                                                                                                                                                                                       | The branch code or short name does not exist.                                                                 | Send a branch from Get Branch Info.                                                     |
| `No financial year covers the date ….` (or a message containing `Financial Year not found`)                                                                                                                                                                          | No financial year in Logic ERP covers `Bill_Date` (or today, when no `Bill_Date` is sent).                    | Check the date, or ask your Logic ERP team to create the year.                          |
| `Branch Code/Branch Short Name Not Set in API Request for Sale/Sale Return...`                                                                                                                                                                                       | `BranchCode` is negative (most negative numbers give `Branch not found` instead).                             | Send a real branch.                                                                     |
| A message containing `Request cannot be processed. API Template is marked as In-Active in the configuration.`                                                                                                                                                        | Your Logic ERP team has switched this endpoint off for the branch. Nothing is saved. See the known issue.     | Ask your Logic ERP team.                                                                |
| `Party Code Not Set in API Request for Sale Return...`                                                                                                                                                                                                               | `PartyUserCode` is empty (the text mentions sale return, but it applies here too).                            | Send the party code.                                                                    |
| `Unable to Retrieve Accounts...`                                                                                                                                                                                                                                     | No account has the code in `PartyUserCode`.                                                                   | Check the code with Get Party Master.                                                   |
| `Party_User_Code : … is not a Customer / Supplier / Cash account..Please Check...`                                                                                                                                                                                   | `PartyUserCode` belongs to another kind of account (for example a bank or expense account).                   | Send the code of a customer, supplier or cash account.                                  |
| `LogicUserCode Or EAN Code Cannot Blank!!`                                                                                                                                                                                                                           | A line has neither `LogicUserCode` nor `AddlItemCode` (or both hold only spaces).                             | Fill one of them.                                                                       |
| `Invalid LogicUserCode / EANCode : …`                                                                                                                                                                                                                                | The item code or barcode shown was not found.                                                                 | Check it with Get Item Master.                                                          |
| `Unable to found LotNo : … againts EAN/Item Code : …`                                                                                                                                                                                                                | A line's `Lot_No` does not exist for the item.                                                                | Send an existing lot number, or leave `Lot_No` empty.                                   |
| `Invalid Item Qty : … for Item Code : … EAN Code : …`                                                                                                                                                                                                                | A line has a quantity of `0` or less.                                                                         | Send a quantity above `0`.                                                              |
| `No Item Present..`                                                                                                                                                                                                                                                  | `LstItems` is empty.                                                                                          | Send at least one line.                                                                 |
| `Invalid Godown Name […]. Please Check...` or `Invalid Godown Name : …`                                                                                                                                                                                              | `Godown_Name` or a line's `GodownName` does not exist.                                                        | Use the godown name as in Logic ERP.                                                    |
| `Unable to found Tax Region : …`                                                                                                                                                                                                                                     | No tax region has that name.                                                                                  | Use the name as in Logic ERP, or leave `Tax_Region` empty.                              |
| `Bill Series : … Not found for Branch Code :… in API Parameter..`                                                                                                                                                                                                    | The `BillSeries` sent is not a sale series of the branch.                                                     | Check the series name and branch.                                                       |
| `Default Bill Series Not Set for Branch Code :…`                                                                                                                                                                                                                     | No `BillSeries` sent and no party or default series is set.                                                   | Send `BillSeries`, or ask your Logic ERP team to set a default series for the API site. |
| `Cannot allow Bill Saving If Bill Number defined without Bill Series....`                                                                                                                                                                                            | `Bill_Number` sent without `BillSeries`.                                                                      | Send the series too, or leave `Bill_Number` at `0`.                                     |
| `Bill No. […] against Branch Code : … already exists...Please Check..`                                                                                                                                                                                               | That invoice number is already used in the series and year.                                                   | Send another number, or `0`.                                                            |
| `Order No. Cannot be blank....`                                                                                                                                                                                                                                      | Your API site does not allow duplicate order numbers, and `OrderNo` is empty.                                 | Send `OrderNo`.                                                                         |
| `Order No. already exists for same Customer.Please Check`                                                                                                                                                                                                            | A bill with this `OrderNo` already exists for this branch and customer in the year.                           | The bill was probably saved before – look it up instead of sending it again.            |
| `Sale Bill Locked against Party(Setup New Accounts)`                                                                                                                                                                                                                 | The party is locked for billing in Logic ERP.                                                                 | Ask your Logic ERP team.                                                                |
| `The Above Customer has crossed the Credit Limit....Cannot Continue`                                                                                                                                                                                                 | The party is over its credit limit.                                                                           | Ask your Logic ERP team.                                                                |
| `Stock not available for Item Code : … Quantity : … and Billing Qty : …`                                                                                                                                                                                             | The branch (or the godown you named) does not have the full quantity of that item.                            | Reduce the quantity or check the stock.                                                 |
| `Unable to find available stock/lot for Item Code : …`                                                                                                                                                                                                               | The same, on sites switched to the newer save routine: no lot of the item with stock was found at the branch. | Reduce the quantity or check the stock.                                                 |
| `Unable to found A/E Party : …`                                                                                                                                                                                                                                      | `ActEntryPartyUserCode` does not exist.                                                                       | Check the code.                                                                         |
| `Invalid Agent […] .Please Check`, `Invalid Tax Form […] .Please Check`, `Unable to found Cost Center […] .Please Check`, `Transporter Name [ … ] not found. Please Check...`                                                                                        | The agent, tax form, cost centre or transporter name was not found.                                           | Use the name as in Logic ERP, or leave the field empty.                                 |
| `Currency Name : … not found...Please Check...` or `Exchange Rate not Defined for Currency Name :…...Please Check...`                                                                                                                                                | Unknown currency, or no `ExchangeRate`.                                                                       | Check the currency and send the rate.                                                   |
| `Way Bill No. :… not found In Branch Code : …` or `Way Bill No. :… is already Finalized..Please Check`                                                                                                                                                               | The way bill does not exist in the branch, or it is already finalized.                                        | Send an open way bill of the branch, or leave `WayBillNo` empty.                        |
| `Please Define Customer Membership Series to Continue...`, `Please Define Mobile No. to Continue...`, `Customer First Name not defined...Please Check..`                                                                                                             | Retail customer details were sent, but the series, mobile number or first name is missing.                    | Send all three, or no retail customer details at all.                                   |
| `Mobile Number cannot be blank...` or `EMail id cannot be blank...`                                                                                                                                                                                                  | Your Logic ERP identifies retail customers by mobile number or e-mail, and it is missing.                     | Fill the field named.                                                                   |
| `Card Name [ … ] not found. Please Check...`                                                                                                                                                                                                                         | The `CardName` of a card payment is not in Logic ERP's card list.                                             | Use the name as in Logic ERP.                                                           |
| A message containing `Credit Card Number Cannot be Blank..` or `Lenght should be 16 Characters`                                                                                                                                                                      | A card payment has no card number, or not 16 characters where Logic ERP requires that.                        | Send the card number.                                                                   |
| `Net Value cannot match with External Net Value...`                                                                                                                                                                                                                  | Logic ERP's net amount differs from `Ext_NetSale_Value`.                                                      | Compare rates, discounts and taxes with Get Sale Invoices; send `0` to skip the check.  |
| `Some Error occurred In ImplementAllSchemes.... Cannot Continue`                                                                                                                                                                                                     | Applying Logic ERP's schemes failed.                                                                          | Ask your Logic ERP team to check the schemes.                                           |
| `Request is pending for processing...`                                                                                                                                                                                                                               | Your API site keeps requests for later processing (see the rules).                                            | Keep the `request_ID`.                                                                  |
| A message from Logic ERP's sale bill checks, for example `Day not open for Addition/Modification.........`, `Selected tax region does not match with party tax region, please check and continue....` or `Sale Rate and MRP at Row No.: … are same... Cannot allow.` | The bill breaks a rule set up in Logic ERP for sale bills.                                                    | Correct the request, or ask your Logic ERP team.                                        |
| `Status: false` with an empty `Message`                                                                                                                                                                                                                              | On an API site set to save in the background, the request was accepted and is still being saved.              | Ask for the result with `TokenStatus`.                                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-invoice.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
