-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from spurjobs/feature/laws-178-mn-2020-changes
LAWS-178 Minnesota Tax Changes for 2020
- Loading branch information
Showing
4 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/Countries/US/Minnesota/MinnesotaIncome/V20200101/MinnesotaIncome.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace Appleton\Taxes\Countries\US\Minnesota\MinnesotaIncome\V20200101; | ||
|
||
use Appleton\Taxes\Countries\US\Minnesota\MinnesotaIncome\MinnesotaIncome as BaseMinnesotaIncome; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class MinnesotaIncome extends BaseMinnesotaIncome | ||
{ | ||
const WITHHOLDING_ALLOWANCE = 4250; | ||
|
||
const SINGLE_TAX_WITHHOLDING_BRACKET = [ | ||
[0, 0, 0], | ||
[3700, .0535, 0], | ||
[30220, .068, 1418.82], | ||
[90810, .0785, 5538.94], | ||
[165420, .0985, 11395.83], | ||
]; | ||
|
||
const MARRIED_TAX_WITHHOLDING_BRACKET = [ | ||
[0, 0, 0], | ||
[11650, .0535, 0], | ||
[50420, .068, 2074.2], | ||
[165670, .0785, 9911.2], | ||
[280660, .0985, 18937.92], | ||
]; | ||
|
||
public function getTaxBrackets() | ||
{ | ||
if ($this->tax_information->filing_status === 'S') { | ||
return self::SINGLE_TAX_WITHHOLDING_BRACKET; | ||
} | ||
|
||
return self::MARRIED_TAX_WITHHOLDING_BRACKET; | ||
} | ||
|
||
public function compute(Collection $tax_areas) | ||
{ | ||
if ($this->isUserClaimingExemption()) { | ||
return 0; | ||
} | ||
|
||
$this->tax_total = $this->payroll->withholdTax($this->getTaxAmountFromTaxBrackets($this->getGrossWages() - $this->getWithholdingAllowances(), $this->getTaxBrackets()) / $this->payroll->pay_periods + $this->tax_information->additional_withholding); | ||
|
||
return round($this->tax_total, 2); | ||
} | ||
|
||
public function getGrossWages() | ||
{ | ||
return $this->getAdjustedEarnings() * $this->payroll->pay_periods; | ||
} | ||
|
||
public function getWithholdingAllowances() | ||
{ | ||
return $this->tax_information->allowances * self::WITHHOLDING_ALLOWANCE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/migrations/2020_03_12_000000_add_parameters_to_minnesota_tax_income_information.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class AddParametersToMinnesotaTaxIncomeInformation extends Migration | ||
{ | ||
protected $minnesota_income_tax_information = 'minnesota_income_tax_information'; | ||
|
||
public function up() | ||
{ | ||
Schema::table($this->minnesota_income_tax_information, function (Blueprint $table) { | ||
$table->integer('additional_withholding')->default(0); | ||
}); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
tests/Unit/Countries/US/Minnesota/V20200101/MinnesotaIncomeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace Appleton\Taxes\Tests\Unit\Countries\US\Minnesota\V20200101; | ||
|
||
use Appleton\Taxes\Countries\US\Minnesota\MinnesotaIncome\MinnesotaIncome; | ||
use Appleton\Taxes\Models\Countries\US\Minnesota\MinnesotaIncomeTaxInformation; | ||
use Appleton\Taxes\Tests\Unit\Countries\TestParameters; | ||
use Appleton\Taxes\Tests\Unit\Countries\TestParametersBuilder; | ||
use Appleton\Taxes\Tests\Unit\Countries\TaxTestCase; | ||
|
||
class MinnesotaIncomeTest extends TaxTestCase | ||
{ | ||
private const DATE = '2020-01-01'; | ||
private const LOCATION = 'us.minnesota'; | ||
private const TAX_CLASS = MinnesotaIncome::class; | ||
private const TAX_INFO_CLASS = MinnesotaIncomeTaxInformation::class; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->query_runner->addTax(self::TAX_CLASS); | ||
|
||
MinnesotaIncomeTaxInformation::createForUser([ | ||
'filing_status' => MinnesotaIncome::FILING_SINGLE, | ||
'allowances' => 0, | ||
'additional_withholding' => 0, | ||
'exempt' => false, | ||
], $this->user); | ||
} | ||
|
||
/** | ||
* @dataProvider provideTestData | ||
*/ | ||
public function testTax(TestParameters $parameters): void | ||
{ | ||
$this->validate($parameters); | ||
} | ||
|
||
public function provideTestData(): array | ||
{ | ||
$builder = new TestParametersBuilder(); | ||
$builder | ||
->setDate(self::DATE) | ||
->setHomeLocation(self::LOCATION) | ||
->setTaxClass(self::TAX_CLASS) | ||
->setTaxInfoClass(self::TAX_INFO_CLASS) | ||
->setPayPeriods(52); | ||
|
||
return [ | ||
'00' => [ | ||
$builder | ||
->setTaxInfoOptions(['exempt' => true]) | ||
->setWagesInCents(30000) | ||
->setExpectedAmountInCents(0) | ||
->build() | ||
], | ||
'01' => [ | ||
$builder | ||
->setTaxInfoOptions(null) | ||
->setWagesInCents(30000) | ||
->setExpectedAmountInCents(1224) | ||
->build() | ||
], | ||
'02' => [ | ||
$builder | ||
->setTaxInfoOptions(['additional_withholding' => 20]) | ||
->setWagesInCents(30000) | ||
->setExpectedAmountInCents(3224) | ||
->build() | ||
], | ||
'03' => [ | ||
$builder | ||
->setTaxInfoOptions(['allowances' => 2]) | ||
->setWagesInCents(100000) | ||
->setExpectedAmountInCents(4465) | ||
->build() | ||
], | ||
'04' => [ | ||
$builder | ||
->setTaxInfoOptions(['allowances' => 2]) | ||
->setWagesInCents(200000) | ||
->setExpectedAmountInCents(11360) | ||
->build() | ||
], | ||
'05' => [ | ||
$builder | ||
->setTaxInfoOptions([ | ||
'filing_status' => MinnesotaIncome::FILING_MARRIED, | ||
'allowances' => 2, | ||
]) | ||
->setWagesInCents(100000) | ||
->setExpectedAmountInCents(3277) | ||
->build() | ||
], | ||
'06' => [ | ||
$builder | ||
->setTaxInfoOptions(['filing_status' => MinnesotaIncome::FILING_MARRIED]) | ||
->setWagesInCents(200000) | ||
->setExpectedAmountInCents(10995) | ||
->build() | ||
], | ||
]; | ||
} | ||
} |