Module: Easyship::SalesTax::Formula

Defined in:
lib/easyship/sales_tax/calculator/formula.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

DOMESTIC =
{
  'AU' => {
    sales_tax_website_name: 'GST',
    sales_tax: { '_ALL': build_fee_struct(0.1, 0, 0.1, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'GB' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.2, 0, 0.2, 0.2) }, # TBC
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'CA' => {
    sales_tax_website_name: 'Taxes',
    sales_tax: {
      'AB' => build_fee_struct(0.05, 0, 0.05, 0.05), # Alberta
      'BC' => build_fee_struct(0.05, 0, 0.05, 0.05), # British Columbia
      'MB' => build_fee_struct(0.05, 0, 0.05, 0.05), # Manitoba
      'NB' => build_fee_struct(0.15, 0, 0.15, 0.15), # New Brunswick
      'NL' => build_fee_struct(0.15, 0, 0.15, 0.15), # Newfoundland and Labrador
      'NT' => build_fee_struct(0.05, 0, 0.05, 0.05), # Northwest Territories
      'NS' => build_fee_struct(0.15, 0, 0.15, 0.15), # Nova Scotia
      'NU' => build_fee_struct(0.05, 0, 0.05, 0.05), # Nunavut
      'ON' => build_fee_struct(0.13, 0, 0.13, 0.13), # Ontario
      'PE' => build_fee_struct(0.15, 0, 0.15, 0.15), # Prince Edward Island
      'QC' => build_fee_struct(0.05, 0, 0.05, 0.05), # Quebec
      'SK' => build_fee_struct(0.05, 0, 0.05, 0.05), # Saskatchewan
      'YT' => build_fee_struct(0.05, 0, 0.05, 0.05), # Yukon
    },
    provincial_sales_taxes: {
      'AB' => no_taxes, # Alberta
      'BC' => no_taxes, # British Columbia
      'MB' => no_taxes, # Manitoba
      'NB' => no_taxes, # New Brunswick
      'NL' => no_taxes, # Newfoundland and Labrador
      'NT' => no_taxes, # Northwest Territories
      'NS' => no_taxes, # Nova Scotia
      'NU' => no_taxes, # Nunavut
      'ON' => no_taxes, # Ontario
      'PE' => no_taxes, # Prince Edward Island
      'QC' => build_fee_struct(0.09975, 0, 0.09975, 0.09975), # Quebec
      'SK' => no_taxes, # Saskatchewan
      'YT' => no_taxes, # Yukon
    }
  },
  'SG' => {
    sales_tax_website_name: 'GST',
    sales_tax: { '_ALL': build_fee_struct(0.07, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'HK' => {
    sales_tax_website_name: nil,
    sales_tax: { '_ALL': no_taxes },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'NL' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.21, 0, 0.21, 0.21) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'US' => {
    sales_tax_website_name: nil,
    sales_tax: { '_ALL': no_taxes },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'DE' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.19, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'FR' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.2, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'IT' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.22, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'BE' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.21, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'ES' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.21, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'PT' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.23, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'AT' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.2, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'IE' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.23, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'DK' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.25, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'SE' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.25, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'FI' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.24, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'NO' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.25, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'CH' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.077, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'MY' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.1, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'JP' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.1, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'NZ' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.15, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'IN' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.15, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'KR' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.1, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  },
  'MX' => {
    sales_tax_website_name: 'VAT',
    sales_tax: { '_ALL': build_fee_struct(0.16, 0, 0, 0) },
    provincial_sales_taxes: { '_ALL': no_taxes }
  }
}.freeze

Class Method Summary collapse

Class Method Details

.build_fee_struct(shipment_charge_total, insurance_fee, pickup_fee, residential_surcharge) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/easyship/sales_tax/calculator/formula.rb', line 6

def build_fee_struct(shipment_charge_total, insurance_fee, pickup_fee, residential_surcharge)
  {
    shipment_charge_total: shipment_charge_total,
    insurance_fee: insurance_fee,
    pickup_fee: pickup_fee,
    residential_surcharge: residential_surcharge
  }
end

.no_taxesObject



15
16
17
# File 'lib/easyship/sales_tax/calculator/formula.rb', line 15

def no_taxes
  build_fee_struct(0, 0, 0, 0)
end