Skip to content

Commit

Permalink
Rework/Cleanup Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Sep 14, 2023
1 parent 25736f4 commit 562cc39
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 47 deletions.
2 changes: 1 addition & 1 deletion examples/En16931PdfMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use horstoeko\zugferd\ZugferdDocumentPdfMerger;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$pdfMerger = new ZugferdDocumentPdfMerger(dirname(__FILE__) . "/invoice_1.xml", dirname(__FILE__) . "/emptypdf.pdf");
$pdfMerger->generateDocument();
Expand Down
2 changes: 1 addition & 1 deletion examples/En16931ReaderPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use horstoeko\zugferd\ZugferdDocumentPdfReader;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/invoice_1.pdf");

Expand Down
2 changes: 1 addition & 1 deletion examples/En16931ReaderPdfWithJsonExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\ZugferdDocumentJsonExporter;
use horstoeko\zugferd\ZugferdDocumentPdfReader;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/invoice_1.pdf");

Expand Down
4 changes: 2 additions & 2 deletions examples/En16931Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_EN16931);
$document
Expand Down Expand Up @@ -47,4 +47,4 @@
->SetDocumentPositionQuantity(50, "H87")
->AddDocumentPositionTax('S', 'VAT', 7)
->SetDocumentPositionLineSummation(275.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/En16931SimpleQuick.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\quick\ZugferdQuickDescriptorEn16931;
use horstoeko\zugferd\codelists\ZugferdTextSubjectCodeQualifiers;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = (ZugferdQuickDescriptorEn16931::doCreateNew())
->doCreateInvoice("471102", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
Expand All @@ -30,4 +30,4 @@
->doAddTradeAllowanceCharge(-2.61, "Rechnungsrabatt 1", "S", "VAT", 7.0)
->doAddTradeAllowanceCharge(-2.50, "Rechnungsrabatt 2", "S", "VAT", 19.0)
->doAddTradeAllowanceCharge(-0.50, "Rechnungsrabatt 2", "S", "VAT", 7.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
37 changes: 14 additions & 23 deletions examples/En16931SimpleReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,22 @@

error_reporting(E_ERROR | E_WARNING | E_PARSE);

use horstoeko\zugferd\exception\ZugferdValidationFailed;
use horstoeko\zugferd\ZugferdDocumentReader;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

try {
$document = ZugferdDocumentReader::readAndGuessFromFile(dirname(__FILE__) . "/../tests/data/en16931_simple.xml", true);

$document = ZugferdDocumentReader::readAndGuessFromFile(dirname(__FILE__) . "/../tests/data/en16931_simple.xml", true);
$document->getDocumentInformation(
$documentno,
$documenttypecode,
$documentdate,
$duedate,
$invoiceCurrency,
$taxCurrency,
$documentname,
$documentlanguage,
$effectiveSpecifiedPeriod
);

$document->getDocumentInformation(
$documentno,
$documenttypecode,
$documentdate,
$duedate,
$invoiceCurrency,
$taxCurrency,
$documentname,
$documentlanguage,
$effectiveSpecifiedPeriod
);

echo "The Invoice No. is {$documentno}" . PHP_EOL;

} catch (ZugferdValidationFailed $e) {

var_dump($e->getValidationErrorList());

}
echo "The Invoice No. is {$documentno}" . PHP_EOL;
4 changes: 2 additions & 2 deletions examples/En16931SimpleToJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;
use horstoeko\zugferd\ZugferdDocumentJsonExporter;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_EN16931);
$document
Expand Down Expand Up @@ -48,7 +48,7 @@
->SetDocumentPositionQuantity(50, "H87")
->AddDocumentPositionTax('S', 'VAT', 7)
->SetDocumentPositionLineSummation(275.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");

$jsonExporter = new ZugferdDocumentJsonExporter($document);
echo $jsonExporter->toPrettyJsonString();
2 changes: 1 addition & 1 deletion examples/En16931SimpleWithPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_EN16931);
$document
Expand Down
4 changes: 2 additions & 2 deletions examples/ExtendedSimpleQuick.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\quick\ZugferdQuickDescriptorExtended;
use horstoeko\zugferd\codelists\ZugferdTextSubjectCodeQualifiers;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = (ZugferdQuickDescriptorExtended::doCreateNew())
->doCreateInvoice("471102", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
Expand Down Expand Up @@ -31,4 +31,4 @@
->doAddTradeAllowanceCharge(-2.50, "Rechnungsrabatt 2", "S", "VAT", 19.0)
->doAddTradeAllowanceCharge(-0.50, "Rechnungsrabatt 2", "S", "VAT", 7.0)
->doAddLogisticsServiceCharge(10.0, "Transportkosten", "VAT", "S", 19.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnung2Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_XRECHNUNG_2);
$document
Expand Down Expand Up @@ -42,4 +42,4 @@
->SetDocumentPositionQuantity(50, "H87")
->AddDocumentPositionTax('S', 'VAT', 7)
->SetDocumentPositionLineSummation(275.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnung2SimpleQuick.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\quick\ZugferdQuickDescriptorXRechnung2;
use horstoeko\zugferd\codelists\ZugferdTextSubjectCodeQualifiers;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = (ZugferdQuickDescriptorXRechnung2::doCreateNew())
->doCreateInvoice("471102", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
Expand All @@ -30,4 +30,4 @@
->doAddTradeAllowanceCharge(-2.61, "Rechnungsrabatt 1", "S", "VAT", 7.0)
->doAddTradeAllowanceCharge(-2.50, "Rechnungsrabatt 2", "S", "VAT", 19.0)
->doAddTradeAllowanceCharge(-0.50, "Rechnungsrabatt 2", "S", "VAT", 7.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnung3Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_XRECHNUNG_3);
$document
Expand Down Expand Up @@ -42,4 +42,4 @@
->SetDocumentPositionQuantity(50, "H87")
->AddDocumentPositionTax('S', 'VAT', 7)
->SetDocumentPositionLineSummation(275.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnung3SimpleQuick.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\quick\ZugferdQuickDescriptorXRechnung3;
use horstoeko\zugferd\codelists\ZugferdTextSubjectCodeQualifiers;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = (ZugferdQuickDescriptorXRechnung3::doCreateNew())
->doCreateInvoice("471102", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
Expand All @@ -30,4 +30,4 @@
->doAddTradeAllowanceCharge(-2.61, "Rechnungsrabatt 1", "S", "VAT", 7.0)
->doAddTradeAllowanceCharge(-2.50, "Rechnungsrabatt 2", "S", "VAT", 19.0)
->doAddTradeAllowanceCharge(-0.50, "Rechnungsrabatt 2", "S", "VAT", 7.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnungSimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use horstoeko\zugferd\ZugferdProfiles;
use horstoeko\zugferd\codelists\ZugferdPaymentMeans;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_XRECHNUNG);
$document
Expand Down Expand Up @@ -42,4 +42,4 @@
->SetDocumentPositionQuantity(50, "H87")
->AddDocumentPositionTax('S', 'VAT', 7)
->SetDocumentPositionLineSummation(275.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");
4 changes: 2 additions & 2 deletions examples/XRechnungSimpleQuick.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use horstoeko\zugferd\quick\ZugferdQuickDescriptorXRechnung;
use horstoeko\zugferd\codelists\ZugferdTextSubjectCodeQualifiers;

require getcwd() . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../vendor/autoload.php";

$document = (ZugferdQuickDescriptorXRechnung::doCreateNew())
->doCreateInvoice("471102", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
Expand All @@ -30,4 +30,4 @@
->doAddTradeAllowanceCharge(-2.61, "Rechnungsrabatt 1", "S", "VAT", 7.0)
->doAddTradeAllowanceCharge(-2.50, "Rechnungsrabatt 2", "S", "VAT", 19.0)
->doAddTradeAllowanceCharge(-0.50, "Rechnungsrabatt 2", "S", "VAT", 7.0)
->writeFile(getcwd() . "/factur-x.xml");
->writeFile(dirname(__FILE__) . "/factur-x.xml");

0 comments on commit 562cc39

Please sign in to comment.