# How invoicing works

There can be different invoicing cases(discounts, additional charges) on an order. This guide outlines different invoicing cases on an order.

## **Before we start**

This guide assumes that you're familiar with creating an [Order](https://app.gitbook.com/@eshop/s/api-reference/order/orders).

## **Step by step guide**

### Cart Discount

It is implemented on the whole order, the total discount is divided equally on each item. Refer to the below table while creating an order request.

| **Attribute** | **Field**           | **Value**                                                                 |
| ------------- | ------------------- | ------------------------------------------------------------------------- |
| Order         | subtotal            | sum of all lineItemTotal of an order                                      |
| Order         | orderTotal          | subtotal + shipping charges                                               |
| Order         | balanceDue          | If order is COD, balanceDue = orderTotal                                  |
| Items         | items.discount      | Discount(in case of multiple items discount = total Discount/No of items) |
| Items         | items.customerPrice | Selling Price\[Inclusive of taxes]                                        |
| Items         | items.lineItemTotal | (Selling Price- Discount)\*Quantity                                       |

Sample request when cart discount is applied on an order:

```
{
 "id": 1842937,
 "externalChannelID": "TATA CLIQ VELOCY KAPAS KRAFT",
 "customerOrderNumber": "OD119208447831346000",
 "vendorOrderNumber": "11920832654052201",
 "shipMethod": "STD",
 "orderDate": "2020-07-09 17:51:05",
 "expectedShipDate": "2020-07-10 15:00:00",
 "promiseDeliveryDate": "0000-00-00 00:00:00",
 "isCOD": "0",
 "paymentType": "DebitCard",
 "taxAmount": 0,
 "shipChargeAmount": 150,
 "subtotal": 1499,
 "orderTotal": 1649,
 "balanceDue": 0,
 "thirdPartyShipping": true,
 "onHold": false,
 "created_at": "2020-07-09 18:03:29",
 "updated_at": "2020-07-09 18:03:29",
 "shippingAddress": {
 "customerName": "John Doe",
 "addressLine1": "Kapas Kraft Apparels Limited",
 "addressLine2": "Banglore",
 "city": "bengluru",
 "state": "Karnataka",
 "postalCode": "560005",
 "countryCode": "IN",
 "countryName": "India",
 "contactPhone": "9998889998",
 "email": "johndoe@gmail.com"
 },
 "billingAddress": {
 "customerName": "John Doe",
 "addressLine1": "Kapas Kraft Apparels Limited",
 "addressLine2": "Banglore",
 "city": "bengluru",
 "state": "Karnataka",
 "postalCode": "560005",
 "countryCode": "IN",
 "countryName": "India",
 "contactPhone": "9998889998",
 "email": "johndoe@gmail.com"
 },
 "items": [
 {
 "lineItemSequenceNumber": 123279,
 "orderItemID": "11920832654052201",
 "itemID": "DB9U03FMGWZ",
 "sku": "1234_S",
 "productName": "Step Maro Sol",
 "quantity": 1,
 "customerPrice": 1999,
 "discount": 500,
 "lineItemTotal": 1499,
 "taxRate": 0,
 "taxAmount": 0,
 "giftMessage": "",
 "giftLabelContent": "",
 "cancellationReason": "",
 "cancellationTime": "0000-00-00 00:00:00",
 "original_order_item_id": null
 }
 ],
 "expectedDeliveryDate": null
}
```

### Shipping Fees

The shipping fee is the cost used to ship items to a buyer. Refer to the below table while creating an order request.

| **Attribute** | **Field**        | **Value**                            |
| ------------- | ---------------- | ------------------------------------ |
| Order         | shipChargeAmount | shipping charges on the order level  |
| Order         | subtotal         | sum of all lineItemTotal of an order |
| Order         | orderTotal       | subtotal + shipping charges          |

Sample request when shipping fee is added to an order:

```
{
 "id": 1842996,
 "externalChannelID": "TATA CLIQ VELOCY KAPAS KRAFT",
 "customerOrderNumber": "OD119208447831346000",
 "vendorOrderNumber": "11920832654052201",
 "shipMethod": "STD",
 "orderDate": "2020-07-09 18:08:10",
 "expectedShipDate": "2020-07-10 15:00:00",
 "promiseDeliveryDate": "0000-00-00 00:00:00",
 "isCOD": "1",
 "paymentType": "CashOnDelivery",
 "taxAmount": 0,
 "shipChargeAmount": 150,
 "subtotal": 2399,
 "orderTotal": 2549,
 "balanceDue": 2549,
 "thirdPartyShipping": true,
 "onHold": false,
 "created_at": "2020-07-09 18:13:32",
 "updated_at": "2020-07-09 18:13:32",
 "shippingAddress": {
 "customerName": "John Doe",
 "addressLine1": "Kapas Kraft Apparels Limited",
 "addressLine2": "Banglore",
 "city": "bengluru",
 "state": "Karnataka",
 "postalCode": "560005",
 "countryCode": "IN",
 "countryName": "India",
 "contactPhone": "9998889998",
 "email": "johndoe@gmail.com"
 },
 "billingAddress": {
 "customerName": "John Doe",
 "addressLine1": "Kapas Kraft Apparels Limited",
 "addressLine2": "Banglore",
 "city": "bengluru",
 "state": "Karnataka",
 "postalCode": "560005",
 "countryCode": "IN",
 "countryName": "India",
 "contactPhone": "9998889998",
 "email": "johndoe@gmail.com"
 },
 "items": [
 {
 "lineItemSequenceNumber": 123282,
 "orderItemID": "11920832654052201",
 "itemID": "DB9U03FMGWZ",
 "sku": "1234_S",
 "productName": "Reazor Edge",
 "quantity": 1,
 "customerPrice": 2399,
 "discount": 0,
 "lineItemTotal": 2399,
 "taxRate": 0,
 "taxAmount": 0,
 "giftMessage": "",
 "giftLabelContent": "",
 "cancellationReason": "",
 "cancellationTime": "0000-00-00 00:00:00",
 "original_order_item_id": null
 }
 ],
 "expectedDeliveryDate": null
}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eshop.gitbook.io/eshopbox-developers/order/orders/how-invoicing-works.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
