Closed maarcingebala closed 6 years ago
The original idea was to have two field types:
price_net = AmountField(currency='USD')
price_gross = AmountField(currency='USD')
price = PriceField(net='price_net', gross='price_gross')
@patrys Now I'm wondering what's the purpose of the price
field in the above example. Having two fields for net
and gross
, one could simply have a price
property that would construct a Price
based on the two amounts. Also, how would you recommend to use those fields to someone who doesn't need to take taxes into account?
@elwoodxblues I guess you could also have a property perform what Django's GenericForeignKey
does but it's a lot of copy-paste work: you have to implement at least a getter and a setter.
Edit: if you don't need taxes then you should be fine using only Amounts and AmountFields. There's no reason for you to deal with Prices.
I'm only concerned about how intuitive would such API be. If usage of the PriceField
is only reasonable with taxes, is the PriceField
a proper name then?
Well, Price is named Price so a field that returns a Price is called... a PriceField. We can of course rename Price to something entirely different.
It just feels strange that the price will sometimes be represented as Price
and sometimes as Amount
. This should probably be discussed in a wider group with other contributors.
@elwoodxblues The only useful feature of Price
is to represent separate net and gross amounts though.
@koradon In this PR we should also bump the version of this package to 1.0.0-beta
.
@elwoodxblues @patrys pls review
Codecov Report
88.88% <0%> (ø)
95.91% <100%> (+2.36%)
100% <100%> (ø)
Continue to review full report at Codecov.