Skip to content

Facades

Richard McDaniel edited this page Feb 8, 2018 · 1 revision
Facade Description
Taxes This facade is how other code bases use this library to easily calculate taxes. The calculate method takes a closure which can be used to provide various payroll and tax information. The taxes calculated are based on the information, work location and user provided.

Example Usage:

FederalIncomeTaxInformation::createForUser([
    'additional_withholding' => 0,
    'exemptions' => 0,
    'filing_status' => FederalIncome::FILING_SINGLE,
    'non_resident_alien' => false,
], $this->user);

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

$results = $this->taxes->calculate(function ($taxes) {
    $taxes->setWorkLocation([33.5207, -86.8025]);
    $taxes->setUser($this->user);
    $taxes->setEarnings(66.68);
    $taxes->setSupplementalEarnings(6.68);
    $taxes->setYtdEarnings(200000);
    $taxes->setPayPeriods(260);
    $taxes->setDate(Carbon::now()->addMonth());
});

$this->assertSame(7.55, $results->getTax(FederalIncome::class));
$this->assertSame(1.57, $results->getTax(Medicare::class));
$this->assertSame(0.97, $results->getTax(MedicareEmployer::class));
$this->assertSame(2.03, $results->getTax(AlabamaIncome::class));
$this->assertSame(0.0, $results->getTax(AlabamaUnemployment::class));
$this->assertSame(0.67, $results->getTax(BirminghamOccupational::class));
Clone this wiki locally