Transfer create and edit currency rate styling..

This commit is contained in:
Cüneyt Şentürk 2021-07-28 16:13:01 +03:00
parent 1689c9139e
commit 64b640e5b3
6 changed files with 152 additions and 38 deletions

View File

@ -56,15 +56,7 @@ class Transfers extends Controller
$currency = Currency::where('code', setting('default.currency'))->first();
$file_type_mimes = explode(',', config('filesystems.mimes'));
$file_types = [];
foreach ($file_type_mimes as $mime) {
$file_types[] = '.' . $mime;
}
$file_types = implode(',', $file_types);
$file_types = $this->prepeareFileTypes();
return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currency', 'file_types'));
}
@ -148,18 +140,6 @@ class Transfers extends Controller
*/
public function edit(Transfer $transfer)
{
$transfer['from_account_id'] = $transfer->expense_transaction->account_id;
$transfer['from_currency_code'] = $transfer->expense_transaction->currency_code;
$transfer['from_account_rate'] = $transfer->expense_transaction->currency_rate;
$transfer['to_account_id'] = $transfer->income_transaction->account_id;
$transfer['to_currency_code'] = $transfer->income_transaction->currency_code;
$transfer['to_account_rate'] = $transfer->income_transaction->currency_rate;
$transfer['transferred_at'] = Date::parse($transfer->expense_transaction->paid_at)->format('Y-m-d');
$transfer['description'] = $transfer->expense_transaction->description;
$transfer['amount'] = $transfer->expense_transaction->amount;
$transfer['payment_method'] = $transfer->expense_transaction->payment_method;
$transfer['reference'] = $transfer->expense_transaction->reference;
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
$payment_methods = Modules::getPaymentMethods();
@ -168,15 +148,7 @@ class Transfers extends Controller
$currency = Currency::where('code', $account->currency_code)->first();
$file_type_mimes = explode(',', config('filesystems.mimes'));
$file_types = [];
foreach ($file_type_mimes as $mime) {
$file_types[] = '.' . $mime;
}
$file_types = implode(',', $file_types);
$file_types = $this->prepeareFileTypes();
return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currency', 'file_types'));
}
@ -287,4 +259,19 @@ class Transfers extends Controller
return $pdf->download($file_name);
}
protected function prepeareFileTypes()
{
$file_type_mimes = explode(',', config('filesystems.mimes'));
$file_types = [];
foreach ($file_type_mimes as $mime) {
$file_types[] = '.' . $mime;
}
$file_types = implode(',', $file_types);
return $file_types;
}
}

View File

@ -16,7 +16,20 @@ class Transfer extends Model
protected $table = 'transfers';
protected $appends = ['attachment'];
protected $appends = [
'attachment',
'from_account_id',
'from_currency_code',
'from_account_rate',
'to_account_id',
'to_currency_code',
'to_account_rate',
'transferred_at',
'description',
'amount',
'payment_method',
'reference',
];
/**
* Attributes that should be mass-assignable.
@ -101,6 +114,116 @@ class Transfer extends Model
return $value ?: 'banking.transfers.print_' . setting('transfer.template');
}
/**
* Get the current balance.
*
* @return int
*/
public function getFromAccountIdAttribute($value = null)
{
return $value ?: $this->expense_transaction->account_id;
}
/**
* Get the current balance.
*
* @return string
*/
public function getFromCurrencyCodeAttribute($value = null)
{
return $value ?: $this->expense_transaction->currency_code;
}
/**
* Get the current balance.
*
* @return string
*/
public function getFromAccountRateAttribute($value = null)
{
return $value ?: $this->expense_transaction->currency_rate;
}
/**
* Get the current balance.
*
* @return int
*/
public function getToAccountIdAttribute($value = null)
{
return $value ?: $this->income_transaction->account_id;
}
/**
* Get the current balance.
*
* @return string
*/
public function getToCurrencyCodeAttribute($value = null)
{
return $value ?: $this->income_transaction->currency_code;
}
/**
* Get the current balance.
*
* @return string
*/
public function getToAccountRateAttribute($value = null)
{
return $value ?: $this->income_transaction->currency_rate;
}
/**
* Get the current balance.
*
* @return date
*/
public function getTransferredAtAttribute($value = null)
{
return $value ?: $this->expense_transaction->paid_at;
}
/**
* Get the current balance.
*
* @return string
*/
public function getDescriptionAttribute($value = null)
{
return $value ?: $this->expense_transaction->description;
}
/**
* Get the current balance.
*
* @return float
*/
public function getAmountAttribute($value = null)
{
return $value ?: $this->expense_transaction->amount;
}
/**
* Get the current balance.
*
* @return string
*/
public function getPaymentMethodAttribute($value = null)
{
return $value ?: $this->expense_transaction->payment_method;
}
/**
* Get the current balance.
*
* @return string
*/
public function getReferenceAttribute($value = null)
{
return $value ?: $this->expense_transaction->reference;
}
/**
* Create a new factory instance for the model.
*

View File

@ -24,11 +24,11 @@
<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
{!! Form::hidden('from_currency_code', null, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}
{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', []) }}
{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [':disabled' => "form.from_currency_code == '" . setting('default.currency') . "'"]) }}
{!! Form::hidden('to_currency_code', null, ['id' => 'to_currency_code', 'v-model' => 'form.to_currency_code']) !!}
{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', []) }}
{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"]) }}
</div>
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], 0) }}

View File

@ -25,11 +25,11 @@
<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
{!! Form::hidden('from_currency_code', $transfer->from_currency_code, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}
{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [], $transfer->from_account_rate) }}
{{ Form::textGroup('from_account_rate', trans('transfers.from_account_rate'), 'sliders-h', [':disabled' => "form.from_currency_code == '" . setting('default.currency') . "'"], $transfer->from_account_rate) }}
{!! Form::hidden('to_currency_code', $transfer->to_currency_code, ['id' => 'to_currency_code', 'v-model' => 'form.to_currency_code']) !!}
{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [], $transfer->to_account_rate) }}
{{ Form::textGroup('to_account_rate', trans('transfers.to_account_rate'), 'sliders-h', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"], $transfer->to_account_rate) }}
</div>
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], $transfer->amount) }}

View File

@ -35,13 +35,13 @@
@if (!$hideHeaderAmount)
<div class="{{ $classHeaderAmount }}">
<span class="float-right">
{{ trans($textHeaderAmount) }}
{{ trans($textHeaderAmount) }}
</span>
<br>
<strong>
<span class="float-right long-texts mwpx-100 transaction-head-text">
@money($transfer->expense_transaction->amount, $transfer->from_currency_code, true)
@money($transfer->expense_transaction->amount, $transfer->expense_transaction->currency_code, true)
</span>
</strong>
<br><br>

View File

@ -2,10 +2,14 @@
<div
class="form-group {{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['readonly']) ? ' readonly' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
:class="[{'has-error': {{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }} }]"
@if (isset($attributes['show']))
v-if="{{ $attributes['show'] }}"
@endif
@if (isset($attributes[':disabled']))
:class="[{'disabled' : {{ $attributes[':disabled'] }}}, {'has-error': {{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }}}]"
@else
:class="[{'has-error': {{ isset($attributes['v-error']) ? $attributes['v-error'] : 'form.errors.get("' . $name . '")' }}}]"
@endif
>
@if (!empty($text))
{!! Form::label($name, $text, ['class' => 'form-control-label'])!!}