Sha256: 87575475bd82ade316464ee2e3b7f3461ff3640b42dd80e0d9c67b4efd5535bf

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe Spree::ReimbursementTaxCalculator, type: :model do

  let!(:tax_rate) { nil }

  let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
  let(:return_item) { reimbursement.return_items.first }
  let(:line_item) { return_item.inventory_unit.line_item }

  subject do
    Spree::ReimbursementTaxCalculator.call(reimbursement)
  end

  context 'without taxes' do
    let!(:tax_rate) { nil }

    it 'leaves the return items additional_tax_total and included_tax_total at zero' do
      subject

      expect(return_item.additional_tax_total).to eq 0
      expect(return_item.included_tax_total).to eq 0
    end
  end

  context 'with additional tax' do
    let!(:tax_rate) do
      create :tax_rate,
             name: "Sales Tax",
             amount: 0.10,
             included_in_price: false,
             tax_category: create(:tax_category),
             zone: create(:zone_with_country, default_tax: true)
    end

    it 'sets additional_tax_total on the return items' do
      subject
      return_item.reload

      expect(return_item.additional_tax_total).to be > 0
      expect(return_item.additional_tax_total).to eq line_item.additional_tax_total
    end
  end

  context 'with included tax' do
    let!(:tax_rate) do
      create :tax_rate,
             name: "VAT Tax",
             amount: 0.10,
             included_in_price: true,
             tax_category: create(:tax_category),
             zone: create(:zone_with_country, default_tax: true)
    end

    it 'sets included_tax_total on the return items' do
      subject
      return_item.reload

      expect(return_item.included_tax_total).to be > 0
      expect(return_item.included_tax_total).to eq line_item.included_tax_total
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_core-3.3.0.rc1 spec/models/spree/reimbursement_tax_calculator_spec.rb
spree_core-3.2.1 spec/models/spree/reimbursement_tax_calculator_spec.rb
spree_core-3.2.0 spec/models/spree/reimbursement_tax_calculator_spec.rb
spree_core-3.2.0.rc3 spec/models/spree/reimbursement_tax_calculator_spec.rb
spree_core-3.2.0.rc2 spec/models/spree/reimbursement_tax_calculator_spec.rb
spree_core-3.2.0.rc1 spec/models/spree/reimbursement_tax_calculator_spec.rb