diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 2f44aba5bce1..0396f4d00012 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -67,133 +67,133 @@ class CompanySettings extends BaseSettings public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send? public $inclusive_taxes = false; //@implemented - public $quote_footer = ''; + public $quote_footer = ''; //@implmented - public $translations; + public $translations; //@TODO not used anywhere - public $counter_number_applied = 'when_saved'; // when_saved , when_sent - public $quote_number_applied = 'when_saved'; // when_saved , when_sent + public $counter_number_applied = 'when_saved'; // when_saved , when_sent //@implemented + public $quote_number_applied = 'when_saved'; // when_saved , when_sent //@implemented /* Counters */ - public $invoice_number_pattern = ''; - public $invoice_number_counter = 1; + public $invoice_number_pattern = ''; //@implemented + public $invoice_number_counter = 1; //@implemented - public $recurring_invoice_number_pattern = ''; - public $recurring_invoice_number_counter = 1; + public $recurring_invoice_number_pattern = ''; //@implemented + public $recurring_invoice_number_counter = 1; //@implemented - public $quote_number_pattern = ''; - public $quote_number_counter = 1; + public $quote_number_pattern = ''; //@implemented + public $quote_number_counter = 1; //@implemented - public $client_number_pattern = ''; - public $client_number_counter = 1; + public $client_number_pattern = ''; //@implemented + public $client_number_counter = 1; //@implemented - public $credit_number_pattern = ''; - public $credit_number_counter = 1; + public $credit_number_pattern = ''; //@implemented + public $credit_number_counter = 1; //@implemented - public $task_number_pattern = ''; - public $task_number_counter = 1; + public $task_number_pattern = ''; //@implemented + public $task_number_counter = 1; //@implemented - public $expense_number_pattern = ''; - public $expense_number_counter = 1; + public $expense_number_pattern = ''; //@implemented + public $expense_number_counter = 1; //@implemented - public $vendor_number_pattern = ''; - public $vendor_number_counter = 1; + public $vendor_number_pattern = ''; //@implemented + public $vendor_number_counter = 1; //@implemented - public $ticket_number_pattern = ''; - public $ticket_number_counter = 1; + public $ticket_number_pattern = ''; //@implemented + public $ticket_number_counter = 1; //@implemented - public $payment_number_pattern = ''; - public $payment_number_counter = 1; + public $payment_number_pattern = ''; //@implemented + public $payment_number_counter = 1; //@implemented - public $project_number_pattern = ''; - public $project_number_counter = 1; + public $project_number_pattern = ''; //@implemented + public $project_number_counter = 1; //@implemented - public $shared_invoice_quote_counter = false; - public $recurring_number_prefix = 'R'; - public $reset_counter_frequency_id = '0'; - public $reset_counter_date = ''; - public $counter_padding = 4; + public $shared_invoice_quote_counter = false; //@implemented + public $recurring_number_prefix = 'R'; //@implemented + public $reset_counter_frequency_id = '0'; //@implemented + public $reset_counter_date = ''; //@implemented + public $counter_padding = 4; //@implemented - public $auto_bill = 'off'; //off,always,optin,optout - public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date + public $auto_bill = 'off'; //off,always,optin,optout //@implemented + public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date //@implemented - public $design = 'views/pdf/design1.blade.php'; + //public $design = 'views/pdf/design1.blade.php'; //@deprecated - never used public $invoice_terms = ''; - public $quote_terms = ''; - public $invoice_taxes = 0; + public $quote_terms = ''; //@implemented + public $invoice_taxes = 0; // ? used in AP only? // public $enabled_item_tax_rates = 0; - public $invoice_design_id = 'VolejRejNm'; - public $quote_design_id = 'VolejRejNm'; - public $credit_design_id = 'VolejRejNm'; + public $invoice_design_id = 'VolejRejNm'; //@implemented + public $quote_design_id = 'VolejRejNm'; //@implemented + public $credit_design_id = 'VolejRejNm'; //@implemented public $invoice_footer = ''; public $credit_footer = ''; public $credit_terms = ''; - public $invoice_labels = ''; - public $tax_name1 = ''; - public $tax_rate1 = 0; - public $tax_name2 = ''; - public $tax_rate2 = 0; - public $tax_name3 = ''; - public $tax_rate3 = 0; - public $payment_type_id = '0'; - public $invoice_fields = ''; + public $invoice_labels = ''; //@TODO used in AP only? + public $tax_name1 = ''; //@TODO where do we use this? + public $tax_rate1 = 0; //@TODO where do we use this? + public $tax_name2 = ''; //@TODO where do we use this? + public $tax_rate2 = 0; //@TODO where do we use this? + public $tax_name3 = ''; //@TODO where do we use this? + public $tax_rate3 = 0; //@TODO where do we use this? + public $payment_type_id = '0'; //@TODO where do we use this? + public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company? - public $show_accept_invoice_terms = false; - public $show_accept_quote_terms = false; - public $require_invoice_signature = false; - public $require_quote_signature = false; + public $show_accept_invoice_terms = false; //@TODO ben to confirm + public $show_accept_quote_terms = false; //@TODO ben to confirm + public $require_invoice_signature = false; //@TODO ben to confirm + public $require_quote_signature = false; //@TODO ben to confirm //email settings - public $email_sending_method = 'default'; //enum 'default','gmail' - public $gmail_sending_user_id = '0'; + public $email_sending_method = 'default'; //enum 'default','gmail' //@implemented + public $gmail_sending_user_id = '0'; //@implemented - public $reply_to_email = ''; - public $bcc_email = ''; - public $pdf_email_attachment = false; - public $ubl_email_attachment = false; + public $reply_to_email = ''; //@TODO + public $bcc_email = ''; //@TODO + public $pdf_email_attachment = false; //@implemented + public $ubl_email_attachment = false; //@implemented - public $email_style = 'light'; //plain, light, dark, custom - public $email_style_custom = ''; //the template itself - public $email_subject_invoice = ''; - public $email_subject_quote = ''; - public $email_subject_credit = ''; - public $email_subject_payment = ''; - public $email_subject_payment_partial = ''; - public $email_subject_statement = ''; - public $email_template_invoice = ''; - public $email_template_credit = ''; - public $email_template_quote = ''; - public $email_template_payment = ''; - public $email_template_payment_partial = ''; - public $email_template_statement = ''; - public $email_subject_reminder1 = ''; - public $email_subject_reminder2 = ''; - public $email_subject_reminder3 = ''; - public $email_subject_reminder_endless = ''; - public $email_template_reminder1 = ''; - public $email_template_reminder2 = ''; - public $email_template_reminder3 = ''; - public $email_template_reminder_endless = ''; - public $email_signature = ''; - public $enable_email_markup = true; + public $email_style = 'light'; //plain, light, dark, custom //@implemented + public $email_style_custom = ''; //the template itself //@implemented + public $email_subject_invoice = ''; //@implemented + public $email_subject_quote = ''; //@implemented + public $email_subject_credit = ''; //@implemented + public $email_subject_payment = ''; //@implemented + public $email_subject_payment_partial = ''; //@implemented + public $email_subject_statement = ''; //@implemented + public $email_template_invoice = ''; //@implemented + public $email_template_credit = ''; //@implemented + public $email_template_quote = ''; //@implemented + public $email_template_payment = ''; //@implemented + public $email_template_payment_partial = ''; //@implemented + public $email_template_statement = ''; //@implemented + public $email_subject_reminder1 = ''; //@implemented + public $email_subject_reminder2 = ''; //@implemented + public $email_subject_reminder3 = ''; //@implemented + public $email_subject_reminder_endless = ''; //@implemented + public $email_template_reminder1 = ''; //@implemented + public $email_template_reminder2 = ''; //@implemented + public $email_template_reminder3 = ''; //@implemented + public $email_template_reminder_endless = ''; //@implemented + public $email_signature = ''; //@implemented + public $enable_email_markup = true; //@TODO - public $email_subject_custom1 = ''; - public $email_subject_custom2 = ''; - public $email_subject_custom3 = ''; + public $email_subject_custom1 = ''; //@TODO + public $email_subject_custom2 = ''; //@TODO + public $email_subject_custom3 = ''; //@TODO - public $email_template_custom1 = ''; - public $email_template_custom2 = ''; - public $email_template_custom3 = ''; + public $email_template_custom1 = ''; //@TODO + public $email_template_custom2 = ''; //@TODO + public $email_template_custom3 = ''; //@TODO - public $enable_reminder1 = false; - public $enable_reminder2 = false; - public $enable_reminder3 = false; - public $enable_reminder_endless = false; + public $enable_reminder1 = false; //@partially implmemented + public $enable_reminder2 = false; //@partially implmemented + public $enable_reminder3 = false; //@partially implmemented + public $enable_reminder_endless = false; //@partially implmemented - public $num_days_reminder1 = 0; - public $num_days_reminder2 = 0; - public $num_days_reminder3 = 0; + public $num_days_reminder1 = 0;//@partially implmemented + public $num_days_reminder2 = 0;//@partially implmemented + public $num_days_reminder3 = 0;//@partially implmemented public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) @@ -429,7 +429,7 @@ class CompanySettings extends BaseSettings 'auto_convert_quote' => 'bool', 'shared_invoice_quote_counter' => 'bool', 'counter_padding' => 'integer', - 'design' => 'string', + //'design' => 'string', 'website' => 'string', 'pdf_variables' => 'object', 'portal_custom_head' => 'string', diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index a8d93a3e713c..9aba18ada4a6 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -82,8 +82,8 @@ class QuoteController extends BaseController * tags={"quotes"}, * summary="Gets a list of quotes", * description="Lists quotes, search and filters allow fine grained lists to be generated. - - Query parameters can be added to performed more fine grained filtering of the quotes, these are handled by the QuoteFilters class which defines the methods available", + * + * Query parameters can be added to performed more fine grained filtering of the quotes, these are handled by the QuoteFilters class which defines the methods available", * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), @@ -207,6 +207,8 @@ class QuoteController extends BaseController $quote = $this->quote_repo->save($request->all(), QuoteFactory::create(auth()->user()->company()->id, auth()->user()->id)); + $quote = $quote->service()->fillDefaults()->save(); + event(new QuoteWasCreated($quote, $quote->company, Ninja::eventVars())); return $this->itemResponse($quote); diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 54ec44405f52..36a884e1d90d 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -301,10 +301,6 @@ class BaseRepository if ($class->name == Quote::class) { $model = $model->calc()->getQuote(); - - if (! $model->design_id) { - $model->design_id = $this->decodePrimaryKey($client->getSetting('quote_design_id')); - } } $model->save(); diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 4db7a15ae816..669de89c5060 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -98,6 +98,13 @@ class CreditService return $this; } + + public function fillDefaults() + { + + return $this; + } + /** * Saves the credit. * @return Credit object diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 02cfef63b8e5..d0d4d4efe1ac 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -362,6 +362,13 @@ class InvoiceService return $this; } + + public function fillDefaults() + { + + return $this; + } + /** * Saves the invoice. * @return Invoice object diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index f74dd3cfe590..b18b23d423d8 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -158,6 +158,23 @@ class QuoteService return true; } + public function fillDefaults() + { + $settings = $this->quote->client->getMergedSettings(); + + if(! $this->quote->design_id) + $this->quote->design_id = $this->decodePrimaryKey($settings->quote_design_id); + + if(!isset($this->quote->footer)) + $this->quote->footer = $settings->quote_footer; + + if(!isset($this->quote->terms)) + $this->quote->terms = $settings->quote_terms; + + + return $this; + } + /** * Saves the quote. * @return Quote|null