Skip to content

Commit

Permalink
Add New Mexico Taxes (#43)
Browse files Browse the repository at this point in the history
* Add New Mexico Taxes

* Fix state income withholding
  • Loading branch information
rmcdaniel authored Sep 5, 2018
1 parent d50704b commit 608c6b4
Show file tree
Hide file tree
Showing 25 changed files with 425 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Classes/BaseIncome.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function compute()
{
return 0.00;
}

$this->tax_total = $this->payroll->withholdTax($this->getTaxAmountFromTaxBrackets($this->getAdjustedEarnings(), $this->getTaxBrackets()) / $this->payroll->pay_periods) +
$this->payroll->withholdTax($this->getSupplementalIncomeTax()) +
$this->payroll->withholdTax($this->getAdditionalWithholding());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function getTaxAmountFromTaxBrackets($amount, $table)

public function getAdjustedEarnings()
{
return $this->payroll->earnings * $this->payroll->pay_periods;
return ($this->payroll->earnings * $this->payroll->pay_periods) - ($this->federal_income_tax * $this->payroll->pay_periods);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function compute()

public function getAdjustedEarnings()
{
$adjusted_earnings = $this->getGrossEarnings() - $this->getExemptionAllowance();
$adjusted_earnings = $this->getGrossEarnings() - ($this->federal_income_tax * $this->payroll->pay_periods) - $this->getExemptionAllowance();

return $adjusted_earnings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(GeorgiaIncomeTaxInformation $tax_information, Federa

public function getAdjustedEarnings()
{
$adjusted_earnings = $this->getGrossEarnings();
$adjusted_earnings = $this->getGrossEarnings() - ($this->federal_income_tax * $this->payroll->pay_periods);

if ($this->tax_information->filing_status != static::FILING_ZERO) {
$adjusted_earnings = $adjusted_earnings - $this->getStandardDeduction() - $this->getPersonalAllowance() - $this->getDependentExemption();
Expand Down
30 changes: 30 additions & 0 deletions src/Countries/US/NewMexico/NewMexicoIncome/NewMexicoIncome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome;

use Appleton\Taxes\Classes\BaseStateIncome;
use Appleton\Taxes\Classes\Payroll;
use Appleton\Taxes\Models\Countries\US\NewMexico\NewMexicoIncomeTaxInformation;

abstract class NewMexicoIncome extends BaseStateIncome
{
const FILING_SINGLE = 0;
const FILING_WIDOW = 1;
const FILING_HEAD_OF_HOUSEHOLD = 2;
const FILING_MARRIED = 3;
const FILING_SEPERATE = 4;

const FILING_STATUSES = [
self::FILING_SINGLE => 'FILING_SINGLE',
self::FILING_WIDOW => 'FILING_WIDOW',
self::FILING_HEAD_OF_HOUSEHOLD => 'FILING_HEAD_OF_HOUSEHOLD',
self::FILING_MARRIED => 'FILING_MARRIED',
self::FILING_SEPERATE => 'FILING_SEPERATE',
];

public function __construct(NewMexicoIncomeTaxInformation $tax_information, Payroll $payroll)
{
parent::__construct($payroll);
$this->tax_information = $tax_information;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome\V20180101;

use Appleton\Taxes\Classes\Payroll;
use Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome\NewMexicoIncome as BaseNewMexicoIncome;
use Appleton\Taxes\Countries\US\FederalIncome\FederalIncome;
use Appleton\Taxes\Models\Countries\US\NewMexico\NewMexicoIncomeTaxInformation;

class NewMexicoIncome extends BaseNewMexicoIncome
{
const SUPPLEMENTAL_TAX_RATE = 0.049;

const SINGLE_BRACKETS = [
[0, 0.00, 0],
[2300, 0.017, 0],
[7800, 0.032, 93.5],
[13300, 0.047, 269.5],
[18300, 0.049, 504.5],
[28300, 0.049, 994.5],
[44300, 0.049, 1778.5],
[67300, 0.049, 2905.5],
];

const MARRIED_BRACKETS = [
[0, 0.00, 0],
[8650, 0.017, 0],
[16650, 0.032, 136],
[24650, 0.047, 392],
[32650, 0.047, 768],
[48650, 0.049, 1552],
[72650, 0.049, 2728],
[108650, 0.049, 4492],
];

const EXEMPTION_ALLOWANCE_AMOUNT = 4050;

public function __construct(NewMexicoIncomeTaxInformation $tax_information, FederalIncome $federal_income, Payroll $payroll)
{
parent::__construct($tax_information, $payroll);
$this->federal_income_tax = $federal_income->getAmount();
$this->tax_information = $tax_information;
}

public function getAdjustedEarnings()
{
return $this->getGrossEarnings() - ($this->federal_income_tax * $this->payroll->pay_periods) - $this->getAllowanceExemption();
}

public function getTaxBrackets()
{
if ($this->tax_information->filing_status === static::FILING_SINGLE || $this->tax_information->filing_status === static::FILING_HEAD_OF_HOUSEHOLD) {
return static::SINGLE_BRACKETS;
} else {
return static::MARRIED_BRACKETS;
}
}

private function getAllowanceExemption()
{
return $this->tax_information->exemptions * self::EXEMPTION_ALLOWANCE_AMOUNT;
}

private function getGrossEarnings()
{
return ($this->payroll->earnings - $this->payroll->supplemental_earnings) * $this->payroll->pay_periods;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Appleton\Taxes\Countries\US\NewMexico\NewMexicoUnemployment;

use Appleton\Taxes\Countries\US\FederalUnemployment\BaseStateUnemployment;

abstract class NewMexicoUnemployment extends BaseStateUnemployment
{
const TYPE = 'state';
const WITHHELD = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Appleton\Taxes\Countries\US\NewMexico\NewMexicoUnemployment\V20180101;

use Appleton\Taxes\Classes\Payroll;
use Appleton\Taxes\Countries\US\NewMexico\NewMexicoUnemployment\NewMexicoUnemployment as BaseNewMexicoUnemployment;

class NewMexicoUnemployment extends BaseNewMexicoUnemployment
{
const FUTA_CREDIT = 0.054;

const NEW_EMPLOYER_RATE = 0.01;

const WAGE_BASE = 24200;

public function __construct(Payroll $payroll)
{
parent::__construct($payroll);
$this->tax_rate = config('taxes.rates.us.new_mexico.unemployment', static::NEW_EMPLOYER_RATE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public function __construct(NorthCarolinaIncomeTaxInformation $tax_information,

public function getAdjustedEarnings()
{
$adjusted_earnings = $this->getGrossEarnings();

$adjusted_earnings = $adjusted_earnings - $this->getStandardDeduction() - $this->getDependentExemption();

return $adjusted_earnings;
return $this->getGrossEarnings() - ($this->federal_income_tax * $this->payroll->pay_periods) - $this->getStandardDeduction() - $this->getDependentExemption();
}

public function getSupplementalIncomeTax()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(WisconsinIncomeTaxInformation $tax_information, Fede
public function getAdjustedEarnings()
{
// For Wisconsin, standard deduction is built into the tables.
return $this->getGrossEarnings() - ($this->tax_information->exemptions * self::EXEMPTION_AMOUNT);
return $this->getGrossEarnings() - ($this->federal_income_tax * $this->payroll->pay_periods) - ($this->tax_information->exemptions * self::EXEMPTION_AMOUNT);
}

public function getTaxBrackets()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Appleton\Taxes\Models\Countries\US\NewMexico;

use Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome\NewMexicoIncome;
use Appleton\Taxes\Classes\BaseTaxInformationModel;

class NewMexicoIncomeTaxInformation extends BaseTaxInformationModel
{
protected $config_name = 'taxes.tables.us.new_mexico.new_mexico_income_tax_information';

public static function getDefault()
{
$tax_information = new self();
$tax_information->additional_withholding = 0;
$tax_information->exemptions = 0;
$tax_information->filing_status = NewMexicoIncome::FILING_SINGLE;
$tax_information->exempt = false;
return $tax_information;
}

public function getAdditionalWithholding($value)
{
return $value * 100;
}

public function setAdditionalWithholding($value)
{
$this->attributes['additional_withholding'] = round($value / 100);
}

public static function getTax()
{
return NewMexicoIncome::class;
}
}
1 change: 1 addition & 0 deletions src/Providers/TaxInformationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TaxInformationServiceProvider extends ServiceProvider
\Appleton\Taxes\Models\Countries\US\Arizona\ArizonaIncomeTaxInformation::class,
\Appleton\Taxes\Models\Countries\US\Colorado\ColoradoIncomeTaxInformation::class,
\Appleton\Taxes\Models\Countries\US\Georgia\GeorgiaIncomeTaxInformation::class,
\Appleton\Taxes\Models\Countries\US\NewMexico\NewMexicoIncomeTaxInformation::class,
\Appleton\Taxes\Models\Countries\US\NorthCarolina\NorthCarolinaIncomeTaxInformation::class,
\Appleton\Taxes\Models\Countries\US\Wisconsin\WisconsinIncomeTaxInformation::class,
];
Expand Down
2 changes: 2 additions & 0 deletions src/Providers/TaxServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class TaxServiceProvider extends ServiceProvider
\Appleton\Taxes\Countries\US\Georgia\GeorgiaUnemployment\GeorgiaUnemployment::class,
\Appleton\Taxes\Countries\US\Florida\FloridaUnemployment\FloridaUnemployment::class,
\Appleton\Taxes\Countries\US\Texas\TexasUnemployment\TexasUnemployment::class,
\Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome\NewMexicoIncome::class,
\Appleton\Taxes\Countries\US\NewMexico\NewMexicoUnemployment\NewMexicoUnemployment::class,
\Appleton\Taxes\Countries\US\NorthCarolina\NorthCarolinaIncome\NorthCarolinaIncome::class,
\Appleton\Taxes\Countries\US\NorthCarolina\NorthCarolinaUnemployment\NorthCarolinaUnemployment::class,
\Appleton\Taxes\Countries\US\Wisconsin\WisconsinIncome\WisconsinIncome::class,
Expand Down
14 changes: 14 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@

],

'new_mexico' => [

'new_mexico_income_tax_information' => env('TAXES_NEW_MEXICO_INCOME_TAX_INFORMATION', 'new_mexico_income_tax_information'),

],

'north_carolina' => [

'north_carolina_income_tax_information' => env('TAXES_NORTH_CAROLINA_INCOME_TAX_INFORMATION', 'north_carolina_income_tax_information'),

],

'wisconsin' => [
Expand Down Expand Up @@ -96,6 +104,12 @@

],

'new_mexico' => [

'unemployment' => env('TAXES_NEW_MEXICO_UNEMPLOYMENT_TAX_RATE', 0.01),

],

'north_carolina' => [

'unemployment' => env('TAXES_NORTH_CAROLINA_UNEMPLOYMENT_TAX_RATE', 0.01),
Expand Down

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
use Appleton\Taxes\Countries\US\Colorado\ColoradoIncome\ColoradoIncome;
use Appleton\Taxes\Countries\US\Georgia\GeorgiaIncome\GeorgiaIncome;
use Appleton\Taxes\Countries\US\FederalIncome\FederalIncome;
use Appleton\Taxes\Countries\US\NewMexico\NewMexicoIncome\NewMexicoIncome;
use Appleton\Taxes\Countries\US\NorthCarolina\NorthCarolinaIncome\NorthCarolinaIncome;
use Appleton\Taxes\Countries\US\Wisconsin\WisconsinIncome\WisconsinIncome;
use Appleton\Taxes\Models\Countries\US\Alabama\AlabamaIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\Arizona\ArizonaIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\Colorado\ColoradoIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\Georgia\GeorgiaIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\FederalIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\NewMexico\NewMexicoIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\NorthCarolina\NorthCarolinaIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\Wisconsin\WisconsinIncomeTaxInformation;
use Appleton\Taxes\Providers\TaxesServiceProvider;
Expand Down Expand Up @@ -86,6 +88,12 @@ public function setUp()
'filing_status' => GeorgiaIncome::FILING_SINGLE,
], $this->user);

NewMexicoIncomeTaxInformation::createForUser([
'additional_withholding' => 0,
'exemptions' => 0,
'filing_status' => NewMexicoIncome::FILING_SINGLE,
], $this->user);

NorthCarolinaIncomeTaxInformation::createForUser([
'additional_withholding' => 0,
'dependents' => 0,
Expand Down Expand Up @@ -139,6 +147,7 @@ protected function getLocation($name)
'us.colorado' => [39.7640021, -105.1352965],
'us.georgia' => [33.7490, -84.3880],
'us.florida' => [27.6648, -81.5158],
'us.new_mexico' => [34.5199, -105.8701],
'us.north_carolina' => [35.7596, -79.0193],
'us.tennessee' => [35.5175, -86.5804],
'us.texas' => [31.9686, -99.9018],
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Countries/US/Arizona/ArizonaIncomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Appleton\Taxes\Countries\US\Arizona\ArizonaIncome;

use Appleton\Taxes\Models\Countries\US\Alabama\AlabamaIncomeTaxInformation;
use Appleton\Taxes\Models\Countries\US\Arizona\ArizonaIncomeTaxInformation;
use Carbon\Carbon;

Expand All @@ -24,7 +23,7 @@ public function testArizonaIncome()
$taxes->setPayPeriods(52);
});

$this->assertSame(1.30, $results->getTax(ArizonaIncome::class));
$this->assertSame(1.26, $results->getTax(ArizonaIncome::class));

ArizonaIncomeTaxInformation::forUser($this->user)->update(['percentage_withheld' => 4.2]);

Expand All @@ -36,5 +35,6 @@ public function testArizonaIncome()
$taxes->setPayPeriods(52);
});

$this->assertSame(4.2, $results->getTax(ArizonaIncome::class));
}}
$this->assertSame(4.08, $results->getTax(ArizonaIncome::class));
}
}
6 changes: 3 additions & 3 deletions tests/Unit/Countries/US/Arizona/ArizonaUnemploymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp()
);
}

public function testGeorgiaUnemployment()
public function testArizonaUnemployment()
{
$results = $this->taxes->calculate(function ($taxes) {
$taxes->setHomeLocation($this->getLocation('us.arizona'));
Expand All @@ -28,7 +28,7 @@ public function testGeorgiaUnemployment()
$this->assertSame(46.00, $results->getTax(ArizonaUnemployment::class));
}

public function testGeorgiaUnemploymentWithTaxRate()
public function testArizonaUnemploymentWithTaxRate()
{
config(['taxes.rates.us.arizona.unemployment' => 0.024]);

Expand All @@ -42,7 +42,7 @@ public function testGeorgiaUnemploymentWithTaxRate()
$this->assertSame(55.20, $results->getTax(ArizonaUnemployment::class));
}

public function testGeorgiaUnemploymentMetWageBase()
public function testArizonaUnemploymentMetWageBase()
{
$results = $this->taxes->calculate(function ($taxes) {
$taxes->setHomeLocation($this->getLocation('us.arizona'));
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Countries/US/Colorado/ColoradoIncomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testColoradoIncome()
$taxes->setPayPeriods(52);
});

$this->assertSame(44.00, $results->getTax(ColoradoIncome::class));
$this->assertSame(38.00, $results->getTax(ColoradoIncome::class));

ColoradoIncomeTaxInformation::forUser($this->user)->update(['filing_status' => ColoradoIncome::FILING_MARRIED]);

Expand All @@ -38,7 +38,7 @@ public function testColoradoIncome()
$taxes->setPayPeriods(52);
});

$this->assertSame(39.00, $results->getTax(ColoradoIncome::class));
$this->assertSame(33.00, $results->getTax(ColoradoIncome::class));
}

public function testIncomeExemptions()
Expand All @@ -53,6 +53,6 @@ public function testIncomeExemptions()
$taxes->setPayPeriods(52);
});

$this->assertSame(41.00, $results->getTax(ColoradoIncome::class));
$this->assertSame(35.00, $results->getTax(ColoradoIncome::class));
}
}
Loading

0 comments on commit 608c6b4

Please sign in to comment.