Skip to content

Commit

Permalink
Remove deprecated VatExoneration (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienPillevesse authored Oct 15, 2024
1 parent 72a41f6 commit fe19935
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 52 deletions.
10 changes: 5 additions & 5 deletions src/BusinessTermsGroup/VatBreakdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Tiime\EN16931\BusinessTermsGroup;

use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\SemanticDataType\Amount;
use Tiime\EN16931\SemanticDataType\DecimalNumber;
use Tiime\EN16931\SemanticDataType\IntegerNumber;
Expand Down Expand Up @@ -66,15 +66,15 @@ class VatBreakdown
*
* Énoncé codé expliquant pourquoi un montant est exonéré de TVA.
*/
private ?VatExoneration $vatExemptionReasonCode;
private ?VatExemptionReasonCode $vatExemptionReasonCode;

public function __construct(
float $vatCategoryTaxableAmount,
float $vatCategoryTaxAmount,
VatCategory $vatCategoryCode,
?float $vatCategoryRate = null,
?string $vatExemptionReasonText = null,
?VatExoneration $vatExemptionReasonCode = null,
?VatExemptionReasonCode $vatExemptionReasonCode = null,
) {
if ($vatCategoryCode !== VatCategory::SERVICE_OUTSIDE_SCOPE_OF_TAX xor is_float($vatCategoryRate)) {
throw new \Exception('@todo');
Expand Down Expand Up @@ -140,7 +140,7 @@ public function getVatExemptionReasonText(): ?string
return $this->vatExemptionReasonText;
}

public function getVatExemptionReasonCode(): ?VatExoneration
public function getVatExemptionReasonCode(): ?VatExemptionReasonCode
{
return $this->vatExemptionReasonCode;
}
Expand All @@ -156,7 +156,7 @@ private function checkExemptionReason(): void

$shallHaveExemptionReason = !in_array($this->vatCategoryCode, $noExemptionCategories);
$hasExemptionReason = is_string($this->vatExemptionReasonText)
|| $this->vatExemptionReasonCode instanceof VatExoneration;
|| $this->vatExemptionReasonCode instanceof VatExemptionReasonCode;

if ($shallHaveExemptionReason !== $hasExemptionReason) {
throw new \Exception('@todo BR-genericVAT-10');
Expand Down
2 changes: 1 addition & 1 deletion src/Codelist/Generator/CodelistGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function generateCodelists(
$generator->generateCodelist(className: 'ChargeReasonCodeUNTDID7161', cases: $code7161List);
$generator->generateCodelist(className: 'MimeCode', cases: $mimeList);
$generator->generateCodelist(className: 'ElectronicAddressSchemeCode', cases: $electronicAddressSchemeList);
$generator->generateCodelist(className: 'VatExemptionReasonCodeList', cases: $vatExemptionReasonCodeList);
$generator->generateCodelist(className: 'VatExemptionReasonCode', cases: $vatExemptionReasonCodeList);
$generator->generateCodelist(className: 'UnitOfMeasureCode', cases: $unitOfMeasure);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tiime\EN16931\Codelist;

enum VatExemptionReasonCodeList : string
enum VatExemptionReasonCode : string
{
case EXEMPT_BASED_ON_ARTICLE_79_POINT_C_OF_COUNCIL_DIRECTIVE_2006_112_EC = 'VATEX-EU-79-C';
case EXEMPT_BASED_ON_ARTICLE_132_OF_COUNCIL_DIRECTIVE_2006_112_EC = 'VATEX-EU-132';
Expand Down
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRAETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -31,7 +32,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRAETest extends TestCase
Expand Down Expand Up @@ -1859,7 +1859,7 @@ public static function provideBrAE9Error(): \Generator
* (or the equivalent standard text in another language).
* @dataProvider provideBrAE10Success
*/
public function brAE10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brAE10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(0, 0, VatCategory::VAT_REVERSE_CHARGE, 0, $reasonText, $reasonCode);

Expand All @@ -1870,7 +1870,7 @@ public static function provideBrAE10Success(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::REVERSE_CHARGE,
'reasonCode' => VatExemptionReasonCode::REVERSE_CHARGE,
];

yield [
Expand All @@ -1880,7 +1880,7 @@ public static function provideBrAE10Success(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::REVERSE_CHARGE,
'reasonCode' => VatExemptionReasonCode::REVERSE_CHARGE,
];
}

Expand All @@ -1891,7 +1891,7 @@ public static function provideBrAE10Success(): \Generator
* (or the equivalent standard text in another language).
* @dataProvider provideBrAE10Error
*/
public function brAE10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brAE10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -30,7 +31,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRETest extends TestCase
Expand Down Expand Up @@ -1120,7 +1120,7 @@ public static function provideBrE9Error(): \Generator
* @dataProvider provideBrE10Success
* @throws \Exception
*/
public function brE10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brE10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(0, 0, VatCategory::EXEMPT_FROM_TAX, 0, $reasonText, $reasonCode);

Expand All @@ -1131,7 +1131,7 @@ public static function provideBrE10Success(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::TRAVEL_AGENTS_VAT_SCHEME,
'reasonCode' => VatExemptionReasonCode::TRAVEL_AGENTS_VAT_SCHEME,
];

yield [
Expand All @@ -1141,7 +1141,7 @@ public static function provideBrE10Success(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::TRAVEL_AGENTS_VAT_SCHEME,
'reasonCode' => VatExemptionReasonCode::TRAVEL_AGENTS_VAT_SCHEME,
];
}

Expand All @@ -1151,7 +1151,7 @@ public static function provideBrE10Success(): \Generator
* exemption reason code (BT-121) or a VAT exemption reason text (BT-120).
* @dataProvider provideBrE10Error
*/
public function brE10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brE10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRGTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -32,7 +33,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRGTest extends TestCase
Expand Down Expand Up @@ -1018,7 +1018,7 @@ public static function provideBrG9Error(): \Generator
* "Export outside the EU" (or the equivalent standard text in another language).
* @dataProvider provideBrG10Success
*/
public function brG10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brG10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(0, 0, VatCategory::FREE_EXPORT_ITEM_TAX_NOT_CHARGED, 0, $reasonText, $reasonCode);

Expand All @@ -1029,7 +1029,7 @@ public static function provideBrG10Success(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::EXPORT_OUTSIDE_THE_EU,
'reasonCode' => VatExemptionReasonCode::EXPORT_OUTSIDE_THE_EU,
];

yield [
Expand All @@ -1039,7 +1039,7 @@ public static function provideBrG10Success(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::EXPORT_OUTSIDE_THE_EU,
'reasonCode' => VatExemptionReasonCode::EXPORT_OUTSIDE_THE_EU,
];
}

Expand All @@ -1050,7 +1050,7 @@ public static function provideBrG10Success(): \Generator
* "Export outside the EU" (or the equivalent standard text in another language).
* @dataProvider provideBrG10Error
*/
public function brG10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brG10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRICTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -34,7 +35,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRICTest extends TestCase
Expand Down Expand Up @@ -1043,7 +1043,7 @@ public static function provideBrIC9Error(): \Generator
* "Intra-community supply" (or the equivalent standard text in another language).
* @dataProvider provideBrIC10Success
*/
public function brIC10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIC10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(
0,
Expand All @@ -1061,7 +1061,7 @@ public static function provideBrIC10Success(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::INTRA_COMMUNITY_SUPPLY,
'reasonCode' => VatExemptionReasonCode::INTRA_COMMUNITY_SUPPLY,
];

yield [
Expand All @@ -1071,7 +1071,7 @@ public static function provideBrIC10Success(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::INTRA_COMMUNITY_SUPPLY,
'reasonCode' => VatExemptionReasonCode::INTRA_COMMUNITY_SUPPLY,
];
}

Expand All @@ -1082,7 +1082,7 @@ public static function provideBrIC10Success(): \Generator
* "Intra-community supply" (or the equivalent standard text in another language).
* @dataProvider provideBrIC10Error
*/
public function brIC10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIC10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRIGTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -30,7 +31,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRIGTest extends TestCase
Expand Down Expand Up @@ -1173,7 +1173,7 @@ public function brIG9(): void
* reason code (BT-121) or VAT exemption reason text (BT-120).
* @dataProvider provideBrIG10Success
*/
public function brIG10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIG10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(0, 0, VatCategory::CANARY_ISLANDS_GENERAL_INDIRECT_TAX, 0, $reasonText, $reasonCode);

Expand All @@ -1194,7 +1194,7 @@ public static function provideBrIG10Success(): \Generator
* reason code (BT-121) or VAT exemption reason text (BT-120).
* @dataProvider provideBrIG10Error
*/
public function brIG10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIG10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand All @@ -1205,7 +1205,7 @@ public static function provideBrIG10Error(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::COUNCIL_DIRECTIVE_309,
'reasonCode' => VatExemptionReasonCode::EXEMPT_BASED_ON_ARTICLE_309_OF_COUNCIL_DIRECTIVE_2006_112_EC,
];

yield [
Expand All @@ -1215,7 +1215,7 @@ public static function provideBrIG10Error(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::COUNCIL_DIRECTIVE_309,
'reasonCode' => VatExemptionReasonCode::EXEMPT_BASED_ON_ARTICLE_309_OF_COUNCIL_DIRECTIVE_2006_112_EC,
];
}
}
10 changes: 5 additions & 5 deletions tests/BusinessRulesVatRulesBRIPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\Codelist\VatExemptionReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand All @@ -30,7 +31,6 @@
use Tiime\EN16931\DataType\InvoiceTypeCode;
use Tiime\EN16931\DataType\UnitOfMeasurement;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\DataType\VatExoneration;
use Tiime\EN16931\Invoice;

class BusinessRulesVatRulesBRIPTest extends TestCase
Expand Down Expand Up @@ -1173,7 +1173,7 @@ public function brIP9(): void
* reason code (BT-121) or VAT exemption reason text (BT-120).
* @dataProvider provideBrIP10Success
*/
public function brIP10_success(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIP10_success(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$vatBreakdown = new VatBreakdown(0, 0, VatCategory::TAX_FOR_PRODUCTION_SERVICES_AND_IMPORTATION_IN_CEUTA_AND_MELILLA, 0, $reasonText, $reasonCode);

Expand All @@ -1194,7 +1194,7 @@ public static function provideBrIP10Success(): \Generator
* reason code (BT-121) or VAT exemption reason text (BT-120).
* @dataProvider provideBrIP10Error
*/
public function brIP10_error(?string $reasonText, ?VatExoneration $reasonCode): void
public function brIP10_error(?string $reasonText, ?VatExemptionReasonCode $reasonCode): void
{
$this->expectException(\Exception::class);

Expand All @@ -1205,7 +1205,7 @@ public static function provideBrIP10Error(): \Generator
{
yield [
'reasonText' => null,
'reasonCode' => VatExoneration::COUNCIL_DIRECTIVE_309,
'reasonCode' => VatExemptionReasonCode::EXEMPT_BASED_ON_ARTICLE_309_OF_COUNCIL_DIRECTIVE_2006_112_EC,
];

yield [
Expand All @@ -1215,7 +1215,7 @@ public static function provideBrIP10Error(): \Generator

yield [
'reasonText' => 'Hoobastank',
'reasonCode' => VatExoneration::COUNCIL_DIRECTIVE_309,
'reasonCode' => VatExemptionReasonCode::EXEMPT_BASED_ON_ARTICLE_309_OF_COUNCIL_DIRECTIVE_2006_112_EC,
];
}
}
Loading

0 comments on commit fe19935

Please sign in to comment.