New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tax clean-up and refactoring (SHOOP-975) #189
Conversation
Refs SHOOP-975
Test not fixed yet though; marked with xfail.
This is unused. Refs SHOOP-975
Refs SHOOP-975
These would need a price unit (i.e. currency and taxfulness info) to be useful. Since they are not limited to single Shop, they can't easily just inherit the unit from a Shop. Until we have decided how to handle price units that are not bound to a shop, we're better without them. Refs SHOOP-975
Make untaxed mandatory and use its currency for type checking the sums. Remove skipping of line taxes without amount, since their base amount should still be taken into account. Add a docstring. Refs SHOOP-975
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
|
||
|
||
class CurrencyBound(object): | ||
def __init__(self, currency=None, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring? What's the use for this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add..
Aside from the few nits I found to pick, this looks like good stuff. I know you're diligent enough to have tested the logic thoroughly, so I didn't start to build a "mental map" of it right now -- especially with a diff this huge. |
Money without currency makes no sense. Better to be explicit with this rather than defaulting to some external setting. Refs SHOOP-975
Refs SHOOP-975
Just for simplicity. Refs SHOOP-975
Refs SHOOP-975
There is no need to require id rather than object. Change the argument names to `shop` and `products`, since they will accept real objects too. Note: Passing ids is still supported.
These pragma directives are cheating.
Easier to debug than "NoneType object has no attribute x". Refs SHOOP-975
Refs SHOOP-975
To get nicer repr; useful in debugging test failures. Refs SHOOP-975
Refs SHOOP-975
Refs SHOOP-975
Rename unit_price to base_unit_price in OrderLine, SourceLine, BasketLine, LinePriceMixin, etc. Refs SHOOP-975
Also move it to shoop.core.pricing. Refs SHOOP-975
…amount For unifying the price fields with PriceInfo. This will be nice when implementing template helpers for price rendering with/without taxes. Refs SHOOP-975
Move stuff from PriceInfo to Priceful mixin and use the Priceful mixin for PriceInfo too. Now all three PriceInfo, OrderLine and SourceLine use the same Priceful API for price stuff. Write some new tests for Priceful too. Refs SHOOP-975
Refs SHOOP-975
These are created with makemigrations and then fine tuned manually, because some field renames were not detected correctly. Refs SHOOP-975
Fix the definition of is_orderable to use `(x|length > 0)` instead of `bool(x)`, since `bool` is not available as a Jinja function.
Refs SHOOP-975 / SHOOP-1074
* Allow changing Tax objects that are not in use (not in order lines). * Allow always changing the enabled property. * Allow always changing the translated names. * Raise ValidationError on clean rather than ImmutabilityError on save so that a nice message will be displayed to user rather than "Internal server error". Refs SHOOP-975
Refer to this link for build results (access rights to CI server needed): |
retest this please |
Refer to this link for build results (access rights to CI server needed): |
Tax clean-up and refactoring (SHOOP-975)
Basket API: allow adding zero priced product
Main part of all this goes to refactoring everything to use
Shop.create_price. That should prevent taxful/taxless price mismatches
in a Shop.
Prices and other money amounts are now passed as Money and Price objects
in the code, which ensures some more type safety. Yeppee!
TaxModule API was rethought through and got some changes.
OrderSource, BaseBasket and StoredBasket now have the price
unit (=currency+taxfullness) stored in them to avoid mixing units after
a basket load.
Calculation of taxes is made more explicit in OrderSource API.
Made OrderLine, SourceLine and PriceInfo to use unified API for price
fields (named Priceful). This should help when implementing template
helpers for rendering prices taxful/taxless depending on
user's/merchant's preference (Shop's taxfullness could differ from
rendering taxfullnes as long as TaxModule may calculate taxes
efficiently, which of course is not always true though.)
There is some small fixes and refactorings included here and there for
some things I found out while implementing this. Hope you don't mind.
TODO:
customers and company customers)
first tax, but actually adding them together)
Good luck reviewing! Have fun!