From 90a2330ae2569c5f67b77d9ff4d5e97e09e631b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 28 Jun 2022 19:20:27 +0300 Subject: [PATCH] Transaction and Transfer show page add new relation slider --- .../View/Components/Transactions/Show.php | 8 +++- app/Models/Banking/Transaction.php | 13 +++++++ .../Components/Transactions/Show/Transfer.php | 18 +++++++++ .../Transfers/Show/Transactions.php | 18 +++++++++ resources/lang/en-GB/transactions.php | 2 + resources/lang/en-GB/transfers.php | 3 ++ .../transactions/show/content.blade.php | 9 +++++ .../transactions/show/transfer.blade.php | 37 +++++++++++++++++++ .../transfers/show/content.blade.php | 2 + .../transfers/show/transactions.blade.php | 33 +++++++++++++++++ 10 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 app/View/Components/Transactions/Show/Transfer.php create mode 100644 app/View/Components/Transfers/Show/Transactions.php create mode 100644 resources/views/components/transactions/show/transfer.blade.php create mode 100644 resources/views/components/transfers/show/transactions.blade.php 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 + +
+ + +
+ @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 @@ +
+ + +
+
+ @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]) !!} +
+
+