#40 - ignore non zero included price quantities#41
Conversation
| .billing_subscriptions | ||
| .active | ||
| .flat_map(&:included_prices) | ||
| .select{ |included_price| included_price.quantity && included_price.quantity > 0 } |
There was a problem hiding this comment.
I would have added a scope, but I am worried about repos like CF that have already cloned the starter repo. I.e. if I were to deploy a new scope, and upgrade CF, everything would break because we override the IncludedPrice model, and there would be no scope definition in there.
|
|
||
| def current_products | ||
| products = parent.team.billing_subscriptions.active.map(&:included_prices).flatten.map(&:price).map(&:product) | ||
| products = non_zero_included_prices.map(&:price).compact.map(&:product).compact |
There was a problem hiding this comment.
I added these compacts to prevent breakages in the event of a dev or someone removing a product or price from the products.yml
| .billing_subscriptions | ||
| .active | ||
| .flat_map(&:included_prices) | ||
| .select { |included_price| included_price.quantity && included_price.quantity > 0 } |
There was a problem hiding this comment.
I would have added a scope, but I am worried about repos like CF that have already cloned the starter repo. I.e. if I were to deploy a new scope, and upgrade CF, everything would break because we override the IncludedPrice model, and there would be no scope definition in there.
Would love to add a spec, but it is not possible to test this class in this repo alone. I decided to run some local tests in the CF repo to make sure this change did as it is supposed to.
closes #40