Skip to content

Commit

Permalink
Refactor filing status
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard McDaniel committed Jul 29, 2017
1 parent 5534512 commit fbe2ff8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 28 deletions.
6 changes: 6 additions & 0 deletions src/Countries/US/Alabama/AlabamaIncome/AlabamaIncome.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ abstract class AlabamaIncome extends BaseIncome
{
const TYPE = 'state';
const WITHHELD = true;

const FILING_ZERO = 0;
const FILING_SINGLE = 1;
const FILING_HEAD_OF_HOUSEHOLD = 2;
const FILING_MARRIED = 3;
const FILING_SEPERATE = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

class AlabamaIncome extends BaseAlabamaIncome
{
const FILING_ZERO = 0;
const FILING_SINGLE = 1;
const FILING_HEAD_OF_HOUSEHOLD = 2;
const FILING_MARRIED = 3;
const FILING_SEPERATE = 4;

const SUPPLEMENTAL_TAX_RATE = 0.05;

const SINGLE_BRACKETS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@

class AlabamaIncomeTaxInformation extends BaseTaxInformationModel
{
const FILING_ZERO = 0;
const FILING_SINGLE = 1;
const FILING_HEAD_OF_HOUSEHOLD = 2;
const FILING_MARRIED = 3;
const FILING_SEPERATE = 4;

protected $config_name = 'taxes.tables.us.alabama.alabama_income_tax_information';

public static function getDefault()
{
$tax_information = new self();
$tax_information->dependents = 0;
$tax_information->filing_status = static::FILING_SINGLE;
$tax_information->filing_status = AlabamaIncome::FILING_SINGLE;
return $tax_information;
}

Expand Down
8 changes: 1 addition & 7 deletions src/Models/Countries/US/FederalIncomeTaxInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@

class FederalIncomeTaxInformation extends BaseTaxInformationModel
{
const FILING_SINGLE = 0;
const FILING_WIDOW = 1;
const FILING_HEAD_OF_HOUSEHOLD = 2;
const FILING_MARRIED = 3;
const FILING_SEPERATE = 4;

protected $config_name = 'taxes.tables.us.federal_income_tax_information';

public static function getDefault()
{
$tax_information = new self();
$tax_information->exemptions = 0;
$tax_information->filing_status = static::FILING_SINGLE;
$tax_information->filing_status = FederalIncome::FILING_SINGLE;
$tax_information->non_resident_alien = false;
return $tax_information;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function setUp()
FederalIncomeTaxInformation::createForUser([
'additional_withholding' => 0,
'exemptions' => 0,
'filing_status' => FederalIncomeTaxInformation::FILING_SINGLE,
'filing_status' => FederalIncome::FILING_SINGLE,
'non_resident_alien' => false,
], $this->user);

AlabamaIncomeTaxInformation::createForUser([
'additional_withholding' => 0,
'dependents' => 0,
'filing_status' => AlabamaIncomeTaxInformation::FILING_SINGLE,
'filing_status' => AlabamaIncome::FILING_SINGLE,
], $this->user);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Countries/US/Alabama/AlabamaIncomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testAlabamaIncomeNonNegative()

public function testAlabamaIncomeWithNoPersonalExemption()
{
AlabamaIncomeTaxInformation::forUser($this->user)->update(['filing_status' => AlabamaIncomeTaxInformation::FILING_ZERO]);
AlabamaIncomeTaxInformation::forUser($this->user)->update(['filing_status' => AlabamaIncome::FILING_ZERO]);

$results = $this->taxes->calculate(function ($taxes) {
$taxes->setWorkLocation($this->getLocation('us.alabama'));
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Countries/US/FederalIncomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testNoTaxesOwed()

$this->assertSame(0.0, $results->getTax(FederalIncome::class));

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

$results = $this->taxes->calculate(function ($taxes) {
$taxes->setWorkLocation($this->getLocation('us'));
Expand All @@ -58,7 +58,7 @@ public function testTaxesOwed()

$this->assertSame(0.10, $results->getTax(FederalIncome::class));

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

$results = $this->taxes->calculate(function ($taxes) {
$taxes->setWorkLocation($this->getLocation('us'));
Expand All @@ -83,7 +83,7 @@ public function testAdditionalWithholding()

FederalIncomeTaxInformation::forUser($this->user)->update([
'additional_withholding' => 20,
'filing_status' => FederalIncomeTaxInformation::FILING_MARRIED
'filing_status' => FederalIncome::FILING_MARRIED
]);

$results = $this->taxes->calculate(function ($taxes) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Models/TaxInformationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public function testCreateForUser()
$federal_income_tax_information = TaxInformation::forUser($this->user)->isTypeOf(FederalIncomeTaxInformation::class)->first()->information;

$this->assertSame(0, $federal_income_tax_information->exemptions);
$this->assertSame(FederalIncomeTaxInformation::FILING_SINGLE, $federal_income_tax_information->filing_status);
$this->assertSame(FederalIncome::FILING_SINGLE, $federal_income_tax_information->filing_status);
$this->assertSame(false, $federal_income_tax_information->non_resident_alien);

$federal_income_tax_information = FederalIncomeTaxInformation::forUser($this->user)->first();

$this->assertSame(0, $federal_income_tax_information->exemptions);
$this->assertSame(FederalIncomeTaxInformation::FILING_SINGLE, $federal_income_tax_information->filing_status);
$this->assertSame(FederalIncome::FILING_SINGLE, $federal_income_tax_information->filing_status);
$this->assertSame(false, $federal_income_tax_information->non_resident_alien);
}
}

0 comments on commit fbe2ff8

Please sign in to comment.