S
S
Stanislav Gordienko2016-09-05 07:27:37
Django
Stanislav Gordienko, 2016-09-05 07:27:37

How to implement the logic for calculating the cost depending on the number of units of goods?

The task is to calculate the purchase price depending on the number of units of goods. Are there ready-made libraries that would provide an opportunity to describe the calculation of the total cost from the number of specified units of goods? For example, in the same python code:
If the user specified up to 10 units, then the unit cost does not change;
If the user specified from 10 to 20 units - then the unit cost is -3%;
If the user has indicated more than 20 units - then the cost of a unit of goods is -5%
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2016-09-05
@fireSparrow

If the scheme is always "from ... to ... - discount ... percent", then you can simply make a rules constructor.
The constructor script will show the simplest form in which the user enters three numbers into the text fields, after which this rule is saved in a special file.
Well, the main program will take the rules from the same file.

S
sim3x, 2016-09-05
@sim3x

It’s not ready, because it’s not clear what you need to get in the end
Make a custom basket Write down
the rules in it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question