From 0093bf4d53299c3c982d135c673920a1b647799b Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Mon, 6 Apr 2026 23:24:11 +0200 Subject: [PATCH] Copy custom fields when converting estimate to invoice Custom fields defined on an estimate are now carried over to the invoice when using Convert to Invoice. Uses the same pattern as the clone method. Fixes #282 --- app/Services/EstimateService.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Services/EstimateService.php b/app/Services/EstimateService.php index e6d97fe2..f39b12f6 100644 --- a/app/Services/EstimateService.php +++ b/app/Services/EstimateService.php @@ -358,6 +358,19 @@ class EstimateService $this->documentItemService->createTaxes($invoice, $estimate->taxes->toArray()); } + if ($estimate->fields()->exists()) { + $customFields = []; + + foreach ($estimate->fields as $data) { + $customFields[] = [ + 'id' => $data->custom_field_id, + 'value' => $data->defaultAnswer, + ]; + } + + $invoice->addCustomFields($customFields); + } + $estimate->checkForEstimateConvertAction(); return Invoice::find($invoice->id);