mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Move e_invoice null filter into form request
This commit is contained in:
parent
fa369e79cf
commit
ada65c8da9
@ -150,7 +150,7 @@ class DocumentController extends BaseController
|
||||
$document->fill($request->all());
|
||||
$document->save();
|
||||
|
||||
if($document->documentable) {
|
||||
if($document->documentable) { //@phpstan-ignore-line
|
||||
$document->documentable->touch();
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,10 @@ class UpdateClientRequest extends Request
|
||||
$input['shipping_country_id'] = $this->getCountryCode($input['shipping_country_code']);
|
||||
}
|
||||
|
||||
if (isset($input['e_invoice']) && is_array($input['e_invoice'])) {
|
||||
//ensure it is normalized first!
|
||||
$input['e_invoice'] = $this->client->filterNullsRecursive($input['e_invoice']);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -115,6 +115,11 @@ class UpdateCompanyRequest extends Request
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
}
|
||||
|
||||
if (isset($input['e_invoice']) && is_array($input['e_invoice'])) {
|
||||
//ensure it is normalized first!
|
||||
$input['e_invoice'] = $this->company->filterNullsRecursive($input['e_invoice']);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,11 @@ class UpdateInvoiceRequest extends Request
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays((int)$client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
if (isset($input['e_invoice']) && is_array($input['e_invoice'])) {
|
||||
//ensure it is normalized first!
|
||||
$input['e_invoice'] = $this->invoice->filterNullsRecursive($input['e_invoice']);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -306,19 +306,19 @@ class BaseModel extends Model
|
||||
|
||||
|
||||
/**
|
||||
* arrayFilterRecursive
|
||||
* arrayFilterRecursive nee filterNullsRecursive
|
||||
*
|
||||
* Removes null properties from an array
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public function arrayFilterRecursive(array $array): array
|
||||
public function filterNullsRecursive(array $array): array
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
// Recursively filter the nested array
|
||||
$array[$key] = $this->arrayFilterRecursive($value);
|
||||
$array[$key] = $this->filterNullsRecursive($value);
|
||||
}
|
||||
// Remove null values
|
||||
if (is_null($array[$key])) {
|
||||
|
@ -76,13 +76,6 @@ class ClientRepository extends BaseRepository
|
||||
$client->country_id = $company->settings->country_id;
|
||||
}
|
||||
|
||||
if(isset($data['e_invoice']) && is_array($data['e_invoice'])) {
|
||||
//ensure it is normalized first!
|
||||
$data['e_invoice'] = $client->arrayFilterRecursive($data['e_invoice']);
|
||||
|
||||
$client->e_invoice = $data['e_invoice'];
|
||||
}
|
||||
|
||||
$client->save();
|
||||
|
||||
if (! isset($client->number) || empty($client->number) || strlen($client->number) == 0) {
|
||||
|
@ -58,13 +58,6 @@ class CompanyRepository extends BaseRepository
|
||||
$company->smtp_password = $data['smtp_password'];
|
||||
}
|
||||
|
||||
if(isset($data['e_invoice']) && is_array($data['e_invoice'])){
|
||||
//ensure it is normalized first!
|
||||
$data['e_invoice'] = $company->arrayFilterRecursive($data['e_invoice']);
|
||||
|
||||
$company->e_invoice = $data['e_invoice'];
|
||||
}
|
||||
|
||||
$company->save();
|
||||
|
||||
return $company;
|
||||
|
109
public/build/assets/app-e0713224.js
vendored
109
public/build/assets/app-e0713224.js
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@
|
||||
]
|
||||
},
|
||||
"resources/js/app.js": {
|
||||
"file": "assets/app-e0713224.js",
|
||||
"file": "assets/app-234e3402.js",
|
||||
"imports": [
|
||||
"_index-08e160a7.js",
|
||||
"__commonjsHelpers-725317a4.js"
|
||||
|
Loading…
x
Reference in New Issue
Block a user