Skip to content

Commit

Permalink
chore: adjust error messages and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zembrowski committed Jul 9, 2024
1 parent 29f6918 commit 43cf7d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
Formats bidirectionally German tax numbers originating from tax office letters (German: Bescheidformat) or the ELSTER-Format (German: bundeseinheitliches ELSTER-Steuernummerformat) and validates it.

Based on the [official ELSTER documentation](https://download.elster.de/download/schnittstellen/Pruefung_der_Steuer_und_Steueridentifikatsnummer.pdf) (chapters: 3-7; as of 2024-03-01). Inspired by [kontist/normalize-steuernummer](https://github.com/kontist/normalize-steuernummer) and [kontist/denormalize-steuernummer](https://github.com/kontist/denormalize-steuernummer).
Based on the [official ELSTER documentation](https://download.elster.de/download/schnittstellen/Pruefung_der_Steuer_und_Steueridentifikatsnummer.pdf) (chapters: 3-7; as of 2024-06-17). Inspired by [kontist/normalize-steuernummer](https://github.com/kontist/normalize-steuernummer) and [kontist/denormalize-steuernummer](https://github.com/kontist/denormalize-steuernummer).

Hint: This package validates solely the syntax and check digit of the provided input. It does not confirm, that the provided Steuernummer was assigned to any entity. Please contact the responsible tax office in case of any doubts concerning the correctness of your Steuernummer.

## Installation

Expand Down Expand Up @@ -135,7 +137,7 @@ use Rechtlogisch\Steuernummer\Validate;
->getErrors();
// [
// 'Rechtlogisch\Steuernummer\Exceptions\InvalidElsterSteuernummerLength'
// => 'elsterSteuernummer is not 13 digits long, and is 12 digits long'
// => 'elsterSteuernummer must be 13 digits long. You provided: 12 digits.'
// ]
```

Expand All @@ -149,7 +151,7 @@ use Rechtlogisch\Steuernummer\Normalize;
->getErrors();
// [
// 'Rechtlogisch\Steuernummer\Exceptions\InvalidSteuernummerLength'
// => 'steuernummer for BE must contain exactly 10 digits, and 9 digits have been provided'
// => 'steuernummer for BE must contain exactly 10 digits. You provided: 9 digits.'
// ]
```

Expand All @@ -163,15 +165,15 @@ use Rechtlogisch\Steuernummer\Denormalize;
->getErrors();
// [
// 'Rechtlogisch\Steuernummer\Exceptions\InvalidElsterSteuernummerLength'
// => 'elsterSteuernummer is not 13 digits long, and is 12 digits long'
// => 'elsterSteuernummer must be 13 digits long. You provided: 12 digits.'
// ]
```

Hint: All `*Result::class` extend the [ResultDto](./src/Abstracts/ResultDto.php).

### Supported tax offices

By default, tax office codes (German: Bundesfinanzamtsnummer - short BUFA) included in the [ELSTER ERiC libraries](https://www.elster.de/elsterweb/infoseite/entwickler) are supported by this package. Currently, based on ERiC 39.6.4. You'll find the list in [src/Bufas.php](./src/Bufas.php).
By default, tax office codes (German: Bundesfinanzamtsnummer - short BUFA) included in the [ELSTER ERiC libraries](https://www.elster.de/elsterweb/infoseite/entwickler) are supported by this package. Currently, based on ERiC 40.1.8. You'll find the list in [src/Bufas.php](./src/Bufas.php).

The list includes test BUFAs, which are invalid in production. It is recommended to disable them in production with the following environment variable:

Expand Down
4 changes: 2 additions & 2 deletions src/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function guardElsterSteuernummer(): void
$expectedElsterSteuernummerLength = Constants::ELSTER_STEUERNUMMER_LENGTH;
$actualElsterSteuernummerLength = strlen($this->elsterSteuernummer);
if ($actualElsterSteuernummerLength !== $expectedElsterSteuernummerLength) {
throw new InvalidElsterSteuernummerLength("elsterSteuernummer is not {$expectedElsterSteuernummerLength} digits long, and is {$actualElsterSteuernummerLength} digits long");
throw new InvalidElsterSteuernummerLength("elsterSteuernummer must be {$expectedElsterSteuernummerLength} digits long. You provided: {$actualElsterSteuernummerLength} digits.");
}

$formatKey = Constants::ELSTER_STEUERNUMMER_FORMAT_KEY;
Expand Down Expand Up @@ -110,7 +110,7 @@ protected function determineFederalState(): string
$expectedBufaLength = Constants::BUFA_LENGTH;
$bufa = substr($this->elsterSteuernummer, 0, $expectedBufaLength);
if (($actualBufaLength = strlen($bufa)) < 4) {
throw new InvalidElsterSteuernummerLength("bufa in elsterSteuernummer is not {$expectedBufaLength} digits long, and is {$actualBufaLength} digits long");
throw new InvalidElsterSteuernummerLength("bufa in elsterSteuernummer must be {$expectedBufaLength} digits long. You provided: {$actualBufaLength} digits.");
}

$bufasTest = (getenv('STEUERNUMMER_PRODUCTION') === 'true') ? [] : Bufas::TEST;
Expand Down
2 changes: 1 addition & 1 deletion src/Normalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private function guardSteuernummer(): void
$actualLength = strlen($this->steuernummer);

if ($expectedLength !== $actualLength) {
throw new InvalidSteuernummerLength("steuernummer for {$this->federalState} must contain exactly {$expectedLength} digits, and {$actualLength} digits have been provided");
throw new InvalidSteuernummerLength("steuernummer for {$this->federalState} must contain exactly {$expectedLength} digits. You provided: {$actualLength} digits.");
}
}

Expand Down

0 comments on commit 43cf7d3

Please sign in to comment.