Transaction and Transfer show page add new relation slider
This commit is contained in:
parent
239b4d6276
commit
90a2330ae2
@ -285,6 +285,9 @@ abstract class Show extends Component
|
||||
/** @var bool */
|
||||
public $hideChildren;
|
||||
|
||||
/** @var bool */
|
||||
public $hideTransfer;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
|
||||
@ -329,7 +332,7 @@ abstract class Show extends Component
|
||||
string $textRelatedTransansaction = '', string $textRelatedDocumentNumber = '', string $textRelatedContact = '', string $textRelatedDocumentDate = '', string $textRelatedDocumentAmount = '', string $textRelatedAmount = '',
|
||||
string $routeDocumentShow = '', string $routeTransactionShow = '', string $textButtonAddNew = '',
|
||||
|
||||
bool $hideSchedule = false, bool $hideChildren = false, bool $hideAttachment = false, $attachment = [],
|
||||
bool $hideSchedule = false, bool $hideChildren = false, bool $hideTransfer = false, bool $hideAttachment = false, $attachment = [],
|
||||
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false, bool $hideCreated = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
@ -386,6 +389,9 @@ abstract class Show extends Component
|
||||
// Hide Children
|
||||
$this->hideChildren = $hideChildren;
|
||||
|
||||
// Hide Transfer
|
||||
$this->hideTransfer = $hideTransfer;
|
||||
|
||||
// Hide Attachment
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
|
||||
|
@ -141,6 +141,19 @@ class Transaction extends Model
|
||||
return $this->morphOne('App\Models\Common\Recurring', 'recurable');
|
||||
}
|
||||
|
||||
public function transfer()
|
||||
{
|
||||
if ($this->type == self::INCOME_TYPE) {
|
||||
return $this->belongsTo('App\Models\Banking\Transfer', 'id', 'income_transaction_id');
|
||||
}
|
||||
|
||||
if ($this->type == self::EXPENSE_TYPE) {
|
||||
return $this->belongsTo('App\Models\Banking\Transfer', 'id', 'expense_transaction_id');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function splits()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transaction', 'split_id');
|
||||
|
18
app/View/Components/Transactions/Show/Transfer.php
Normal file
18
app/View/Components/Transactions/Show/Transfer.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transactions\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Transactions\Show as Component;
|
||||
|
||||
class Transfer extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transactions.show.transfer');
|
||||
}
|
||||
}
|
18
app/View/Components/Transfers/Show/Transactions.php
Normal file
18
app/View/Components/Transfers/Show/Transactions.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Transfers\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Transfers\Show as Component;
|
||||
|
||||
class Transactions extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.transfers.show.transactions');
|
||||
}
|
||||
}
|
@ -24,6 +24,8 @@ return [
|
||||
'create_recurring' => ':user created this recurring template on :date',
|
||||
'schedule' => 'Repeat every :interval :frequency since :date',
|
||||
'children' => ':count transactions were created automatically',
|
||||
'transfer_headline' => 'From :from_account to :to_account',
|
||||
'transfer_desc' => 'Transfer created on :date.',
|
||||
],
|
||||
|
||||
'share' => [
|
||||
|
@ -25,6 +25,9 @@ return [
|
||||
|
||||
'slider' => [
|
||||
'create' => ':user created this transfer on :date',
|
||||
'transactions' => 'In list here are the transactions that were created automatically.',
|
||||
'from_desc' => ':number transaction from :account',
|
||||
'to_desc' => ':number transaction to :account',
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -55,6 +55,15 @@
|
||||
@endif
|
||||
@stack('children_end')
|
||||
|
||||
@stack('transfer_start')
|
||||
@if (! $hideTransfer)
|
||||
<x-transactions.show.transfer
|
||||
type="{{ $type }}"
|
||||
:transaction="$transaction"
|
||||
/>
|
||||
@endif
|
||||
@stack('transfer_end')
|
||||
|
||||
@stack('attachment_start')
|
||||
@if (! $hideAttachment)
|
||||
<x-transactions.show.attachment
|
||||
|
@ -0,0 +1,37 @@
|
||||
@if ($transaction->hasTransferRelation)
|
||||
@php
|
||||
$from_account = '<span class="font-medium">' . $transaction->transfer->expense_account->title . '</span>';
|
||||
$to_account = '<span class="font-medium">' . $transaction->transfer->income_account->title . '</span>';
|
||||
@endphp
|
||||
|
||||
<div class="border-b pb-4" x-data="{ transfer : null }">
|
||||
<button class="relative w-full text-left cursor-pointer group"
|
||||
x-on:click="transfer !== 1 ? transfer = 1 : transfer = null"
|
||||
>
|
||||
<span class="font-medium border-b border-transparent transition-all group-hover:border-black">
|
||||
{{ trans_choice('general.transfers', 1) }}
|
||||
</span>
|
||||
|
||||
<div class="text-black-400 text-sm">
|
||||
{!! trans('transactions.slider.transfer_headline', ['from_account' => $from_account, 'to_account' => $to_account]) !!}
|
||||
</div>
|
||||
|
||||
<span class="material-icons absolute right-0 top-0 transition-all transform"
|
||||
x-bind:class="transfer === 1 ? 'rotate-180' : ''"
|
||||
>expand_more</span>
|
||||
</button>
|
||||
|
||||
<div class="overflow-hidden transition-transform origin-top-left ease-linear duration-100"
|
||||
x-ref="container1"
|
||||
x-bind:class="transfer === 1 ? 'h-auto' : 'scale-y-0 h-0'"
|
||||
>
|
||||
@php
|
||||
$date = '<a href="' . route('transfers.show', $transaction->transfer->id) . '" class="text-purple">' . company_date($transaction->paid_at) . '</a>';
|
||||
@endphp
|
||||
|
||||
<div class="my-2">
|
||||
{!! trans('transactions.slider.transfer_desc', ['date' => $date]) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
@ -2,6 +2,8 @@
|
||||
<div class="w-full lg:w-5/12 space-y-12">
|
||||
<x-transfers.show.create :model="$transfer" />
|
||||
|
||||
<x-transfers.show.transactions :model="$transfer" />
|
||||
|
||||
<x-transfers.show.attachment :model="$transfer" />
|
||||
</div>
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
<div class="border-b pb-4" x-data="{ transactions : null }">
|
||||
<button class="relative w-full text-left group" x-on:click="transactions !== 1 ? transactions = 1 : transactions = null">
|
||||
<span class="font-medium border-b border-transparent transition-all group-hover:border-black">
|
||||
{{ trans_choice('general.transactions', 2) }}
|
||||
</span>
|
||||
|
||||
<div class="text-black-400 text-sm">
|
||||
{!! trans('transfers.slider.transactions', ['user' => $transfer->owner->name]) !!}
|
||||
</div>
|
||||
|
||||
<span class="material-icons absolute right-0 top-0 transition-all transform" x-bind:class="transactions === 1 ? 'rotate-180' : ''">expand_more</span>
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="overflow-hidden transition-transform origin-top-left ease-linear duration-100"
|
||||
x-ref="container1"
|
||||
x-bind:class="transactions === 1 ? 'h-auto' : 'scale-y-0 h-0'"
|
||||
>
|
||||
<div class="my-2">
|
||||
@php
|
||||
$number = '<a href="' . route('transactions.show', $transfer->expense_transaction->id) . '" class="text-purple">' . $transfer->expense_transaction->number . '</a>';
|
||||
@endphp
|
||||
{!! trans('transfers.slider.from_desc', ['number' => $number, 'account' => $transfer->expense_account->title]) !!}
|
||||
</div>
|
||||
|
||||
<div class="my-2">
|
||||
@php
|
||||
$number = '<a href="' . route('transactions.show', $transfer->income_transaction->id) . '" class="text-purple">' . $transfer->income_transaction->number . '</a>';
|
||||
@endphp
|
||||
{!! trans('transfers.slider.from_desc', ['number' => $number, 'account' => $transfer->income_account->title]) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user