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

Stop passing line_item to compute unit cancelation adjustment's amount #5278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BenMorganIO
Copy link
Contributor

Summary

Simple refactoring for the Spree::UnitCancel. There's no need to do inventory_unit.line_item and then pass the line item through everywhere when we can get it through a has_one. I also changed weighted_amount to accept an arbitrary amount instead of a line item object.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@BenMorganIO BenMorganIO requested a review from a team as a code owner July 23, 2023 16:52
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Jul 23, 2023
raise "Adjustable does not match line item" unless line_item == inventory_unit.line_item

-weighted_line_item_amount(line_item)
def compute_amount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute_amount is a public method. We have two ways of handling the change of the signature of a public method:

  1. Rename the method and deprecate compute_amount, delegating its usage to the new method.
  2. Keep compute_amount with the same signature but make the argument optional and deprecate its usage.

I think it works both ways, up to you!

@kennyadsl kennyadsl changed the title no need to pass line_item when a has_one will doin Spree::UnitCancel Stop passing line_item to compute unit cancelation adjustment's amount Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants