{"action":"created","issue":{"url":"https://api.github.com/repos/solidusio/solidus/issues/532","labels_url":"https://api.github.com/repos/solidusio/solidus/issues/532/labels{/name}","comments_url":"https://api.github.com/repos/solidusio/solidus/issues/532/comments","events_url":"https://api.github.com/repos/solidusio/solidus/issues/532/events","html_url":"https://github.com/solidusio/solidus/issues/532","id":118488076,"number":532,"title":"Line item price modifier adjustments","user":{"login":"mamhoff","id":703401,"avatar_url":"https://avatars.githubusercontent.com/u/703401?v=3","gravatar_id":"","url":"https://api.github.com/users/mamhoff","html_url":"https://github.com/mamhoff","followers_url":"https://api.github.com/users/mamhoff/followers","following_url":"https://api.github.com/users/mamhoff/following{/other_user}","gists_url":"https://api.github.com/users/mamhoff/gists{/gist_id}","starred_url":"https://api.github.com/users/mamhoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mamhoff/subscriptions","organizations_url":"https://api.github.com/users/mamhoff/orgs","repos_url":"https://api.github.com/users/mamhoff/repos","events_url":"https://api.github.com/users/mamhoff/events{/privacy}","received_events_url":"https://api.github.com/users/mamhoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-23T22:29:41Z","updated_at":"2015-11-24T23:16:49Z","closed_at":null,"body":"When looking deeply at the line item, I found out that the price of a line item need not be the price of its variant. A number of things can come inbetween: Currencies, Price modifiers from the variant, or hard-setting a line item's price. In a large way, that's also how the test suite is structured: The line item factory makes line items worth 10, while the associated variant is 19.99. \r\n\r\nThat's very flexible, but a little unfortunate for the upcoming [MOSS](https://github.com/spree/spree/issues/6154) refactoring. For MOSS, prices have to change depending on the order's tax address. Previously, we helped ourselves by using the [variant's price as the single source of truth](https://github.com/spree/spree/blob/master/core/app/models/spree/line_item.rb#L55-L57). However, the variant's price is not necessarily the right price for your already price-adjusted line item. \r\n\r\nWhat do you think about the following idea: We introduce *price modifier adjustments*. They can be added to a line item the same way a promotion or tax adjustment is added, and their sum is then added to the line item's price. I'll try to illustrate this in pseudo-ruby: \r\n\r\n``` ruby \r\nclass Adjustment\r\n  scope :price_modifier, -> { where(price_modifier: true) }\r\nend\r\n\r\nclass LineItem \r\n  def price\r\n    super + price_modifier_total\r\n  end\r\nend\r\n```\r\n\r\nVAT rates will have to make price modifications, so they can be the adjustment's source. I think the model would also quite nicely fit the existing, variant-based price modifiers: The source is the variant, and the tax stuff just wouldn't touch those adjustments. \r\n\r\nI hope I've explained myself well here. The nice thing about it would be that we could adjust and *re-adjust* line item prices in a transparent, reproducible way. The not-so-nice-thing is that it would introduce yet another complex moving piece, but if we have to do it, let's at least do it in a way that mirrors other complex moving pieces. \r\n\r\nWhat do you think?\r\n"},"comment":{"url":"https://api.github.com/repos/solidusio/solidus/issues/comments/159436340","html_url":"https://github.com/solidusio/solidus/issues/532#issuecomment-159436340","issue_url":"https://api.github.com/repos/solidusio/solidus/issues/532","id":159436340,"user":{"login":"cbrunsdon","id":279013,"avatar_url":"https://avatars.githubusercontent.com/u/279013?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrunsdon","html_url":"https://github.com/cbrunsdon","followers_url":"https://api.github.com/users/cbrunsdon/followers","following_url":"https://api.github.com/users/cbrunsdon/following{/other_user}","gists_url":"https://api.github.com/users/cbrunsdon/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrunsdon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrunsdon/subscriptions","organizations_url":"https://api.github.com/users/cbrunsdon/orgs","repos_url":"https://api.github.com/users/cbrunsdon/repos","events_url":"https://api.github.com/users/cbrunsdon/events{/privacy}","received_events_url":"https://api.github.com/users/cbrunsdon/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T23:16:49Z","updated_at":"2015-11-24T23:16:49Z","body":"Putting on the variant is almost definitely wrong, and would have a bunch of historical data problems (as it would actually have to be on the Spree::Price and not the variant). We're also hoping to make a large number of changes to allow for more dynamic pricing which wouldn't make sense on the variant.\r\n\r\nPutting the initial_price on line items makes much more sense to me and something I definitely support."}}