<< Back to discount page
Discount calculation

Table tbl_discounts

  Product code Client code Product class discount Client class discount
DB-field/
index
code cust_code code_disc_class code_client_class
1. A X 0 0
2. A 0 0 CD
3. 0 X AD 0
4. 0 0 AD CD
5. A 0 0 0
6. 0 0 AD 0
7. 0 X 0 0
8. 0 0 0 CD

A customer X with client class discount CD buys the product A with the product class discount AD.

It will be searched a record in one of the next situations in the specified order. First record found gives the final result.

1. PRODUCT + CLIENT
It will be searched if there is a record with Product code = A and Client code = X and Article class discount = 0 and Client class discount = 0. If such a record exists, then this is the resulting discount - this means that the product A has a specific discount for the client X

2. PRODUCT + CLIENT CLASS
A record will be searched with Product code = A and Client code = 0 and Article class discount = 0 and Client class discount = CD - that means that the product A has a discount for the client class discount CD.

3. PRODUCT CLASS + CLIENT
A record will be searched with Product code = 0 and Client code = X and Article class discount = AD and Client class discount = 0 - that means that the client X has a discount for the product class discount.

4. PRODUCT CLASS + CLIENT CLASS
A record will be searched with Product code = 0 and Client code = 0 and Article class discount = AD and Client class discount =CD .

5. GENERIC PRODUCT
A record will be searched with Product code = A and Client code = 0 and Article class discount = 0 and Client class discount = 0 - the product A has a general discount for all clients and all client discount classes.

6. GENERIC PRODUCT CLASS
A record will be searched with Product code = 0 and Client code = 0 and Article class discount = AD and Client class discount = 0 - the article class discount AD has a general discount for all clients and all client classes discount.

7. GENERIC CLIENT
A record will be searched with Product code = 0 and Client code = X and Article class discount = 0 and Client class discount = 0 - the client X has a generic discount for all products and all classes of discounts for products.

8. GENERIC CLIENT CLASS
A record will be searched with Product code = 0 and Client code = 0 and Article class discount = 0 and Client class discount = CD - the client discount class CD has a generic discount for all products and all classes of discounts for products.

Otherwise there is no discount.

OBS: Always check the quantity and validity date.