From a0f8b04dec8b230b46adb4fb4534868c4e825359 Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Wed, 29 May 2024 05:12:17 +0200 Subject: [PATCH] Added method setUnitAmountDecimals to ZugferdSettings --- README.md | 62 +---------------------------------------- src/ZugferdSettings.php | 18 ++++++++---- 2 files changed, 14 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 9b55d88..2d713f3 100644 --- a/README.md +++ b/README.md @@ -101,67 +101,7 @@ For detailed eplanation you may have a look in the [examples](https://github.com ### Configuration -By means of the `ZugferdSettings` class it is possible to control various options for XML and PDF generation: - -```php -public static function getAmountDecimals(): int -``` - -Returns the currently configured number of decimal places for amount fields _(Default: 2)_. - -```php -public static function setAmountDecimals(int $amountDecimals): void -``` - -Set the number of decimal places for amount fields. - -```php -public static function getQuantityDecimals(): int -``` - -Returns the currently configured number of decimal places for quantity fields _(Default: 2)_. - -```php -public static function setQuantityDecimals(int $quantityDecimals): void -``` - -Set the number of decimal places for quantity fields. - -```php -public static function getPercentDecimals(): int -``` - -Returns the currently configured number of decimal places for percentage fields _(Default: 2)_. - -```php -public static function setPercentDecimals(int $percentDecimals): void -``` - -Set the number of decimal places for percentage fields. - -```php -public static function getDecimalSeparator(): string -``` - -Returns the currently configured character for the decimal separator. _(Default: .) - -```php -public static function setDecimalSeparator(string $decimalSeparator): void -``` - -Set the character to use as the decimal separator. - -```php -public static function getThousandsSeparator(): string -``` - -Returns the currently configured character for the thousands separator. _(Default: Empty)_ - -```php -public static function setThousandsSeparator(string $thousandsSeparator): void -``` - -Set the character to use as the thousands separator. +This library can be configured in various ways. For more information please visit our [Wiki](https://github.com/horstoeko/zugferd/wiki/Configuration). ### Reading a xml file diff --git a/src/ZugferdSettings.php b/src/ZugferdSettings.php index 531caed..6f4a59f 100644 --- a/src/ZugferdSettings.php +++ b/src/ZugferdSettings.php @@ -76,11 +76,7 @@ class ZugferdSettings * * @var array */ - protected static $specialDecimalPlacesMaps = [ - //Examples: - //'/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeAgreement/ram:GrossPriceProductTradePrice/ram:ChargeAmount' => 2, - //'/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount' => 2, - ]; + protected static $specialDecimalPlacesMaps = []; /** * Get the number of decimals to use for amount values @@ -275,6 +271,18 @@ public static function addSpecialDecimalPlacesMap(string $nodePath, int $default static::$specialDecimalPlacesMaps[$nodePath] = $defaultDecimalPlaces; } + /** + * Set the number of decimals to use for unit single amount (unit prices) values + * + * @param integer $amountDecimals + * @return void + */ + public static function setUnitAmountDecimals(int $amountDecimals): void + { + ZugferdSettings::addSpecialDecimalPlacesMap('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeAgreement/ram:GrossPriceProductTradePrice/ram:ChargeAmount', $amountDecimals); + ZugferdSettings::addSpecialDecimalPlacesMap('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice/ram:ChargeAmount', $amountDecimals); + } + /** * Get root directory *