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
This commit is contained in:
Darko Gjorgjijoski
2026-04-06 23:24:11 +02:00
parent 25b61b73a0
commit 0093bf4d53

View File

@@ -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);