Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example from readme does not work #1

Open
aurel-g opened this issue Aug 31, 2023 · 0 comments
Open

Example from readme does not work #1

aurel-g opened this issue Aug 31, 2023 · 0 comments

Comments

@aurel-g
Copy link

aurel-g commented Aug 31, 2023

Hi,

The example usage code given in the readme seems not to work.

I tried with a simplified version of it, in order to just generate XML :

<?php

require 'vendor/autoload.php';

$invoice = new \Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice(
    \Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice::PROFILE_MINIMUM
);
$invoice->setInvoiceNumber("FC123456789");
$invoice->setInvoiceType(Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice::INVOICE_TYPE_COMMERCIAL_INVOICE);
$invoice->setPaymentInstruction(null);
$invoice->setPaymentMeansCode(0);
$invoice->setIssueDate( new \DateTime('today') );
$invoice->setDueDate( (new \DateTime('today'))->modify('+30 days') );
$invoice->setSeller( new \Kinulab\Facturx\CrossIndustryInvoice\LegalEntity() );
$invoice->setBuyer( new \Kinulab\Facturx\CrossIndustryInvoice\LegalEntity() );
$invoice->setCurrencyCode('EUR');
$invoice->setTaxBasisTotalAmount(100);
$invoice->setTaxTotalAmount(5.61);
$invoice->setGrandTotalAmount( 105.61 );
$invoice->setDuePayableAmount( 105.61 );

$seller = $invoice->getSeller();
$seller->setName('My Company Name');
$seller->setSiret('XXXXXX');
$seller->setVatIdentifier( 'XXXXX');
$seller->setAddress( new \Kinulab\Facturx\CrossIndustryInvoice\Address() );

$sellerAddress = $seller->getAddress();
$sellerAddress->setCountryId('FR');

$buyer = $invoice->getBuyer();
$buyer->setName('The Client');
$buyer->setVatIdentifier("ABC123");

echo \Kinulab\Facturx\CrossIndustryInvoice\XmlWriter::write($invoice);

I get the fatal error Typed property Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice::$paymentInstruction must not be accessed before initialization in (...)/vendor/kinulab/facturx/src/CrossIndustryInvoice/CrossIndustryInvoice.php:470

If I add $invoice->setPaymentInstruction(null); I get Typed property Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice::$paymentMeansCode must not be accessed before initialization in (...)/vendor/kinulab/facturx/src/CrossIndustryInvoice/CrossIndustryInvoice.php:210

And finally if I add $invoice->setPaymentMeansCode(0); I get :

<br />
<b>Fatal error</b>:  Uncaught Exception: The MINIMUM XML file is not valid against the official
            XML Schema Definition : Exception: MINIMUM XML file invalid schema : XML error &quot;Element '{urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}PayeeTradeParty': This element is not expected. Expected is ( {urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100}SpecifiedTradeSettlementHeaderMonetarySummation ).
&quot;
 in /var/www/html/vendor/atgp/factur-x/src/Facturx.php:162
Stack trace:
#0 /var/www/html/vendor/kinulab/facturx/src/CrossIndustryInvoice/XmlWriter.php(34): Atgp\FacturX\Facturx-&gt;checkFacturxXsd('&lt;?xml version=&quot;...')
#1 /var/www/html/xml.php(72): Kinulab\Facturx\CrossIndustryInvoice\XmlWriter::write(Object(Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice))
#2 {main}. in /var/www/html/vendor/atgp/factur-x/src/Facturx.php:165
Stack trace:
#0 /var/www/html/vendor/kinulab/facturx/src/CrossIndustryInvoice/XmlWriter.php(34): Atgp\FacturX\Facturx-&gt;checkFacturxXsd('&lt;?xml version=&quot;...')
#1 /var/www/html/xml.php(72): Kinulab\Facturx\CrossIndustryInvoice\XmlWriter::write(Object(Kinulab\Facturx\CrossIndustryInvoice\CrossIndustryInvoice))
#2 {main}
  thrown in <b>/var/www/html/vendor/atgp/factur-x/src/Facturx.php</b> on line <b>165</b><br />

I haven't managed to generate a minimal XML example yet :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant