Merge pull request #2203 from cuneytsenturk/master
Transfer page currency rate enhancement
This commit is contained in:
commit
d022d67f3c
@ -56,15 +56,7 @@ class Transfers extends Controller
|
|||||||
|
|
||||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||||
|
|
||||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
$file_types = $this->prepeareFileTypes();
|
||||||
|
|
||||||
$file_types = [];
|
|
||||||
|
|
||||||
foreach ($file_type_mimes as $mime) {
|
|
||||||
$file_types[] = '.' . $mime;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_types = implode(',', $file_types);
|
|
||||||
|
|
||||||
return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currency', 'file_types'));
|
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)
|
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');
|
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
$payment_methods = Modules::getPaymentMethods();
|
$payment_methods = Modules::getPaymentMethods();
|
||||||
@ -168,15 +148,7 @@ class Transfers extends Controller
|
|||||||
|
|
||||||
$currency = Currency::where('code', $account->currency_code)->first();
|
$currency = Currency::where('code', $account->currency_code)->first();
|
||||||
|
|
||||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
$file_types = $this->prepeareFileTypes();
|
||||||
|
|
||||||
$file_types = [];
|
|
||||||
|
|
||||||
foreach ($file_type_mimes as $mime) {
|
|
||||||
$file_types[] = '.' . $mime;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_types = implode(',', $file_types);
|
|
||||||
|
|
||||||
return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currency', 'file_types'));
|
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);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,20 @@ class Transfer extends Model
|
|||||||
|
|
||||||
protected $table = 'transfers';
|
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.
|
* Attributes that should be mass-assignable.
|
||||||
@ -101,6 +114,116 @@ class Transfer extends Model
|
|||||||
return $value ?: 'banking.transfers.print_' . setting('transfer.template');
|
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.
|
* Create a new factory instance for the model.
|
||||||
*
|
*
|
||||||
|
27
resources/assets/js/views/banking/transfers.js
vendored
27
resources/assets/js/views/banking/transfers.js
vendored
@ -30,6 +30,11 @@ const app = new Vue({
|
|||||||
form: new Form('transfer'),
|
form: new Form('transfer'),
|
||||||
bulk_action: new BulkAction('transfers'),
|
bulk_action: new BulkAction('transfers'),
|
||||||
show_rate: false,
|
show_rate: false,
|
||||||
|
edit: {
|
||||||
|
status: false,
|
||||||
|
form_account: false,
|
||||||
|
to_account: false,
|
||||||
|
},
|
||||||
|
|
||||||
transfer_form: new Form('template'),
|
transfer_form: new Form('template'),
|
||||||
template: {
|
template: {
|
||||||
@ -48,6 +53,11 @@ const app = new Vue({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.edit.status && this.edit.form_account < 2) {
|
||||||
|
this.edit.form_account++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let from_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
|
let from_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
|
||||||
params: {
|
params: {
|
||||||
account_id: from_account_id
|
account_id: from_account_id
|
||||||
@ -77,6 +87,11 @@ const app = new Vue({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.edit.status && this.edit.to_account < 2) {
|
||||||
|
this.edit.to_account++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let to_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
|
let to_promise = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
|
||||||
params: {
|
params: {
|
||||||
account_id: to_account_id
|
account_id: to_account_id
|
||||||
@ -126,5 +141,15 @@ const app = new Vue({
|
|||||||
errors: this.transfer_form.errors
|
errors: this.transfer_form.errors
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
if (typeof transfer_edit !== 'undefined' && transfer_edit) {
|
||||||
|
this.show_rate = true;
|
||||||
|
|
||||||
|
this.edit.status = true;
|
||||||
|
this.edit.form_account = 1;
|
||||||
|
this.edit.to_account = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -24,11 +24,11 @@
|
|||||||
<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
|
<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::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::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>
|
</div>
|
||||||
|
|
||||||
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], 0) }}
|
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], 0) }}
|
||||||
|
@ -22,15 +22,27 @@
|
|||||||
|
|
||||||
{{ Form::selectGroup('to_account_id', trans('transfers.to_account'), 'university', $accounts, $transfer->to_account_id, ['required' => 'required', 'change' => 'onChangeToAccount']) }}
|
{{ Form::selectGroup('to_account_id', trans('transfers.to_account'), 'university', $accounts, $transfer->to_account_id, ['required' => 'required', 'change' => 'onChangeToAccount']) }}
|
||||||
|
|
||||||
<div class="d-none w-100" :class="[{'d-flex' : show_rate}]">
|
@if ($transfer->from_currency_code != $transfer->to_currency_code)
|
||||||
{!! Form::hidden('from_currency_code', $transfer->from_currency_code, ['id' => 'from_currency_code', 'v-model' => 'form.from_currency_code']) !!}
|
<div class="w-100" :class="[show_rate ? 'd-flex' : 'd-none']">
|
||||||
|
{!! 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::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>
|
</div>
|
||||||
|
@else
|
||||||
|
<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', [':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', [':disabled' => "form.to_currency_code == '" . setting('default.currency') . "'"], $transfer->to_account_rate) }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], $transfer->amount) }}
|
{{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'currency' => $currency, 'dynamic-currency' => 'currency'], $transfer->amount) }}
|
||||||
|
|
||||||
@ -61,5 +73,9 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('scripts_start')
|
@push('scripts_start')
|
||||||
|
<script type="text/javascript">
|
||||||
|
var transfer_edit = {{ $transfer->id }};
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="{{ asset('public/js/banking/transfers.js?v=' . version('short')) }}"></script>
|
<script src="{{ asset('public/js/banking/transfers.js?v=' . version('short')) }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -35,13 +35,13 @@
|
|||||||
@if (!$hideHeaderAmount)
|
@if (!$hideHeaderAmount)
|
||||||
<div class="{{ $classHeaderAmount }}">
|
<div class="{{ $classHeaderAmount }}">
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
{{ trans($textHeaderAmount) }}
|
{{ trans($textHeaderAmount) }}
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<strong>
|
<strong>
|
||||||
<span class="float-right long-texts mwpx-100 transaction-head-text">
|
<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>
|
</span>
|
||||||
</strong>
|
</strong>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="form-group {{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['readonly']) ? ' readonly' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
|
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']))
|
@if (isset($attributes['show']))
|
||||||
v-if="{{ $attributes['show'] }}"
|
v-if="{{ $attributes['show'] }}"
|
||||||
@endif
|
@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))
|
@if (!empty($text))
|
||||||
{!! Form::label($name, $text, ['class' => 'form-control-label'])!!}
|
{!! Form::label($name, $text, ['class' => 'form-control-label'])!!}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user