This commit is contained in:
2024-10-30 17:38:21 +05:00
parent f73c17c852
commit 379f756526

View File

@@ -64,19 +64,21 @@ class MakeSberPaymentAction extends Action
public function fields(NovaRequest $request)
{
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
$usd_to_rub = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->first('value');
$rub_to_tmt = CurrencyRate::where('currency_from', 'RUB')->where('currency_to', 'TMT')->first('value');
if (! $usd_to_tmt) {
if (! $usd_to_tmt || ! $usd_to_rub || ! $rub_to_tmt) {
return [];
}
$max_value = number_format(96.05 * 250 * 0.036621, 2, '.', '');
$max_value = number_format($usd_to_rub * 250 * $rub_to_tmt, 2, '.', '');
$tvebTaxTMT = $usd_to_tmt->value * 18;
$bankTax = 120.75;
return [
Heading::make(Blade::render(<<<HTML
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt->value TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 RUB = 0.036621 TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 RUB = $rub_to_tmt TMT</h3>
<br>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">TVEB USD tutumy: 18 USD</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">TVEB tutumy TMT = $tvebTaxTMT TMT</h3>
@@ -93,9 +95,9 @@ class MakeSberPaymentAction extends Action
Text::make(__('USD ekwalendi'), 'usd_rate')
->fullWidth()
->readonly()
->dependsOn('payment_amount', function ($field, $request, $formData) {
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_rub, $rub_to_tmt) {
if ($formData->payment_amount) {
$usdValue = number_format($formData->payment_amount / (96.05 * 0.036621), 2, '.', '');
$usdValue = number_format($formData->payment_amount / ($usd_to_rub * $rub_to_tmt), 2, '.', '');
$field->setValue($usdValue);
} else {
@@ -153,10 +155,6 @@ class MakeSberPaymentAction extends Action
];
}
info([
$paymentResponse->body()
]);
OnlinePaymentHistory::create([
'online_paymantable_id' => $resource->id,
'online_paymantable_type' => SberPaymentOrder::class,