diff --git a/app/Services/Quote/ConvertQuoteToProject.php b/app/Services/Quote/ConvertQuoteToProject.php new file mode 100644 index 000000000000..d15aabd13562 --- /dev/null +++ b/app/Services/Quote/ConvertQuoteToProject.php @@ -0,0 +1,55 @@ +quote->line_items); + + $project = ProjectFactory::create($this->quote->company_id, $this->quote->user_id); + $project->name = ctrans('texts.quote_number_short'). " " . $this->quote->number . "[{$this->quote->client->present()->name()}]"; + $project->client_id = $this->quote->client_id; + $project->public_notes = $this->quote->public_notes; + $project->private_notes = $this->quote->private_notes; + $project->budgeted_hours = $quote_items->sum('quantity') ?? 0; + $project->task_rate = ($this->quote->amount / $project->budgeted_hours) ?? 0; + $project->saveQuietly(); + $project->number = $this->getNextProjectNumber($project); + $project->saveQuietly(); + + $this->quote->project_id = $project->id; + $this->quote->saveQuietly(); + + event('eloquent.created: App\Models\Project', $project); + + $quote_items->each(function($item){ + + }); + + return $project; + } +} \ No newline at end of file diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 97b2e7ea46f5..058f9ed36731 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -663,6 +663,12 @@ class HtmlEngine $data['$payment.custom3'] = ['value' => '', 'label' => ctrans('texts.payment')]; $data['$payment.custom4'] = ['value' => '', 'label' => ctrans('texts.payment')]; + $data['$payment.amount'] = ['value' => '', 'label' => ctrans('texts.payment')]; + $data['$payment.date'] = ['value' => '', 'label' => ctrans('texts.payment_date')]; + $data['$payment.number'] = ['value' => '', 'label' => ctrans('texts.payment_number')]; + $data['$payment.transaction_reference'] = ['value' => '', 'label' => ctrans('texts.transaction_reference')]; + + if ($this->entity_string == 'invoice' && $this->entity->payments()->exists()) { $payment_list = '

'; @@ -672,7 +678,6 @@ class HtmlEngine $data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')]; - $payment = $this->entity->payments()->first(); $data['$payment.custom1'] = ['value' => $payment->custom_value1, 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment1')]; @@ -680,6 +685,11 @@ class HtmlEngine $data['$payment.custom3'] = ['value' => $payment->custom_value3, 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment3')]; $data['$payment.custom4'] = ['value' => $payment->custom_value4, 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment4')]; + $data['$payment.amount'] = ['value' => Number::formatMoney($payment->amount, $this->client), 'label' => ctrans('texts.payment')]; + $data['$payment.date'] = ['value' => $this->formatDate($payment->date, $this->client->date_format()), 'label' => ctrans('texts.payment_date')]; + $data['$payment.number'] = ['value' => $payment->number, 'label' => ctrans('texts.payment_number')]; + $data['$payment.transaction_reference'] = ['value' => $payment->transaction_reference, 'label' => ctrans('texts.transaction_reference')]; + } if (($this->entity_string == 'invoice' || $this->entity_string == 'recurring_invoice') && isset($this->company?->custom_fields?->company1)) {