diff --git a/src/Classes/Taxes.php b/src/Classes/Taxes.php index a2305fb2e..93f0f804b 100644 --- a/src/Classes/Taxes.php +++ b/src/Classes/Taxes.php @@ -24,6 +24,11 @@ public function setEarnings($earnings) $this->earnings = $earnings; } + public function setHomeLocation($location) + { + $this->home_location = $location; + } + public function setPayPeriods($pay_periods) { $this->pay_periods = $pay_periods; @@ -41,8 +46,7 @@ public function setUser($user) public function setWorkLocation($location) { - $this->latitude = $location[0]; - $this->longitude = $location[1]; + $this->work_location = $location; } public function setYtdEarnings($ytd_earnings) @@ -122,7 +126,16 @@ private function getDate() private function getTaxes() { - $this->taxes = TaxArea::atPoint($this->latitude, $this->longitude) + $this->taxes = TaxArea::where(function ($query) { + $query + ->basedOnHomeLocation() + ->atPoint($this->home_location[0], $this->home_location[1]); + }) + ->orWhere(function ($query) { + $query + ->basedOnWorkLocation() + ->atPoint($this->work_location[0], $this->work_location[1]); + }) ->get() ->pluck('tax'); } diff --git a/src/Models/TaxArea.php b/src/Models/TaxArea.php index 4a76e19bb..702fcf9d4 100755 --- a/src/Models/TaxArea.php +++ b/src/Models/TaxArea.php @@ -6,6 +6,9 @@ class TaxArea extends Model { + const BASED_ON_HOME_LOCATION = 'home'; + const BASED_ON_WORK_LOCATION = 'work'; + protected $table = 'tax_areas'; protected $guarded = []; @@ -28,4 +31,14 @@ public function scopeAtPoint($query, $latitude, $longitude) $query->atPoint($latitude, $longitude); }); } + + public function scopeBasedOnHomeLocation($query) + { + return $query->where('based', TaxArea::BASED_ON_HOME_LOCATION); + } + + public function scopeBasedOnWorkLocation($query) + { + return $query->where('based', TaxArea::BASED_ON_WORK_LOCATION); + } } diff --git a/src/migrations/2018_01_01_000007_add_based_to_tax_areas.php b/src/migrations/2018_01_01_000007_add_based_to_tax_areas.php new file mode 100644 index 000000000..29c7d2ed6 --- /dev/null +++ b/src/migrations/2018_01_01_000007_add_based_to_tax_areas.php @@ -0,0 +1,118 @@ +tax_areas, function (Blueprint $table) { + $table->string('based')->default(''); + }); + + DB::table($this->tax_areas) + ->whereIn('tax', [ + AlabamaUnemployment::class, + GeorgiaUnemployment::class, + ]) + ->update(['based' => TaxArea::BASED_ON_HOME_LOCATION]); + + DB::table($this->tax_areas) + ->whereIn('tax', [ + FederalIncome::class, + FederalUnemployment::class, + Medicare::class, + MedicareEmployer::class, + SocialSecurity::class, + SocialSecurityEmployer::class, + AlabamaIncome::class, + AttallaOccupational::class, + AuburnOccupational::class, + BearCreekOccupational::class, + BessemerOccupational::class, + BirminghamOccupational::class, + BrilliantOccupational::class, + FairfieldOccupational::class, + GadsdenOccupational::class, + GlencoeOccupational::class, + GoodwaterOccupational::class, + GuinOccupational::class, + HackleburgOccupational::class, + HaleyvilleOccupational::class, + HamiltonOccupational::class, + LeedsOccupational::class, + LynnOccupational::class, + MaconCountyOccupational::class, + MidfieldOccupational::class, + MossesOccupational::class, + OpelikaOccupational::class, + RainbowCityOccupational::class, + RedBayOccupational::class, + ShorterOccupational::class, + SouthsideOccupational::class, + SulligentOccupational::class, + TuskegeeOccupational::class, + GeorgiaIncome::class, + ]) + ->update(['based' => TaxArea::BASED_ON_WORK_LOCATION]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table($this->tax_areas, function (Blueprint $table) { + $table->dropColumn('based'); + }); + } +} diff --git a/tests/Unit/Countries/US/Alabama/AlabamaIncomeTest.php b/tests/Unit/Countries/US/Alabama/AlabamaIncomeTest.php index 3f3c70635..be30857ab 100755 --- a/tests/Unit/Countries/US/Alabama/AlabamaIncomeTest.php +++ b/tests/Unit/Countries/US/Alabama/AlabamaIncomeTest.php @@ -10,6 +10,7 @@ class AlabamaIncomeTest extends \TestCase public function testAlabamaIncome() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -23,6 +24,7 @@ public function testAlabamaIncome() ); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -37,6 +39,7 @@ public function testAlabamaAdditionalWithholding() AlabamaIncomeTaxInformation::forUser($this->user)->update(['additional_withholding' => 10]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(0); @@ -46,6 +49,7 @@ public function testAlabamaAdditionalWithholding() $this->assertSame(0.0, $results->getTax(AlabamaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(1); @@ -55,6 +59,7 @@ public function testAlabamaAdditionalWithholding() $this->assertSame(0.92, $results->getTax(AlabamaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -64,6 +69,7 @@ public function testAlabamaAdditionalWithholding() $this->assertSame(9.12, $results->getTax(AlabamaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -76,6 +82,7 @@ public function testAlabamaAdditionalWithholding() public function testAlabamaSupplemental() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -88,6 +95,7 @@ public function testAlabamaSupplemental() public function testAlabamaIncomeNonNegative() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -102,6 +110,7 @@ public function testAlabamaIncomeWithNoPersonalExemption() AlabamaIncomeTaxInformation::forUser($this->user)->update(['filing_status' => AlabamaIncome::FILING_ZERO]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); diff --git a/tests/Unit/Countries/US/Alabama/AlabamaUnemploymentTest.php b/tests/Unit/Countries/US/Alabama/AlabamaUnemploymentTest.php index e38fa2748..93021f781 100755 --- a/tests/Unit/Countries/US/Alabama/AlabamaUnemploymentTest.php +++ b/tests/Unit/Countries/US/Alabama/AlabamaUnemploymentTest.php @@ -2,11 +2,14 @@ namespace Appleton\Taxes\Countries\US\Alabama\AlabamaUnemployment; +use Appleton\Taxes\Countries\US\Alabama\AlabamaIncome; + class AlabamaUnemploymentTest extends \TestCase { public function testAlabamaUnemployment() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -20,6 +23,7 @@ public function testAlabamaUnemploymentWithTaxRate() config(['taxes.rates.us.alabama.unemployment' => 0.024]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -31,6 +35,7 @@ public function testAlabamaUnemploymentWithTaxRate() public function testAlabamaUnemploymentMetWageBase() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -40,6 +45,7 @@ public function testAlabamaUnemploymentMetWageBase() $this->assertSame(2.70, $results->getTax(AlabamaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -49,6 +55,7 @@ public function testAlabamaUnemploymentMetWageBase() $this->assertSame(1.35, $results->getTax(AlabamaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -58,6 +65,7 @@ public function testAlabamaUnemploymentMetWageBase() $this->assertSame(0.0, $results->getTax(AlabamaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -72,6 +80,7 @@ public function testCaseStudy1() config(['taxes.rates.us.alabama.unemployment' => 0.019]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -79,4 +88,17 @@ public function testCaseStudy1() $this->assertSame(1.27, $results->getTax(AlabamaUnemployment::class)); } + + public function testWorkOutOfState() + { + $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); + $taxes->setWorkLocation($this->getLocation('us')); + $taxes->setUser($this->user); + $taxes->setEarnings(2300); + }); + + $this->assertNull($results->getTax(AlabamaIncome::class)); + $this->assertSame(62.10, $results->getTax(AlabamaUnemployment::class)); + } } diff --git a/tests/Unit/Countries/US/Alabama/AttallaOccupationalTest.php b/tests/Unit/Countries/US/Alabama/AttallaOccupationalTest.php index 5717fbd42..492604477 100755 --- a/tests/Unit/Countries/US/Alabama/AttallaOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/AttallaOccupationalTest.php @@ -7,6 +7,7 @@ class AttallaOccupationalTest extends \TestCase public function testAttallaOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.attalla')); $taxes->setWorkLocation($this->getLocation('us.alabama.attalla')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/AuburnOccupationalTest.php b/tests/Unit/Countries/US/Alabama/AuburnOccupationalTest.php index d7fb31a51..82729c359 100755 --- a/tests/Unit/Countries/US/Alabama/AuburnOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/AuburnOccupationalTest.php @@ -7,6 +7,7 @@ class AuburnOccupationalTest extends \TestCase public function testAuburnOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.auburn')); $taxes->setWorkLocation($this->getLocation('us.alabama.auburn')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/BearCreekOccupationalTest.php b/tests/Unit/Countries/US/Alabama/BearCreekOccupationalTest.php index 501590b25..39d8f3f42 100755 --- a/tests/Unit/Countries/US/Alabama/BearCreekOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/BearCreekOccupationalTest.php @@ -7,6 +7,7 @@ class BearCreekOccupationalTest extends \TestCase public function testBearCreekOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.bearcreek')); $taxes->setWorkLocation($this->getLocation('us.alabama.bearcreek')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/BessemerOccupationalTest.php b/tests/Unit/Countries/US/Alabama/BessemerOccupationalTest.php index 8abc7582a..64217df70 100755 --- a/tests/Unit/Countries/US/Alabama/BessemerOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/BessemerOccupationalTest.php @@ -7,6 +7,7 @@ class BessemerOccupationalTest extends \TestCase public function testBessemerOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.bessemer')); $taxes->setWorkLocation($this->getLocation('us.alabama.bessemer')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/BirminghamOccupationalTest.php b/tests/Unit/Countries/US/Alabama/BirminghamOccupationalTest.php index 2b2d8f1fd..892335ef2 100755 --- a/tests/Unit/Countries/US/Alabama/BirminghamOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/BirminghamOccupationalTest.php @@ -7,6 +7,7 @@ class BirminghamOccupationalTest extends \TestCase public function testBirminghamOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -18,6 +19,7 @@ public function testBirminghamOccupational() public function testCaseStudy1() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); diff --git a/tests/Unit/Countries/US/Alabama/BrilliantOccupationalTest.php b/tests/Unit/Countries/US/Alabama/BrilliantOccupationalTest.php index 25fa98648..d9aa0f9c7 100755 --- a/tests/Unit/Countries/US/Alabama/BrilliantOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/BrilliantOccupationalTest.php @@ -7,6 +7,7 @@ class BrilliantOccupationalTest extends \TestCase public function testBrilliantOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.brilliant')); $taxes->setWorkLocation($this->getLocation('us.alabama.brilliant')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/FairfieldOccupationalTest.php b/tests/Unit/Countries/US/Alabama/FairfieldOccupationalTest.php index faf93b39e..fdd30b5a6 100755 --- a/tests/Unit/Countries/US/Alabama/FairfieldOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/FairfieldOccupationalTest.php @@ -7,6 +7,7 @@ class FairfieldOccupationalTest extends \TestCase public function testFairfieldOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.fairfield')); $taxes->setWorkLocation($this->getLocation('us.alabama.fairfield')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/GadsdenOccupationalTest.php b/tests/Unit/Countries/US/Alabama/GadsdenOccupationalTest.php index 148a593dc..315cb4450 100755 --- a/tests/Unit/Countries/US/Alabama/GadsdenOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/GadsdenOccupationalTest.php @@ -7,6 +7,7 @@ class GadsdenOccupationalTest extends \TestCase public function testGadsdenOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.gadsden')); $taxes->setWorkLocation($this->getLocation('us.alabama.gadsden')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/GlencoeOccupationalTest.php b/tests/Unit/Countries/US/Alabama/GlencoeOccupationalTest.php index 72a5c28c1..4fd27ac00 100755 --- a/tests/Unit/Countries/US/Alabama/GlencoeOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/GlencoeOccupationalTest.php @@ -7,6 +7,7 @@ class GlencoeOccupationalTest extends \TestCase public function testGlencoeOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.glencoe')); $taxes->setWorkLocation($this->getLocation('us.alabama.glencoe')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/GoodwaterOccupationalTest.php b/tests/Unit/Countries/US/Alabama/GoodwaterOccupationalTest.php index d2839df45..605ec43a9 100755 --- a/tests/Unit/Countries/US/Alabama/GoodwaterOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/GoodwaterOccupationalTest.php @@ -7,6 +7,7 @@ class GoodwaterOccupationalTest extends \TestCase public function testGoodwaterOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.goodwater')); $taxes->setWorkLocation($this->getLocation('us.alabama.goodwater')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/GuinOccupationalTest.php b/tests/Unit/Countries/US/Alabama/GuinOccupationalTest.php index c41d6861d..4d15288b0 100755 --- a/tests/Unit/Countries/US/Alabama/GuinOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/GuinOccupationalTest.php @@ -7,6 +7,7 @@ class GuinOccupationalTest extends \TestCase public function testGuinOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.guin')); $taxes->setWorkLocation($this->getLocation('us.alabama.guin')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/HackleburgOccupationalTest.php b/tests/Unit/Countries/US/Alabama/HackleburgOccupationalTest.php index 18659f3f0..f5e1429ed 100755 --- a/tests/Unit/Countries/US/Alabama/HackleburgOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/HackleburgOccupationalTest.php @@ -7,6 +7,7 @@ class HackleburgOccupationalTest extends \TestCase public function testHackleburgOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.hackleburg')); $taxes->setWorkLocation($this->getLocation('us.alabama.hackleburg')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/HaleyvilleOccupationalTest.php b/tests/Unit/Countries/US/Alabama/HaleyvilleOccupationalTest.php index c9518188d..51221966d 100755 --- a/tests/Unit/Countries/US/Alabama/HaleyvilleOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/HaleyvilleOccupationalTest.php @@ -7,6 +7,7 @@ class HaleyvilleOccupationalTest extends \TestCase public function testHaleyvilleOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.haleyville')); $taxes->setWorkLocation($this->getLocation('us.alabama.haleyville')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/HamiltonOccupationalTest.php b/tests/Unit/Countries/US/Alabama/HamiltonOccupationalTest.php index 3b80514e1..8fce645eb 100755 --- a/tests/Unit/Countries/US/Alabama/HamiltonOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/HamiltonOccupationalTest.php @@ -7,6 +7,7 @@ class HamiltonOccupationalTest extends \TestCase public function testHamiltonOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.hamilton')); $taxes->setWorkLocation($this->getLocation('us.alabama.hamilton')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/LeedsOccupationalTest.php b/tests/Unit/Countries/US/Alabama/LeedsOccupationalTest.php index c8f54f802..cf156c207 100755 --- a/tests/Unit/Countries/US/Alabama/LeedsOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/LeedsOccupationalTest.php @@ -7,6 +7,7 @@ class LeedsOccupationalTest extends \TestCase public function testLeedsOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.leeds')); $taxes->setWorkLocation($this->getLocation('us.alabama.leeds')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/LynnOccupationalTest.php b/tests/Unit/Countries/US/Alabama/LynnOccupationalTest.php index 8083437a3..5e4a1d17f 100755 --- a/tests/Unit/Countries/US/Alabama/LynnOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/LynnOccupationalTest.php @@ -7,6 +7,7 @@ class LynnOccupationalTest extends \TestCase public function testLynnOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.lynn')); $taxes->setWorkLocation($this->getLocation('us.alabama.lynn')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/MaconCountyOccupationalTest.php b/tests/Unit/Countries/US/Alabama/MaconCountyOccupationalTest.php index c2d756bb0..88c2eff95 100755 --- a/tests/Unit/Countries/US/Alabama/MaconCountyOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/MaconCountyOccupationalTest.php @@ -7,6 +7,7 @@ class MaconCountyOccupationalTest extends \TestCase public function testMaconCountyOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.maconcounty')); $taxes->setWorkLocation($this->getLocation('us.alabama.maconcounty')); $taxes->setUser($this->user); $taxes->setEarnings(300); diff --git a/tests/Unit/Countries/US/Alabama/MidfieldOccupationalTest.php b/tests/Unit/Countries/US/Alabama/MidfieldOccupationalTest.php index 98d2487a7..e490adab1 100755 --- a/tests/Unit/Countries/US/Alabama/MidfieldOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/MidfieldOccupationalTest.php @@ -7,6 +7,7 @@ class MidfieldOccupationalTest extends \TestCase public function testMidfieldOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.midfield')); $taxes->setWorkLocation($this->getLocation('us.alabama.midfield')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/MossesOccupationalTest.php b/tests/Unit/Countries/US/Alabama/MossesOccupationalTest.php index 068afb726..efce0fba2 100755 --- a/tests/Unit/Countries/US/Alabama/MossesOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/MossesOccupationalTest.php @@ -7,6 +7,7 @@ class MossesOccupationalTest extends \TestCase public function testMossesOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.mosses')); $taxes->setWorkLocation($this->getLocation('us.alabama.mosses')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/OpelikaOccupationalTest.php b/tests/Unit/Countries/US/Alabama/OpelikaOccupationalTest.php index e8f0faab8..fff4d33a2 100755 --- a/tests/Unit/Countries/US/Alabama/OpelikaOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/OpelikaOccupationalTest.php @@ -7,6 +7,7 @@ class OpelikaOccupationalTest extends \TestCase public function testOpelikaOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.opelika')); $taxes->setWorkLocation($this->getLocation('us.alabama.opelika')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/RainbowCityOccupationalTest.php b/tests/Unit/Countries/US/Alabama/RainbowCityOccupationalTest.php index f1be5e168..0995bb550 100755 --- a/tests/Unit/Countries/US/Alabama/RainbowCityOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/RainbowCityOccupationalTest.php @@ -7,6 +7,7 @@ class RainbowCityOccupationalTest extends \TestCase public function testRainbowCityOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.rainbowcity')); $taxes->setWorkLocation($this->getLocation('us.alabama.rainbowcity')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/RedBayOccupationalTest.php b/tests/Unit/Countries/US/Alabama/RedBayOccupationalTest.php index 663597f2c..0566d37b2 100755 --- a/tests/Unit/Countries/US/Alabama/RedBayOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/RedBayOccupationalTest.php @@ -7,6 +7,7 @@ class RedBayOccupationalTest extends \TestCase public function testRedBayOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.redbay')); $taxes->setWorkLocation($this->getLocation('us.alabama.redbay')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/ShorterOccupationalTest.php b/tests/Unit/Countries/US/Alabama/ShorterOccupationalTest.php index bd8001058..72356c7f0 100755 --- a/tests/Unit/Countries/US/Alabama/ShorterOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/ShorterOccupationalTest.php @@ -7,6 +7,7 @@ class ShorterOccupationalTest extends \TestCase public function testShorterOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.shorter')); $taxes->setWorkLocation($this->getLocation('us.alabama.shorter')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/SouthsideOccupationalTest.php b/tests/Unit/Countries/US/Alabama/SouthsideOccupationalTest.php index 4f6e804ea..525cbe638 100755 --- a/tests/Unit/Countries/US/Alabama/SouthsideOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/SouthsideOccupationalTest.php @@ -7,6 +7,7 @@ class SouthsideOccupationalTest extends \TestCase public function testSouthsideOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.southside')); $taxes->setWorkLocation($this->getLocation('us.alabama.southside')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/SulligentOccupationalTest.php b/tests/Unit/Countries/US/Alabama/SulligentOccupationalTest.php index 43e648b7d..ed4fe3773 100755 --- a/tests/Unit/Countries/US/Alabama/SulligentOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/SulligentOccupationalTest.php @@ -7,6 +7,7 @@ class SulligentOccupationalTest extends \TestCase public function testSulligentOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.sulligent')); $taxes->setWorkLocation($this->getLocation('us.alabama.sulligent')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/Alabama/TuskegeeOccupationalTest.php b/tests/Unit/Countries/US/Alabama/TuskegeeOccupationalTest.php index 97d7b931e..1f9873b18 100755 --- a/tests/Unit/Countries/US/Alabama/TuskegeeOccupationalTest.php +++ b/tests/Unit/Countries/US/Alabama/TuskegeeOccupationalTest.php @@ -9,6 +9,7 @@ class TuskegeeOccupationalTest extends \TestCase public function testTuskegeeOccupational() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.tuskegee')); $taxes->setWorkLocation($this->getLocation('us.alabama.tuskegee')); $taxes->setUser($this->user); $taxes->setEarnings(2300); diff --git a/tests/Unit/Countries/US/FederalIncomeTest.php b/tests/Unit/Countries/US/FederalIncomeTest.php index a45a1829d..5c1d05bcb 100755 --- a/tests/Unit/Countries/US/FederalIncomeTest.php +++ b/tests/Unit/Countries/US/FederalIncomeTest.php @@ -11,6 +11,7 @@ class FederalIncomeTest extends \TestCase public function testCalledTwice() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -19,6 +20,7 @@ public function testCalledTwice() $this->assertSame(0.0, $results->getTax(FederalIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -30,6 +32,7 @@ public function testCalledTwice() public function testNoTaxesOwed() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -40,6 +43,7 @@ public function testNoTaxesOwed() FederalIncomeTaxInformation::forUser($this->user)->update(['filing_status' => FederalIncome::FILING_MARRIED]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(8650); @@ -51,6 +55,7 @@ public function testNoTaxesOwed() public function testTaxesOwed() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2301); @@ -61,6 +66,7 @@ public function testTaxesOwed() FederalIncomeTaxInformation::forUser($this->user)->update(['filing_status' => FederalIncome::FILING_MARRIED]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(8651); @@ -74,6 +80,7 @@ public function testAdditionalWithholding() FederalIncomeTaxInformation::forUser($this->user)->update(['additional_withholding' => 10]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(0); @@ -82,6 +89,7 @@ public function testAdditionalWithholding() $this->assertSame(0.0, $results->getTax(FederalIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(1); @@ -90,6 +98,7 @@ public function testAdditionalWithholding() $this->assertSame(1.0, $results->getTax(FederalIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -98,6 +107,7 @@ public function testAdditionalWithholding() $this->assertSame(10.0, $results->getTax(FederalIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2301); @@ -111,6 +121,7 @@ public function testAdditionalWithholding() ]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(8651); @@ -122,6 +133,7 @@ public function testAdditionalWithholding() public function testSupplemental() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -134,6 +146,7 @@ public function testSupplemental() public function testWeekly() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -146,6 +159,7 @@ public function testWeekly() public function testBimonthly() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -158,6 +172,7 @@ public function testBimonthly() public function testMonthly() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -170,6 +185,7 @@ public function testMonthly() public function testNonNegative() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -182,6 +198,7 @@ public function testNonNegative() public function testCaseStudy1() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -198,6 +215,7 @@ public function testTaxesOwed2018A() FederalIncomeTaxInformation::forUser($this->user)->update(['exemptions' => 1]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(258.69); @@ -216,6 +234,7 @@ public function testTaxesOwed2018B() ]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(475.25); @@ -233,6 +252,7 @@ public function testTaxesOwed2018C() ]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(112.33); @@ -248,6 +268,7 @@ public function testTaxesOwed2018D() FederalIncomeTaxInformation::forUser($this->user)->update(['filing_status' => FederalIncome::FILING_SEPERATE]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(865.14); @@ -266,6 +287,7 @@ public function testTaxesOwed2018E() ]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(367.57); @@ -283,6 +305,7 @@ public function testTaxesOwed2018H() ]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(800); diff --git a/tests/Unit/Countries/US/FederalUnemploymentTest.php b/tests/Unit/Countries/US/FederalUnemploymentTest.php index 99c1b69ac..436fee0d2 100755 --- a/tests/Unit/Countries/US/FederalUnemploymentTest.php +++ b/tests/Unit/Countries/US/FederalUnemploymentTest.php @@ -9,6 +9,7 @@ class FederalUnemploymentTest extends \TestCase public function testFederalUnemployment() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -20,6 +21,7 @@ public function testFederalUnemployment() public function testFederalUnemploymentWithStateCredit() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -31,6 +33,7 @@ public function testFederalUnemploymentWithStateCredit() public function testFederalUnemploymentMetWageBase() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -40,6 +43,7 @@ public function testFederalUnemploymentMetWageBase() $this->assertSame(0.60, $results->getTax(FederalUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -49,6 +53,7 @@ public function testFederalUnemploymentMetWageBase() $this->assertSame(0.30, $results->getTax(FederalUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -58,6 +63,7 @@ public function testFederalUnemploymentMetWageBase() $this->assertSame(0.0, $results->getTax(FederalUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -70,6 +76,7 @@ public function testFederalUnemploymentMetWageBase() public function testCaseStudy1() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama')); $taxes->setWorkLocation($this->getLocation('us.alabama')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); diff --git a/tests/Unit/Countries/US/Georgia/GeorgiaIncomeTest.php b/tests/Unit/Countries/US/Georgia/GeorgiaIncomeTest.php index e163479f4..8ba3a7b43 100644 --- a/tests/Unit/Countries/US/Georgia/GeorgiaIncomeTest.php +++ b/tests/Unit/Countries/US/Georgia/GeorgiaIncomeTest.php @@ -19,6 +19,7 @@ public function setUp() public function testGeorgiaIncome() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -33,6 +34,7 @@ public function testGeorgiaAdditionalWithholding() GeorgiaIncomeTaxInformation::forUser($this->user)->update(['additional_withholding' => 10]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(0); @@ -42,6 +44,7 @@ public function testGeorgiaAdditionalWithholding() $this->assertSame(0.0, $results->getTax(GeorgiaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -54,6 +57,7 @@ public function testGeorgiaAdditionalWithholding() public function testGeorgiaSupplemental() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -66,6 +70,7 @@ public function testGeorgiaSupplemental() public function testGeorgiaIncomeNonNegative() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(10); diff --git a/tests/Unit/Countries/US/Georgia/GeorgiaUnemploymentTest.php b/tests/Unit/Countries/US/Georgia/GeorgiaUnemploymentTest.php index 5dbbaefa4..42fb4dacf 100644 --- a/tests/Unit/Countries/US/Georgia/GeorgiaUnemploymentTest.php +++ b/tests/Unit/Countries/US/Georgia/GeorgiaUnemploymentTest.php @@ -2,6 +2,7 @@ namespace Appleton\Taxes\Countries\US\Georgia\GeorgiaUnemployment; +use Appleton\Taxes\Countries\US\Georgia\GeorgiaIncome; use Carbon\Carbon; class GeorgiaUnemploymentTest extends \TestCase @@ -18,6 +19,7 @@ public function setUp() public function testGeorgiaUnemployment() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -31,6 +33,7 @@ public function testGeorgiaUnemploymentWithTaxRate() config(['taxes.rates.us.georgia.unemployment' => 0.024]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -42,6 +45,7 @@ public function testGeorgiaUnemploymentWithTaxRate() public function testGeorgiaUnemploymentMetWageBase() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -51,6 +55,7 @@ public function testGeorgiaUnemploymentMetWageBase() $this->assertSame(2.70, $results->getTax(GeorgiaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -60,6 +65,7 @@ public function testGeorgiaUnemploymentMetWageBase() $this->assertSame(1.35, $results->getTax(GeorgiaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -69,6 +75,7 @@ public function testGeorgiaUnemploymentMetWageBase() $this->assertSame(0.0, $results->getTax(GeorgiaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -83,6 +90,7 @@ public function testCaseStudy1() config(['taxes.rates.us.georgia.unemployment' => 0.019]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -90,4 +98,19 @@ public function testCaseStudy1() $this->assertSame(1.27, $results->getTax(GeorgiaUnemployment::class)); } + + public function testWorkOutOfState() + { + config(['taxes.rates.us.georgia.unemployment' => 0.019]); + + $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); + $taxes->setWorkLocation($this->getLocation('us')); + $taxes->setUser($this->user); + $taxes->setEarnings(66.68); + }); + + $this->assertNull($results->getTax(GeorgiaIncome::class)); + $this->assertSame(1.27, $results->getTax(GeorgiaUnemployment::class)); + } } diff --git a/tests/Unit/Countries/US/MedicareTest.php b/tests/Unit/Countries/US/MedicareTest.php index 5b933f0d4..2d0e6f978 100755 --- a/tests/Unit/Countries/US/MedicareTest.php +++ b/tests/Unit/Countries/US/MedicareTest.php @@ -7,6 +7,7 @@ class MedicareTest extends \TestCase public function testMedicare() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -18,6 +19,7 @@ public function testMedicare() public function testMedicareWithAdditionalTax() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -27,6 +29,7 @@ public function testMedicareWithAdditionalTax() $this->assertSame(1.45, $results->getTax(Medicare::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -36,6 +39,7 @@ public function testMedicareWithAdditionalTax() $this->assertSame(1.90, $results->getTax(Medicare::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -45,6 +49,7 @@ public function testMedicareWithAdditionalTax() $this->assertSame(2.35, $results->getTax(Medicare::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -57,6 +62,7 @@ public function testMedicareWithAdditionalTax() public function testMedicareEmployer() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -69,6 +75,7 @@ public function testMedicareEmployer() public function testCaseStudy1() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -82,6 +89,7 @@ public function testCaseStudy1() public function testCaseStudyA() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(271.67); @@ -96,6 +104,7 @@ public function testCaseStudyA() public function testCaseStudyB() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(765.12); diff --git a/tests/Unit/Countries/US/SocialSecurityTest.php b/tests/Unit/Countries/US/SocialSecurityTest.php index f0abf5b69..f7bda9edf 100755 --- a/tests/Unit/Countries/US/SocialSecurityTest.php +++ b/tests/Unit/Countries/US/SocialSecurityTest.php @@ -7,6 +7,7 @@ class SocialSecurityTest extends \TestCase public function testSocialSecurity() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -18,6 +19,7 @@ public function testSocialSecurity() public function testSocialSecurityEmployer() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(2300); @@ -29,6 +31,7 @@ public function testSocialSecurityEmployer() public function testSocialSecurityMetWageBase() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -38,6 +41,7 @@ public function testSocialSecurityMetWageBase() $this->assertSame(6.20, $results->getTax(SocialSecurity::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -47,6 +51,7 @@ public function testSocialSecurityMetWageBase() $this->assertSame(3.10, $results->getTax(SocialSecurity::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -56,6 +61,7 @@ public function testSocialSecurityMetWageBase() $this->assertSame(0.0, $results->getTax(SocialSecurity::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(100); @@ -68,6 +74,7 @@ public function testSocialSecurityMetWageBase() public function testCaseStudy1() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -81,6 +88,7 @@ public function testCaseStudy1() public function testCaseStudy2018A() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(640); @@ -94,6 +102,7 @@ public function testCaseStudy2018A() public function testCaseStudy2018B() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(774.28); @@ -107,6 +116,7 @@ public function testCaseStudy2018B() public function testCaseStudy2018C() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(640); @@ -121,6 +131,7 @@ public function testCaseStudy2018C() public function testCaseStudy2018D() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us')); $taxes->setWorkLocation($this->getLocation('us')); $taxes->setUser($this->user); $taxes->setEarnings(774.28); diff --git a/tests/Unit/TaxResultsTest.php b/tests/Unit/TaxResultsTest.php index a8b12db86..c5e630be2 100644 --- a/tests/Unit/TaxResultsTest.php +++ b/tests/Unit/TaxResultsTest.php @@ -17,6 +17,7 @@ class TaxResultsTest extends \TestCase public function testTaxes() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -71,6 +72,7 @@ public function testTaxes() public function testAdjustedEarnings() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(10000); diff --git a/tests/Unit/TaxesTest.php b/tests/Unit/TaxesTest.php index 0e006ec6b..e695b7390 100644 --- a/tests/Unit/TaxesTest.php +++ b/tests/Unit/TaxesTest.php @@ -24,6 +24,7 @@ class TaxesTest extends \TestCase public function testTaxes() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -47,6 +48,7 @@ public function testTaxes() ); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.georgia')); $taxes->setWorkLocation($this->getLocation('us.georgia')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -62,6 +64,7 @@ public function testTaxes() public function testTaxesYtdEarnings() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -74,6 +77,7 @@ public function testTaxesYtdEarnings() $this->assertSame(0.0, $results->getTax(FederalUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -87,6 +91,7 @@ public function testTaxesYtdEarnings() $this->assertSame(0.0, $results->getTax(AlabamaUnemployment::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -102,6 +107,7 @@ public function testTaxesYtdEarnings() $this->assertSame(0.0, $results->getTax(SocialSecurityEmployer::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -119,6 +125,7 @@ public function testTaxesYtdEarnings() $this->assertSame(0.67, $results->getTax(BirminghamOccupational::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -141,6 +148,7 @@ public function testTaxesUnresolvableDate() $this->expectExceptionMessage('The implementation could not be found.'); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -152,6 +160,7 @@ public function testTaxesUnresolvableDate() public function testTaxesNoUser() { $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser(null); $taxes->setEarnings(66.68); @@ -175,6 +184,7 @@ public function testUnbindsPayrollAfter() $this->expectException(BindingResolutionException::class); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(66.68); @@ -197,6 +207,7 @@ public function testAdditionalWithholding() AlabamaIncomeTaxInformation::forUser($this->user)->update(['additional_withholding' => 10]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -206,6 +217,7 @@ public function testAdditionalWithholding() $this->assertSame(0.0, $results->getTax(AlabamaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(11); @@ -221,6 +233,7 @@ public function testNegativeAdditionalWithholding() AlabamaIncomeTaxInformation::forUser($this->user)->update(['additional_withholding' => -10]); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(10); @@ -230,6 +243,7 @@ public function testNegativeAdditionalWithholding() $this->assertSame(0.0, $results->getTax(AlabamaIncome::class)); $results = $this->taxes->calculate(function ($taxes) { + $taxes->setHomeLocation($this->getLocation('us.alabama.birmingham')); $taxes->setWorkLocation($this->getLocation('us.alabama.birmingham')); $taxes->setUser($this->user); $taxes->setEarnings(11);