This PR closes #133 and It is an update to closed PR #152
Added discount field for a receipt entry, that is applied to tax base.
e.g:
quantity = 2
unit_price = 2
discount = 1
# tax base or total before discount
total = quantity * unit_price
# total = 4 -> 2 * 2
# discount applied to total
total_price = quantity * unit_price - discount
# total_price = 3 -> 2 * 2 - 1
discount field has two constraints, one to check that discount value it is always positive (due to how validators runs a value validator in the field won't ensure that only positive value is admitted in a manual object creation) and the second one checks that discount value is not greater that total before discount, also a MinValueValidator was added to discount field to cases when a form validation takes place.
This PR closes #133 and It is an update to closed PR #152
Added discount field for a receipt entry, that is applied to tax base. e.g:
discount
field has two constraints, one to check that discount value it is always positive (due to how validators runs a value validator in the field won't ensure that only positive value is admitted in a manual object creation) and the second one checks that discount value is not greater that total before discount, also a MinValueValidator was added to discount field to cases when a form validation takes place.Also some tests cases were added, see: https://github.com/Alvezgr/django-afip/blob/0ff51b164bc642df2bad181e5431df7772d51011/tests/test_models.py#L332-L392