diff --git a/app/Abstracts/View/Components/Transactions/Show.php b/app/Abstracts/View/Components/Transactions/Show.php index b02f6b0d4..fe7ca80a6 100644 --- a/app/Abstracts/View/Components/Transactions/Show.php +++ b/app/Abstracts/View/Components/Transactions/Show.php @@ -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; diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index e0f15b75b..f0939d374 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -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'); diff --git a/app/View/Components/Transactions/Show/Transfer.php b/app/View/Components/Transactions/Show/Transfer.php new file mode 100644 index 000000000..c9862afbe --- /dev/null +++ b/app/View/Components/Transactions/Show/Transfer.php @@ -0,0 +1,18 @@ + ':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' => [ diff --git a/resources/lang/en-GB/transfers.php b/resources/lang/en-GB/transfers.php index a527a9cd4..f085ac82c 100644 --- a/resources/lang/en-GB/transfers.php +++ b/resources/lang/en-GB/transfers.php @@ -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', ], ]; diff --git a/resources/views/components/transactions/show/content.blade.php b/resources/views/components/transactions/show/content.blade.php index 80617c27c..7000ada98 100644 --- a/resources/views/components/transactions/show/content.blade.php +++ b/resources/views/components/transactions/show/content.blade.php @@ -55,6 +55,15 @@ @endif @stack('children_end') + @stack('transfer_start') + @if (! $hideTransfer) + + @endif + @stack('transfer_end') + @stack('attachment_start') @if (! $hideAttachment) hasTransferRelation) + @php + $from_account = '' . $transaction->transfer->expense_account->title . ''; + $to_account = '' . $transaction->transfer->income_account->title . ''; + @endphp + + + + + {{ trans_choice('general.transfers', 1) }} + + + + {!! trans('transactions.slider.transfer_headline', ['from_account' => $from_account, 'to_account' => $to_account]) !!} + + + expand_more + + + + @php + $date = '' . company_date($transaction->paid_at) . ''; + @endphp + + + {!! trans('transactions.slider.transfer_desc', ['date' => $date]) !!} + + + +@endif diff --git a/resources/views/components/transfers/show/content.blade.php b/resources/views/components/transfers/show/content.blade.php index da157817f..5db189ec4 100644 --- a/resources/views/components/transfers/show/content.blade.php +++ b/resources/views/components/transfers/show/content.blade.php @@ -2,6 +2,8 @@ + + diff --git a/resources/views/components/transfers/show/transactions.blade.php b/resources/views/components/transfers/show/transactions.blade.php new file mode 100644 index 000000000..7dbab2e46 --- /dev/null +++ b/resources/views/components/transfers/show/transactions.blade.php @@ -0,0 +1,33 @@ + + + + {{ trans_choice('general.transactions', 2) }} + + + + {!! trans('transfers.slider.transactions', ['user' => $transfer->owner->name]) !!} + + + expand_more + + + + + @php + $number = '' . $transfer->expense_transaction->number . ''; + @endphp + {!! trans('transfers.slider.from_desc', ['number' => $number, 'account' => $transfer->expense_account->title]) !!} + + + + @php + $number = '' . $transfer->income_transaction->number . ''; + @endphp + {!! trans('transfers.slider.from_desc', ['number' => $number, 'account' => $transfer->income_account->title]) !!} + + +