From a67c03ef170baeac0fe69f52ec5e3c1abb36908a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Fri, 7 Aug 2020 17:10:24 +0300 Subject: [PATCH] added withholding option in report --- app/Reports/TaxSummary.php | 23 ++++++++++++++++++- resources/views/common/reports/edit.blade.php | 6 ++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Reports/TaxSummary.php b/app/Reports/TaxSummary.php index 2bf703d0a..6ed76977f 100644 --- a/app/Reports/TaxSummary.php +++ b/app/Reports/TaxSummary.php @@ -32,7 +32,9 @@ class TaxSummary extends Report public function setTables() { - $taxes = Tax::enabled()->notWithholding()->notRate(0)->orderBy('name')->pluck('name')->toArray(); + $withholding = ($this->getSetting('withholding') == 'yes') ? 'withholding' : 'notWithholding'; + + $taxes = Tax::enabled()->$withholding()->notRate(0)->orderBy('name')->pluck('name')->toArray(); $this->tables = array_combine($taxes, $taxes); } @@ -122,6 +124,25 @@ class TaxSummary extends Report return [ $this->getPeriodField(), $this->getBasisField(), + $this->getWithholdingField(), + ]; + } + + public function getWithholdingField() + { + return [ + 'type' => 'selectGroup', + 'name' => 'withholding', + 'title' => trans('taxes.withholding'), + 'icon' => 'hand-holding-usd', + 'values' => [ + 'yes' => trans('general.yes'), + 'no' => trans('general.no'), + ], + 'selected' => 'no', + 'attributes' => [ + 'required' => 'required', + ], ]; } } diff --git a/resources/views/common/reports/edit.blade.php b/resources/views/common/reports/edit.blade.php index 8a57a73e4..dcf4d333b 100644 --- a/resources/views/common/reports/edit.blade.php +++ b/resources/views/common/reports/edit.blade.php @@ -42,16 +42,16 @@ 'data-field' => 'settings', ], $field['attributes']), - isset($class->model->settings->{$field['name']}) ? $class->model->settings->{$field['name']}: null + isset($report->settings->{$field['name']}) ? $report->settings->{$field['name']}: null ) }} @elseif ($type == 'selectGroup') - {{ Form::$type($field['name'], $field['title'], $field['icon'], $field['values'], $report->settings->{$field['name']}, array_merge([ + {{ Form::$type($field['name'], $field['title'], $field['icon'], $field['values'], isset($report->settings->{$field['name']}) ? $report->settings->{$field['name']} : $field['selected'], array_merge([ 'data-field' => 'settings' ], $field['attributes']) ) }} @elseif ($type == 'radioGroup') - {{ Form::$type($field['name'], $field['title'], isset($report->settings->{$field['name']}) ? $report->settings->{$field['name']} : 1, $field['enable'], $field['disable'], array_merge([ + {{ Form::$type($field['name'], $field['title'], isset($report->settings->{$field['name']}) ? $report->settings->{$field['name']} : true, $field['enable'], $field['disable'], array_merge([ 'data-field' => 'settings' ], $field['attributes'])