mirumee / django-prices

Django fields for the prices module
158 stars 53 forks source link

Taxes are not being saved #45

Closed sqts closed 6 years ago

sqts commented 7 years ago

Whereas Gross and Taxes can be changed within the Price, the changes are not being saved in the model object.

>>> from prices import Price, LinearTax, inspect_price
>>> p = Price('1.99')
>>> p += Price(50)
>>> p |= LinearTax('0.23', '23% VAT')
>>> p
Price(net='51.99', gross='63.9477', currency=None)

>>> product = Product.objects.create(name="Asd", price=p)
>>> product.price.gross
Decimal('63.9477')

>>> Product.objects.last().price.gross
Decimal('51.99')
>>> Product.objects.last().price.tax
Decimal('0.00')

In the django-prices.models I can see that only net value is saved to db. Please confirm if that is the case and let me know how other values can be added. I need to have taxes in the store and I don't want to redo the whole product->cart->checkout->order stack.

rafalp commented 6 years ago

With 1.0.0 release recommended way to store tax amount is to define both gross and net MoneyField as well as combined TaxedMoneyField. We have an example for this in our readme.

Thanks!