Static Analysis

This commit is contained in:
David Bomba 2024-06-07 10:32:10 +10:00
parent 9a5b1e4292
commit cdde25baf7
9 changed files with 67 additions and 90 deletions

View File

@ -1,24 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataProviders;
/**
* Class FACT1.
*/
class FACT1
{
public function build()
{
$i = new \InvoiceNinja\EInvoice\Models\FACT1\Invoice();
}
}

View File

@ -998,7 +998,7 @@ class BaseController extends Controller
if(request()->has('einvoice')){ if(request()->has('einvoice')){
$ro = new Schema(); $ro = new Schema();
$response_data['einvoice_schema'] = $ro('FACT1'); $response_data['einvoice_schema'] = $ro('Peppol');
} }

View File

@ -62,7 +62,7 @@ class StaticController extends BaseController
if(request()->has('einvoice')){ if(request()->has('einvoice')){
$schema = new Schema(); $schema = new Schema();
$response_data['einvoice_schema'] = $schema('FACT1'); $response_data['einvoice_schema'] = $schema('Peppol');
} }

View File

@ -71,7 +71,7 @@ class LockedInvoiceRule implements Rule
//if now is greater than the end of month the invoice was dated - do not modify //if now is greater than the end of month the invoice was dated - do not modify
case 'end_of_month': case 'end_of_month':
if(\Carbon\Carbon::setTimezone($this->invoice->company->timezone()->name)->parse($this->invoice->date)->endOfMonth()->lte(now())) if(\Carbon\Carbon::parse($this->invoice->date)->setTimezone($this->invoice->company->timezone()->name)->endOfMonth()->lte(now()))
return false; return false;
return true; return true;

View File

@ -389,17 +389,17 @@ class NinjaMailerJob implements ShouldQueue
$company = $this->company; $company = $this->company;
$smtp_host = $company->smtp_host; $smtp_host = $company->smtp_host ?? '';
$smtp_port = $company->smtp_port; $smtp_port = $company->smtp_port;
$smtp_username = $company->smtp_username; $smtp_username = $company->smtp_username ?? '';
$smtp_password = $company->smtp_password; $smtp_password = $company->smtp_password ?? '';
$smtp_encryption = $company->smtp_encryption ?? 'tls'; $smtp_encryption = $company->smtp_encryption ?? 'tls';
$smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null; $smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null;
$smtp_verify_peer = $company->smtp_verify_peer ?? true; $smtp_verify_peer = $company->smtp_verify_peer ?? true;
if(strlen($smtp_host ?? '') <= 1 || if(strlen($smtp_host) <= 1 ||
strlen($smtp_username ?? '') <= 1 || strlen($smtp_username) <= 1 ||
strlen($smtp_password ?? '') <= 1 strlen($smtp_password) <= 1
) )
{ {
$this->nmo->settings->email_sending_method = 'default'; $this->nmo->settings->email_sending_method = 'default';

View File

@ -27,6 +27,7 @@ class OrderXDocument extends AbstractService
public OrderDocumentBuilder $orderxdocument; public OrderDocumentBuilder $orderxdocument;
/** @var \App\Models\Invoice | \App\Models\Quote | \App\Models\PurchaseOrder | \App\Models\Credit $document */ /** @var \App\Models\Invoice | \App\Models\Quote | \App\Models\PurchaseOrder | \App\Models\Credit $document */
public function __construct(public mixed $document, private readonly bool $returnObject = false, private array $tax_map = []) public function __construct(public mixed $document, private readonly bool $returnObject = false, private array $tax_map = [])
{ {
} }

View File

@ -616,17 +616,17 @@ class Email implements ShouldQueue
$company = $this->company; $company = $this->company;
$smtp_host = $company->smtp_host; $smtp_host = $company->smtp_host ?? '';
$smtp_port = $company->smtp_port; $smtp_port = $company->smtp_port;
$smtp_username = $company->smtp_username; $smtp_username = $company->smtp_username ?? '';
$smtp_password = $company->smtp_password; $smtp_password = $company->smtp_password ?? '';
$smtp_encryption = $company->smtp_encryption ?? 'tls'; $smtp_encryption = $company->smtp_encryption ?? 'tls';
$smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null; $smtp_local_domain = strlen($company->smtp_local_domain) > 2 ? $company->smtp_local_domain : null;
$smtp_verify_peer = $company->smtp_verify_peer ?? true; $smtp_verify_peer = $company->smtp_verify_peer ?? true;
if(strlen($smtp_host ?? '') <= 1 || if(strlen($smtp_host) <= 1 ||
strlen($smtp_username ?? '') <= 1 || strlen($smtp_username) <= 1 ||
strlen($smtp_password ?? '') <= 1 strlen($smtp_password) <= 1
) { ) {
$this->email_object->settings->email_sending_method = 'default'; $this->email_object->settings->email_sending_method = 'default';
return $this->setMailDriver(); return $this->setMailDriver();

42
composer.lock generated
View File

@ -1385,16 +1385,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.310.0", "version": "3.311.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "8ac02d36c609c6507136e5996f60cfd5152b4fd7" "reference": "90218b9372469babf294f97bdd764c9d47ec8a57"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/8ac02d36c609c6507136e5996f60cfd5152b4fd7", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/90218b9372469babf294f97bdd764c9d47ec8a57",
"reference": "8ac02d36c609c6507136e5996f60cfd5152b4fd7", "reference": "90218b9372469babf294f97bdd764c9d47ec8a57",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1474,9 +1474,9 @@
"support": { "support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.310.0" "source": "https://github.com/aws/aws-sdk-php/tree/3.311.1"
}, },
"time": "2024-06-04T18:05:36+00:00" "time": "2024-06-06T18:05:50+00:00"
}, },
{ {
"name": "bacon/bacon-qr-code", "name": "bacon/bacon-qr-code",
@ -4630,16 +4630,16 @@
}, },
{ {
"name": "horstoeko/zugferd", "name": "horstoeko/zugferd",
"version": "v1.0.51", "version": "v1.0.53",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/horstoeko/zugferd.git", "url": "https://github.com/horstoeko/zugferd.git",
"reference": "9e036d4a9660638b4f51d2babb397fcff29ef046" "reference": "939e93ab2e84ec476735e5957f4db7e7d58880c3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/horstoeko/zugferd/zipball/9e036d4a9660638b4f51d2babb397fcff29ef046", "url": "https://api.github.com/repos/horstoeko/zugferd/zipball/939e93ab2e84ec476735e5957f4db7e7d58880c3",
"reference": "9e036d4a9660638b4f51d2babb397fcff29ef046", "reference": "939e93ab2e84ec476735e5957f4db7e7d58880c3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4699,9 +4699,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/horstoeko/zugferd/issues", "issues": "https://github.com/horstoeko/zugferd/issues",
"source": "https://github.com/horstoeko/zugferd/tree/v1.0.51" "source": "https://github.com/horstoeko/zugferd/tree/v1.0.53"
}, },
"time": "2024-05-31T17:20:07+00:00" "time": "2024-06-05T16:49:22+00:00"
}, },
{ {
"name": "http-interop/http-factory-guzzle", "name": "http-interop/http-factory-guzzle",
@ -5076,12 +5076,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/invoiceninja/einvoice.git", "url": "https://github.com/invoiceninja/einvoice.git",
"reference": "d067c8d89e61c76d1ef122ce15b4ed950289d900" "reference": "17c57fabb8f065d2782dfc432df9fb801136d82b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/d067c8d89e61c76d1ef122ce15b4ed950289d900", "url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/17c57fabb8f065d2782dfc432df9fb801136d82b",
"reference": "d067c8d89e61c76d1ef122ce15b4ed950289d900", "reference": "17c57fabb8f065d2782dfc432df9fb801136d82b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5122,7 +5122,7 @@
"source": "https://github.com/invoiceninja/einvoice/tree/main", "source": "https://github.com/invoiceninja/einvoice/tree/main",
"issues": "https://github.com/invoiceninja/einvoice/issues" "issues": "https://github.com/invoiceninja/einvoice/issues"
}, },
"time": "2024-06-04T22:01:40+00:00" "time": "2024-06-07T00:28:18+00:00"
}, },
{ {
"name": "invoiceninja/inspector", "name": "invoiceninja/inspector",
@ -18244,16 +18244,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.11.3", "version": "1.11.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "e64220a05c1209fc856d58e789c3b7a32c0bb9a5" "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e64220a05c1209fc856d58e789c3b7a32c0bb9a5", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9100a76ce8015b9aa7125b9171ae3a76887b6c82",
"reference": "e64220a05c1209fc856d58e789c3b7a32c0bb9a5", "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -18298,7 +18298,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-05-31T13:53:37+00:00" "time": "2024-06-06T12:19:22+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",

View File

@ -23,51 +23,51 @@ use Illuminate\Support\Facades\Cache;
use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validation;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Invoiceninja\Einvoice\Models\FACT1\ItemType\Item; use Invoiceninja\Einvoice\Models\Peppol\ItemType\Item;
use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Invoiceninja\Einvoice\Models\FACT1\PartyType\Party; use Invoiceninja\Einvoice\Models\Peppol\PartyType\Party;
use Invoiceninja\Einvoice\Models\FACT1\PriceType\Price; use Invoiceninja\Einvoice\Models\Peppol\PriceType\Price;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor; use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Invoiceninja\Einvoice\Models\FACT1\ContactType\Contact; use Invoiceninja\Einvoice\Models\Peppol\ContactType\Contact;
use Invoiceninja\Einvoice\Models\FACT1\CountryType\Country; use Invoiceninja\Einvoice\Models\Peppol\CountryType\Country;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\TaxAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\TaxAmount;
use Invoiceninja\Einvoice\Models\FACT1\TaxTotalType\TaxTotal; use Invoiceninja\Einvoice\Models\Peppol\TaxTotalType\TaxTotal;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\PriceAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\PriceAmount;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Invoiceninja\Einvoice\Models\FACT1\TaxSchemeType\TaxScheme; use Invoiceninja\Einvoice\Models\Peppol\TaxSchemeType\TaxScheme;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader; use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Invoiceninja\Einvoice\Models\FACT1\AddressType\PostalAddress; use Invoiceninja\Einvoice\Models\Peppol\AddressType\PostalAddress;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Invoiceninja\Einvoice\Models\FACT1\InvoiceLineType\InvoiceLine; use Invoiceninja\Einvoice\Models\Peppol\InvoiceLineType\InvoiceLine;
use Invoiceninja\Einvoice\Models\FACT1\TaxScheme as FACT1TaxScheme; use Invoiceninja\Einvoice\Models\Peppol\TaxScheme as PeppolTaxScheme;
use Invoiceninja\Einvoice\Models\FACT1\TaxSubtotalType\TaxSubtotal; use Invoiceninja\Einvoice\Models\Peppol\TaxSubtotalType\TaxSubtotal;
use Invoiceninja\Einvoice\Models\FACT1\QuantityType\InvoicedQuantity; use Invoiceninja\Einvoice\Models\Peppol\QuantityType\InvoicedQuantity;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\LineExtensionAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\LineExtensionAmount;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\PayableAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\PayableAmount;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\TaxableAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\TaxableAmount;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\TaxExclusiveAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\TaxExclusiveAmount;
use Invoiceninja\Einvoice\Models\FACT1\AmountType\TaxInclusiveAmount; use Invoiceninja\Einvoice\Models\Peppol\AmountType\TaxInclusiveAmount;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Invoiceninja\Einvoice\Models\FACT1\PartyTaxSchemeType\PartyTaxScheme; use Invoiceninja\Einvoice\Models\Peppol\PartyTaxSchemeType\PartyTaxScheme;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter; use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Invoiceninja\Einvoice\Models\FACT1\MonetaryTotalType\LegalMonetaryTotal; use Invoiceninja\Einvoice\Models\Peppol\MonetaryTotalType\LegalMonetaryTotal;
use Invoiceninja\Einvoice\Models\FACT1\PartyLegalEntityType\PartyLegalEntity; use Invoiceninja\Einvoice\Models\Peppol\PartyLegalEntityType\PartyLegalEntity;
use Invoiceninja\Einvoice\Models\FACT1\TaxCategoryType\ClassifiedTaxCategory; use Invoiceninja\Einvoice\Models\Peppol\TaxCategoryType\ClassifiedTaxCategory;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata; use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Invoiceninja\Einvoice\Models\FACT1\CustomerPartyType\AccountingCustomerParty; use Invoiceninja\Einvoice\Models\Peppol\CustomerPartyType\AccountingCustomerParty;
use Invoiceninja\Einvoice\Models\FACT1\SupplierPartyType\AccountingSupplierParty; use Invoiceninja\Einvoice\Models\Peppol\SupplierPartyType\AccountingSupplierParty;
use Invoiceninja\Einvoice\Models\FACT1\PartyIdentificationType\PartyIdentification; use Invoiceninja\Einvoice\Models\Peppol\PartyIdentificationType\PartyIdentification;
use Invoiceninja\Einvoice\Models\FACT1\TaxCategoryType\TaxCategory; use Invoiceninja\Einvoice\Models\Peppol\TaxCategoryType\TaxCategory;
/** /**
* @test * @test
*/ */
class Fact1Test extends TestCase class PeppolTest extends TestCase
{ {
use MockAccountData; use MockAccountData;
use DatabaseTransactions; use DatabaseTransactions;
@ -140,7 +140,7 @@ class Fact1Test extends TestCase
$_invoice->service()->markSent()->save(); $_invoice->service()->markSent()->save();
$calc = $_invoice->calc(); $calc = $_invoice->calc();
$invoice = new \Invoiceninja\Einvoice\Models\FACT1\Invoice(); $invoice = new \Invoiceninja\Einvoice\Models\Peppol\Invoice();
$invoice->UBLVersionID = '2.1'; $invoice->UBLVersionID = '2.1';
$invoice->CustomizationID = 'urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1'; $invoice->CustomizationID = 'urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1';
$invoice->ID = $_invoice->number; $invoice->ID = $_invoice->number;
@ -298,7 +298,7 @@ class Fact1Test extends TestCase
$i->Description = $item->notes; $i->Description = $item->notes;
$i->Name = $item->product_key; $i->Name = $item->product_key;
$tax_scheme = new FACT1TaxScheme(); $tax_scheme = new PeppolTaxScheme();
$tax_scheme->ID = $item->tax_name1; $tax_scheme->ID = $item->tax_name1;
$tax_scheme->Name = $item->tax_rate1; $tax_scheme->Name = $item->tax_rate1;