Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Display time promotion on order page #409
Display time promotion on order page #409
Changes from all commits
929f6f4
51340bf
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Just to verbalise my thoughts: I wonder if the information about the type of the discount is needed here. I don't know for now, but I think I would transfer this information through the
PercentageDiscount
class. That way we don't have to change method's interface. And it would be simple to add some default (such asGENERAL_DISCOUNT
). What do you think @marlena-b?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.
That was my first thought as well. The main problem is that once we add it to
PercentageDiscount
class it no longer is a value object. There can be only one discount of a specific type assigned to the order so type is actually an identifier of a discount.This also leads to problems like what type should we use if we want to add two discounts? Or what type should be used for the initial accumulator in the inject here:
discounts.values.inject(Discounts::NoPercentageDiscount.new, :add).apply(catalog_price_for_single)
? These problems made me feel it is not a right design to add it to 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.
The type would still be a type. If only one discount of specifiic type can be assigned to an order this is just a rule that can be exectued within the order class. But I wouldn't say that extending
PercentageDiscount
by type would make it an entity.I assume that would still be true:
I'll refer to the second part of your reply later :)
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.
Ok, I can give it another shot 👍 I will merge this PR and fix it in another one.