Fixed transfer and split transaction show/create pages real_type issue ( #3qec0xc )

This commit is contained in:
Cüneyt Şentürk 2022-10-31 00:43:30 +03:00
parent 6bb35cf3a3
commit 083ea42aa6
4 changed files with 25 additions and 13 deletions

View File

@ -86,8 +86,9 @@ class Transactions extends Controller
public function show(Transaction $transaction) public function show(Transaction $transaction)
{ {
$title = $transaction->isIncome() ? trans_choice('general.receipts', 1) : trans('transactions.payment_made'); $title = $transaction->isIncome() ? trans_choice('general.receipts', 1) : trans('transactions.payment_made');
$real_type = $this->getRealTypeTransaction($transaction->type);
return view('banking.transactions.show', compact('transaction', 'title')); return view('banking.transactions.show', compact('transaction', 'title', 'real_type'));
} }
/** /**
@ -98,6 +99,7 @@ class Transactions extends Controller
public function create() public function create()
{ {
$type = request()->get('type', 'income'); $type = request()->get('type', 'income');
$real_type = $this->getRealTypeTransaction($type);
$number = $this->getNextTransactionNumber(); $number = $this->getNextTransactionNumber();
@ -109,6 +111,7 @@ class Transactions extends Controller
return view('banking.transactions.create', compact( return view('banking.transactions.create', compact(
'type', 'type',
'real_type',
'number', 'number',
'contact_type', 'contact_type',
'account_currency_code', 'account_currency_code',

View File

@ -204,6 +204,15 @@ trait Transactions
]; ];
} }
public function getRealTypeTransaction(string $type): string
{
$type = $this->getRealTypeOfRecurringTransaction($type);
$type = $this->getRealTypeOfTransferTransaction($type);
$type = $this->getRealTypeOfSplitTransaction($type);
return $type;
}
public function getRealTypeOfRecurringTransaction(string $recurring_type): string public function getRealTypeOfRecurringTransaction(string $recurring_type): string
{ {
return Str::replace('-recurring', '', $recurring_type); return Str::replace('-recurring', '', $recurring_type);

View File

@ -1,13 +1,13 @@
<x-layouts.admin> <x-layouts.admin>
<x-slot name="title"> <x-slot name="title">
{{ trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($type), 1)]) }} {{ trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($real_type), 1)]) }}
</x-slot> </x-slot>
@php $fav_icon = ($type == 'income') ? 'request_quote' : 'paid'; @endphp @php $fav_icon = ($real_type == 'income') ? 'request_quote' : 'paid'; @endphp
<x-slot name="favorite" <x-slot name="favorite"
title="{{ trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($type), 1)]) }}" title="{{ trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($real_type), 1)]) }}"
icon="{{ $fav_icon }}" icon="{{ $fav_icon }}"
url="{{ route('transactions.create', ['type' => $type]) }}" url="{{ route('transactions.create', ['type' => $real_type]) }}"
></x-slot> ></x-slot>
<x-slot name="content"> <x-slot name="content">
@ -36,13 +36,13 @@
<x-form.section> <x-form.section>
<x-slot name="head"> <x-slot name="head">
<x-form.section.head title="{{ trans('general.assign') }}" description="{{ trans('transactions.form_description.assign_' . $type) }}" /> <x-form.section.head title="{{ trans('general.assign') }}" description="{{ trans('transactions.form_description.assign_' . $real_type) }}" />
</x-slot> </x-slot>
<x-slot name="body"> <x-slot name="body">
<x-form.group.category type="{{ $type }}" :selected="setting('default.' . $type . '_category')" /> <x-form.group.category type="{{ $real_type }}" :selected="setting('default.' . $real_type . '_category')" />
<x-form.group.contact type="{{ config('type.transaction.' . $type . '.contact_type') }}" not-required /> <x-form.group.contact type="{{ config('type.transaction.' . $real_type . '.contact_type') }}" not-required />
</x-slot> </x-slot>
</x-form.section> </x-form.section>
@ -66,7 +66,7 @@
</x-slot> </x-slot>
</x-form.section> </x-form.section>
<x-form.input.hidden name="type" :value="$type" /> <x-form.input.hidden name="type" :value="$real_type" />
</x-form> </x-form>
</x-form.container> </x-form.container>
</x-slot> </x-slot>

View File

@ -4,20 +4,20 @@
</x-slot> </x-slot>
<x-slot name="buttons"> <x-slot name="buttons">
<x-transactions.show.buttons type="{{ $transaction->type }}" :transaction="$transaction" /> <x-transactions.show.buttons type="{{ $real_type }}" :transaction="$transaction" />
</x-slot> </x-slot>
<x-slot name="moreButtons"> <x-slot name="moreButtons">
<x-transactions.show.more-buttons type="{{ $transaction->type }}" :transaction="$transaction" hide-divider-3 hide-button-end /> <x-transactions.show.more-buttons type="{{ $real_type }}" :transaction="$transaction" hide-divider-3 hide-button-end />
</x-slot> </x-slot>
<x-slot name="content"> <x-slot name="content">
<x-transactions.show.content type="{{ $transaction->type }}" :transaction="$transaction" hide-schedule hide-children /> <x-transactions.show.content type="{{ $real_type }}" :transaction="$transaction" hide-schedule hide-children />
</x-slot> </x-slot>
@push('stylesheet') @push('stylesheet')
<link rel="stylesheet" href="{{ asset('public/css/print.css?v=' . version('short')) }}" type="text/css"> <link rel="stylesheet" href="{{ asset('public/css/print.css?v=' . version('short')) }}" type="text/css">
@endpush @endpush
<x-transactions.script type="{{ $transaction->type }}" /> <x-transactions.script type="{{ $real_type }}" />
</x-layouts.admin> </x-layouts.admin>