Working with discounts and rounding

Main information

Starting the 6.0 version, the work with discounts was changed. The key change is that order discount is being considered not in order total sum, but is being distributed between items and is being considered in each separate item of order. Herewith the distributed discount does not affect on item discount, it may be specified like earlier.

Let's see on the example. We have the following order:

| Item      |    Price|    Discount       |  Q-ty  |    Total |
|           |         |                   |        |          |
| Shorts    | 10 euro | 1 euro (per item) |      2 | 18 euro  |
|           |         |                   |        |          |
| Flip-flops| 5 euro  | 0 euro (per item) |      3 |  15 euro |
|                                                  |          |
| Total                                            | 33 euro  |

We gave the order discount on amount of 5 euro.

In 5.0 and lower versions of system this discount will be considered in the order total sum:

| Item		|    Price| Discount          | Q-ty   |    Total|
|               |         |                   |        |         |
| Shorts        | 10 euro | 1 euro (per item) |      2 | 18 euro |
|               |         |                   |        |         |
| Flip-flops    | 5 euro  | 0 euro (per item) |      3 |  15 euro|
|                                                      |         |
| Discount on order                                    |  5 euro |
|                                                      |         |
| Total                                                | 28 euro |

In 6.0 and higher versions the order discount will be distributed between items and will be considered in their cost:

| Item        |    Price| Discount          |  Q-ty  |    Total |
|             |         |                   |        |          |
| Shorts      | 10 euro | 1 euro (per item) |      2 |  16 euro |
|             |         | 1 euro (on order) |        |          |
|             |         |                   |        |          |
| Flip-flops  | 5 euro  | 0 euro (per item) |      3 |  12 euro |
|             |         | 1 euro (on order) |        |          |
|                                                    |          |
| Total                                              |  28 euro |

Order sum in such case will be calculated the following way: (10 – 1 – 1) x 2 + (5 – 1) x 3 = 28

API

API v4

In API v4 and lower the discount fields order[discount], order[discountPercent], order[items][][discount], order[items][][discountPercent] in order are stay the same and are available for reading and writing.

On the example above when creating the order, it is necessary to transfer values the following way:

order = {
    // ...
    "discount": 5,
    "items": [
        {
            "offer": { "externalId": "1" },
            "initialPrice": 10,
            "discount": 1,
            "quantity": 2
        },
        {
            "offer": { "externalId": "2" },
            "initialPrice": 5,
            "quantity": 3
        }
    ],
    // ...
}

In API methods of getting orders the content and values will be the same:

{
    // ...
    "discount": 5,
    "items": [
        {
            "offer": { "externalId": "1" },
            "initialPrice": 10,
            "discount": 1,
            "quantity": 2
        },
        {
            "offer": { "externalId": "2" },
            "initialPrice": 5,
            "quantity": 3
        }
    ],
    // ...
}

API v5

In methods of order creation and editing /api/v5/orders/create, /api/v5/orders/{externalId}/edit, /api/v5/orders/upload it is possible to transfer discounts on order and items in the fields order[discountManualAmount], order[discountManualPercent], order[items][][discountManualAmount], order[items][][discountManualPercent], herewith order discounts will be distributed between items.

On the example above when creating the order, it is necessary to transfer values the following way:

order = {
    // ...
    "discountManualAmount": 5,
    "items": [
        {
            "offer": { "externalId": "1" },
            "initialPrice": 10,
            "discountManualAmount": 1,
            "quantity": 2
        },
        {
            "offer": { "externalId": "2" },
            "initialPrice": 5,
            "quantity": 3
        }
    ],
    // ...
}

In methods of getting orders /api/v5/orders, /api/v5/orders/{externalId} the total monetary discount per item for each item position will be returned in the field order[items][][discountTotal], which considers both discount on current item and order discount distributed between items.

{
    // ...
    "items": [
        {
            "offer": { "externalId": "1" },
            "initialPrice": 10,
            "discountTotal": 2,
            "quantity": 2
        },
        {
            "offer": { "externalId": "2" },
            "initialPrice": 5,
            "discountTotal": 1,
            "quantity": 3
        }
    ],
    // ...
}

The extreme cases in order discount distribution between items

In several cases the system cannot distribute order discount between items. Let`s see on example.

We have the order with following content:

| Item     |    Price|   Discount        | Q-ty   |    Total |
|          |         |                   |        |          |
| Shorts   | 10 euro | –                 |      3 | 300 euro |
|                                                 |          |
| Total                                           | 300 euro |

We added the order discount in amount of 0.4 euro. System should distribute this order discount between all items, which are 3 in the order.

By default the system will show the error message on trying to set such discount. The important thing is that error will occur when creating the order manually or through API, independently of API version.

If there is “Auto correct discount for order” setting in Settings > Orders, section, then the system will correct order discount up to closer divisible value (in our example discount will become 0.39 euro).

Rounding

There is a rounding function added to 6.0 version, which can be enabled in Settings > Orders section. Rounding, if enabled, is being applied to order items. The amount, which removed from item sum as a result of rounding, will be moved to item discount.

In settings there is also an option of rounding the item cost considering the order cost, which are by default when enabled rounding. Due to this option the item cost rounding is being made such way, that total order cost will be maximum close to order cost without rounding.


PrintEditHistory
Page last modified on October 20, 2017, at 02:40 PM