Quantity Pricing Integration
This article explains how to integrate the quantity pricing module.
Introduction
Section titled “Introduction”Quantity pricing integration is performed by sending a JSON string containing the price-by-quantity variations in field 27 of records in Table 13 - Product Prices.
Below is a practical scenario to facilitate understanding.
Maintenance in Demander Web
Section titled “Maintenance in Demander Web”Tiers can also be managed visually under Products > Prices > Edit, in Quantity pricing. The module walkthrough explains New, Edit, Delete, Save and Cancel, with screenshots.
The popup uses the same five integration attributes:
| Screen field | JSON attribute | Required |
|---|---|---|
| Tier description | descricao |
No |
| Minimum quantity | qtdeInicial |
Yes |
| List price (R$) | valorUnitario |
Yes |
| Maximum discount (%) | percDescontoMaximo |
No |
| Maximum markup (%) | percAcrescimoMaximo |
No |
Save in the popup adds or replaces the tier in the form’s collection and updates ListaPrecoProduto.jsonPrecoPorQuantidade. Deletion removes only the selected tier. Changes are persisted when you click Update in the price form, and tiers are loaded again when you reopen that same record. Other price records, tiers and existing attributes are preserved.
Absent percentages remain absent: the popup does not convert them to zero. Leaving a field blank, including after erasing an entered value, preserves inheritance; entering zero sets a zero limit for the tier. Minimum and maximum prices are calculated from the effective percentages for display only, without adding attributes to the JSON.
The starting quantity is inclusive. A tier with zero qtdeInicial is optional; when no tier applies, the product’s normal price is retained. JSON remains editable and synchronized with the grid. Empty content is accepted, and invalid content is flagged without being silently erased.
Example Scenario
Section titled “Example Scenario”Suppose the price of the product 20 KG BAG RICE FEED has the following tier prices:
| Tier Description | Minimum Quantity (>=) | List Price | Maximum Discount | Minimum Price | Maximum Markup | Maximum Price |
| Under 100 KG | 0 | $ 19.00 | 10% | $ 17.10 | 12% | $ 21.28 |
| Between 100 and 200 KG | 5 | $ 18.50 | 8% | $ 17.02 | 14% | $ 21.09 |
| Between 200 and 500 KG | 10 | $ 18.00 | 6% | $ 16.92 | 16% | $ 20.88 |
| Between 500 and 800 KG | 25 | $ 17.50 | 4% | $ 16.80 | 18% | $ 20.65 |
| 800 KG or more | 40 | $ 17.00 | 2% | $ 16.66 | 20% | $ 20.40 |
Full JSON Example
Section titled “Full JSON Example”The JSON string representing the example scenario is shown below:
NOTE: At the end of this article you will find the documentation for each JSON attribute.
[ { "descricao": "Under 100 KG", "qtdeInicial": 0, "valorUnitario": 19, "percDescontoMaximo": 10, "percAcrescimoMaximo": 12 }, { "descricao": "Between 100 and 200 KG", "qtdeInicial": 5, "valorUnitario": 18.5, "percDescontoMaximo": 8, "percAcrescimoMaximo": 14 }, { "descricao": "Between 200 and 500 KG", "qtdeInicial": 10, "valorUnitario": 18, "percDescontoMaximo": 6, "percAcrescimoMaximo": 16 }, { "descricao": "Between 500 and 800 KG", "qtdeInicial": 25, "valorUnitario": 17.5, "percDescontoMaximo": 4, "percAcrescimoMaximo": 18 }, { "descricao": "800 KG or more", "qtdeInicial": 40, "valorUnitario": 17, "percDescontoMaximo": 2, "percAcrescimoMaximo": 20 }]NOTE: For easier viewing, line breaks and formatting are shown; however, when sending data in Demander’s standard layout, line breaks should not be included.
Summary JSON Example
Section titled “Summary JSON Example”Below is the simplest version of the JSON, containing only the mandatory attributes.
Notice that the initial tier starting at zero is optional; if omitted, the app uses the product’s regular price.
[ { "qtdeInicial": 5, "valorUnitario": 18.50 }, { "qtdeInicial": 10, "valorUnitario": 18.00 }, { "qtdeInicial": 25, "valorUnitario": 17.50 }, { "qtdeInicial": 40, "valorUnitario": 17.00 }]JSON Documentation
Section titled “JSON Documentation”The JSON to be sent consists of an array of objects, where each object can have the following attributes:
| Name | Attribute | Required | Explanation |
| Tier name | descricao | No | Optional attribute. Used to provide a descriptive name for the tier. EX: Up to 100 KG, Above 800 KG |
| Initial quantity | qtdeInicial | Yes | Determines from which product quantity the price applies. NOTE: We use >= (greater than or equal to) to match the tier based on quantity. |
| Price | valorUnitario | Yes | Determines the unit value of the product. |
| % Max discount | percDescontoMaximo | No | Optional attribute. Determines the maximum discount percentage allowed in this tier. When omitted, the system uses the default percentage from Table 13 or company settings. |
| % Max markup | percAcrescimoMaximo | No | Optional attribute. Determines the maximum markup percentage allowed in this tier. When omitted, the system uses the default percentage from Table 13 or company settings. |
Table 13 Line Example
Section titled “Table 13 Line Example”Below is an example of a product price line/record including the quantity pricing JSON:
13|99999|48|UN||200.00|20|0|0|||||||||7.57|2.8||||||||[ { "descricao": "Under 100 KG", "qtdeInicial": 0, "valorUnitario": 19, "percDescontoMaximo": 10, "percAcrescimoMaximo": 12 }, { "descricao": "Between 100 and 200 KG", "qtdeInicial": 5, "valorUnitario": 18.5, "percDescontoMaximo": 8, "percAcrescimoMaximo": 14 }, { "descricao": "Between 200 and 500 KG", "qtdeInicial": 10, "valorUnitario": 18, "percDescontoMaximo": 6, "percAcrescimoMaximo": 16 }, { "descricao": "Between 500 and 800 KG", "qtdeInicial": 25, "valorUnitario": 17.5, "percDescontoMaximo": 4, "percAcrescimoMaximo": 18 }, { "descricao": "800 KG or more", "qtdeInicial": 40, "valorUnitario": 17, "percDescontoMaximo": 2, "percAcrescimoMaximo": 20 }]|[ { "qtdeInicial": "5", "valorUnitario": "100.00", "percDescontoMaximo": 10.00, "percAcrescimoMaximo": 10.00 }, { "qtdeInicial": "5", "valorUnitario": "92.50", "percDescontoMaximo": 5.00, "percAcrescimoMaximo": 5.00 }, { "qtdeInicial": "20", "valorUnitario": "80.00" }]