From 35c196305eab6bcab641b853cc3f35da8fde5cd2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 8 Apr 2019 22:43:20 +1000 Subject: [PATCH] Configuring invoice settings for consumption --- app/DataMapper/ClientSettings.php | 22 ++++++++++++++-------- app/DataMapper/CompanySettings.php | 3 +++ app/Helpers/Invoice/InvoiceCalc.php | 11 ++++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/DataMapper/ClientSettings.php b/app/DataMapper/ClientSettings.php index 889336164fc2..dc60f7ea3dfa 100644 --- a/app/DataMapper/ClientSettings.php +++ b/app/DataMapper/ClientSettings.php @@ -8,11 +8,19 @@ use App\Utils\TranslationHelper; /** * ClientSettings + * + * Client settings are built as a superset of Company Settings + * + * If no client settings is specified, the default company setting is used. + * + * Client settings are passed down to the entity level where they can be further customized and then saved + * into the settings column of the entity, so there is no need to create additional entity level settings handlers. + * */ class ClientSettings extends BaseSettings { /** - * settings which also have a parent company setting + * Settings which also have a parent company setting */ public $timezone_id; public $date_format_id; @@ -32,6 +40,7 @@ class ClientSettings extends BaseSettings public $custom_message_unapproved_quote; public $show_currency_symbol; public $show_currency_code; + public $inclusive_taxes; /** * settings which which are unique to client settings @@ -76,7 +85,8 @@ class ClientSettings extends BaseSettings 'send_reminders' => NULL, 'show_tasks_in_portal' => NULL, 'show_currency_symbol' => NULL, - 'show_currency_code' => NULL + 'show_currency_code' => NULL, + 'inclusive_taxes' => NULL, ]; } @@ -98,13 +108,9 @@ class ClientSettings extends BaseSettings if(!isset($client_settings->{$key}) && property_exists($company_settings, $key)) $client_settings->{$key} = $company_settings->{$key}; - } - /** Replace ID with Object for presentation in multi-select */ - $client_settings->currency_id = TranslationHelper::getCurrencies()->where('id', $client_settings->currency_id)->first(); - $client_settings->language_id = TranslationHelper::getLanguages()->where('id', $client_settings->language_id)->first(); - $client_settings->payment_terms = TranslationHelper::getPaymentTerms()->where('num_days', $client_settings->payment_terms)->first(); - //todo $client_settings->timezone_id + } + return $client_settings; } diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 4f03c1c9a6f2..2451b243f148 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -64,6 +64,8 @@ class CompanySettings extends BaseSettings public $custom_message_paid_invoice; public $custom_message_unapproved_quote; + public $inclusive_taxes; + public $translations; /** @@ -101,6 +103,7 @@ class CompanySettings extends BaseSettings 'show_tasks_in_portal' => 1, 'show_currency_symbol' => 1, 'show_currency_code' => 0, + 'inclusive_taxes' => 1, 'translations' => (object) [], ]; diff --git a/app/Helpers/Invoice/InvoiceCalc.php b/app/Helpers/Invoice/InvoiceCalc.php index b98321977a93..fb07fcbefec5 100644 --- a/app/Helpers/Invoice/InvoiceCalc.php +++ b/app/Helpers/Invoice/InvoiceCalc.php @@ -54,10 +54,19 @@ class InvoiceCalc */ public function build() { - $this->calcLineItems(); + $this->calcLineItems()->calcTaxes(); } + + /** + * Calculates the Invoice Level taxes. + */ + private function calcTaxes() + { + + } + /** * Calculates the line items. *