Skip to content
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

Merged

Conversation

jordan-brough
Copy link
Contributor

@jordan-brough jordan-brough commented Aug 29, 2017

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.

@jordan-brough jordan-brough force-pushed the tax-fix-line-level-adjustments branch from aa265a3 to ec8bc02 Compare August 29, 2017 18:00
@solidusio solidusio deleted a comment from houndci-bot Aug 29, 2017
# @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)
Copy link
Contributor

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)

Copy link
Contributor Author

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.

@jordan-brough
Copy link
Contributor Author

jordan-brough commented Aug 31, 2017

final_amount_without_tax might be a better name than final_amount_without_additional_tax? Having both included and additional types of tax make things more confusing. I'm not sure which name is better. Or if there's something else even better. The fact that we also have LineItem#pre_tax_amount makes things even more confusing, since that method is dealing with included tax.

Update: With some feedback from @mamhoff I've updated with what seem like some better names all around.

@jordan-brough jordan-brough force-pushed the tax-fix-line-level-adjustments branch 4 times, most recently from 2c8a4dc to 5d8834d Compare September 8, 2017 20:28
Copy link
Contributor

@mamhoff mamhoff left a 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!

Copy link
Member

@gmacdougall gmacdougall left a 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)
@jordan-brough jordan-brough force-pushed the tax-fix-line-level-adjustments branch from 4a4a677 to dd24466 Compare September 13, 2017 15:38
@jordan-brough jordan-brough merged commit 4a2556b into solidusio:master Sep 20, 2017
@jordan-brough jordan-brough deleted the tax-fix-line-level-adjustments branch September 20, 2017 16:13
@jhawthorn jhawthorn changed the title Update Solidus to work correctly with non-promotion line-level adjustments Support non-promotion line-level adjustments Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants