{"action":"created","comment":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/comments/54549883","id":54549883,"diff_hunk":"@@ -1,46 +1,56 @@\n module Spree\n   class ShippingRate < Spree::Base\n+    attr_writer :order\n+\n     belongs_to :shipment, class_name: 'Spree::Shipment'\n     belongs_to :shipping_method, -> { with_deleted }, class_name: 'Spree::ShippingMethod', inverse_of: :shipping_rates\n-    belongs_to :tax_rate, -> { with_deleted }, class_name: 'Spree::TaxRate'\n \n-    delegate :order, :currency, to: :shipment\n-    delegate :name, to: :shipping_method\n+    has_many :taxes,\n+             class_name: \"Spree::ShippingRateTax\",\n+             foreign_key: \"shipping_rate_id\",\n+             dependent: :destroy\n+\n+    delegate :currency, to: :shipment\n+    delegate :order, to: :shipment, prefix: true\n+    delegate :name, :tax_category, to: :shipping_method\n     delegate :code, to: :shipping_method, prefix: true\n+    alias_attribute :amount, :cost\n \n-    def display_base_price\n-      Spree::Money.new(cost, currency: currency)\n-    end\n+    extend DisplayMoney\n+    money_methods :amount\n+    alias_method :discounted_amount, :amount\n \n-    def calculate_tax_amount\n-      tax_rate.calculator.compute_shipping_rate(self)\n+    def order\n+      @order || shipment_order\n     end\n \n     def display_price\n-      price = display_base_price.to_s\n-      if tax_rate\n-        tax_amount = calculate_tax_amount\n-        if tax_amount != 0\n-          if tax_rate.included_in_price?\n-            if tax_amount > 0\n-              amount = \"#{display_tax_amount(tax_amount)} #{tax_rate.name}\"\n-              price += \" (#{Spree.t(:incl)} #{amount})\"\n-            else\n-              amount = \"#{display_tax_amount(tax_amount * -1)} #{tax_rate.name}\"\n-              price += \" (#{Spree.t(:excl)} #{amount})\"\n-            end\n-          else\n-            amount = \"#{display_tax_amount(tax_amount)} #{tax_rate.name}\"\n-            price += \" (+ #{amount})\"\n-          end\n-        end\n-      end\n-      price\n+      price = display_amount.to_s\n+\n+      return price if taxes.empty? || amount == 0\n+\n+      tax_explanations = taxes.map(&:label).join(tax_label_separator)\n+\n+      Spree.t :display_price_with_explanations,\n+               scope: 'shipping_rate.display_price',\n+               price: price,\n+               explanations: tax_explanations\n     end\n     alias_method :display_cost, :display_price\n \n-    def display_tax_amount(tax_amount)\n-      Spree::Money.new(tax_amount, currency: currency)\n+    def pre_tax_amount\n+      default_vat_amount_sum = Spree::TaxRate.","path":"core/app/models/spree/shipping_rate.rb","position":71,"original_position":71,"commit_id":"e101dd5ef79aa3a1abdaffe19fca2d828ee7a439","original_commit_id":"e101dd5ef79aa3a1abdaffe19fca2d828ee7a439","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},"body":"Here we go https://github.com/solidusio/solidus/pull/941","created_at":"2016-03-01T10:43:52Z","updated_at":"2016-03-01T10:43:52Z","html_url":"https://github.com/solidusio/solidus/pull/904#discussion_r54549883","pull_request_url":"https://api.github.com/repos/solidusio/solidus/pulls/904","_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments/54549883"},"html":{"href":"https://github.com/solidusio/solidus/pull/904#discussion_r54549883"},"pull_request":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/904"}}},"pull_request":{"url":"https://api.github.com/repos/solidusio/solidus/pulls/904","id":60583425,"html_url":"https://github.com/solidusio/solidus/pull/904","diff_url":"https://github.com/solidusio/solidus/pull/904.diff","patch_url":"https://github.com/solidusio/solidus/pull/904.patch","issue_url":"https://api.github.com/repos/solidusio/solidus/issues/904","number":904,"state":"open","locked":false,"title":"Add Spree::ShippingRateTax model","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},"body":"This is the minimal thing required to correctly display shipping rates\r\nwithout having to recalculate all the taxes every time we display a tax\r\nrate's price.\r\n\r\n","created_at":"2016-02-24T21:41:23Z","updated_at":"2016-03-01T10:43:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8520e3a060781d541d7eb965bba05d7e4ebaf5e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/solidusio/solidus/pulls/904/commits","review_comments_url":"https://api.github.com/repos/solidusio/solidus/pulls/904/comments","review_comment_url":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solidusio/solidus/issues/904/comments","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/e101dd5ef79aa3a1abdaffe19fca2d828ee7a439","head":{"label":"magiclabs:tax-estimations-on-shipping-rates","ref":"tax-estimations-on-shipping-rates","sha":"e101dd5ef79aa3a1abdaffe19fca2d828ee7a439","user":{"login":"magiclabs","id":714995,"avatar_url":"https://avatars.githubusercontent.com/u/714995?v=3","gravatar_id":"","url":"https://api.github.com/users/magiclabs","html_url":"https://github.com/magiclabs","followers_url":"https://api.github.com/users/magiclabs/followers","following_url":"https://api.github.com/users/magiclabs/following{/other_user}","gists_url":"https://api.github.com/users/magiclabs/gists{/gist_id}","starred_url":"https://api.github.com/users/magiclabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magiclabs/subscriptions","organizations_url":"https://api.github.com/users/magiclabs/orgs","repos_url":"https://api.github.com/users/magiclabs/repos","events_url":"https://api.github.com/users/magiclabs/events{/privacy}","received_events_url":"https://api.github.com/users/magiclabs/received_events","type":"Organization","site_admin":false},"repo":{"id":45269516,"name":"solidus","full_name":"magiclabs/solidus","owner":{"login":"magiclabs","id":714995,"avatar_url":"https://avatars.githubusercontent.com/u/714995?v=3","gravatar_id":"","url":"https://api.github.com/users/magiclabs","html_url":"https://github.com/magiclabs","followers_url":"https://api.github.com/users/magiclabs/followers","following_url":"https://api.github.com/users/magiclabs/following{/other_user}","gists_url":"https://api.github.com/users/magiclabs/gists{/gist_id}","starred_url":"https://api.github.com/users/magiclabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magiclabs/subscriptions","organizations_url":"https://api.github.com/users/magiclabs/orgs","repos_url":"https://api.github.com/users/magiclabs/repos","events_url":"https://api.github.com/users/magiclabs/events{/privacy}","received_events_url":"https://api.github.com/users/magiclabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/magiclabs/solidus","description":"Solidus, Rails eCommerce System","fork":true,"url":"https://api.github.com/repos/magiclabs/solidus","forks_url":"https://api.github.com/repos/magiclabs/solidus/forks","keys_url":"https://api.github.com/repos/magiclabs/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magiclabs/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magiclabs/solidus/teams","hooks_url":"https://api.github.com/repos/magiclabs/solidus/hooks","issue_events_url":"https://api.github.com/repos/magiclabs/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/magiclabs/solidus/events","assignees_url":"https://api.github.com/repos/magiclabs/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/magiclabs/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/magiclabs/solidus/tags","blobs_url":"https://api.github.com/repos/magiclabs/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magiclabs/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magiclabs/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/magiclabs/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magiclabs/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/magiclabs/solidus/languages","stargazers_url":"https://api.github.com/repos/magiclabs/solidus/stargazers","contributors_url":"https://api.github.com/repos/magiclabs/solidus/contributors","subscribers_url":"https://api.github.com/repos/magiclabs/solidus/subscribers","subscription_url":"https://api.github.com/repos/magiclabs/solidus/subscription","commits_url":"https://api.github.com/repos/magiclabs/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/magiclabs/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/magiclabs/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/magiclabs/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/magiclabs/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/magiclabs/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magiclabs/solidus/merges","archive_url":"https://api.github.com/repos/magiclabs/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magiclabs/solidus/downloads","issues_url":"https://api.github.com/repos/magiclabs/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/magiclabs/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/magiclabs/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/magiclabs/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magiclabs/solidus/labels{/name}","releases_url":"https://api.github.com/repos/magiclabs/solidus/releases{/id}","deployments_url":"https://api.github.com/repos/magiclabs/solidus/deployments","created_at":"2015-10-30T18:34:37Z","updated_at":"2016-01-21T21:16:31Z","pushed_at":"2016-03-01T10:42:12Z","git_url":"git://github.com/magiclabs/solidus.git","ssh_url":"git@github.com:magiclabs/solidus.git","clone_url":"https://github.com/magiclabs/solidus.git","svn_url":"https://github.com/magiclabs/solidus","homepage":"http://solidus.io/","size":65816,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"solidusio:master","ref":"master","sha":"9bedd546f1d0b94a65f9d96636a28f32dca1a726","user":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"repo":{"id":30985840,"name":"solidus","full_name":"solidusio/solidus","owner":{"login":"solidusio","id":11045486,"avatar_url":"https://avatars.githubusercontent.com/u/11045486?v=3","gravatar_id":"","url":"https://api.github.com/users/solidusio","html_url":"https://github.com/solidusio","followers_url":"https://api.github.com/users/solidusio/followers","following_url":"https://api.github.com/users/solidusio/following{/other_user}","gists_url":"https://api.github.com/users/solidusio/gists{/gist_id}","starred_url":"https://api.github.com/users/solidusio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solidusio/subscriptions","organizations_url":"https://api.github.com/users/solidusio/orgs","repos_url":"https://api.github.com/users/solidusio/repos","events_url":"https://api.github.com/users/solidusio/events{/privacy}","received_events_url":"https://api.github.com/users/solidusio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solidusio/solidus","description":"Solidus, Rails eCommerce System","fork":false,"url":"https://api.github.com/repos/solidusio/solidus","forks_url":"https://api.github.com/repos/solidusio/solidus/forks","keys_url":"https://api.github.com/repos/solidusio/solidus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solidusio/solidus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solidusio/solidus/teams","hooks_url":"https://api.github.com/repos/solidusio/solidus/hooks","issue_events_url":"https://api.github.com/repos/solidusio/solidus/issues/events{/number}","events_url":"https://api.github.com/repos/solidusio/solidus/events","assignees_url":"https://api.github.com/repos/solidusio/solidus/assignees{/user}","branches_url":"https://api.github.com/repos/solidusio/solidus/branches{/branch}","tags_url":"https://api.github.com/repos/solidusio/solidus/tags","blobs_url":"https://api.github.com/repos/solidusio/solidus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solidusio/solidus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solidusio/solidus/git/refs{/sha}","trees_url":"https://api.github.com/repos/solidusio/solidus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solidusio/solidus/statuses/{sha}","languages_url":"https://api.github.com/repos/solidusio/solidus/languages","stargazers_url":"https://api.github.com/repos/solidusio/solidus/stargazers","contributors_url":"https://api.github.com/repos/solidusio/solidus/contributors","subscribers_url":"https://api.github.com/repos/solidusio/solidus/subscribers","subscription_url":"https://api.github.com/repos/solidusio/solidus/subscription","commits_url":"https://api.github.com/repos/solidusio/solidus/commits{/sha}","git_commits_url":"https://api.github.com/repos/solidusio/solidus/git/commits{/sha}","comments_url":"https://api.github.com/repos/solidusio/solidus/comments{/number}","issue_comment_url":"https://api.github.com/repos/solidusio/solidus/issues/comments{/number}","contents_url":"https://api.github.com/repos/solidusio/solidus/contents/{+path}","compare_url":"https://api.github.com/repos/solidusio/solidus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solidusio/solidus/merges","archive_url":"https://api.github.com/repos/solidusio/solidus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solidusio/solidus/downloads","issues_url":"https://api.github.com/repos/solidusio/solidus/issues{/number}","pulls_url":"https://api.github.com/repos/solidusio/solidus/pulls{/number}","milestones_url":"https://api.github.com/repos/solidusio/solidus/milestones{/number}","notifications_url":"https://api.github.com/repos/solidusio/solidus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solidusio/solidus/labels{/name}","releases_url":"https://api.github.com/repos/solidusio/solidus/releases{/id}","deployments_url":"https://api.github.com/repos/solidusio/solidus/deployments","created_at":"2015-02-18T20:41:58Z","updated_at":"2016-02-29T17:09:27Z","pushed_at":"2016-03-01T10:42:13Z","git_url":"git://github.com/solidusio/solidus.git","ssh_url":"git@github.com:solidusio/solidus.git","clone_url":"https://github.com/solidusio/solidus.git","svn_url":"https://github.com/solidusio/solidus","homepage":"http://solidus.io/","size":67666,"stargazers_count":832,"watchers_count":832,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":212,"mirror_url":null,"open_issues_count":112,"forks":212,"open_issues":112,"watchers":832,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/904"},"html":{"href":"https://github.com/solidusio/solidus/pull/904"},"issue":{"href":"https://api.github.com/repos/solidusio/solidus/issues/904"},"comments":{"href":"https://api.github.com/repos/solidusio/solidus/issues/904/comments"},"review_comments":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/904/comments"},"review_comment":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solidusio/solidus/pulls/904/commits"},"statuses":{"href":"https://api.github.com/repos/solidusio/solidus/statuses/e101dd5ef79aa3a1abdaffe19fca2d828ee7a439"}}}}