Skip to content

Commit

Permalink
add test for obtain the sat code for tax
Browse files Browse the repository at this point in the history
  • Loading branch information
Yorchi committed Mar 18, 2018
1 parent daed8ac commit 14915fe
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Taxes/IEPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class IEPS extends Tax implements TaxContract
{
/**
* Code from the SAT Catalog.
*
* @var string
*/
protected $code = '003';

/**
* Calculate tax percentage of a given amount.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Taxes/ISR.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class ISR extends Tax implements TaxContract
{
/**
* Code from the SAT Catalog.
*
* @var string
*/
protected $code = '001';

/**
* Calculate tax percentage of a given amount.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Taxes/IVA.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class IVA extends Tax implements TaxContract
{
/**
* Code from the SAT Catalog.
*
* @var string
*/
protected $code = '002';

/**
* Calculate tax percentage of a given amount.
*
Expand Down
4 changes: 4 additions & 0 deletions src/Taxes/Tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function __get($property)
return $this->getTaxName();
}

if (property_exists($this, $property)) {
return $this->{$property};
}

throw new \Exception('Property not exists');
}

Expand Down
12 changes: 12 additions & 0 deletions tests/TaxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,16 @@ public function testCanGetPercentageByType()
$ieps = new IEPS($retention);
$this->assertEquals(-0.08, $ieps->percentage());
}

public function testCanGetFiscalCode()
{
$iva = new IVA();
$this->assertEquals('002', $iva->code);

$isr = new ISR();
$this->assertEquals('001', $isr->code);

$ieps = new IEPS();
$this->assertEquals('003', $ieps->code);
}
}

0 comments on commit 14915fe

Please sign in to comment.