Skip to content

Commit

Permalink
Added method setUnitAmountDecimals to ZugferdSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed May 29, 2024
1 parent d5b192a commit a0f8b04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 66 deletions.
62 changes: 1 addition & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 13 additions & 5 deletions src/ZugferdSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit a0f8b04

Please sign in to comment.