diff --git a/src/External/Enums/TransactionType.php b/src/External/Enums/TransactionType.php new file mode 100644 index 000000000..d59f31194 --- /dev/null +++ b/src/External/Enums/TransactionType.php @@ -0,0 +1,13 @@ +getTaxPercent($type); + } + + $feeMinimum = null; + $feeMaximum = null; + if ($wallet instanceof TaxConstraintsInterface) { + $feeMinimum = $wallet->getMinimumTax($type); + $feeMaximum = $wallet->getMaximumTax($type); + } + + $fee = '0'; + if ($feePercent !== null) { + $fee = $this->mathService->floor( + $this->mathService->div( + $this->mathService->mul($amount, $feePercent, 0), + 100, + $this->castService->getWallet($wallet) + ->decimal_places + ) + ); + } + + if ($feeMinimum !== null && $this->mathService->compare($fee, $feeMinimum) === -1) { + $fee = $feeMinimum; + } + + if ($feeMaximum !== null && $this->mathService->compare($feeMaximum, $fee) === -1) { + $fee = $feeMaximum; + } + + return $fee; + } +} diff --git a/src/Services/TaxCollectionServiceInterface.php b/src/Services/TaxCollectionServiceInterface.php new file mode 100644 index 000000000..11ba866a4 --- /dev/null +++ b/src/Services/TaxCollectionServiceInterface.php @@ -0,0 +1,17 @@ +