mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Move null filter to basemodel
This commit is contained in:
parent
94da1d9ded
commit
516533c374
@ -304,6 +304,31 @@ class BaseModel extends Model
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* arrayFilterRecursive
|
||||||
|
*
|
||||||
|
* Removes null properties from an array
|
||||||
|
*
|
||||||
|
* @param array $array
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function arrayFilterRecursive(array $array): array
|
||||||
|
{
|
||||||
|
foreach ($array as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
// Recursively filter the nested array
|
||||||
|
$array[$key] = $this->arrayFilterRecursive($value);
|
||||||
|
}
|
||||||
|
// Remove null values
|
||||||
|
if (is_null($array[$key])) {
|
||||||
|
unset($array[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base64 encoded PDF string of the entity
|
* Returns the base64 encoded PDF string of the entity
|
||||||
* @deprecated - unused implementation
|
* @deprecated - unused implementation
|
||||||
|
@ -50,7 +50,7 @@ use Laracasts\Presenter\PresentableTrait;
|
|||||||
* @property int|null $last_login
|
* @property int|null $last_login
|
||||||
* @property int|null $industry_id
|
* @property int|null $industry_id
|
||||||
* @property int|null $size_id
|
* @property int|null $size_id
|
||||||
* @property object|null $e_invoice
|
* @property object|array|null $e_invoice
|
||||||
* @property string|null $address1
|
* @property string|null $address1
|
||||||
* @property string|null $address2
|
* @property string|null $address2
|
||||||
* @property string|null $city
|
* @property string|null $city
|
||||||
|
@ -76,6 +76,13 @@ class ClientRepository extends BaseRepository
|
|||||||
$client->country_id = $company->settings->country_id;
|
$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();
|
$client->save();
|
||||||
|
|
||||||
if (! isset($client->number) || empty($client->number) || strlen($client->number) == 0) {
|
if (! isset($client->number) || empty($client->number) || strlen($client->number) == 0) {
|
||||||
@ -106,6 +113,7 @@ class ClientRepository extends BaseRepository
|
|||||||
if (array_key_exists('contacts', $contact_data) || $client->contacts()->count() == 0) {
|
if (array_key_exists('contacts', $contact_data) || $client->contacts()->count() == 0) {
|
||||||
$this->contact_repo->save($contact_data, $client);
|
$this->contact_repo->save($contact_data, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class CompanyRepository extends BaseRepository
|
|||||||
|
|
||||||
if(isset($data['e_invoice']) && is_array($data['e_invoice'])){
|
if(isset($data['e_invoice']) && is_array($data['e_invoice'])){
|
||||||
//ensure it is normalized first!
|
//ensure it is normalized first!
|
||||||
$data['e_invoice'] = $this->arrayFilterRecursive($data['e_invoice']);
|
$data['e_invoice'] = $company->arrayFilterRecursive($data['e_invoice']);
|
||||||
|
|
||||||
$company->e_invoice = $data['e_invoice'];
|
$company->e_invoice = $data['e_invoice'];
|
||||||
}
|
}
|
||||||
@ -70,24 +70,6 @@ class CompanyRepository extends BaseRepository
|
|||||||
return $company;
|
return $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function arrayFilterRecursive(array $array): array
|
|
||||||
{
|
|
||||||
foreach ($array as $key => $value) {
|
|
||||||
if (is_array($value)) {
|
|
||||||
// Recursively filter the nested array
|
|
||||||
$array[$key] = $this->arrayFilterRecursive($value);
|
|
||||||
}
|
|
||||||
// Remove null values
|
|
||||||
if (is_null($array[$key])) {
|
|
||||||
unset($array[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $array;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parseCustomFields
|
* parseCustomFields
|
||||||
*
|
*
|
||||||
|
@ -123,10 +123,11 @@ class SendEDocument implements ShouldQueue
|
|||||||
$activity->company_id = $model->company_id;
|
$activity->company_id = $model->company_id;
|
||||||
$activity->activity_type_id = Activity::EMAIL_EINVOICE_SUCCESS;
|
$activity->activity_type_id = Activity::EMAIL_EINVOICE_SUCCESS;
|
||||||
$activity->invoice_id = $model->id;
|
$activity->invoice_id = $model->id;
|
||||||
$activity->notes = $guid;
|
$activity->notes = str_replace('"', '', $guid);
|
||||||
|
|
||||||
$activity->save();
|
$activity->save();
|
||||||
|
|
||||||
$model->backup = $guid;
|
$model->backup = str_replace('"', '', $guid);
|
||||||
$model->saveQuietly();
|
$model->saveQuietly();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ class Peppol extends AbstractService
|
|||||||
$this->p_invoice->DueDate = new \DateTime($this->invoice->due_date);
|
$this->p_invoice->DueDate = new \DateTime($this->invoice->due_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->p_invoice->InvoiceTypeCode = 380; //
|
$this->p_invoice->InvoiceTypeCode = ($this->invoice->amount >= 0) ? 380 : 381; //
|
||||||
$this->p_invoice->AccountingSupplierParty = $this->getAccountingSupplierParty();
|
$this->p_invoice->AccountingSupplierParty = $this->getAccountingSupplierParty();
|
||||||
$this->p_invoice->AccountingCustomerParty = $this->getAccountingCustomerParty();
|
$this->p_invoice->AccountingCustomerParty = $this->getAccountingCustomerParty();
|
||||||
$this->p_invoice->InvoiceLine = $this->getInvoiceLines();
|
$this->p_invoice->InvoiceLine = $this->getInvoiceLines();
|
||||||
|
@ -201,8 +201,8 @@
|
|||||||
"url": "https://github.com/turbo124/snappdf"
|
"url": "https://github.com/turbo124/snappdf"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"vcs",
|
"type": "vcs",
|
||||||
"url":"https://github.com/karneaud/QuickBooks-V3-PHP-SDK.git"
|
"url": "https://github.com/karneaud/QuickBooks-V3-PHP-SDK.git"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
|
@ -67,7 +67,7 @@ use InvoiceNinja\EInvoice\Models\Peppol\TaxCategoryType\TaxCategory;
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
class FACT1Test extends TestCase
|
class Fact1Test extends TestCase
|
||||||
{
|
{
|
||||||
use MockAccountData;
|
use MockAccountData;
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
* @license https://www.elastic.co/licensing/elastic-license
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use App\Jobs\EDocument\CreateEDocument;
|
use App\Jobs\EDocument\CreateEDocument;
|
||||||
use App\Jobs\Entity\CreateRawPdf;
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use horstoeko\zugferd\ZugferdDocumentReader;
|
use horstoeko\zugferd\ZugferdDocumentReader;
|
||||||
|
Loading…
Reference in New Issue
Block a user