Refactor CurrencyRateForm and PayVisaMasterPaymentAction: streamline component definitions, enhance layout with fieldsets, and update Turkish translations for payment-related terms.
This commit is contained in:
@@ -13,27 +13,27 @@ class CurrencyRateForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('currency_from')
|
||||
->label(__('Currency from'))
|
||||
->native(false)
|
||||
->searchable()
|
||||
->options(CurrencyRate::currencies())
|
||||
->rules('required')
|
||||
->belowLabel('1 möçberi'),
|
||||
Select::make('currency_from')
|
||||
->label(__('Currency from'))
|
||||
->native(false)
|
||||
->searchable()
|
||||
->options(CurrencyRate::currencies())
|
||||
->rules('required')
|
||||
->belowLabel('1 möçberi'),
|
||||
|
||||
Select::make('currency_to')
|
||||
->label(__('Currency to'))
|
||||
->native(false)
|
||||
->searchable()
|
||||
->options(CurrencyRate::currencies())
|
||||
->rules('required')
|
||||
->belowLabel('1 möçberi'),
|
||||
Select::make('currency_to')
|
||||
->label(__('Currency to'))
|
||||
->native(false)
|
||||
->searchable()
|
||||
->options(CurrencyRate::currencies())
|
||||
->rules('required')
|
||||
->belowLabel('1 möçberi'),
|
||||
|
||||
TextInput::make('value')
|
||||
->label(__('Currency value'))
|
||||
->required()
|
||||
->numeric()
|
||||
->belowLabel('Bitin däl sanlary "." bilen ýazmaly'),
|
||||
TextInput::make('value')
|
||||
->label(__('Currency value'))
|
||||
->required()
|
||||
->numeric()
|
||||
->belowLabel('Bitin däl sanlary "." bilen ýazmaly'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterSettings;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class VisaMasterSettingsForm
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Modules\CurrencyRate\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -13,22 +13,23 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
class CurrencyRate extends Model
|
||||
class CurrencyRate extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected $table = 'currency_rates';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the user's first name.
|
||||
*/
|
||||
protected function name(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => $this->currency_from . '-' . $this->currency_to,
|
||||
get: fn () => $this->currency_from.'-'.$this->currency_to,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
|
||||
@@ -8,14 +8,15 @@ use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterSettings;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
|
||||
class PayVisaMasterPaymentAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('pay_visa_master_payment')
|
||||
->label(__('Make payment'))
|
||||
->label(sprintf('%s %s', __('Make payment for:'), today()->translatedFormat('F')))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->modal()
|
||||
->schema(function () {
|
||||
@@ -32,86 +33,66 @@ class PayVisaMasterPaymentAction
|
||||
$max_value = number_format($usd_to_tmt * 250, 2);
|
||||
|
||||
return [
|
||||
Section::make('Customer Information')
|
||||
->schema([
|
||||
TextEntry::make('usd_to_tmt')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('1 USD = %s TMT', $usd_to_tmt)),
|
||||
Fieldset::make(__('Tax'))
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'md' => 2,
|
||||
'xl' => 3,
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('usd_to_tmt')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('1 USD = %s TMT', $usd_to_tmt)),
|
||||
|
||||
TextEntry::make('bank_fee')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('Bankyň tutumy: %s TMT', $bank_fee)),
|
||||
TextEntry::make('bank_fee')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('Bankyň tutumy: %s TMT', $bank_fee)),
|
||||
|
||||
TextEntry::make('gbus_fee')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('GBÜS tutumy: %s TMT', $gbus_fee)),
|
||||
]),
|
||||
TextEntry::make('gbus_fee')
|
||||
->extraAttributes(['class' => 'uppercase tracking-wide font-bold text-xs'])
|
||||
->label(sprintf('GBÜS tutumy: %s TMT', $gbus_fee)),
|
||||
]),
|
||||
|
||||
Fieldset::make()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'md' => 2,
|
||||
'xl' => 3,
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('payment_amount')
|
||||
->label(sprintf('%s (%s)', __('Payment amount'), __('TMT')))
|
||||
->required()
|
||||
->numeric()
|
||||
->maxValue($max_value)
|
||||
->helperText(sprintf('Iň ýokary möçberi: %s TMT', $max_value))
|
||||
->live()
|
||||
->afterStateUpdated(function (Set $set, ?string $state) use ($usd_to_tmt) {
|
||||
if (! $state || $state === 0 || $state === '') {
|
||||
$set('usd_rate', '');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$usd_rate = number_format($state / $usd_to_tmt, 2, '.', '');
|
||||
$total_amount = floatval(number_format($state, 2, '.', '')) + 23;
|
||||
|
||||
$set('usd_rate', $usd_rate.' USD');
|
||||
$set('total_amount', $total_amount.' TMT');
|
||||
}),
|
||||
|
||||
TextEntry::make('usd_rate')
|
||||
->label(__('USD ekwalendi')),
|
||||
|
||||
TextEntry::make('total_amount')
|
||||
->label(__('Total amount')),
|
||||
]),
|
||||
|
||||
TextInput::make(__('Töleg aý'), 'month')
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->default(today()->translatedFormat('F')),
|
||||
];
|
||||
|
||||
// Text::make(sprintf('%s (%s)', __('Töleg möçberi'), __('TMT')), 'payment_amount')
|
||||
// ->fullWidth()
|
||||
// ->required()
|
||||
// ->rules('required', 'numeric', 'max:'.$max_value)
|
||||
// ->help("Iň ýokary möçberi: {$max_value} TMT"),
|
||||
|
||||
// Text::make(__('USD ekwalendi'), 'usd_rate')
|
||||
// ->fullWidth()
|
||||
// ->readonly()
|
||||
// ->dependsOn('payment_amount', function (Text $field, NovaRequest $request, FormData $formData) use ($usd_to_tmt) {
|
||||
// $payment_amount = $formData->get('payment_amount');
|
||||
|
||||
// if ($payment_amount) {
|
||||
// $field->setValue(number_format($payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
// } else {
|
||||
// $field->setValue('');
|
||||
// }
|
||||
// }),
|
||||
|
||||
// Hidden::make('usd_payment')
|
||||
// ->dependsOn('payment_amount', function (Hidden $field, NovaRequest $request, FormData $formData) use ($usd_to_tmt) {
|
||||
// $payment_amount = $formData->get('payment_amount');
|
||||
|
||||
// if ($payment_amount) {
|
||||
// $field->setValue(number_format($payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
// } else {
|
||||
// $field->setValue('');
|
||||
// }
|
||||
// }),
|
||||
|
||||
// Text::make(__('Jemi (TMT)'), 'total_amount')
|
||||
// ->fullWidth()
|
||||
// ->readonly()
|
||||
// ->dependsOn('payment_amount', function ($field, $request, $formData) {
|
||||
// $payment_amount = $formData->get('payment_amount');
|
||||
|
||||
// if ($payment_amount) {
|
||||
// $field->setValue(
|
||||
// floatval(number_format($payment_amount, 2, '.', '')) + 23
|
||||
// );
|
||||
// } else {
|
||||
// $field->setValue('');
|
||||
// }
|
||||
// }),
|
||||
|
||||
// Heading::make(Blade::render(<<<HTML
|
||||
// <div class="w-full border text-left appearance-none rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 relative inline-flex items-center justify-center shadow h-9 px-3 bg-primary-500 border-primary-500 text-white dark:text-gray-900">
|
||||
// <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6 mr-2">
|
||||
// <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
// </svg>
|
||||
// <span>$payment_warning_text->value</span>
|
||||
// </div>
|
||||
// HTML))->asHtml(),
|
||||
// ];
|
||||
})
|
||||
->action(function (array $data, VisaMasterPaymentOrder $record): void {
|
||||
// $record->author()->associate($data['authorId']);
|
||||
// $record->save();
|
||||
})
|
||||
->modalFooterActions([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Modules\VisaMasterPaymentOrder\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $display_name
|
||||
|
||||
@@ -711,5 +711,8 @@
|
||||
"Currency value": "Kursy",
|
||||
"Currency rates": "Walýuta kurslary",
|
||||
"Warning text": "Duýduruş teksti",
|
||||
"Content": "Mazmuny"
|
||||
"Content": "Mazmuny",
|
||||
"Payment month": "Töleg aýy",
|
||||
"Make payment for:": "Töleg üçin:",
|
||||
"Payment amount": "Töleg möçberi"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user