-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support non-promotion line-level adjustments #2188
Support non-promotion line-level adjustments #2188
Conversation
aa265a3
to
ec8bc02
Compare
core/app/models/spree/line_item.rb
Outdated
# @return [BigDecimal] the amount of this item, taking into consideration | ||
# all non-tax adjustments. | ||
def final_amount_without_additional_tax | ||
amount + adjustments.reject(&:tax?).sum(&:amount) |
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.
This probably needs to check eligible?
(and a spec catching that would be great)
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.
👍 thanks. Added a spec as well.
Update: With some feedback from @mamhoff I've updated with what seem like some better names all around. |
2c8a4dc
to
5d8834d
Compare
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.
Excellent work, especially the naming improvement!
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.
This is looking very reasonable. Could you please rebase this to take care of the conflict?
…ments In PR 1933 we starting allowing allow non-promotion adjustments on line items and shipments. However, we didn't update some other important code (including the DefaultTax calculator) to consider these adjustments. This commit: - Adds a `total_before_tax` method on LineItem, Shipment, and ShippingRate. - Updates Calculator::DefaultTax to use this method when calculating taxes. - Updates all other code inside Solidus to use this method. - Deprecates the old `discounted_amount` methods.
Aiming to provide more consistent and obvious naming for these fields. Shipment: `final_price` -> `total` (and the display_ method) `pre_tax_amount` -> `total_excluding_vat` `final_price_with_items` -> `total_with_items` LineItem: `final_amount` -> `total` (and the display_ method) `pre_tax_amount` -> `total_excluding_vat` (and the display_ method) Order: `pre_tax_item_amount` -> `item_total_excluding_vat` ReturnAuthorization: `pre_tax_total` -> `total_excluding_vat` (and the display_ method) ReturnItem: `pre_tax_amount` -> `total_excluding_vat` (and the display_ method) CustomerReturn: `pre_tax_total` -> `total_excluding_vat` (and the display_ method)
4a4a677
to
dd24466
Compare
In #1933 we starting allowing non-promotion adjustments on line items
and shipments. However, we didn't update some other important code (including
the DefaultTax calculator) to consider these adjustments.
This PR fixes the above issue in its first commit and renames several existing methods in its second commit.
Please see individual commits.