> 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/orders/push/save-a-purchase-voucher-against-a-delivery-note.md).

# Save a Purchase Voucher Against a Delivery Note

Bills a supplier's **delivery note** that is already in Logic ERP as a **purchase voucher** (goods receipt / GRN) posted to the delivery note's supplier. A delivery note records goods a supplier is sending against one or more purchase orders; you send the delivery note's internal number and the items and quantities you received, and Logic ERP builds the voucher lines from the delivery note's pending lines and the purchase-order lines behind them, as [Save a Purchase Voucher Against a Purchase Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-purchase-voucher-against-a-purchase-order.md) does for an order.

To record a purchase **without** a delivery note or order, use [Save a Purchase Voucher](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-voucher.md). To find delivery notes, use [Get Delivery Notes](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/pull/get-delivery-notes.md).

### **Endpoint**

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

The response envelope, branches, dates, queueing 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).

### **Request fields**

This endpoint has its **own, short request** – it is not the Save a Purchase Voucher request. Field names are not case-sensitive.

| Field                                          | Type   | Required | Default    | Meaning                                                                                                                                                                                                                                                                                  |
| ---------------------------------------------- | ------ | -------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DNO_Code`                                     | number | Yes      | `0`        | Logic ERP's internal number of the delivery note (`Doc_Code` in [Get Delivery Notes](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/pull/get-delivery-notes.md)). The **supplier** of the voucher is the delivery note's supplier. |
| `BranchCode`                                   | number | Yes\*    | `0`        | The branch the voucher is saved in (as explained in How Every API Call Works). It must be the delivery note's branch – see the rules. \*It may be left out only for a delivery note of Logic ERP's empty placeholder branch (`0`). There is no branch short name field.                  |
| `Bill_No`                                      | text   | No       | empty      | The supplier's bill (invoice) number.                                                                                                                                                                                                                                                    |
| `Bill_Date`                                    | date   | No       | today      | The supplier's bill date, `yyyy-MM-dd`.                                                                                                                                                                                                                                                  |
| `GRN_Prefix`                                   | text   | No       | `GRN`      | Prefix of the goods receipt (GRN) number. The voucher gets the next GRN number for that prefix.                                                                                                                                                                                          |
| `PU_Remarks_1`, `PU_Remarks_2`, `PU_Remarks_3` | text   | No       | empty      | Remarks 1 to 3 of the voucher.                                                                                                                                                                                                                                                           |
| `LstItems`                                     | list   | Yes      | empty list | The items and quantities you received – see below. Only the delivery note's lines of the items you list are received.                                                                                                                                                                    |
| `DisplayError`                                 | text   | No       | `"0"`      | `"1"` = when the request fails, `Message` holds the full technical detail. Use only while testing.                                                                                                                                                                                       |

**`LstItems` – one entry per item received**

| Field            | Type   | Required       | Default              | Meaning                                                                                                                                                                                                                                 |
| ---------------- | ------ | -------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `LogicUser_Code` | text   | One of the two | empty                | The item code shown in Logic ERP (`UserCode` in [Get Item Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-item-master.md)). A code that is not found is refused. |
| `AddlItemCode`   | text   | One of the two | empty                | The additional item code / barcode. Used only when `LogicUser_Code` is empty.                                                                                                                                                           |
| `ScannedQty`     | number | Yes            | `0`                  | Quantity received. Must be above `0` and not more than the item's pending quantity on the delivery note (see the rules). An item may be listed in more than one entry; its quantities are added together.                               |
| `Lot_Mrp`        | number | No             | the order line's MRP | The MRP of the lot, as on Save a Purchase Voucher Against a Purchase Order.                                                                                                                                                             |

**Ignored fields.** `PO_Code`, `Challan_Code`, `DocCode` and `GRN_Number`. Leave `Doc_Type` out (it defaults to `PU`; any value other than `PU` or `PR` stops the reverse-charge setting being taken from the tax region). The other fields of Save a Purchase Voucher Against a Purchase Order – for example `InvoiceDate`, `AccountCode`, `SupplierCode`, `BranchShortName`, `Godown_Name`, `LotNo` and the rates – are not part of this request and are ignored.

### **Rules Logic ERP applies**

* **Delivery note.** `DNO_Code` must be a delivery note in Logic ERP; otherwise the request is refused with `Invalid DNO Code […]. Please Check...` (also when it is missing). Its lines must be linked to a purchase order; otherwise the request is refused with `No Purchase Order found for DNO […]...`.
* **Branch.** The delivery note must belong to the branch you send; otherwise the request is refused with `DNO Code […] belongs to another branch...`. With no `BranchCode`, a delivery note of a branch is refused with `Branch_Code or Branch_Short_Name is required.`.
* **What is received.** The delivery note's lines of the items in `LstItems` that are not cancelled, whose purchase-order line is not cancelled, and that still have a pending quantity. For each item, the `ScannedQty` of all its entries together must not be more than the item's pending quantity on the delivery note; otherwise the request is refused with `GRN Quantity must be less than PO Pending Qty...`. Unlike a purchase against an order, no extra percentage is allowed. An item that is not on the delivery note, or has nothing pending on it, is refused with `Item Code Not belongs to PO Or No Pending Qty Available to GRN. Item Code: …`.
* **Series.** The voucher is saved in the purchase series chosen as **Default Configuration** for *Purchase against DNO* in your API site's settings; without one the request is refused with `Default Configuration Not Defined in API Template..`. There is no request field for the series. The voucher gets the series' next number and the next GRN number for `GRN_Prefix`.
* **Date.** The voucher is dated today and saved in the current financial year.
* **Godown.** The godown set as Default Godown in your API site's settings, else each item's default godown.
* **Checks of the series.** The purchase series' own checks apply – for example a mandatory MRP or purchase/sale rate, or refusing a supplier bill number that already exists for the supplier.
* Your Logic ERP licence must include the API for purchase orders and delivery notes.

### **Example request**

```json
{
  "DNO_Code": 412,
  "BranchCode": 2,
  "Bill_No": "INV/26-27/3108",
  "Bill_Date": "2026-10-29",
  "PU_Remarks_1": "Received against DN-412",
  "LstItems": [
    { "LogicUser_Code": "KRT3301", "ScannedQty": 24 },
    { "LogicUser_Code": "JNS4410", "ScannedQty": 9 }
  ]
}
```

### **Response**

| Field            | Type         | Meaning                                                                                                                               |
| ---------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`         | true / false | `true` when the voucher was saved.                                                                                                    |
| `Message`        | text         | Empty when saved; the reason when not saved.                                                                                          |
| `LastSavedCode`  | number       | Logic ERP's internal number of the new purchase voucher; `0` when not saved.                                                          |
| `LastSavedDocNo` | text         | The voucher's GRN number – prefix, a hyphen and the number with two decimals, for example `GRN-15.00`. Empty (`null`) when not saved. |
| `request_ID`     | text         | The ID of this request – quote it to support.                                                                                         |

### **Example response**

```json
{
  "LastSavedDocNo": "GRN-15.00",
  "Status": true,
  "Message": "",
  "LastSavedCode": 292,
  "request_ID": "3c7e91a2-4b8d-4f06-a1d5-6e2f8b0c9d47"
}
```

### **Messages you may see**

Messages from checks made while the voucher is being built and saved (marked \*) come back with technical text before the reason and technical detail after it – look for the reason in the first line.

| Message                                                                                                                | Meaning                                                                                           | What to do                                                |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `Invalid DNO Code […]. Please Check...`                                                                                | `DNO_Code` is missing or no delivery note has that number.                                        | Take `Doc_Code` from Get Delivery Notes.                  |
| `Default Configuration Not Defined in API Template..`                                                                  | No purchase series is chosen for purchase against DNO in your API site's settings.                | Ask your Logic ERP team to set it.                        |
| `Branch_Code or Branch_Short_Name is required.`                                                                        | No `BranchCode` was sent and the delivery note belongs to a branch. Nothing was saved.            | Send the delivery note's branch.                          |
| `DNO Code […] belongs to another branch...`                                                                            | The delivery note is not of the branch you sent.                                                  | Send the delivery note's own branch.                      |
| `Logic User Code/Additional Item Code Not Defined for Item No : …`                                                     | An entry in `LstItems` has neither code.                                                          | Send `LogicUser_Code`.                                    |
| `Invalid Logic User Code : '…' Defined for Item No : …` / `Invalid Additional Item Code : '…' Defined for Item No : …` | The item code is not found.                                                                       | Check the code with Get Item Master.                      |
| `Quantity Not Defined For : '…' Item No : …`                                                                           | `ScannedQty` is `0` or less.                                                                      | Send the quantity received.                               |
| `Invalid Bill Date...`                                                                                                 | `Bill_Date` is not a date.                                                                        | Send it as `yyyy-MM-dd`, or leave it out.                 |
| `No Purchase Order found for DNO […]...`                                                                               | The delivery note's lines are not linked to a purchase order.                                     | Bill the delivery note in Logic ERP.                      |
| `GRN Quantity must be less than PO Pending Qty...`                                                                     | The quantity of an item (all its entries together) is more than is pending on the delivery note.  | Send no more than is pending.                             |
| `Item Code Not belongs to PO Or No Pending Qty Available to GRN. Item Code: …`                                         | The item is not on the delivery note, or has nothing pending on it.                               | Check the delivery note with Get Delivery Notes.          |
| `Lot No.… cannot be blank. Item Code: …` \*                                                                            | A line ended up without a lot number. There is no lot field in this request.                      | Bill the delivery note in Logic ERP.                      |
| `M.R.P. Entry is mandatory......Row No: …` \*                                                                          | The purchase series needs an MRP and the line has none.                                           | Send `Lot_Mrp`.                                           |
| `Purchase Rate entry is mandatory.... Row No:…` / `Sale Rate entry is mandatory.... Row No:…` \*                       | The purchase series needs a rate and the line has none. There are no rate fields in this request. | Bill the delivery note in Logic ERP.                      |
| `Default Tax Region not Set.Please Check....` \*                                                                       | No tax region could be found for the supplier.                                                    | Ask your Logic ERP team to set the supplier's tax region. |
| `Voucher not saved. The item-wise amounts could not be calculated.`                                                    | Saving stopped inside Logic ERP without giving a reason. Nothing was saved.                       | Contact your Logic ERP team with `request_ID`.            |
| Another technical error \*                                                                                             | Saving failed inside Logic ERP; nothing was saved.                                                | Contact your Logic ERP team with `request_ID`.            |


---

# 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/orders/push/save-a-purchase-voucher-against-a-delivery-note.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.
