mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-18 18:54:07 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user