diff --git a/resources/tax_type/ca_ab_gst.json b/resources/tax_type/ca_ab_gst.json new file mode 100644 index 0000000..6c6d290 --- /dev/null +++ b/resources/tax_type/ca_ab_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Alberta", + "generic_label": "GST", + "zone": "ca_ab", + "tag": "CA", + "rates": [ + { + "id": "ca_ab_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_ab_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_bc_gst.json b/resources/tax_type/ca_bc_gst.json new file mode 100644 index 0000000..cf45c1f --- /dev/null +++ b/resources/tax_type/ca_bc_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - British Columbia", + "generic_label": "GST", + "zone": "ca_bc", + "tag": "CA", + "rates": [ + { + "id": "ca_bc_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_bc_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_bc_pst.json b/resources/tax_type/ca_bc_pst.json new file mode 100644 index 0000000..105011b --- /dev/null +++ b/resources/tax_type/ca_bc_pst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - British Columbia", + "generic_label": "PST", + "zone": "ca_bc", + "tag": "CA", + "rates": [ + { + "id": "ca_bc_pst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_bc_pst_standard_2013", + "amount": 0.07, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_mb_gst.json b/resources/tax_type/ca_mb_gst.json new file mode 100644 index 0000000..d2ce5d0 --- /dev/null +++ b/resources/tax_type/ca_mb_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Manitoba", + "generic_label": "GST", + "zone": "ca_mb", + "tag": "CA", + "rates": [ + { + "id": "ca_mb_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_mb_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_mb_pst.json b/resources/tax_type/ca_mb_pst.json new file mode 100644 index 0000000..a568f4c --- /dev/null +++ b/resources/tax_type/ca_mb_pst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Manitoba", + "generic_label": "PST", + "zone": "ca_mb", + "tag": "CA", + "rates": [ + { + "id": "ca_mb_pst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_mb_pst_standard_2013", + "amount": 0.08, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_nb_hst.json b/resources/tax_type/ca_nb_hst.json new file mode 100644 index 0000000..57d8b7f --- /dev/null +++ b/resources/tax_type/ca_nb_hst.json @@ -0,0 +1,21 @@ +{ + "name": "Canada - New Brunswick", + "generic_label": "HST", + "zone": "ca_nb", + "tag": "CA", + "compound": false, + "rates": [ + { + "id": "ca_nb_hst_standard", + "name": "hst", + "default": true, + "amounts": [ + { + "id": "ca_nb_hst_standard_2013", + "amount": 0.13, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_nl_hst.json b/resources/tax_type/ca_nl_hst.json new file mode 100644 index 0000000..2369357 --- /dev/null +++ b/resources/tax_type/ca_nl_hst.json @@ -0,0 +1,26 @@ +{ + "name": "Canada - Newfoundland and Labrador", + "generic_label": "HST", + "zone": "ca_nl", + "tag": "CA", + "rates": [ + { + "id": "ca_nl_hst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_nl_hst_standard_2013", + "amount": 0.13, + "start_date": "2013-04-01", + "end_date": "2015-12-31" + }, + { + "id": "ca_nl_hst_standard_2016", + "amount": 0.15, + "start_date": "2016-01-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_ns_hst.json b/resources/tax_type/ca_ns_hst.json new file mode 100644 index 0000000..c50714b --- /dev/null +++ b/resources/tax_type/ca_ns_hst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Nova Scotia", + "generic_label": "HST", + "zone": "ca_ns", + "tag": "CA", + "rates": [ + { + "id": "ca_ns_hst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_ns_hst_standard_2013", + "amount": 0.15, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_nt_hst.json b/resources/tax_type/ca_nt_hst.json new file mode 100644 index 0000000..d8dd5f2 --- /dev/null +++ b/resources/tax_type/ca_nt_hst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Northwest Territories", + "generic_label": "GST", + "zone": "ca_nt", + "tag": "CA", + "rates": [ + { + "id": "ca_nt_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_nt_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_nu_gst.json b/resources/tax_type/ca_nu_gst.json new file mode 100644 index 0000000..a8d72cf --- /dev/null +++ b/resources/tax_type/ca_nu_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Nunavut", + "generic_label": "GST", + "zone": "ca_nu", + "tag": "CA", + "rates": [ + { + "id": "ca_nu_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_nu_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_on_hst.json b/resources/tax_type/ca_on_hst.json new file mode 100644 index 0000000..d8f2d28 --- /dev/null +++ b/resources/tax_type/ca_on_hst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Ontario", + "generic_label": "HST", + "zone": "ca_on", + "tag": "CA", + "rates": [ + { + "id": "ca_on_hst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_on_hst_standard_2013", + "amount": 0.13, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_pe_hst.json b/resources/tax_type/ca_pe_hst.json new file mode 100644 index 0000000..ffd73d4 --- /dev/null +++ b/resources/tax_type/ca_pe_hst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Prince Edward Island", + "generic_label": "HST", + "zone": "ca_pe", + "tag": "CA", + "rates": [ + { + "id": "ca_pe_hst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_pe_hst_standard_2013", + "amount": 0.14, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_qc_gst.json b/resources/tax_type/ca_qc_gst.json new file mode 100644 index 0000000..359fdf2 --- /dev/null +++ b/resources/tax_type/ca_qc_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Quebec", + "generic_label": "GST", + "zone": "ca_qc", + "tag": "CA", + "rates": [ + { + "id": "ca_qc_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_qc_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_qc_qst.json b/resources/tax_type/ca_qc_qst.json new file mode 100644 index 0000000..9acf684 --- /dev/null +++ b/resources/tax_type/ca_qc_qst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Quebec", + "generic_label": "QST", + "zone": "ca_qc", + "tag": "CA", + "rates": [ + { + "id": "ca_qc_qst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_qc_qst_standard_2013", + "amount": 0.09975, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_sk_gst.json b/resources/tax_type/ca_sk_gst.json new file mode 100644 index 0000000..820d870 --- /dev/null +++ b/resources/tax_type/ca_sk_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Saskatchewan", + "generic_label": "GST", + "zone": "ca_sk", + "tag": "CA", + "rates": [ + { + "id": "ca_sk_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_sk_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_sk_pst.json b/resources/tax_type/ca_sk_pst.json new file mode 100644 index 0000000..ef692ce --- /dev/null +++ b/resources/tax_type/ca_sk_pst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Saskatchewan", + "generic_label": "PST", + "zone": "ca_sk", + "tag": "CA", + "rates": [ + { + "id": "ca_sk_pst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_sk_pst_standard_2006", + "amount": 0.05, + "start_date": "2006-10-28" + } + ] + } + ] +} diff --git a/resources/tax_type/ca_yt_gst.json b/resources/tax_type/ca_yt_gst.json new file mode 100644 index 0000000..c8d9657 --- /dev/null +++ b/resources/tax_type/ca_yt_gst.json @@ -0,0 +1,20 @@ +{ + "name": "Canada - Yukon", + "generic_label": "GST", + "zone": "ca_yt", + "tag": "CA", + "rates": [ + { + "id": "ca_yt_gst_standard", + "name": "Standard", + "default": true, + "amounts": [ + { + "id": "ca_yt_gst_standard_2013", + "amount": 0.05, + "start_date": "2013-04-01" + } + ] + } + ] +} diff --git a/resources/zone/ca_ab.json b/resources/zone/ca_ab.json new file mode 100644 index 0000000..7cf6069 --- /dev/null +++ b/resources/zone/ca_ab.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Alberta (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_ab", + "name": "Canada - Alberta", + "country_code": "CA", + "administrative_area": "CA-AB" + } + ] +} diff --git a/resources/zone/ca_bc.json b/resources/zone/ca_bc.json new file mode 100644 index 0000000..5e1d82b --- /dev/null +++ b/resources/zone/ca_bc.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - British Columbia (HST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_bc", + "name": "Canada - British Columbia", + "country_code": "CA", + "administrative_area": "CA-BC" + } + ] +} diff --git a/resources/zone/ca_mb.json b/resources/zone/ca_mb.json new file mode 100644 index 0000000..2222c01 --- /dev/null +++ b/resources/zone/ca_mb.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Manitoba (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_mb", + "name": "Canada - Manitoba", + "country_code": "CA", + "administrative_area": "CA-MB" + } + ] +} diff --git a/resources/zone/ca_nb.json b/resources/zone/ca_nb.json new file mode 100644 index 0000000..b6df95d --- /dev/null +++ b/resources/zone/ca_nb.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - New Brunswick (HST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_nb", + "name": "Canada - New Brunswick", + "country_code": "CA", + "administrative_area": "CA-NB" + } + ] +} diff --git a/resources/zone/ca_nl.json b/resources/zone/ca_nl.json new file mode 100644 index 0000000..575a58c --- /dev/null +++ b/resources/zone/ca_nl.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Newfoundland and Labrador (HST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_nl", + "name": "Canada - Newfoundland and Labrador", + "country_code": "CA", + "administrative_area": "CA-NL" + } + ] +} diff --git a/resources/zone/ca_ns.json b/resources/zone/ca_ns.json new file mode 100644 index 0000000..2e01ccd --- /dev/null +++ b/resources/zone/ca_ns.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Nova Scotia (HST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_ns", + "name": "Canada - Nova Scotia", + "country_code": "CA", + "administrative_area": "CA-NS" + } + ] +} diff --git a/resources/zone/ca_nt.json b/resources/zone/ca_nt.json new file mode 100644 index 0000000..2eb8f26 --- /dev/null +++ b/resources/zone/ca_nt.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Northwest Territories (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_nt", + "name": "Canada - Northwest Territories", + "country_code": "CA", + "administrative_area": "CA-NT" + } + ] +} diff --git a/resources/zone/ca_nu.json b/resources/zone/ca_nu.json new file mode 100644 index 0000000..d52ae3e --- /dev/null +++ b/resources/zone/ca_nu.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Nunavut (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_ns", + "name": "Canada - Nunavut", + "country_code": "CA", + "administrative_area": "CA-NU" + } + ] +} diff --git a/resources/zone/ca_on.json b/resources/zone/ca_on.json new file mode 100644 index 0000000..188bec5 --- /dev/null +++ b/resources/zone/ca_on.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Ontario (HST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_on", + "name": "Canada - Ontario", + "country_code": "CA", + "administrative_area": "CA-ON" + } + ] +} diff --git a/resources/zone/ca_pe.json b/resources/zone/ca_pe.json new file mode 100644 index 0000000..6006ee0 --- /dev/null +++ b/resources/zone/ca_pe.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Prince Edward Island (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_pe", + "name": "Canada - Prince Edward Island", + "country_code": "CA", + "administrative_area": "CA-PE" + } + ] +} diff --git a/resources/zone/ca_qc.json b/resources/zone/ca_qc.json new file mode 100644 index 0000000..ca4dc6b --- /dev/null +++ b/resources/zone/ca_qc.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Quebec (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_qc", + "name": "Canada - Quebec", + "country_code": "CA", + "administrative_area": "CA-QC" + } + ] +} diff --git a/resources/zone/ca_sk.json b/resources/zone/ca_sk.json new file mode 100644 index 0000000..0723fbe --- /dev/null +++ b/resources/zone/ca_sk.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Saskatchewan (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_sk", + "name": "Canada - Saskatchewan", + "country_code": "CA", + "administrative_area": "CA-SK" + } + ] +} diff --git a/resources/zone/ca_yt.json b/resources/zone/ca_yt.json new file mode 100644 index 0000000..9d8c232 --- /dev/null +++ b/resources/zone/ca_yt.json @@ -0,0 +1,13 @@ +{ + "name": "Canada - Yukon (GST)", + "scope": "tax", + "members": [ + { + "type": "country", + "id": "ca_yt", + "name": "Canada - Yukon", + "country_code": "CA", + "administrative_area": "CA-YT" + } + ] +} diff --git a/tests/Resolver/TaxType/CanadaTaxTypeResolverTest.php b/tests/Resolver/TaxType/CanadaTaxTypeResolverTest.php index 94d2fdb..65dec38 100644 --- a/tests/Resolver/TaxType/CanadaTaxTypeResolverTest.php +++ b/tests/Resolver/TaxType/CanadaTaxTypeResolverTest.php @@ -19,18 +19,18 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase */ protected $taxTypes = [ 'ca_on_hst' => [ - 'name' => 'Ontario HST', + 'name' => 'Ontario HST', 'generic_label' => 'hst', - 'tag' => 'CA', - 'zone' => 'ca_on_hst', - 'rates' => [ + 'tag' => 'CA', + 'zone' => 'ca_on_hst', + 'rates' => [ [ - 'id' => 'ca_on_hst', - 'name' => 'Ontario HST', + 'id' => 'ca_on_hst', + 'name' => 'Ontario HST', 'amounts' => [ [ - 'id' => 'ca_on_hst_13', - 'amount' => 0.13, + 'id' => 'ca_on_hst_13', + 'amount' => 0.13, 'start_date' => '2010-07-01', ], ], @@ -38,24 +38,52 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase ], ], 'ca_ns_hst' => [ - 'name' => 'Nova Scotia HST', + 'name' => 'Nova Scotia HST', 'generic_label' => 'hst', - 'tag' => 'CA', - 'zone' => 'ca_ns_hst', - 'rates' => [ + 'tag' => 'CA', + 'zone' => 'ca_ns_hst', + 'rates' => [ [ - 'id' => 'ca_ns_hst', - 'name' => 'Nova Scotia HST', + 'id' => 'ca_ns_hst', + 'name' => 'Nova Scotia HST', 'amounts' => [ [ - 'id' => 'ca_ns_hst_15', - 'amount' => 0.15, + 'id' => 'ca_ns_hst_15', + 'amount' => 0.15, 'start_date' => '2010-07-01', ], ], ], ], ], + "ca_mb_gst" => [ + "name" => "Manitoba GST", + "generic_label" => "gst", + "tag" => "CA", + "zone" => "ca_mb", + "rates" => [ + [ + "id" => "ca_mb_gst", + "name" => "Manitoba GST", + "default" => true, + "amounts" => [["id" => "ca_mb_gst_2013", "amount" => 0.05]] + ] + ] + ], + "ca_mb_pst" => [ + "name" => "Manitoba PST", + "generic_label" => "pst", + "tag" => "CA", + "zone" => "ca_mb", + "rates" => [ + [ + "id" => "ca_mb_pst", + "name" => "Manitoba PST", + "default" => true, + "amounts" => [["id" => "ca_mb_pst_2013", "amount" => 0.08]] + ] + ] + ] ]; /** @@ -65,7 +93,7 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase */ protected $zones = [ 'ca_on_hst' => [ - 'name' => 'Ontario (HST)', + 'name' => 'Ontario (HST)', 'members' => [ [ 'type' => 'country', @@ -77,7 +105,7 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase ], ], 'ca_ns_hst' => [ - 'name' => 'Nova Scotia (HST)', + 'name' => 'Nova Scotia (HST)', 'members' => [ [ 'type' => 'country', @@ -88,6 +116,18 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase ], ], ], + 'ca_mb' => [ + 'name' => 'Manitoba Tax', + 'members' => [ + [ + 'type' => 'country', + 'id' => '1', + 'name' => 'Canada - Manitoba', + 'country_code' => 'CA', + 'administrative_area' => 'CA-MB', + ], + ], + ], ]; /** @@ -97,7 +137,7 @@ class CanadaTaxTypeResolverTest extends \PHPUnit_Framework_TestCase */ public function testConstructor() { - $root = vfsStream::setup('resources'); + $root = vfsStream::setup('resources'); $directory = vfsStream::newDirectory('tax_type')->at($root); foreach ($this->taxTypes as $id => $definition) { $filename = $id . '.json'; @@ -110,7 +150,7 @@ public function testConstructor() } $taxTypeRepository = new TaxTypeRepository('vfs://resources/'); - $resolver = new CanadaTaxTypeResolver($taxTypeRepository); + $resolver = new CanadaTaxTypeResolver($taxTypeRepository); $this->assertSame($taxTypeRepository, $this->getObjectAttribute($resolver, 'taxTypeRepository')); return $resolver; @@ -129,7 +169,7 @@ public function testConstructor() */ public function testResolver($resolver) { - $taxable = $this + $taxable = $this ->getMockBuilder('CommerceGuys\Tax\TaxableInterface') ->getMock(); $usAddress = $this @@ -160,26 +200,43 @@ public function testResolver($resolver) // Nova Scotia store, Ontario customer. $context = $this->getContext($ontarioAddress, $novaScotiaAddress); $results = $resolver->resolve($taxable, $context); - $result = reset($results); + $result = reset($results); $this->assertInstanceOf('CommerceGuys\Tax\Model\TaxType', $result); $this->assertEquals('ca_on_hst', $result->getId()); // Ontario store, Nova Scotia customer. $context = $this->getContext($novaScotiaAddress, $ontarioAddress); $results = $resolver->resolve($taxable, $context); - $result = reset($results); + $result = reset($results); $this->assertInstanceOf('CommerceGuys\Tax\Model\TaxType', $result); $this->assertEquals('ca_ns_hst', $result->getId()); // Ontario store, US customer. $context = $this->getContext($usAddress, $ontarioAddress); - $result = $resolver->resolve($taxable, $context); + $result = $resolver->resolve($taxable, $context); $this->assertEquals([], $result); // US store, Ontario customer. $context = $this->getContext($ontarioAddress, $usAddress); - $result = $resolver->resolve($taxable, $context); + $result = $resolver->resolve($taxable, $context); $this->assertEquals([], $result); + + // Ontario store, Manitoba customer. + $context = $this->getContext($manitobaAddress, $ontarioAddress); + $results = $resolver->resolve($taxable, $context); + reset($results); + $this->assertCount(2, $results); + $ids = []; + /** @var TaxType $result */ + foreach ($results as $result) { + $this->assertInstanceOf('CommerceGuys\Tax\Model\TaxType', $result); + $ids[] = $result->getId(); + } + + foreach (["ca_mb_gst", "ca_mb_pst"] as $id) { + $this->assertContains($id, $ids); + } + } /**