Skip to content

Commit

Permalink
Remove deprecated AllowanceReasonCode (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienPillevesse authored Oct 15, 2024
1 parent 15090e3 commit 657c4fa
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
10 changes: 5 additions & 5 deletions src/BusinessTermsGroup/DocumentLevelAllowance.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tiime\EN16931\BusinessTermsGroup;

use Tiime\EN16931\DataType\AllowanceReasonCode;
use Tiime\EN16931\Codelist\AllowanceReasonCodeUNTDID5189;
use Tiime\EN16931\DataType\VatCategory;
use Tiime\EN16931\SemanticDataType\Amount;
use Tiime\EN16931\SemanticDataType\Percentage;
Expand Down Expand Up @@ -57,16 +57,16 @@ class DocumentLevelAllowance
* BT-98
* The reason for the document level allowance, expressed as a code.
*/
private ?AllowanceReasonCode $reasonCode;
private ?AllowanceReasonCodeUNTDID5189 $reasonCode;

public function __construct(
float $amount,
VatCategory $vatCategoryCode,
?string $reason = null,
?AllowanceReasonCode $reasonCode = null,
?AllowanceReasonCodeUNTDID5189 $reasonCode = null,
?float $vatRate = null
) {
if ((!is_string($reason) || empty($reason)) && !$reasonCode instanceof AllowanceReasonCode) {
if ((!is_string($reason) || empty($reason)) && !$reasonCode instanceof AllowanceReasonCodeUNTDID5189) {
throw new \Exception('@todo');
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public function getReason(): ?string
return $this->reason;
}

public function getReasonCode(): ?AllowanceReasonCode
public function getReasonCode(): ?AllowanceReasonCodeUNTDID5189
{
return $this->reasonCode;
}
Expand Down
10 changes: 5 additions & 5 deletions src/BusinessTermsGroup/InvoiceLineAllowance.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Tiime\EN16931\BusinessTermsGroup;

use Tiime\EN16931\DataType\AllowanceReasonCode;
use Tiime\EN16931\Codelist\AllowanceReasonCodeUNTDID5189;
use Tiime\EN16931\SemanticDataType\Amount;
use Tiime\EN16931\SemanticDataType\Percentage;

Expand Down Expand Up @@ -44,11 +44,11 @@ class InvoiceLineAllowance
* BT-140
* The reason for the Invoice line allowance, expressed as a code.
*/
private ?AllowanceReasonCode $reasonCode;
private ?AllowanceReasonCodeUNTDID5189 $reasonCode;

public function __construct(float $amount, ?string $reason = null, ?AllowanceReasonCode $reasonCode = null)
public function __construct(float $amount, ?string $reason = null, ?AllowanceReasonCodeUNTDID5189 $reasonCode = null)
{
if ((!is_string($reason) || empty($reason)) && !$reasonCode instanceof AllowanceReasonCode) {
if ((!is_string($reason) || empty($reason)) && !$reasonCode instanceof AllowanceReasonCodeUNTDID5189) {
throw new \Exception('@todo');
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public function getReason(): ?string
return $this->reason;
}

public function getReasonCode(): ?AllowanceReasonCode
public function getReasonCode(): ?AllowanceReasonCodeUNTDID5189
{
return $this->reasonCode;
}
Expand Down
32 changes: 16 additions & 16 deletions tests/BusinessRulesConditionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\DataType\AllowanceReasonCode;
use Tiime\EN16931\Codelist\AllowanceReasonCodeUNTDID5189;
use Tiime\EN16931\DataType\ChargeReasonCode;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
Expand Down Expand Up @@ -738,7 +738,7 @@ public static function provideBrCo11Success(): \Generator
)
],
'documentLevelAllowances' => [
new DocumentLevelAllowance(100, VatCategory::SERVICE_OUTSIDE_SCOPE_OF_TAX, reasonCode: AllowanceReasonCode::STANDARD)
new DocumentLevelAllowance(100, VatCategory::SERVICE_OUTSIDE_SCOPE_OF_TAX, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD)
]
];
yield 'BR-CO-11 Success #2' => [
Expand All @@ -765,7 +765,7 @@ public static function provideBrCo11Success(): \Generator
)
],
'documentLevelAllowances' => [
new DocumentLevelAllowance(0, VatCategory::SERVICE_OUTSIDE_SCOPE_OF_TAX, reasonCode: AllowanceReasonCode::STANDARD)
new DocumentLevelAllowance(0, VatCategory::SERVICE_OUTSIDE_SCOPE_OF_TAX, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD)
]
];
yield 'BR-CO-11 Success #3' => [
Expand Down Expand Up @@ -793,8 +793,8 @@ public static function provideBrCo11Success(): \Generator
)
],
'documentLevelAllowances' => [
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20),
new DocumentLevelAllowance(900.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20)
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20),
new DocumentLevelAllowance(900.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20)
]
];
}
Expand Down Expand Up @@ -858,7 +858,7 @@ public static function provideBrCo11Error(): \Generator
sumOfAllowancesOnDocumentLevel: 1000.00
),
'documentLevelAllowances' => [
new DocumentLevelAllowance(0.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20)
new DocumentLevelAllowance(0.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20)
]
];
yield 'BR-CO-11 Error #2' => [
Expand All @@ -872,8 +872,8 @@ public static function provideBrCo11Error(): \Generator
sumOfAllowancesOnDocumentLevel: 1000.00
),
'documentLevelAllowances' => [
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20),
new DocumentLevelAllowance(1000.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20)
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20),
new DocumentLevelAllowance(1000.0, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20)
]
];
}
Expand Down Expand Up @@ -2024,7 +2024,7 @@ public function brCo20_error(): void
* @testdox BR-CO-21 : Each Document level allowance (BG-20) shall contain a Document level allowance reason (BT-97) or a Document level allowance reason code (BT-98), or both.
* @dataProvider provideBrCo21_success
*/
public function brCo21_success(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function brCo21_success(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$documentLevelAllowance = new DocumentLevelAllowance(14, VatCategory::STANDARD_RATE, $reason, $reasonCode, vatRate: 20);

Expand All @@ -2041,11 +2041,11 @@ public static function provideBrCo21_success(): \Generator
];
yield 'Document level allowance reason code (BT-98) is present' => [
'reason' => null,
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
];
yield 'Document level allowance reason (BT-97) and Document level allowance reason code (BT-98) are present' => [
'reason' => 'Reason',
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
];
}

Expand All @@ -2054,7 +2054,7 @@ public static function provideBrCo21_success(): \Generator
* @testdox BR-CO-21 : Each Document level allowance (BG-20) shall contain a Document level allowance reason (BT-97) or a Document level allowance reason code (BT-98), or both.
* @dataProvider provideBrCo21_error
*/
public function brCo21_error(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function brCo21_error(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down Expand Up @@ -2132,7 +2132,7 @@ public static function provideBrCo22_error(): \Generator
* @testdox BR-CO-23 : Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.
* @dataProvider provideBrCo23_success
*/
public function brCo23_success(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function brCo23_success(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$invoiceLineAllowance = new InvoiceLineAllowance(14, $reason, $reasonCode);

Expand All @@ -2149,11 +2149,11 @@ public static function provideBrCo23_success(): \Generator
];
yield 'Invoice line allowance reason code (BT-140) is present' => [
'reason' => null,
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
];
yield 'Invoice line allowance reason (BT-139) and Invoice line allowance reason code (BT-140) are present' => [
'reason' => 'Reason',
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
];
}

Expand All @@ -2162,7 +2162,7 @@ public static function provideBrCo23_success(): \Generator
* @testdox BR-CO-23 : Each Invoice line allowance (BG-27) shall contain an Invoice line allowance reason (BT-139) or an Invoice line allowance reason code (BT-140), or both.
* @dataProvider provideBrCo23_error
*/
public function brCo23_error(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function brCo23_error(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$this->expectException(\Exception::class);

Expand Down
18 changes: 9 additions & 9 deletions tests/BusinessRulesIntegrityConstraintsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Tiime\EN16931\BusinessTermsGroup\PrecedingInvoice;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\DataType\AllowanceReasonCode;
use Tiime\EN16931\Codelist\AllowanceReasonCodeUNTDID5189;
use Tiime\EN16931\DataType\ChargeReasonCode;
use Tiime\EN16931\DataType\ElectronicAddressScheme;
use Tiime\EN16931\DataType\Identifier\ElectronicAddressIdentifier;
Expand Down Expand Up @@ -759,7 +759,7 @@ public function br33CaseWithoutReasonOrCode(): void
* @testdox BR-33 [cases with at least a reason or code] : Each document level allowance shall have a document level allowance reason or a document level allowance reason code
* @dataProvider provideBR33ReasonAndCodeCombinations
*/
public function br33CasesWithReasonAndCodeCombinations(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function br33CasesWithReasonAndCodeCombinations(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$allowance = new DocumentLevelAllowance(1, VatCategory::STANDARD_RATE, $reason, $reasonCode, vatRate: 20);

Expand All @@ -768,7 +768,7 @@ public function br33CasesWithReasonAndCodeCombinations(?string $reason, ?Allowan
}

/**
* @return array<string, array{reason: ?string, reasonCode: ?AllowanceReasonCode}>
* @return array<string, array{reason: ?string, reasonCode: ?AllowanceReasonCodeUNTDID5189}>
*/
public static function provideBR33ReasonAndCodeCombinations(): array
{
Expand All @@ -779,11 +779,11 @@ public static function provideBR33ReasonAndCodeCombinations(): array
],
'with reason, with code' => [
'reason' => 'Hoobastank',
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
],
'without reason, with code' => [
'reason' => null,
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
],
];
}
Expand Down Expand Up @@ -883,7 +883,7 @@ public function br42CaseWithoutReasonOrCode(): void
* @testdox BR-42 [cases with at least a reason or code] : Each invoice line allowance shall have an invoice line allowance reason or an invoice line allowance reason code
* @dataProvider provideBR42ReasonAndCodeCombinations
*/
public function br42CasesWithReasonAndCodeCombinations(?string $reason, ?AllowanceReasonCode $reasonCode): void
public function br42CasesWithReasonAndCodeCombinations(?string $reason, ?AllowanceReasonCodeUNTDID5189 $reasonCode): void
{
$allowance = new InvoiceLineAllowance(1, $reason, $reasonCode);

Expand All @@ -892,7 +892,7 @@ public function br42CasesWithReasonAndCodeCombinations(?string $reason, ?Allowan
}

/**
* @return array<string, array{reason: ?string, reasonCode: ?AllowanceReasonCode}>
* @return array<string, array{reason: ?string, reasonCode: ?AllowanceReasonCodeUNTDID5189}>
*/
public static function provideBR42ReasonAndCodeCombinations(): array
{
Expand All @@ -903,11 +903,11 @@ public static function provideBR42ReasonAndCodeCombinations(): array
],
'with reason, with code' => [
'reason' => 'Hoobastank',
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
],
'without reason, with code' => [
'reason' => null,
'reasonCode' => AllowanceReasonCode::STANDARD
'reasonCode' => AllowanceReasonCodeUNTDID5189::STANDARD
],
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/BusinessRulesVatRulesBRSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativeParty;
use Tiime\EN16931\BusinessTermsGroup\SellerTaxRepresentativePostalAddress;
use Tiime\EN16931\BusinessTermsGroup\VatBreakdown;
use Tiime\EN16931\DataType\AllowanceReasonCode;
use Tiime\EN16931\Codelist\AllowanceReasonCodeUNTDID5189;
use Tiime\EN16931\DataType\CountryAlpha2Code;
use Tiime\EN16931\DataType\CurrencyCode;
use Tiime\EN16931\DataType\Identifier\InvoiceIdentifier;
Expand Down Expand Up @@ -128,7 +128,7 @@ public static function provideBrS1Success(): \Generator
),
],
'documentLevelAllowances' => [
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCode::STANDARD, vatRate: 20)
new DocumentLevelAllowance(100, VatCategory::STANDARD_RATE, reasonCode: AllowanceReasonCodeUNTDID5189::STANDARD, vatRate: 20)
],
'documentLevelCharges' => [],
'vatBreakdowns' => [
Expand Down

0 comments on commit 657c4fa

Please sign in to comment.