> 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-packing-slip-against-a-sale-order.md).

# Save a Packing Slip Against a Sale Order

Creates a **packing slip** against a **sale order** that is already in Logic ERP. A packing slip records which goods were packed in which box for an order: it takes the packed quantity off the order's pending quantity and sets the stock aside in the godown, so it is no longer free to sell. The packed goods are then billed or transferred from the packing slip – with [Save a Sale Invoice Against a Delivery Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-sale-invoice-against-a-delivery-order.md) or [Save a Stock Transfer Out Against a Delivery Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-stock-transfer-out-against-a-delivery-order.md), using the packing slip's `LastSavedCode`.

You send the sale order, the godown you packed from, and for each item the boxes and the quantity in each box. Logic ERP picks the lots, links every unit to an open line of the order and saves the packing slip.

### **Endpoint**

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

A second address, `PackingSlipDeliveryOrder`, saves the same packing slip with a looser item check – see [Save a Packing Slip Allowing Items Outside the Sale Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-packing-slip-allowing-items-outside-the-sale-order.md).

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).

### **Before you start**

Your Logic ERP team must choose, in your API site's settings for this endpoint, a **packing slip configuration** (and may set a packing slip prefix). The configuration decides several things described below: how `ItemCode` is read, whether bins are used, whether negative stock or more than the order's pending quantity is allowed, and how lots are chosen. Without a configuration every request is refused.

### **Request fields**

Field names are matched without regard to upper/lower case; fields not listed are ignored.

| Field                | Type   | Required                                | Default | Meaning                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------- | ------ | --------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SaleOrderVouchCode` | number | Yes, or `PartyOrderNo`                  | `0`     | Logic ERP's internal number of the sale order – the `LastSavedCode` from [Save a Sale Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-sale-order.md), or the order's internal number in [Get Sale Orders](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/pull/get-sale-orders.md). |
| `PartyOrderNo`       | text   | Yes, if `SaleOrderVouchCode` is `0`     | empty   | The order's party order number (the `Party_Order_No` sent with Save a Sale Order). Used only when `SaleOrderVouchCode` is `0`: Logic ERP looks for an order of the branch with exactly this party order number. When more than one order of the branch has it, the request is refused – send `SaleOrderVouchCode`.                                                                                               |
| `BranchCode`         | number | Recommended (or `BranchShortName`)      | `0`     | The branch the packing slip is saved in and packed from, by Logic ERP's branch number (`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)). Send the sale order's branch. When neither this nor `BranchShortName` is sent, the default branch is used (see How Every API Call Works).             |
| `BranchShortName`    | text   | No                                      | empty   | The branch by its short name; used only when `BranchCode` is `0`.                                                                                                                                                                                                                                                                                                                                                |
| `GodownName`         | text   | **Yes**                                 | –       | The godown the goods were packed from, by its name exactly as in Logic ERP. All stock is taken from this godown.                                                                                                                                                                                                                                                                                                 |
| `PS_Prefix`          | text   | Yes, unless your API site sets a prefix | empty   | Prefix of the packing slip number, for example `"PS"`. A prefix set in your API site's settings replaces it.                                                                                                                                                                                                                                                                                                     |
| `PS_Number`          | number | No                                      | –       | **Ignored** – the packing slip always gets the next number for its prefix.                                                                                                                                                                                                                                                                                                                                       |
| `Remarks`            | text   | No                                      | empty   | Remarks saved on the packing slip.                                                                                                                                                                                                                                                                                                                                                                               |
| `Box_No_Prefix`      | text   | No                                      | empty   | Prefix of the box numbers, saved on the packing slip.                                                                                                                                                                                                                                                                                                                                                            |
| `ListItems`          | list   | **Yes**                                 | empty   | The items packed – see below.                                                                                                                                                                                                                                                                                                                                                                                    |
| `DisplayError`       | text   | No                                      | `""`    | `"1"` = full technical error text in `Message` when something fails.                                                                                                                                                                                                                                                                                                                                             |
| `GodownCode`         | number | No                                      | –       | **Ignored** – the godown is found from `GodownName`.                                                                                                                                                                                                                                                                                                                                                             |

**`ListItems` – one entry per item**

| Field      | Type   | Required | Default | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------- | ------ | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ItemCode` | text   | **Yes**  | –       | The item. By default 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)), matched exactly (spaces around it are trimmed). The packing slip configuration can tell Logic ERP to read it as an additional item code / barcode, a lot code or lot number, a carton number, a serial number or a set code instead. The item must be on the sale order. |
| `Quantity` | number | No       | `0`     | **Ignored** – the box quantities are used.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `ListBoxs` | list   | **Yes**  | empty   | The boxes this item was packed in – see below.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

**`ListBoxs` – one entry per box**

| Field          | Type   | Required           | Default | Meaning                                                                                                                                 |
| -------------- | ------ | ------------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `PackingBoxNo` | text   | **Yes**            | –       | The box number, for example `"B01"`. Must not be empty.                                                                                 |
| `Quantity`     | number | **Yes**            | `0`     | Quantity of the item in this box. A whole number of `1` or more, unless the packing slip configuration reads `ItemCode` as a lot code.  |
| `BoxWeight`    | number | No                 | `0`     | Weight of the box; used only when the packing slip configuration takes box weights from the request.                                    |
| `BinName`      | text   | When bins are used | empty   | The bin the box was picked from, by name. Required (or `BinCode`) only when the packing slip configuration uses bins and asks for them. |
| `BinCode`      | number | No                 | `0`     | The bin by Logic ERP's number; used instead of `BinName` when above `0`.                                                                |

### **Rules Logic ERP applies**

**Order, branch and party**

* The packing slip is made out to the sale order's customer, in the branch you send, and dated **today** (the server's date) in the current financial year.
* Only order lines that still have a pending quantity and are not cancelled line by line are used.
* The sale order must exist, belong to the branch you send, be approved and not be cancelled as a whole; otherwise the request is refused and nothing is saved.

**Items, lots and quantities**

* Each box quantity is packed **one unit at a time**: for every unit Logic ERP picks a lot of the item with stock in `GodownName` at the branch (largest stock first, or by purchase date, as the packing slip configuration says; expired or damaged lots, and lots tracked piece by piece, are not used), and links the unit to an order line of that item that still has something pending.
* An item that is not on the order is refused. When everything pending for an item has been packed, a further unit is refused – unless the packing slip configuration allows packing more than the order's pending quantity; the extra units are then linked to the item's first order line, whose pending quantity goes below zero.
* When no lot of the item has stock in `GodownName`, the request is refused. If the packing slip configuration allows negative stock, a lot without stock can be used, but the item must still have a lot in that godown for the current year.
* Several boxes of the same item, and several items in one box, are fine. One packing slip line is saved for each combination of lot, godown, box, bin and order line.

**After saving**

* The packed quantity is taken off the order lines' pending quantity and set aside in the lot's stock in that godown.
* The packing slip number is the prefix and the next number after the highest number used with that prefix in any branch, for example `PS-118`.
* If Logic ERP's approval rules require it, the packing slip is saved as waiting for approval; it cannot then be billed or transferred until it is approved.
* Everything is saved in one step; if anything fails, nothing is saved.
* **Duplicates.** There is no duplicate check on the request. Sending the same request again saves a second packing slip as long as the order still has enough pending; otherwise it is refused. Check `Status` before you resend.
* Requests to this endpoint are queued together for all branches when your API site queues requests.
* Your Logic ERP licence must include this endpoint.

> **Known issue – messages from the saving step come wrapped in technical text.** Reasons found while the packing slip is being written – for example *Packing Slip number already exists....*, *Entry not allowed in back date.......*, *Invalid Packing Slip No........* or *Sale Order Pending Quantity will become -ve..* – arrive preceded and followed by technical text. Look for the reason inside `Message` rather than at its start.

> **Known issue – an apostrophe in a code or name.** `PartyOrderNo`, `GodownName`, `BinName`, `ItemCode` and `PS_Prefix` are looked up exactly as typed. An apostrophe (`'`) in any of them makes the request fail with a database error. Leave apostrophes out of codes and names you send.

### **Example request**

```json
{
  "BranchCode": 2,
  "SaleOrderVouchCode": 18342,
  "GodownName": "MAIN GODOWN",
  "PS_Prefix": "PS",
  "Remarks": "Packed for dispatch on 30-10",
  "Box_No_Prefix": "B",
  "ListItems": [
    {
      "ItemCode": "SHRT-BLU-M",
      "ListBoxs": [
        { "PackingBoxNo": "B01", "Quantity": 20 },
        { "PackingBoxNo": "B02", "Quantity": 4 }
      ]
    },
    {
      "ItemCode": "KRT-WHT-L",
      "ListBoxs": [
        { "PackingBoxNo": "B02", "Quantity": 12 }
      ]
    }
  ]
}
```

### **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 and sets the packed stock aside. The example's test order may have nothing left to pack – first save a test order with Save a Sale Order and send its internal number.

## Save a Packing Slip Against a Sale Order

> Creates a packing slip against a sale order that is already in Logic ERP. A packing slip records which goods were packed in which box for an order: it takes the packed quantity off the order's pending quantity and sets the stock aside in the godown, so it is no longer free to sell. The packed goods are then billed or transferred from the packing slip – with Save a Sale Invoice Against a Delivery Order or Save a Stock Transfer Out Against a Delivery Order, using the packing slip's \`LastSavedCode\`.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Orders - 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":{"/PackingSlipAgainstSO":{"post":{"tags":["Orders - Push"],"operationId":"PackingSlipAgainstSO","summary":"Save a Packing Slip Against a Sale Order","description":"Creates a packing slip against a sale order that is already in Logic ERP. A packing slip records which goods were packed in which box for an order: it takes the packed quantity off the order's pending quantity and sets the stock aside in the godown, so it is no longer free to sell. The packed goods are then billed or transferred from the packing slip – with Save a Sale Invoice Against a Delivery Order or Save a Stock Transfer Out Against a Delivery Order, using the packing slip's `LastSavedCode`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"BranchCode":{"type":"integer","description":"The branch the packing slip is saved in and packed from, by Logic ERP's branch number (`Branch_Code` in Get Branch Info). Send the sale order's branch. When neither this nor `BranchShortName` is sent, the default branch is used (see How Every API Call Works)."},"SaleOrderVouchCode":{"type":"integer","description":"Logic ERP's internal number of the sale order – the `LastSavedCode` from Save a Sale Order, or the order's internal number in Get Sale Orders."},"GodownName":{"type":"string","description":"The godown the goods were packed from, by its name exactly as in Logic ERP. All stock is taken from this godown."},"PS_Prefix":{"type":"string","description":"Prefix of the packing slip number, for example `\"PS\"`. A prefix set in your API site's settings replaces it."},"Remarks":{"type":"string","description":"Remarks saved on the packing slip."},"Box_No_Prefix":{"type":"string","description":"Prefix of the box numbers, saved on the packing slip."},"ListItems":{"type":"array","items":{"type":"object","properties":{"ItemCode":{"type":"string","description":"The item. By default the item code shown in Logic ERP (`UserCode` in Get Item Master), matched exactly (spaces around it are trimmed). The packing slip configuration can tell Logic ERP to read it as an additional item code / barcode, a lot code or lot number, a carton number, a serial number or a set code instead. The item must be on the sale order."},"ListBoxs":{"type":"array","items":{"type":"object","properties":{"PackingBoxNo":{"type":"string","description":"The box number, for example `\"B01\"`. Must not be empty."},"Quantity":{"type":"integer","description":"Ignored – the box quantities are used."}}},"description":"The boxes this item was packed in – see below."}}},"description":"The items packed – see below."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"LastSavedDocNo":{"type":"string","description":"The packing slip's number, for example `PS-118`."},"Status":{"type":"boolean","description":"`true` = the packing slip was saved. (Also `true` when the endpoint is switched off – see the messages.)"},"Message":{"type":"string","description":"`Success` when saved; otherwise why it failed."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal number of the packing slip. Send it as `Doc_Code` to bill or transfer the packed goods. `0` when nothing was saved."},"request_ID":{"type":"string","description":"The ID of this request – quote it to support. Can be empty when the request fails at an early check."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field            | Type         | Meaning                                                                                                                                  |
| ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`         | true / false | `true` = the packing slip was saved. (Also `true` when the endpoint is switched off – see the messages.)                                 |
| `Message`        | text         | `Success` when saved; otherwise why it failed.                                                                                           |
| `LastSavedCode`  | number       | Logic ERP's internal number of the packing slip. Send it as `Doc_Code` to bill or transfer the packed goods. `0` when nothing was saved. |
| `LastSavedDocNo` | text         | The packing slip's number, for example `PS-118`.                                                                                         |
| `request_ID`     | text         | The ID of this request – quote it to support. Can be empty when the request fails at an early check.                                     |

### **Example response**

```json
{
  "LastSavedDocNo": "PS-118",
  "Status": true,
  "Message": "Success",
  "LastSavedCode": 7716,
  "request_ID": "3f6a0c52-91de-4b7e-a2c4-58e1d07b9f36"
}
```

### **Messages you may see**

All with `Status: false` unless stated. Text in `…` is replaced by the value concerned. Where the reason comes from an error inside Logic ERP it may be followed by technical detail – read the first line (and see the known issue on the saving step).

| Message                                                                                                                                    | Meaning                                                                                                                   | What to do                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `Packing Slip Configuration Not Set in Setup API Template`                                                                                 | No packing slip configuration is chosen for this endpoint in your API site.                                               | Ask your Logic ERP team to choose one.                              |
| `Unable to found Sale Order...`                                                                                                            | No order with that party order number in the branch, or neither `SaleOrderVouchCode` nor `PartyOrderNo` was sent.         | Send `SaleOrderVouchCode`, or check `PartyOrderNo` and the branch.  |
| `More than one Sale Order found for Party Order No. : … in Branch Code : …..Please send the Sale Order code (SaleOrderVouchCode)..`        | More than one order of the branch has that party order number.                                                            | Send `SaleOrderVouchCode`.                                          |
| `Unable to found Sale Order : …`                                                                                                           | No sale order has that `SaleOrderVouchCode`.                                                                              | Check `SaleOrderVouchCode` with Get Sale Orders.                    |
| `Sale Order : … belongs to Branch Code : …, not to Branch Code : …..Please Check...`                                                       | The order is of another branch than the one you sent.                                                                     | Send the sale order's own branch.                                   |
| `Sale Order Is marked as Un Approved. Cannot allow Packing Slip...`                                                                        | The order is waiting for approval.                                                                                        | Have it approved in Logic ERP first.                                |
| `Sale Order is Cancelled. Cannot allow Packing Slip...`                                                                                    | The order has been cancelled as a whole.                                                                                  | Nothing to pack.                                                    |
| `New Financial Year has been created... Cannot allow New Entry/Modification.`                                                              | A newer financial year already exists for stock.                                                                          | Ask your Logic ERP team.                                            |
| `Invalid GodownName..`, `Unable to found Godown Name :…`                                                                                   | `GodownName` is empty or not found.                                                                                       | Send the godown name exactly as in Logic ERP.                       |
| `Invalid Bin Name...`, `Unable to found Bin Name :…`                                                                                       | Bins are required and a box has no bin, or the bin is not found.                                                          | Send `BinName` or `BinCode` for every box.                          |
| `Packing BOX Number cannot be blank.....`                                                                                                  | A box has no `PackingBoxNo`.                                                                                              | Send a box number.                                                  |
| `Invalid Quantity : … for Item Code : … Box : …. Quantity must be a whole number of 1 or more..`                                           | A box quantity is a fraction or below `1` (not when the configuration reads `ItemCode` as a lot code). Nothing was saved. | Send whole-unit quantities.                                         |
| `Item/Lot does Not exist In database....`                                                                                                  | `ItemCode` was not found (read as the configuration says).                                                                | Check the code with Get Item Master.                                |
| `Invalid Barcode.... Item does Not exist In Sale Order. Please check.`                                                                     | The item has nothing pending on the order, or the order has nothing pending at all.                                       | Pack only items of the order; check the order with Get Sale Orders. |
| `No Pending quantity found......`, `No Pending Items found for Sale Order.......`                                                          | You packed more of an item than the order still has pending.                                                              | Reduce the box quantities.                                          |
| `No Stock Found.........`                                                                                                                  | No lot of the item has stock in that godown.                                                                              | Check stock in the godown.                                          |
| `Invalid Lot Code`, `Invalid Serial Number`, `Barcode - … belongs To multiple items. Please check.`, `No Stock found For this barcode....` | Only when the configuration reads `ItemCode` as a lot, serial or lot number: the code is not valid.                       | Check the code.                                                     |
| `Invalid Packing Slip No........` (inside technical text)                                                                                  | No prefix – neither `PS_Prefix` nor a prefix in your API site.                                                            | Send `PS_Prefix`.                                                   |
| `Packing Slip number already exists....` (inside technical text)                                                                           | The next number is already used in the branch.                                                                            | Send again; ask your Logic ERP team if it repeats.                  |
| `Entry not allowed in back date.......`, `Entry/Modification is locked for this period....` (inside technical text)                        | Logic ERP's date locks do not allow a packing slip today.                                                                 | Ask your Logic ERP team.                                            |
| `Request cannot be processed. API Template is marked as In-Active in the configuration.` – with `Status: true`                             | Your Logic ERP team has switched this endpoint off. Nothing is saved, although `Status` is `true`.                        | Treat as not saved; ask your Logic ERP team.                        |


---

# 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-packing-slip-against-a-sale-order.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.
