Skip to content

Commit

Permalink
Merge pull request #229 from spurjobs/feature/laws-178-mn-2020-changes
Browse files Browse the repository at this point in the history
LAWS-178 Minnesota Tax Changes for 2020
  • Loading branch information
Aidancs authored Mar 24, 2020
2 parents c6778d3 + 1c360ce commit 2bd69d9
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 0 deletions.
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MinnesotaIncomeTaxInformation extends BaseTaxInformationModel
public static function getDefault()
{
$tax_information = new self();
$tax_information->additional_withholding = 0;
$tax_information->allowances = 0;
$tax_information->filing_status = 0;
$tax_information->exempt = MinnesotaIncome::FILING_SINGLE;
Expand Down
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 tests/Unit/Countries/US/Minnesota/V20200101/MinnesotaIncomeTest.php
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()
],
];
}
}

0 comments on commit 2bd69d9

Please sign in to comment.