calculation
This commit is contained in:
@@ -2092,8 +2092,10 @@ final class Router
|
||||
$resolvedBonusUnit = $resolvedBonusValue !== null ? $resolvedSpeedUnit : null;
|
||||
|
||||
$purchaseCurrency = $this->optionalCurrency($input['currency'] ?? null) ?? (string) ($offer['effective_price_currency'] ?? $offer['price_currency'] ?? $offer['base_price_currency'] ?? '');
|
||||
if ($paymentType === 'crypto' || !$isAutoRenew) {
|
||||
if ($paymentType === 'crypto') {
|
||||
$purchaseCurrency = $cryptoCurrency;
|
||||
} elseif ($purchaseCurrency === '' || $this->isCryptoCurrencyCode($purchaseCurrency)) {
|
||||
$purchaseCurrency = $this->requiredCurrency($settings['report_currency'] ?? 'EUR', 'report_currency');
|
||||
}
|
||||
$purchaseCost = $this->optionalDecimal($input['total_cost_amount'] ?? null);
|
||||
if ($purchaseCost === null) {
|
||||
@@ -2112,6 +2114,21 @@ final class Router
|
||||
$purchasedAt = array_key_exists('purchased_at', $input)
|
||||
? $this->requiredDateTime($input['purchased_at'], 'purchased_at', $this->projectTimezone($projectKey))
|
||||
: $this->currentTimestamp();
|
||||
$settledValueAmount = null;
|
||||
$settledValueCurrency = null;
|
||||
if ($this->isCryptoCurrencyCode($purchaseCurrency)) {
|
||||
$settledValueCurrency = $this->requiredCurrency($settings['report_currency'] ?? 'EUR', 'report_currency');
|
||||
$settledValueAmount = $purchaseCurrency === $settledValueCurrency
|
||||
? $purchaseCost
|
||||
: $this->convertMiningAssetAmount((float) $purchaseCost, $purchaseCurrency, $settledValueCurrency, $purchasedAt);
|
||||
if ($settledValueAmount === null) {
|
||||
throw new ApiException(
|
||||
'Der aktuelle Kurs fuer die Krypto-Zahlung konnte nicht ermittelt werden. Der Miner wird nicht ohne feste Bewertung gespeichert.',
|
||||
422,
|
||||
['currency' => $purchaseCurrency, 'target_currency' => $settledValueCurrency]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->repository()->purchaseMiner($projectKey, null, [
|
||||
'purchased_at' => $purchasedAt,
|
||||
@@ -2126,6 +2143,8 @@ final class Router
|
||||
'usd_reference_amount' => $offer['usd_reference_amount'] ?? null,
|
||||
'reference_price_amount' => $referencePriceAmount,
|
||||
'reference_price_currency' => $referencePriceCurrency,
|
||||
'settled_value_amount' => $settledValueAmount,
|
||||
'settled_value_currency' => $settledValueCurrency,
|
||||
'auto_renew' => $isAutoRenew ? 1 : 0,
|
||||
'note' => $this->optionalString($input['note'] ?? ($offer['note'] ?? null), 1000),
|
||||
'is_active' => 1,
|
||||
|
||||
Reference in New Issue
Block a user