> 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/edit-gr-details-of-sale-invoices.md).

# Edit GR Details of Sale Invoices

Changes some **dispatch (GR) details** already recorded on **sale invoices** – the GR number and date, vehicle number, cases, removal time, gate-pass date and three remark lines. You can edit **one invoice** by its printed invoice number, or **every invoice of a GR document** at once. Unlike [Save GR Details for Sale Invoices](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-gr-details-for-sale-invoices.md), this endpoint creates nothing: it does not create a GR document, does not add or remove invoices, and does not change the transporter, agent, delivery address or second GR number.

### **Endpoint**

| Name          | Detail                                           |
| ------------- | ------------------------------------------------ |
| Address       | `https://your-server/api/EditGREntryAgainstSale` |
| 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).

It uses the licence of Save GR Details for Sale Invoices. Field names are matched without regard to upper/lower case; fields not listed below are ignored.

### **Request fields**

**Which invoices to edit** – send `Bill_No` for one invoice, or leave it empty and name a GR document.

| Field                      | Type         | Required        | Default    | Meaning                                                                                                                                                                                                                                  |
| -------------------------- | ------------ | --------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Bill_No`                  | text         | One of the ways | empty      | The **printed invoice number** of one invoice, for example `"2627/ESL-346"` (only series with their own number format have one). When filled, only this invoice is edited and the GR document fields below are not used.                 |
| `Doc_Prefix`, `Doc_Number` | text, number | One of the ways | empty, `0` | Prefix and number of a GR document (the two parts of `LastSavedDocNo` from the save, for example `"LR"` and `8`). Used when `Bill_No` is empty.                                                                                          |
| `Ext_Doc_No`               | text         | One of the ways | empty      | An external number of a GR document. Used instead of `Doc_Prefix`/`Doc_Number` when filled – but see the known issue below. On a database without external GR numbers it is refused.                                                     |
| `BranchCode`               | number       | One of the two  | `0`        | The branch (`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 invoice or GR document is looked for in this branch. |
| `BranchShortName`          | text         | One of the two  | empty      | The branch short name, used when `BranchCode` is `0`.                                                                                                                                                                                    |
| `DisplayError`             | text         | No              | `"0"`      | `"1"` = `Message` carries the full technical detail when the edit fails.                                                                                                                                                                 |

**Values written to the invoices** – a field left empty keeps the invoice's present value; you cannot clear a value with this endpoint.

| Field                                 | Type | Required | Default   | Meaning                                                                            |
| ------------------------------------- | ---- | -------- | --------- | ---------------------------------------------------------------------------------- |
| `GR_No`                               | text | No       | unchanged | The (first) GR / LR number.                                                        |
| `GR_Date`                             | date | No       | unchanged | Date of the GR, `yyyy-MM-dd`.                                                      |
| `Vehicle_No`                          | text | No       | unchanged | Vehicle number.                                                                    |
| `Cases`                               | text | No       | unchanged | Number of cases or packages.                                                       |
| `Removal_Time`                        | text | No       | unchanged | Time the goods left, for example `"07:15 PM"`. Saved only when it is a valid time. |
| `Token_GP_Date`                       | date | No       | unchanged | Token / gate-pass date, `yyyy-MM-dd`.                                              |
| `Remarks_1`, `Remarks_2`, `Remarks_3` | text | No       | unchanged | The three remark lines of the invoice.                                             |
| `ListBills`                           | list | No       | empty     | Only when editing by GR document: different values per invoice. See below.         |

**`ListBills`** (GR document only)

| Field                                                                                                             | Type     | Required | Default   | Meaning                                                      |
| ----------------------------------------------------------------------------------------------------------------- | -------- | -------- | --------- | ------------------------------------------------------------ |
| `Bill_No`                                                                                                         | text     | **Yes**  | –         | The printed invoice number of an invoice in the GR document. |
| `GR_No`, `GR_Date`, `Vehicle_No`, `Cases`, `Removal_Time`, `Token_GP_Date`, `Remarks_1`, `Remarks_2`, `Remarks_3` | as above | No       | unchanged | Values for this invoice, as in the table above.              |

**GR document fields** – `Doc_Remarks_1`, `Doc_Remarks_2`, `Pickup_Stage`, `Estimated_Delv_Days`, `Non_Delv_Reason`, `Pickup_Date`, `Pickup_Delv_Date`, `Non_Delv_Date`: written to the GR document when editing by GR document. A field your database does not have is refused – see the rules.

### **Rules Logic ERP applies**

* **One invoice (`Bill_No`).** The invoice must belong to the branch and to the **current financial year** (the year containing today's date on the server), and must have a printed invoice number. It does not need to be in a GR document. The values in the request are written to it.
* **A GR document.** The GR document must be a sale GR document of the branch; it may be of any year.
  * With `ListBills` **empty**, the same values are written to **every invoice** in the GR document.
  * With `ListBills` filled, **every invoice in the GR document must be listed** by its printed number; each gets its own values. If one is missing, nothing is changed and you get *Unable to found Bill No. : …*. Invoices you list that are not in the GR document are ignored.
* Empty values never overwrite: only fields you fill are changed.
* All changes are saved together; if one fails, nothing is changed.
* No audit-trail entry is written for this edit.

> **GR document fields your database does not have.** Most Logic ERP databases do not have the GR document fields. When you send a value for one of them, the request is refused with `… is not available on this database.` (naming the field) and nothing is changed; leave such fields out and the edit by `Doc_Prefix`/`Doc_Number` works. `Doc_Remarks_2`, `Pickup_Date` and `Pickup_Delv_Date` are not supported – sending them is always refused this way. `Estimated_Delv_Days` is written only when it is above `0`.

> **Known issue – `Ext_Doc_No` cannot find a GR saved through the API.** Save GR Details for Sale Invoices does not store an external number, so a GR document it created is never found by `Ext_Doc_No`. Use `Doc_Prefix` and `Doc_Number`.

### **Example request**

One invoice:

```json
{
  "BranchCode": 2,
  "Bill_No": "2627/ESL-346",
  "GR_No": "LDH45821",
  "GR_Date": "2026-10-29",
  "Vehicle_No": "PB10CD5678",
  "Cases": "4",
  "Removal_Time": "07:15 PM",
  "Remarks_1": "Re-loaded on second vehicle"
}
```

### **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 edits the sandbox's test GR document `APIGR-1`.

## Edit GR Details of Sale Invoices

> Changes some dispatch (GR) details already recorded on sale invoices – the GR number and date, vehicle number, cases, removal time, gate-pass date and three remark lines. You can edit one invoice by its printed invoice number, or every invoice of a GR document at once. Unlike Save GR Details for Sale Invoices, this endpoint creates nothing: it does not create a GR document, does not add or remove invoices, and does not change the transporter, agent, delivery address or second GR number.

```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":{"/EditGREntryAgainstSale":{"post":{"tags":["Sale - Push"],"operationId":"EditGREntryAgainstSale","summary":"Edit GR Details of Sale Invoices","description":"Changes some dispatch (GR) details already recorded on sale invoices – the GR number and date, vehicle number, cases, removal time, gate-pass date and three remark lines. You can edit one invoice by its printed invoice number, or every invoice of a GR document at once. Unlike Save GR Details for Sale Invoices, this endpoint creates nothing: it does not create a GR document, does not add or remove invoices, and does not change the transporter, agent, delivery address or second GR number.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"BranchCode":{"type":"integer","description":"The branch (`Branch_Code` in Get Branch Info). The invoice or GR document is looked for in this branch."},"Bill_No":{"type":"string","description":"The printed invoice number of one invoice, for example `\"2627/ESL-346\"` (only series with their own number format have one). When filled, only this invoice is edited and the GR document fields below are not used."},"Doc_Prefix":{"type":"string","description":"Prefix and number of a GR document (the two parts of `LastSavedDocNo` from the save, for example `\"LR\"` and `8`). Used when `Bill_No` is empty."},"Doc_Number":{"type":"integer","description":"Prefix and number of a GR document (the two parts of `LastSavedDocNo` from the save, for example `\"LR\"` and `8`). Used when `Bill_No` is empty."},"GR_No":{"type":"string","description":"The (first) GR / LR number."},"GR_Date":{"type":"string","description":"Date of the GR, `yyyy-MM-dd`."},"Cases":{"type":"string","description":"Number of cases or packages."},"Remarks_1":{"type":"string","description":"The three remark lines of the invoice."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"LastSavedDocNo":{"type":"string","description":"One invoice: the `Bill_No` you sent. GR document: its external number, or prefix and number joined by a hyphen (for example `\"LR-8\"`)."},"Status":{"type":"boolean","description":"`true` when the changes were saved."},"Message":{"type":"string","description":"`\"Success\"` when saved; otherwise the reason."},"LastSavedCode":{"type":"integer","description":"One invoice: Logic ERP's internal number of the invoice. GR document: the internal number of the GR document."},"request_ID":{"type":"string","description":"As described on the common page. `null` when the invoice or GR document was not found."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field            | Type         | Meaning                                                                                                                                |
| ---------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| `Status`         | true / false | `true` when the changes were saved.                                                                                                    |
| `Message`        | text         | `"Success"` when saved; otherwise the reason.                                                                                          |
| `LastSavedCode`  | number       | One invoice: Logic ERP's internal number of the invoice. GR document: the internal number of the GR document.                          |
| `LastSavedDocNo` | text         | One invoice: the `Bill_No` you sent. GR document: its external number, or prefix and number joined by a hyphen (for example `"LR-8"`). |
| `request_ID`     | text         | As described on the common page. `null` when the invoice or GR document was not found.                                                 |

### **Example response**

```json
{
  "LastSavedDocNo": "2627/ESL-346",
  "Status": true,
  "Message": "Success",
  "LastSavedCode": 10452,
  "request_ID": "9e2b6c71-4d0a-4f6e-8a35-c1d7b2e04a58"
}
```

### **Messages you may see**

| Message                                                                                                                | Meaning                                                                                                                                                                | What to do                                                                   |
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `Please Define Ext_Doc_No Or Doc_Prefix And Doc_Number to Continue...`                                                 | `Bill_No` is empty and no GR document was named.                                                                                                                       | Send `Bill_No`, or `Doc_Prefix` with `Doc_Number`.                           |
| `Unable to found Sale GR Entry....`                                                                                    | The invoice (by `Bill_No`) or the GR document was not found in the branch. For `Bill_No`, the invoice must be of the current financial year and have a printed number. | Check the number, branch and year.                                           |
| `Unable to found Bill No. : …`                                                                                         | With `ListBills`, an invoice of the GR document is not listed. The message shows that invoice's printed number (empty when it has none).                               | List every invoice of the GR document, or send `ListBills` empty.            |
| `Branch_Short_Name : … not exists.`                                                                                    | `BranchShortName` does not exist.                                                                                                                                      | Check the short name.                                                        |
| `… is not available on this database.`, `Ext_Doc_No is not available on this database. Use Doc_Prefix And Doc_Number.` | A GR document field (or `Ext_Doc_No`) was sent that your Logic ERP database does not have.                                                                             | Leave that field out; name the GR document by `Doc_Prefix` and `Doc_Number`. |


---

# 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/edit-gr-details-of-sale-invoices.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.
