From 61923a08d8f875fa00b3db04eedc37796b79b773 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Tue, 2 Nov 2021 16:04:01 +0300 Subject: [PATCH 1/6] filter option for the recurring documents and transactions added #1pbthq3 --- app/View/Components/SearchString.php | 12 ++++----- config/search-string.php | 35 ++++++++++++++++++++++++++ resources/lang/en-GB/search_string.php | 1 + 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/app/View/Components/SearchString.php b/app/View/Components/SearchString.php index 7859aeea8..fa7a575eb 100644 --- a/app/View/Components/SearchString.php +++ b/app/View/Components/SearchString.php @@ -89,12 +89,12 @@ class SearchString extends Component $column = $options['key']; } - if (isset($options['relationship'])) { - if (isset($options['foreign_key'])) { - $column .= '.' . $options['foreign_key']; - } else { - $column .= '.id'; - } + if (isset($options['relationship']) && isset($options['foreign_key']) && !empty($options['foreign_key'])) { + $column .= '.' . $options['foreign_key']; + } + + if (isset($options['relationship']) && !isset($options['foreign_key'])) { + $column .= '.id'; } return $column; diff --git a/config/search-string.php b/config/search-string.php index 60dc341dc..9b070ba9d 100644 --- a/config/search-string.php +++ b/config/search-string.php @@ -112,6 +112,12 @@ return [ 'route' => 'categories.index' ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'foreign_key' => '', + 'relationship' => true, + 'boolean' => true, + ] ], ], @@ -205,6 +211,11 @@ return [ 'route' => 'categories.index' ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'relationship' => true, + 'boolean' => true, + ] ], ], @@ -243,6 +254,12 @@ return [ 'route' => ['categories.index', 'search=type:expense'] ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'foreign_key' => '', + 'relationship' => true, + 'boolean' => true, + ] ], ], @@ -269,6 +286,12 @@ return [ 'route' => ['categories.index', 'search=type:expense'] ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'foreign_key' => '', + 'relationship' => true, + 'boolean' => true, + ] ], ], @@ -308,6 +331,12 @@ return [ 'route' => ['categories.index', 'search=type:income'] ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'foreign_key' => '', + 'relationship' => true, + 'boolean' => true, + ] ], ], @@ -334,6 +363,12 @@ return [ 'route' => ['categories.index', 'search=type:income'] ], 'parent_id', + 'recurring' => [ + 'key' => 'recurring', + 'foreign_key' => '', + 'relationship' => true, + 'boolean' => true, + ] ], ], diff --git a/resources/lang/en-GB/search_string.php b/resources/lang/en-GB/search_string.php index 05e9aef86..c6d1c313c 100644 --- a/resources/lang/en-GB/search_string.php +++ b/resources/lang/en-GB/search_string.php @@ -15,6 +15,7 @@ return [ 'reconciled' => 'Reconciled', 'expense_account' => 'From Account', 'income_account' => 'To Account', + 'recurring' => 'Recurring', ], ]; From 2087a2de3b9c9ef6083c73bdffa22c2528bd8601 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Tue, 2 Nov 2021 16:33:31 +0300 Subject: [PATCH 2/6] validation for the recurring documents and transactions added #1pbthq3 --- app/Http/Requests/Banking/Transaction.php | 2 ++ app/Http/Requests/Document/Document.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/Http/Requests/Banking/Transaction.php b/app/Http/Requests/Banking/Transaction.php index 1c1870302..bb1283add 100644 --- a/app/Http/Requests/Banking/Transaction.php +++ b/app/Http/Requests/Banking/Transaction.php @@ -32,6 +32,8 @@ class Transaction extends FormRequest 'category_id' => 'required|integer', 'payment_method' => 'required|string', 'attachment.*' => $attachment, + 'recurring_count' => 'gte:0', + 'recurring_interval' => 'exclude_unless:recurring_frequency,custom|gt:0', ]; } diff --git a/app/Http/Requests/Document/Document.php b/app/Http/Requests/Document/Document.php index f52a3fd12..4fec70b10 100644 --- a/app/Http/Requests/Document/Document.php +++ b/app/Http/Requests/Document/Document.php @@ -66,6 +66,8 @@ class Document extends FormRequest 'category_id' => 'required|integer', 'company_logo' => $company_logo, 'attachment.*' => $attachment, + 'recurring_count' => 'gte:0', + 'recurring_interval' => 'exclude_unless:recurring_frequency,custom|gt:0', ]; } From b6f5394bbd8f65d1e93ee35662d558beb7a57129 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Wed, 3 Nov 2021 18:37:57 +0300 Subject: [PATCH 3/6] connection between docs or transactions added to recurring messages part #1pbthq3 --- .../View/Components/TransactionShow.php | 27 +++++++++++- app/Models/Banking/Transaction.php | 5 +++ app/Models/Document/Document.php | 5 +++ resources/lang/en-GB/recurring.php | 1 + .../show/recurring-message.blade.php | 21 +++++++++ .../transactions/show/content.blade.php | 10 +++++ .../show/recurring-message.blade.php | 44 +++++++++++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 resources/views/components/transactions/show/recurring-message.blade.php diff --git a/app/Abstracts/View/Components/TransactionShow.php b/app/Abstracts/View/Components/TransactionShow.php index 2291c17d6..2e4b1111e 100644 --- a/app/Abstracts/View/Components/TransactionShow.php +++ b/app/Abstracts/View/Components/TransactionShow.php @@ -314,6 +314,12 @@ abstract class TransactionShow extends Base /** @var string */ public $classFooterHistories; + /** @var string */ + public $textRecurringType; + + /** @var bool */ + public $hideRecurringMessage; + /** * Create a new component instance. * @@ -346,7 +352,7 @@ abstract class TransactionShow extends Base bool $hideAttachment = false, $attachment = [], bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [], - string $textHistories = '', string $classFooterHistories = '' + string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false ) { $this->type = $type; $this->transaction = $transaction; @@ -354,6 +360,8 @@ abstract class TransactionShow extends Base $this->logo = $this->getLogo($logo); $this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all'); $this->date_format = $this->getCompanyDateFormat(); + $this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType); + $this->hideRecurringMessage = $hideRecurringMessage; // Navbar Hide $this->hideButtonAddNew = $hideButtonAddNew; @@ -1276,4 +1284,21 @@ abstract class TransactionShow extends Base return 'col-sm-6 col-md-6 col-lg-6 col-xl-6'; } + + protected function getTextRecurringType($type, $textRecurringType) + { + if (!empty($textRecurringType)) { + return $textRecurringType; + } + + $default_key = config('type.' . $type . '.translation.prefix'); + + $translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key); + + if (!empty($translation)) { + return $translation; + } + + return 'general.revenues'; + } } diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index 701747bf7..a9c351479 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -126,6 +126,11 @@ class Transaction extends Model return $this->belongsTo('App\Models\Auth\User', 'contact_id', 'id'); } + public function parent() + { + return $this->belongsTo('App\Models\Banking\Transaction', 'parent_id'); + } + /** * Scope to only include contacts of a given type. * diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index c8570e3be..5ece9995b 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -140,6 +140,11 @@ class Document extends Model return $this->totals()->orderBy('sort_order'); } + public function parent() + { + return $this->belongsTo('App\Models\Document\Document', 'parent_id'); + } + public function scopeLatest(Builder $query) { return $query->orderBy('issued_at', 'desc'); diff --git a/resources/lang/en-GB/recurring.php b/resources/lang/en-GB/recurring.php index 79fefa042..8ce404aca 100644 --- a/resources/lang/en-GB/recurring.php +++ b/resources/lang/en-GB/recurring.php @@ -16,5 +16,6 @@ return [ 'months' => 'Month(s)', 'years' => 'Year(s)', 'message' => 'This is a recurring :type and the next :type will be automatically generated on :date', + 'message_parent' => 'This :type was automatically generated from :link', ]; diff --git a/resources/views/components/documents/show/recurring-message.blade.php b/resources/views/components/documents/show/recurring-message.blade.php index 04e36c01d..cb56d6482 100644 --- a/resources/views/components/documents/show/recurring-message.blade.php +++ b/resources/views/components/documents/show/recurring-message.blade.php @@ -20,4 +20,25 @@ @endif +@if ($document->parent) +
+
+ +
+
+@endif @stack('recurring_message_end') diff --git a/resources/views/components/transactions/show/content.blade.php b/resources/views/components/transactions/show/content.blade.php index 833101bae..22b2fb4f4 100644 --- a/resources/views/components/transactions/show/content.blade.php +++ b/resources/views/components/transactions/show/content.blade.php @@ -22,6 +22,16 @@ @endif @stack('content_header_end') +@stack('recurring_message_start') +@if (!$hideRecurringMessage) + +@endif +@stack('recurring_message_end') + @stack('transaction_start') recurring) && ($next = $recurring->getNextRecurring())) +
+
+ +
+
+@endif +@if ($transaction->parent) +
+
+ +
+
+@endif +@stack('recurring_message_end') From a7369530ffef0a228a187e805de58eadb6c20c38 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Wed, 3 Nov 2021 19:00:58 +0300 Subject: [PATCH 4/6] icon added to show it as recurring #1pbthq3 --- .../documents/index/card-table-row.blade.php | 4 ++++ .../views/purchases/payments/index.blade.php | 15 ++++++++++----- resources/views/sales/revenues/index.blade.php | 15 ++++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/resources/views/partials/documents/index/card-table-row.blade.php b/resources/views/partials/documents/index/card-table-row.blade.php index 948b0db7b..60d3e869e 100644 --- a/resources/views/partials/documents/index/card-table-row.blade.php +++ b/resources/views/partials/documents/index/card-table-row.blade.php @@ -18,6 +18,10 @@ {{ $item->document_number }} @endif + @if ($item->recurring) + + @endif + @stack('document_number_td_inside_end') @endif diff --git a/resources/views/purchases/payments/index.blade.php b/resources/views/purchases/payments/index.blade.php index 9b720c103..e5185adf2 100644 --- a/resources/views/purchases/payments/index.blade.php +++ b/resources/views/purchases/payments/index.blade.php @@ -46,11 +46,16 @@ @foreach($payments as $item) {{ Form::bulkActionGroup($item->id, $item->contact->name) }} - @if ($item->reconciled) - @date($item->paid_at) - @else - @date($item->paid_at) - @endif + + @if ($item->reconciled) + @date($item->paid_at) + @else + @date($item->paid_at) + @endif + @if ($item->recurring) + + @endif + @money($item->amount, $item->currency_code, true) {{ $item->contact->name }} diff --git a/resources/views/sales/revenues/index.blade.php b/resources/views/sales/revenues/index.blade.php index 5d276fb6c..9f81fdda2 100644 --- a/resources/views/sales/revenues/index.blade.php +++ b/resources/views/sales/revenues/index.blade.php @@ -46,11 +46,16 @@ @foreach($revenues as $item) {{ Form::bulkActionGroup($item->id, $item->contact->name) }} - @if ($item->reconciled) - @date($item->paid_at) - @else - @date($item->paid_at) - @endif + + @if ($item->reconciled) + @date($item->paid_at) + @else + @date($item->paid_at) + @endif + @if ($item->recurring) + + @endif + @money($item->amount, $item->currency_code, true) {{ $item->contact->name }} From d624ad3f8417c1d8f862acd3f2be47627d765452 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Mon, 8 Nov 2021 23:33:46 +0300 Subject: [PATCH 5/6] underline added to links #1pbthq3 --- .../views/components/documents/show/recurring-message.blade.php | 2 +- .../components/transactions/show/recurring-message.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/components/documents/show/recurring-message.blade.php b/resources/views/components/documents/show/recurring-message.blade.php index cb56d6482..db8cdcccd 100644 --- a/resources/views/components/documents/show/recurring-message.blade.php +++ b/resources/views/components/documents/show/recurring-message.blade.php @@ -33,7 +33,7 @@ @stack('recurring_parent_message_body_start')

{!! trans('recurring.message_parent', [ 'type' => mb_strtolower(trans_choice($textRecurringType, 1)), - 'link' => '' . $document->parent->document_number . '' + 'link' => '' . $document->parent->document_number . '' ]) !!}

@stack('recurring_parent_message_body_end') diff --git a/resources/views/components/transactions/show/recurring-message.blade.php b/resources/views/components/transactions/show/recurring-message.blade.php index 67b6034dc..d02f4e64a 100644 --- a/resources/views/components/transactions/show/recurring-message.blade.php +++ b/resources/views/components/transactions/show/recurring-message.blade.php @@ -33,7 +33,7 @@ @stack('recurring_parent_message_body_start')

{!! trans('recurring.message_parent', [ 'type' => mb_strtolower(trans_choice($textRecurringType, 1)), - 'link' => '' . trans_choice($textRecurringType, 1) . '#' . $transaction->parent->id . '' + 'link' => '' . trans_choice($textRecurringType, 1) . '#' . $transaction->parent->id . '' ]) !!}

@stack('recurring_parent_message_body_end') From dfb77a8a294c6292ef7c03b64060248865745407 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Thu, 11 Nov 2021 12:02:47 +0300 Subject: [PATCH 6/6] recurring tooltip added #1pbthq3 --- .../js/components/AkauntingRecurring.vue | 48 +++++++++++++++---- resources/lang/en-GB/recurring.php | 4 ++ .../views/partials/form/recurring.blade.php | 4 ++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/components/AkauntingRecurring.vue b/resources/assets/js/components/AkauntingRecurring.vue index c4a813fce..ed9504ae6 100644 --- a/resources/assets/js/components/AkauntingRecurring.vue +++ b/resources/assets/js/components/AkauntingRecurring.vue @@ -4,6 +4,15 @@ name="recurring_frequency" :class="frequencyClasses" :error="frequencyError"> +