diff --git a/.task/dev.yaml b/.task/dev.yaml index e1acb31..092e13e 100644 --- a/.task/dev.yaml +++ b/.task/dev.yaml @@ -25,3 +25,13 @@ tasks: desc: Fixes the PHP files with PHP-CS-Fixer cmds: - ./vendor/bin/php-cs-fixer fix + + generators: + desc: Runs the code generators (Enums etc.) + cmds: + - php ./tools/Generators/CountryCodeEnumGenerator.php + - php ./tools/Generators/CurrencyCodeEnumGenerator.php + - php ./tools/Generators/DocumentTypeEnumGenerator.php + - php ./tools/Generators/ReferenceQualifierEnumGenerator.php + - php ./tools/Generators/UnitCodeEnumGenerator.php + - ./vendor/bin/php-cs-fixer fix \ No newline at end of file diff --git a/README.md b/README.md index e1164fa..4e01880 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,16 @@ In this example we generate a CIUS (XRechnung 3.0) as UBL document ```PHP use easybill\eInvoicing\Transformer; use easybill\eInvoicing\UBL\Documents\UblInvoice; +use easybill\eInvoicing\Enums\CurrencyCode; +use easybill\eInvoicing\Enums\DocumentType; $document = new UblInvoice(); $document->customizationId = 'urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0'; $document->profileId = 'urn:fdc:peppol.eu:2017:poacc:billing:01:1.0'; $document->id = '123456XX'; $document->issueDate = '2016-04-04'; -$document->invoiceTypeCode = 380; -$document->documentCurrencyCode = 'EUR'; +$document->invoiceTypeCode = DocumentType::COMMERCIAL_INVOICE; +$document->documentCurrencyCode = CurrencyCode::EUR; $document->buyerReference = '04011000-12345-03'; // etc... $xml = Transformer::create()->transformToXml($document) diff --git a/phpstan.neon b/phpstan.neon index 1d79e87..c2ef599 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,6 @@ parameters: level: 9 + excludePaths: + - tests/* paths: - - 'src' \ No newline at end of file + - src \ No newline at end of file diff --git a/src/CII/Models/Amount.php b/src/CII/Models/Amount.php index d298ba2..2d6d79e 100644 --- a/src/CII/Models/Amount.php +++ b/src/CII/Models/Amount.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\CurrencyCode; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlAttribute; @@ -15,12 +16,12 @@ final class Amount #[XmlValue(cdata: false)] public string $value; - #[Type('string')] + #[Type(CurrencyCode::class)] #[XmlAttribute] #[SerializedName('currencyID')] - public ?string $currency = null; + public ?CurrencyCode $currency = null; - public static function create(string $amount, ?string $currency = null): self + public static function create(string $amount, ?CurrencyCode $currency = null): self { $self = new self(); $self->value = $amount; diff --git a/src/CII/Models/BinaryObject.php b/src/CII/Models/BinaryObject.php index 5e50709..6c28102 100644 --- a/src/CII/Models/BinaryObject.php +++ b/src/CII/Models/BinaryObject.php @@ -4,14 +4,15 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\MimeType; use JMS\Serializer\Annotation as JMS; final class BinaryObject { - #[JMS\Type('string')] + #[JMS\Type(MimeType::class)] #[JMS\XmlAttribute] #[JMS\SerializedName('mimeCode')] - public string $mimeCode; + public MimeType $mimeCode; #[JMS\Type('string')] #[JMS\XmlAttribute] diff --git a/src/CII/Models/ClassCode.php b/src/CII/Models/ClassCode.php new file mode 100644 index 0000000..43e603b --- /dev/null +++ b/src/CII/Models/ClassCode.php @@ -0,0 +1,30 @@ +value = $id; + $self->listID = $listID; + return $self; + } +} diff --git a/src/CII/Models/ExchangedDocument.php b/src/CII/Models/ExchangedDocument.php index 04955c9..6ebd48d 100644 --- a/src/CII/Models/ExchangedDocument.php +++ b/src/CII/Models/ExchangedDocument.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\DocumentType; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; @@ -21,10 +22,10 @@ final class ExchangedDocument #[SerializedName('Name')] public ?string $name = null; - #[Type('string')] + #[Type(DocumentType::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('TypeCode')] - public string $typeCode; + public DocumentType $typeCode; #[Type(DateTime::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] diff --git a/src/CII/Models/HeaderTradeAgreement.php b/src/CII/Models/HeaderTradeAgreement.php index 52b7453..a13104f 100644 --- a/src/CII/Models/HeaderTradeAgreement.php +++ b/src/CII/Models/HeaderTradeAgreement.php @@ -16,6 +16,7 @@ 'buyerTradeParty', 'sellerTaxRepresentativeTradeParty', 'buyerTaxRepresentativeTradeParty', + 'sellerOrderReferencedDocument', 'buyerOrderReferencedDocument', 'contractReferencedDocument', 'additionalReferencedDocuments', @@ -48,6 +49,11 @@ final class HeaderTradeAgreement #[SerializedName('BuyerTaxRepresentativeTradeParty')] public ?TradeParty $buyerTaxRepresentativeTradeParty = null; + #[Type(ReferencedDocument::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('SellerOrderReferencedDocument')] + public ?ReferencedDocument $sellerOrderReferencedDocument = null; + #[Type(ReferencedDocument::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('BuyerOrderReferencedDocument')] diff --git a/src/CII/Models/HeaderTradeDelivery.php b/src/CII/Models/HeaderTradeDelivery.php index 67d71c8..ace25cc 100644 --- a/src/CII/Models/HeaderTradeDelivery.php +++ b/src/CII/Models/HeaderTradeDelivery.php @@ -20,6 +20,16 @@ final class HeaderTradeDelivery #[SerializedName('ActualDeliverySupplyChainEvent')] public ?SupplyChainEvent $chainEvent = null; + #[Type(ReferencedDocument::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DespatchAdviceReferencedDocument')] + public ?ReferencedDocument $despatchAdviceReferencedDocument = null; + + #[Type(ReferencedDocument::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ReceivingAdviceReferencedDocument')] + public ?ReferencedDocument $receivingAdviceReferencedDocument = null; + #[Type(ReferencedDocument::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('DeliveryNoteReferencedDocument')] diff --git a/src/CII/Models/HeaderTradeSettlement.php b/src/CII/Models/HeaderTradeSettlement.php index d4a087d..37b84a0 100644 --- a/src/CII/Models/HeaderTradeSettlement.php +++ b/src/CII/Models/HeaderTradeSettlement.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\CurrencyCode; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; @@ -21,10 +22,15 @@ final class HeaderTradeSettlement #[SerializedName('PaymentReference')] public ?string $paymentReference = null; - #[Type('string')] + #[Type(CurrencyCode::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('TaxCurrencyCode')] + public ?CurrencyCode $taxCurrency = null; + + #[Type(CurrencyCode::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('InvoiceCurrencyCode')] - public string $currency; + public CurrencyCode $invoiceCurrency; #[Type(TradeParty::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] @@ -80,4 +86,9 @@ final class HeaderTradeSettlement #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('InvoiceReferencedDocument')] public ?ReferencedDocument $invoiceReferencedDocument = null; + + /** @var TradeAccountingAccount[] */ + #[Type('array')] + #[XmlList(entry: 'ReceivableSpecifiedTradeAccountingAccount', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + public array $tradeAccountingAccount = []; } diff --git a/src/CII/Models/LineTradeSettlement.php b/src/CII/Models/LineTradeSettlement.php index 5719c59..8da7724 100644 --- a/src/CII/Models/LineTradeSettlement.php +++ b/src/CII/Models/LineTradeSettlement.php @@ -4,23 +4,21 @@ namespace easybill\eInvoicing\CII\Models; +use JMS\Serializer\Annotation\AccessorOrder; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; use JMS\Serializer\Annotation\XmlList; +#[AccessorOrder(order: 'custom', custom: ['tradeTax', 'billingSpecifiedPeriod', 'specifiedTradeAllowanceCharge', 'name', 'description', 'tradeCountry', 'monetarySummation', 'additionalReferencedDocument', 'tradeAccountingAccount'])] final class LineTradeSettlement { - /** - * @var TradeTax[] - */ + /** @var TradeTax[] */ #[Type('array')] #[XmlList(entry: 'ApplicableTradeTax', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $tradeTax = []; - /** - * @var TradeAllowanceCharge[] - */ + /** @var TradeAllowanceCharge[] */ #[Type('array')] #[XmlList(entry: 'SpecifiedTradeAllowanceCharge', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $specifiedTradeAllowanceCharge = []; @@ -35,10 +33,13 @@ final class LineTradeSettlement #[SerializedName('SpecifiedTradeSettlementLineMonetarySummation')] public TradeSettlementLineMonetarySummation $monetarySummation; - /** - * @var TradeAccountingAccount[] - */ + /** @var TradeAccountingAccount[] */ #[Type('array')] #[XmlList(entry: 'ReceivableSpecifiedTradeAccountingAccount', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] public array $tradeAccountingAccount = []; + + /** @var ReferencedDocument[] */ + #[Type('array')] + #[XmlList(entry: 'AdditionalReferencedDocument', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + public array $additionalReferencedDocument = []; } diff --git a/src/CII/Models/ProductCharacteristic.php b/src/CII/Models/ProductCharacteristic.php new file mode 100644 index 0000000..6516efd --- /dev/null +++ b/src/CII/Models/ProductCharacteristic.php @@ -0,0 +1,22 @@ +value = $value; diff --git a/src/CII/Models/ReferencedDocument.php b/src/CII/Models/ReferencedDocument.php index 8087ce5..4ea2065 100644 --- a/src/CII/Models/ReferencedDocument.php +++ b/src/CII/Models/ReferencedDocument.php @@ -4,6 +4,8 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\DocumentType; +use easybill\eInvoicing\Enums\ReferenceQualifier; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; @@ -20,10 +22,10 @@ final class ReferencedDocument #[SerializedName('URIID')] public ?Id $uriid = null; - #[Type('string')] + #[Type(DocumentType::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('TypeCode')] - public ?string $typeCode = null; + public ?DocumentType $typeCode = null; #[Type('string')] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] @@ -45,6 +47,11 @@ final class ReferencedDocument #[SerializedName('LineID')] public ?string $lineId = null; + #[Type(ReferenceQualifier::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('ReferenceTypeCode')] + public ?ReferenceQualifier $referenceTypeCode = null; + public static function create(string $issuerAssignedID): self { $self = new self(); diff --git a/src/CII/Models/TradeAddress.php b/src/CII/Models/TradeAddress.php index 2301a21..f1ae368 100644 --- a/src/CII/Models/TradeAddress.php +++ b/src/CII/Models/TradeAddress.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\CII\Models; +use easybill\eInvoicing\Enums\CountryCode; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; @@ -35,10 +36,10 @@ final class TradeAddress #[SerializedName('CityName')] public ?string $city = null; - #[Type('string')] + #[Type(CountryCode::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('CountryID')] - public ?string $countryCode = null; + public ?CountryCode $countryCode = null; #[Type('string')] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] diff --git a/src/CII/Models/TradeAllowanceCharge.php b/src/CII/Models/TradeAllowanceCharge.php index 4a0e15d..9d23726 100644 --- a/src/CII/Models/TradeAllowanceCharge.php +++ b/src/CII/Models/TradeAllowanceCharge.php @@ -31,6 +31,11 @@ final class TradeAllowanceCharge #[JMS\SerializedName('ActualAmount')] public Amount $actualAmount; + #[JMS\Type('string')] + #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[JMS\SerializedName('ReasonCode')] + public ?string $reasonCode = null; + #[JMS\Type('string')] #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[JMS\SerializedName('Reason')] diff --git a/src/CII/Models/TradeParty.php b/src/CII/Models/TradeParty.php index b1d1143..e98022b 100644 --- a/src/CII/Models/TradeParty.php +++ b/src/CII/Models/TradeParty.php @@ -10,7 +10,7 @@ use JMS\Serializer\Annotation\XmlElement; use JMS\Serializer\Annotation\XmlList; -#[AccessorOrder(order: 'custom', custom: ['id', 'globalID', 'name', 'definedTradeContact', 'postalTradeAddress', 'uriUniversalCommunication', 'taxRegistrations'])] +#[AccessorOrder(order: 'custom', custom: ['id', 'globalID', 'name', 'description', 'specifiedLegalOrganization', 'definedTradeContact', 'postalTradeAddress', 'uriUniversalCommunication', 'taxRegistrations'])] final class TradeParty { #[Type(Id::class)] @@ -28,6 +28,11 @@ final class TradeParty #[SerializedName('Name')] public string $name; + #[Type('string')] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('Description')] + public ?string $description = null; + #[Type(TradeContact::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('DefinedTradeContact')] @@ -53,11 +58,6 @@ final class TradeParty #[SerializedName('RoleCode')] public ?string $roleCode = null; - #[Type('string')] - #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[SerializedName('Description')] - public ?string $description = null; - #[Type(LegalOrganization::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('SpecifiedLegalOrganization')] diff --git a/src/CII/Models/TradePrice.php b/src/CII/Models/TradePrice.php index 56044f5..accc427 100644 --- a/src/CII/Models/TradePrice.php +++ b/src/CII/Models/TradePrice.php @@ -20,15 +20,10 @@ final class TradePrice #[JMS\SerializedName('BasisQuantity')] public ?Quantity $basisQuantity = null; - #[Type(TradeAllowanceCharge::class)] - #[JMS\XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - #[JMS\SerializedName('AppliedTradeAllowanceCharge')] - public ?TradeAllowanceCharge $appliedTradeAllowanceCharge = null; - /** @var TradeAllowanceCharge[] */ #[Type('array')] #[XmlList(entry: 'AppliedTradeAllowanceCharge', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] - public ?array $appliedTradeAllowanceCharges = null; + public ?array $appliedTradeAllowanceCharge = null; /** @param array|null $tradeAllowanceCharge */ public static function create(string $amount, Quantity $quantity = null, array $tradeAllowanceCharge = null): self @@ -36,7 +31,7 @@ public static function create(string $amount, Quantity $quantity = null, array $ $self = new self(); $self->chargeAmount = Amount::create($amount); $self->basisQuantity = $quantity; - $self->appliedTradeAllowanceCharges = $tradeAllowanceCharge; + $self->appliedTradeAllowanceCharge = $tradeAllowanceCharge; return $self; } } diff --git a/src/CII/Models/TradeProduct.php b/src/CII/Models/TradeProduct.php index 889a572..0e843d1 100644 --- a/src/CII/Models/TradeProduct.php +++ b/src/CII/Models/TradeProduct.php @@ -8,8 +8,9 @@ use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; +use JMS\Serializer\Annotation\XmlList; -#[AccessorOrder(order: 'custom', custom: ['globalID', 'sellerAssignedID', 'buyerAssignedID', 'name', 'description', 'tradeCountry'])] +#[AccessorOrder(order: 'custom', custom: ['globalID', 'sellerAssignedID', 'buyerAssignedID', 'name', 'description', 'applicableProductCharacteristic', 'designatedProductClassification', 'originTradeCountry'])] final class TradeProduct { #[Type(Id::class)] @@ -40,5 +41,15 @@ final class TradeProduct #[Type(TradeCountry::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('OriginTradeCountry')] - public ?TradeCountry $tradeCountry = null; + public ?TradeCountry $originTradeCountry = null; + + /** @var ProductCharacteristic[] */ + #[Type('array')] + #[XmlList(entry: 'ApplicableProductCharacteristic', inline: true, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + public ?array $applicableProductCharacteristic = []; + + #[Type(ProductClassification::class)] + #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] + #[SerializedName('DesignatedProductClassification')] + public ?ProductClassification $designatedProductClassification = null; } diff --git a/src/CII/Models/TradeTax.php b/src/CII/Models/TradeTax.php index a00aafd..c5150c4 100644 --- a/src/CII/Models/TradeTax.php +++ b/src/CII/Models/TradeTax.php @@ -7,7 +7,7 @@ use JMS\Serializer\Annotation\AccessorOrder; use JMS\Serializer\Annotation as JMS; -#[AccessorOrder(order: 'custom', custom: ['calculatedAmount', 'typeCode', 'exemptionReason'])] +#[AccessorOrder(order: 'custom', custom: ['calculatedAmount', 'typeCode', 'exemptionReason', 'basisAmount', 'categoryCode', 'exemptionReasonCode', 'taxPointDate', 'dueDateTypeCode', 'rateApplicablePercent'])] final class TradeTax { #[JMS\Type(Amount::class)] diff --git a/src/CII/Models/UniversalCommunication.php b/src/CII/Models/UniversalCommunication.php index 7f3f953..bb94729 100644 --- a/src/CII/Models/UniversalCommunication.php +++ b/src/CII/Models/UniversalCommunication.php @@ -15,8 +15,8 @@ final class UniversalCommunication #[SerializedName('CompleteNumber')] public ?string $completeNumber = null; - #[Type(Id::class)] + #[Type(UriID::class)] #[XmlElement(cdata: false, namespace: 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100')] #[SerializedName('URIID')] - public ?Id $uriid = null; + public ?UriID $uriid = null; } diff --git a/src/CII/Models/UriID.php b/src/CII/Models/UriID.php new file mode 100644 index 0000000..9ea4115 --- /dev/null +++ b/src/CII/Models/UriID.php @@ -0,0 +1,31 @@ +value = $id; + $self->schemeID = $schemeID; + return $self; + } +} diff --git a/src/ConfiguredSerializer.php b/src/ConfiguredSerializer.php new file mode 100644 index 0000000..9a28f20 --- /dev/null +++ b/src/ConfiguredSerializer.php @@ -0,0 +1,53 @@ +setDebug(true) + ->configureHandlers(function (HandlerRegistryInterface $registry) { + $registry->registerSubscribingHandler(new CountryCodeEnumHandler()); + $registry->registerSubscribingHandler(new CurrencyCodeEnumHandler()); + $registry->registerSubscribingHandler(new DocumentTypeEnumHandler()); + $registry->registerSubscribingHandler(new ReferenceQualifierEnumHandler()); + $registry->registerSubscribingHandler(new UnitCodeEnumHandler()); + $registry->registerSubscribingHandler(new MimeTypeEnumHandler()); + $registry->registerSubscribingHandler(new ElectronicAddressSchemeIdentifierEnumHandler()); + }) + ->build() + ; + return new self($serializer); + } + + public function serialize($data, string $format, ?SerializationContext $context = null, ?string $type = null): string + { + return $this->serializer->serialize($data, $format, $context, $type); + } + + public function deserialize(string $data, string $type, string $format, ?DeserializationContext $context = null) + { + return $this->serializer->deserialize($data, $type, $format, $context); + } +} diff --git a/src/Enums/CountryCode.php b/src/Enums/CountryCode.php new file mode 100644 index 0000000..24b448f --- /dev/null +++ b/src/Enums/CountryCode.php @@ -0,0 +1,761 @@ + 10 kpa + case XWG = 'XWG'; + + // Intermediate bulk container, aluminium, pressurised > 10 kpa + case XWH = 'XWH'; + + // Intermediate bulk container, metal, pressure 10 kpa + case XWJ = 'XWJ'; + + // Intermediate bulk container, steel, liquid + case XWK = 'XWK'; + + // Intermediate bulk container, aluminium, liquid + case XWL = 'XWL'; + + // Intermediate bulk container, metal, liquid + case XWM = 'XWM'; + + // Intermediate bulk container, woven plastic, without coat/liner + case XWN = 'XWN'; + + // Intermediate bulk container, woven plastic, coated + case XWP = 'XWP'; + + // Intermediate bulk container, woven plastic, with liner + case XWQ = 'XWQ'; + + // Intermediate bulk container, woven plastic, coated and liner + case XWR = 'XWR'; + + // Intermediate bulk container, plastic film + case XWS = 'XWS'; + + // Intermediate bulk container, textile with out coat/liner + case XWT = 'XWT'; + + // Intermediate bulk container, natural wood, with inner liner + case XWU = 'XWU'; + + // Intermediate bulk container, textile, coated + case XWV = 'XWV'; + + // Intermediate bulk container, textile, with liner + case XWW = 'XWW'; + + // Intermediate bulk container, textile, coated and liner + case XWX = 'XWX'; + + // Intermediate bulk container, plywood, with inner liner + case XWY = 'XWY'; + + // Intermediate bulk container, reconstituted wood, with inner liner + case XWZ = 'XWZ'; + + // Bag, woven plastic, without inner coat/liner + case XXA = 'XXA'; + + // Bag, woven plastic, sift proof + case XXB = 'XXB'; + + // Bag, woven plastic, water resistant + case XXC = 'XXC'; + + // Bag, plastics film + case XXD = 'XXD'; + + // Bag, textile, without inner coat/liner + case XXF = 'XXF'; + + // Bag, textile, sift proof + case XXG = 'XXG'; + + // Bag, textile, water resistant + case XXH = 'XXH'; + + // Bag, paper, multi-wall + case XXJ = 'XXJ'; + + // Bag, paper, multi-wall, water resistant + case XXK = 'XXK'; + + // Composite packaging, plastic receptacle in steel drum + case XYA = 'XYA'; + + // Composite packaging, plastic receptacle in steel crate box + case XYB = 'XYB'; + + // Composite packaging, plastic receptacle in aluminium drum + case XYC = 'XYC'; + + // Composite packaging, plastic receptacle in aluminium crate + case XYD = 'XYD'; + + // Composite packaging, plastic receptacle in wooden box + case XYF = 'XYF'; + + // Composite packaging, plastic receptacle in plywood drum + case XYG = 'XYG'; + + // Composite packaging, plastic receptacle in plywood box + case XYH = 'XYH'; + + // Composite packaging, plastic receptacle in fibre drum + case XYJ = 'XYJ'; + + // Composite packaging, plastic receptacle in fibreboard box + case XYK = 'XYK'; + + // Composite packaging, plastic receptacle in plastic drum + case XYL = 'XYL'; + + // Composite packaging, plastic receptacle in solid plastic box + case XYM = 'XYM'; + + // Composite packaging, glass receptacle in steel drum + case XYN = 'XYN'; + + // Composite packaging, glass receptacle in steel crate box + case XYP = 'XYP'; + + // Composite packaging, glass receptacle in aluminium drum + case XYQ = 'XYQ'; + + // Composite packaging, glass receptacle in aluminium crate + case XYR = 'XYR'; + + // Composite packaging, glass receptacle in wooden box + case XYS = 'XYS'; + + // Composite packaging, glass receptacle in plywood drum + case XYT = 'XYT'; + + // Composite packaging, glass receptacle in wickerwork hamper + case XYV = 'XYV'; + + // Composite packaging, glass receptacle in fibre drum + case XYW = 'XYW'; + + // Composite packaging, glass receptacle in fibreboard box + case XYX = 'XYX'; + + // Composite packaging, glass receptacle in expandable plastic pack + case XYY = 'XYY'; + + // Composite packaging, glass receptacle in solid plastic pack + case XYZ = 'XYZ'; + + // Intermediate bulk container, paper, multi-wall + case XZA = 'XZA'; + + // Bag, large + case XZB = 'XZB'; + + // Intermediate bulk container, paper, multi-wall, water resistant + case XZC = 'XZC'; + + // Intermediate bulk container, rigid plastic, with structural equipment, solids + case XZD = 'XZD'; + + // Intermediate bulk container, rigid plastic, freestanding, solids + case XZF = 'XZF'; + + // Intermediate bulk container, rigid plastic, with structural equipment, pressurised + case XZG = 'XZG'; + + // Intermediate bulk container, rigid plastic, freestanding, pressurised + case XZH = 'XZH'; + + // Intermediate bulk container, rigid plastic, with structural equipment, liquids + case XZJ = 'XZJ'; + + // Intermediate bulk container, rigid plastic, freestanding, liquids + case XZK = 'XZK'; + + // Intermediate bulk container, composite, rigid plastic, solids + case XZL = 'XZL'; + + // Intermediate bulk container, composite, flexible plastic, solids + case XZM = 'XZM'; + + // Intermediate bulk container, composite, rigid plastic, pressurised + case XZN = 'XZN'; + + // Intermediate bulk container, composite, flexible plastic, pressurised + case XZP = 'XZP'; + + // Intermediate bulk container, composite, rigid plastic, liquids + case XZQ = 'XZQ'; + + // Intermediate bulk container, composite, flexible plastic, liquids + case XZR = 'XZR'; + + // Intermediate bulk container, composite + case XZS = 'XZS'; + + // Intermediate bulk container, fibreboard + case XZT = 'XZT'; + + // Intermediate bulk container, flexible + case XZU = 'XZU'; + + // Intermediate bulk container, metal, other than steel + case XZV = 'XZV'; + + // Intermediate bulk container, natural wood + case XZW = 'XZW'; + + // Intermediate bulk container, plywood + case XZX = 'XZX'; + + // Intermediate bulk container, reconstituted wood + case XZY = 'XZY'; + + // Mutually defined + case XZZ = 'XZZ'; +} diff --git a/src/Handlers/AbstractBackedEnumHandler.php b/src/Handlers/AbstractBackedEnumHandler.php new file mode 100644 index 0000000..8d56b4d --- /dev/null +++ b/src/Handlers/AbstractBackedEnumHandler.php @@ -0,0 +1,62 @@ + */ + public static function getEnumClass(): string + { + throw new \RuntimeException('not yet implemented'); + } + + /** @return array> */ + public static function getSubscribingMethods(): array + { + $methods = []; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, + 'format' => 'xml', + 'type' => static::getEnumClass(), + 'method' => 'deserializeEnum', + ]; + + $methods[] = [ + 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, + 'format' => 'xml', + 'type' => static::getEnumClass(), + 'method' => 'serializeEnum', + ]; + + return $methods; + } + + /** @param array $type */ + public function serializeEnum(XmlSerializationVisitor $visitor, \BackedEnum $enum, array $type): \DOMText + { + return $visitor->visitSimpleString($enum->value, $type); + } + + public function deserializeEnum(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data): \BackedEnum + { + $class = static::getEnumClass(); + + $rEnum = new \ReflectionEnum($class); + + $rBackingType = $rEnum->getBackingType(); + + return match ((string)$rBackingType) { + 'string' => $class::from((string)$data), + 'int' => $class::from((int)$data), + default => throw new \BadMethodCallException('Unknown backing type'), + }; + } +} diff --git a/src/Handlers/CountryCodeEnumHandler.php b/src/Handlers/CountryCodeEnumHandler.php new file mode 100644 index 0000000..f6088fe --- /dev/null +++ b/src/Handlers/CountryCodeEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return CountryCode::class; + } +} diff --git a/src/Handlers/CurrencyCodeEnumHandler.php b/src/Handlers/CurrencyCodeEnumHandler.php new file mode 100644 index 0000000..30ea11b --- /dev/null +++ b/src/Handlers/CurrencyCodeEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return CurrencyCode::class; + } +} diff --git a/src/Handlers/DocumentTypeEnumHandler.php b/src/Handlers/DocumentTypeEnumHandler.php new file mode 100644 index 0000000..621877d --- /dev/null +++ b/src/Handlers/DocumentTypeEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return DocumentType::class; + } +} diff --git a/src/Handlers/ElectronicAddressSchemeIdentifierEnumHandler.php b/src/Handlers/ElectronicAddressSchemeIdentifierEnumHandler.php new file mode 100644 index 0000000..c4dc253 --- /dev/null +++ b/src/Handlers/ElectronicAddressSchemeIdentifierEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return ElectronicAddressScheme::class; + } +} diff --git a/src/Handlers/MimeTypeEnumHandler.php b/src/Handlers/MimeTypeEnumHandler.php new file mode 100644 index 0000000..133e567 --- /dev/null +++ b/src/Handlers/MimeTypeEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return MimeType::class; + } +} diff --git a/src/Handlers/ReferenceQualifierEnumHandler.php b/src/Handlers/ReferenceQualifierEnumHandler.php new file mode 100644 index 0000000..78aaf9f --- /dev/null +++ b/src/Handlers/ReferenceQualifierEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return ReferenceQualifier::class; + } +} diff --git a/src/Handlers/UnitCodeEnumHandler.php b/src/Handlers/UnitCodeEnumHandler.php new file mode 100644 index 0000000..de71bab --- /dev/null +++ b/src/Handlers/UnitCodeEnumHandler.php @@ -0,0 +1,16 @@ + */ + public static function getEnumClass(): string + { + return UnitCode::class; + } +} diff --git a/src/Reader.php b/src/Reader.php index 5a0b214..5e69096 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -8,12 +8,10 @@ use easybill\eInvoicing\Dtos\ReaderResult; use easybill\eInvoicing\UBL\Documents\UblCredit; use easybill\eInvoicing\UBL\Documents\UblInvoice; -use JMS\Serializer\SerializerBuilder; -use JMS\Serializer\SerializerInterface; final readonly class Reader { - public function __construct(private SerializerInterface $serializer) {} + public function __construct(private ConfiguredSerializer $serializer) {} public function read(string $xml): ReaderResult { @@ -50,11 +48,7 @@ public function read(string $xml): ReaderResult public static function create(): Reader { - $serializer = SerializerBuilder::create() - ->setDebug(true) - ->build() - ; - return new self($serializer); + return new self(ConfiguredSerializer::create()); } private function tryDeserializingCIIDocument(\DOMDocument $document): ReaderResult diff --git a/src/Transformer.php b/src/Transformer.php index e67c873..ba31464 100644 --- a/src/Transformer.php +++ b/src/Transformer.php @@ -6,13 +6,11 @@ use easybill\eInvoicing\CII\Documents\CrossIndustryInvoice; use easybill\eInvoicing\UBL\Documents\UblAbstractDocument; -use JMS\Serializer\SerializerBuilder; -use JMS\Serializer\SerializerInterface; final readonly class Transformer { private function __construct( - private SerializerInterface $serializer, + private ConfiguredSerializer $serializer, ) {} public function transformToXml(CrossIndustryInvoice|UblAbstractDocument $document): string @@ -22,10 +20,6 @@ public function transformToXml(CrossIndustryInvoice|UblAbstractDocument $documen public static function create(): self { - $serializer = SerializerBuilder::create() - ->setDebug(true) - ->build() - ; - return new self($serializer); + return new self(ConfiguredSerializer::create()); } } diff --git a/src/UBL/Documents/UblAbstractDocument.php b/src/UBL/Documents/UblAbstractDocument.php index 84d5c08..bc43d69 100644 --- a/src/UBL/Documents/UblAbstractDocument.php +++ b/src/UBL/Documents/UblAbstractDocument.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\UBL\Documents; +use easybill\eInvoicing\Enums\CurrencyCode; use easybill\eInvoicing\UBL\Models\AccountingParty; use easybill\eInvoicing\UBL\Models\AllowanceCharge; use easybill\eInvoicing\UBL\Models\BillingReference; @@ -50,10 +51,20 @@ abstract class UblAbstractDocument #[XmlList(entry: 'Note', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] public array $note = []; - #[Type('string')] + #[Type(CurrencyCode::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('DocumentCurrencyCode')] - public ?string $documentCurrencyCode = null; + public ?CurrencyCode $documentCurrencyCode = null; + + #[Type(CurrencyCode::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('TaxCurrencyCode')] + public ?CurrencyCode $taxCurrencyCode = null; + + #[Type('string')] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('AccountingCost')] + public ?string $accountingCost = null; #[Type('string')] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] @@ -75,6 +86,16 @@ abstract class UblAbstractDocument #[SerializedName('OrderReference')] public ?OrderReference $orderReference = null; + #[Type(DocumentReference::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + #[SerializedName('DespatchDocumentReference')] + public ?DocumentReference $despatchDocumentReference = null; + + #[Type(DocumentReference::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + #[SerializedName('ReceiptDocumentReference')] + public ?DocumentReference $receiptDocumentReference = null; + #[Type(DocumentReference::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] #[SerializedName('OriginatorDocumentReference')] @@ -116,10 +137,11 @@ abstract class UblAbstractDocument #[SerializedName('PaymentTerms')] public ?PaymentTerms $paymentTerms = null; - #[Type(AllowanceCharge::class)] - #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + /** @var AllowanceCharge[] */ + #[Type('array')] #[SerializedName('AllowanceCharge')] - public ?AllowanceCharge $allowanceCharge = null; + #[XmlList(entry: 'AllowanceCharge', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + public ?array $allowanceCharge = []; /** @var TaxTotal[] */ #[Type('array')] diff --git a/src/UBL/Documents/UblCredit.php b/src/UBL/Documents/UblCredit.php index 472014a..2687057 100644 --- a/src/UBL/Documents/UblCredit.php +++ b/src/UBL/Documents/UblCredit.php @@ -4,6 +4,8 @@ namespace easybill\eInvoicing\UBL\Documents; +use easybill\eInvoicing\Enums\CurrencyCode; +use easybill\eInvoicing\Enums\DocumentType; use easybill\eInvoicing\UBL\Models\CreditNoteLine; use JMS\Serializer\Annotation\AccessorOrder; use JMS\Serializer\Annotation\SerializedName; @@ -26,10 +28,13 @@ 'note', 'documentCurrencyCode', 'taxCurrencyCode', + 'accountingCost', 'buyerReference', 'invoicePeriod', - 'billingReference', 'orderReference', + 'billingReference', + 'despatchDocumentReference', + 'receiptDocumentReference', 'originatorDocumentReference', 'accountingSupplierParty', 'accountingCustomerParty', @@ -45,15 +50,15 @@ ])] final class UblCredit extends UblAbstractDocument { - #[Type('int')] + #[Type(DocumentType::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('CreditNoteTypeCode')] - public ?int $creditNoteTypeCode = null; + public ?DocumentType $creditNoteTypeCode = null; - #[Type('string')] + #[Type(CurrencyCode::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('TaxCurrencyCode')] - public ?string $taxCurrencyCode = null; + public ?CurrencyCode $taxCurrencyCode = null; /** @var CreditNoteLine[] */ #[Type('array')] diff --git a/src/UBL/Documents/UblInvoice.php b/src/UBL/Documents/UblInvoice.php index 81f92df..5503a9a 100644 --- a/src/UBL/Documents/UblInvoice.php +++ b/src/UBL/Documents/UblInvoice.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\UBL\Documents; +use easybill\eInvoicing\Enums\DocumentType; use easybill\eInvoicing\UBL\Models\DocumentReference; use easybill\eInvoicing\UBL\Models\InvoiceLine; use JMS\Serializer\Annotation\AccessorOrder; @@ -28,10 +29,14 @@ 'note', 'taxPointDate', 'documentCurrencyCode', + 'taxCurrencyCode', + 'accountingCost', 'buyerReference', 'invoicePeriod', - 'billingReference', 'orderReference', + 'billingReference', + 'despatchDocumentReference', + 'receiptDocumentReference', 'originatorDocumentReference', 'contractDocumentReference', 'additionalDocumentReference', @@ -55,10 +60,10 @@ final class UblInvoice extends UblAbstractDocument #[SerializedName('DueDate')] public ?string $dueDate = null; - #[Type('int')] + #[Type(DocumentType::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('InvoiceTypeCode')] - public ?int $invoiceTypeCode = null; + public ?DocumentType $invoiceTypeCode = null; #[Type('string')] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] @@ -70,10 +75,11 @@ final class UblInvoice extends UblAbstractDocument #[SerializedName('ContractDocumentReference')] public ?DocumentReference $contractDocumentReference = null; - #[Type(DocumentReference::class)] - #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + /** @var DocumentReference[] */ + #[Type('array')] #[SerializedName('AdditionalDocumentReference')] - public ?DocumentReference $additionalDocumentReference = null; + #[XmlList(entry: 'AdditionalDocumentReference', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + public array $additionalDocumentReference = []; #[Type(DocumentReference::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] diff --git a/src/UBL/Models/AbstractDocumentLine.php b/src/UBL/Models/AbstractDocumentLine.php index dd72c38..50cd2ff 100644 --- a/src/UBL/Models/AbstractDocumentLine.php +++ b/src/UBL/Models/AbstractDocumentLine.php @@ -4,7 +4,6 @@ namespace easybill\eInvoicing\UBL\Models; -use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; @@ -25,9 +24,13 @@ abstract class AbstractDocumentLine #[Type(Amount::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('LineExtensionAmount')] - #[Serializer\Groups()] public ?Amount $lineExtensionAmount = null; + #[Type('string')] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('AccountingCost')] + public ?string $accountingCost = null; + #[Type(Period::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] #[SerializedName('InvoicePeriod')] @@ -54,4 +57,9 @@ abstract class AbstractDocumentLine #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] #[SerializedName('Price')] public ?Price $price = null; + + #[Type(DocumentReference::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + #[SerializedName('DocumentReference')] + public ?DocumentReference $documentReference = null; } diff --git a/src/UBL/Models/Address.php b/src/UBL/Models/Address.php index 4b399f5..2c3bfb6 100644 --- a/src/UBL/Models/Address.php +++ b/src/UBL/Models/Address.php @@ -31,17 +31,17 @@ final class Address #[SerializedName('PostalZone')] public ?string $postalZone = null; + #[Type('string')] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('CountrySubentity')] + public ?string $countrySubentity = null; + /** @var AddressLine[] */ #[Type('array')] #[SerializedName('AddressLine')] #[XmlList(entry: 'AddressLine', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] public array $addressLines = []; - #[Type('string')] - #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] - #[SerializedName('CountrySubentity')] - public ?string $countrySubentity = null; - #[Type(Country::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] #[SerializedName('Country')] diff --git a/src/UBL/Models/Amount.php b/src/UBL/Models/Amount.php index 777b63d..d6a04a7 100644 --- a/src/UBL/Models/Amount.php +++ b/src/UBL/Models/Amount.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\UBL\Models; +use easybill\eInvoicing\Enums\CurrencyCode; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlAttribute; @@ -11,10 +12,10 @@ final class Amount { - #[Type('string')] + #[Type(CurrencyCode::class)] #[XmlAttribute] #[SerializedName('currencyID')] - public ?string $currencyID = null; + public ?CurrencyCode $currencyID = null; #[Type('string')] #[XmlValue(cdata: false)] diff --git a/src/UBL/Models/Attachment.php b/src/UBL/Models/Attachment.php index 493e323..310173a 100644 --- a/src/UBL/Models/Attachment.php +++ b/src/UBL/Models/Attachment.php @@ -14,4 +14,9 @@ final class Attachment #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('EmbeddedDocumentBinaryObject')] public ?EmbeddedDocumentBinaryObject $embeddedDocumentBinaryObject = null; + + #[Type(ExternalReference::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + #[SerializedName('ExternalReference')] + public ?ExternalReference $externalReference = null; } diff --git a/src/UBL/Models/Country.php b/src/UBL/Models/Country.php index 0d39929..598cfcb 100644 --- a/src/UBL/Models/Country.php +++ b/src/UBL/Models/Country.php @@ -4,14 +4,15 @@ namespace easybill\eInvoicing\UBL\Models; +use easybill\eInvoicing\Enums\CountryCode; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; final class Country { - #[Type('string')] + #[Type(CountryCode::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('IdentificationCode')] - public ?string $identificationCode = null; + public ?CountryCode $identificationCode = null; } diff --git a/src/UBL/Models/CreditNoteLine.php b/src/UBL/Models/CreditNoteLine.php index 610b751..d0d41c3 100644 --- a/src/UBL/Models/CreditNoteLine.php +++ b/src/UBL/Models/CreditNoteLine.php @@ -14,8 +14,10 @@ 'note', 'creditedQuantity', 'lineExtensionAmount', + 'accountingCost', 'invoicePeriod', 'orderLineReference', + 'documentReference', 'allowanceCharge', 'item', 'price', diff --git a/src/UBL/Models/DeliveryLocation.php b/src/UBL/Models/DeliveryLocation.php index 0ac3eca..0deeefd 100644 --- a/src/UBL/Models/DeliveryLocation.php +++ b/src/UBL/Models/DeliveryLocation.php @@ -10,10 +10,10 @@ final class DeliveryLocation { - #[Type('string')] + #[Type(Id::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ID')] - public ?string $id = null; + public ?Id $id = null; #[Type(Address::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] diff --git a/src/UBL/Models/DocumentReference.php b/src/UBL/Models/DocumentReference.php index 86e943c..73d534d 100644 --- a/src/UBL/Models/DocumentReference.php +++ b/src/UBL/Models/DocumentReference.php @@ -4,16 +4,27 @@ namespace easybill\eInvoicing\UBL\Models; +use easybill\eInvoicing\Enums\DocumentType; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlElement; final class DocumentReference { - #[Type('string')] + #[Type(Id::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] #[SerializedName('ID')] - public ?string $id = null; + public ?Id $id = null; + + #[Type('string')] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('IssueDate')] + public ?string $issueDate = null; + + #[Type(DocumentType::class)] + #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] + #[SerializedName('DocumentTypeCode')] + public ?DocumentType $typeCode = null; #[Type('string')] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2')] diff --git a/src/UBL/Models/EmbeddedDocumentBinaryObject.php b/src/UBL/Models/EmbeddedDocumentBinaryObject.php index ff43595..38e2a92 100644 --- a/src/UBL/Models/EmbeddedDocumentBinaryObject.php +++ b/src/UBL/Models/EmbeddedDocumentBinaryObject.php @@ -4,6 +4,7 @@ namespace easybill\eInvoicing\UBL\Models; +use easybill\eInvoicing\Enums\MimeType; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\XmlAttribute; @@ -11,17 +12,17 @@ final class EmbeddedDocumentBinaryObject { - #[Type('string')] + #[Type(MimeType::class)] #[XmlAttribute] #[SerializedName('mimeCode')] - public ?string $mimeCode = null; + public MimeType $mimeCode; #[Type('string')] #[XmlAttribute] #[SerializedName('filename')] - public ?string $filename = null; + public string $filename; #[Type('string')] #[XmlValue(cdata: false)] - public ?string $value = null; + public string $value; } diff --git a/src/UBL/Models/EndpointId.php b/src/UBL/Models/EndpointId.php new file mode 100644 index 0000000..2e47e85 --- /dev/null +++ b/src/UBL/Models/EndpointId.php @@ -0,0 +1,23 @@ +')] #[SerializedName('CommodityClassification')] - public ?CommodityClassification $commodityClassification = null; + #[XmlList(entry: 'CommodityClassification', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + public ?array $commodityClassification = []; #[Type(TaxCategory::class)] #[XmlElement(cdata: false, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] #[SerializedName('ClassifiedTaxCategory')] public ?TaxCategory $classifiedTaxCategory = null; + + /** @var ItemProperty[] */ + #[Type('array')] + #[SerializedName('AdditionalItemProperty')] + #[XmlList(entry: 'AdditionalItemProperty', inline: true, namespace: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2')] + public array $additionalItemProperty = []; } diff --git a/src/UBL/Models/ItemProperty.php b/src/UBL/Models/ItemProperty.php new file mode 100644 index 0000000..b19f605 --- /dev/null +++ b/src/UBL/Models/ItemProperty.php @@ -0,0 +1,22 @@ +exchangedDocumentContext->documentContextParameter = new DocumentContextParameter(); $invoice->exchangedDocumentContext->documentContextParameter->id = 'urn:cen.eu:en16931:2017'; $invoice->exchangedDocument->id = '471102'; - $invoice->exchangedDocument->typeCode = '380'; + $invoice->exchangedDocument->typeCode = DocumentType::COMMERCIAL_INVOICE; $invoice->exchangedDocument->issueDateTime = DateTime::create(102, '20180305'); $invoice->exchangedDocument->notes[] = Note::create('Rechnung gemäß Bestellung vom 01.03.2018.'); - $invoice->exchangedDocument->notes[] = Note::create('Lieferant GmbH - Lieferantenstraße 20 - 80333 München - Deutschland - Geschäftsführer: Hans Muster - Handelsregisternummer: H A 123 - ', 'REG'); - $invoice->supplyChainTradeTransaction = new SupplyChainTradeTransaction(); $invoice->supplyChainTradeTransaction->lineItems[] = $item1 = new SupplyChainTradeLineItem(); @@ -71,7 +68,7 @@ function () { $item1->tradeAgreement->netPrice = TradePrice::create('9.9000'); $item1->delivery = new LineTradeDelivery(); - $item1->delivery->billedQuantity = Quantity::create('20.0000', 'H87'); + $item1->delivery->billedQuantity = Quantity::create('20.0000', UnitCode::H87); $item1->specifiedLineTradeSettlement = new LineTradeSettlement(); $item1->specifiedLineTradeSettlement->tradeTax[] = $item1tax = new TradeTax(); @@ -93,7 +90,7 @@ function () { $item2->tradeAgreement->netPrice = TradePrice::create('5.5000'); $item2->delivery = new LineTradeDelivery(); - $item2->delivery->billedQuantity = Quantity::create('50.0000', 'H87'); + $item2->delivery->billedQuantity = Quantity::create('50.0000', UnitCode::H87); $item2->specifiedLineTradeSettlement = new LineTradeSettlement(); $item2->specifiedLineTradeSettlement->tradeTax[] = $item2tax = new TradeTax(); @@ -112,7 +109,7 @@ function () { $sellerTradeParty->postalTradeAddress->postcode = '80333'; $sellerTradeParty->postalTradeAddress->lineOne = 'Lieferantenstraße 20'; $sellerTradeParty->postalTradeAddress->city = 'München'; - $sellerTradeParty->postalTradeAddress->countryCode = 'DE'; + $sellerTradeParty->postalTradeAddress->countryCode = CountryCode::DE; $sellerTradeParty->taxRegistrations[] = TaxRegistration::create('201/113/40209', 'FC'); $sellerTradeParty->taxRegistrations[] = TaxRegistration::create('DE123456789', 'VA'); @@ -123,14 +120,14 @@ function () { $buyerTradeParty->postalTradeAddress->postcode = '69876'; $buyerTradeParty->postalTradeAddress->lineOne = 'Kundenstraße 15'; $buyerTradeParty->postalTradeAddress->city = 'Frankfurt'; - $buyerTradeParty->postalTradeAddress->countryCode = 'DE'; + $buyerTradeParty->postalTradeAddress->countryCode = CountryCode::DE; $invoice->supplyChainTradeTransaction->applicableHeaderTradeDelivery = new HeaderTradeDelivery(); $invoice->supplyChainTradeTransaction->applicableHeaderTradeDelivery->chainEvent = $supplyChainEvent = new SupplyChainEvent(); $supplyChainEvent->date = DateTime::create(102, '20180305'); $invoice->supplyChainTradeTransaction->applicableHeaderTradeSettlement = new HeaderTradeSettlement(); - $invoice->supplyChainTradeTransaction->applicableHeaderTradeSettlement->currency = 'EUR'; + $invoice->supplyChainTradeTransaction->applicableHeaderTradeSettlement->invoiceCurrency = CurrencyCode::EUR; $invoice->supplyChainTradeTransaction->applicableHeaderTradeSettlement->tradeTaxes[] = $headerTax1 = new TradeTax(); $headerTax1->typeCode = 'VAT'; @@ -154,7 +151,7 @@ function () { $summation->chargeTotalAmount = Amount::create('0.00'); $summation->allowanceTotalAmount = Amount::create('0.00'); $summation->taxBasisTotalAmount[] = Amount::create('473.00'); - $summation->taxTotalAmount[] = Amount::create('56.87', 'EUR'); + $summation->taxTotalAmount[] = Amount::create('56.87', CurrencyCode::EUR); $summation->grandTotalAmount[] = Amount::create('529.87'); $summation->totalPrepaidAmount = Amount::create('0.00'); $summation->duePayableAmount = Amount::create('529.87'); @@ -173,3 +170,43 @@ function () { $this->validateWithKositValidator($xml); } ); + +test( + 'That reading the CII examples and transforming to the object representation and back to xml is identical to the source', + function (string $pathToXmlExample) { + $xml = file_get_contents($pathToXmlExample); + + expect($xml)->not->toBeFalse(); + + $reader = Reader::create()->read($xml); + + expect($reader->isSuccess())->toBeTrue(); + expect($reader->getDocument())->toBeInstanceOf(CrossIndustryInvoice::class); + + $document = $reader->getDocument(); + + assert($document instanceof CrossIndustryInvoice); + + $xmlFromObject = Transformer::create()->transformToXml($document); + + $this->assertSame($this->reformatXml($xml), $this->reformatXml($xmlFromObject)); + } +)->with([ + __DIR__ . '/Examples/CII/CII_business_example_01.xml', + __DIR__ . '/Examples/CII/CII_business_example_02.xml', + __DIR__ . '/Examples/CII/CII_business_example_Z.xml', + __DIR__ . '/Examples/CII/CII_example1.xml', + __DIR__ . '/Examples/CII/CII_example2.xml', + __DIR__ . '/Examples/CII/CII_example3.xml', + __DIR__ . '/Examples/CII/CII_example4.xml', + __DIR__ . '/Examples/CII/CII_example5.xml', + __DIR__ . '/Examples/CII/CII_example6.xml', + __DIR__ . '/Examples/CII/CII_example7.xml', + __DIR__ . '/Examples/CII/CII_example8.xml', + __DIR__ . '/Examples/CII/CII_example9.xml', + __DIR__ . '/Examples/CII/EN16931_AbweichenderZahlungsempf.xml', + __DIR__ . '/Examples/CII/EN16931_Einfach.xml', + __DIR__ . '/Examples/CII/EN16931_Gutschrift.xml', + __DIR__ . '/Examples/CII/EN16931_Innergemeinschaftliche_Lieferungen.xml', + __DIR__ . '/Examples/CII/XRechnung-O.xml', +]); diff --git a/tests/Integration/Examples/CII/CII_business_example_01.xml b/tests/Integration/Examples/CII/CII_business_example_01.xml new file mode 100644 index 0000000..ac82d90 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_business_example_01.xml @@ -0,0 +1,191 @@ + + + + + urn:ferd:CrossIndustryDocument:invoice:1p0:comfort + + + + 2016166 + 380 + + 20150109 + + + This is an example invoice based on data that is used in real business.Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + AAR + + + Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + + + + + + + 1 + + + 846 + Festpreis + Neues DSL Portfolio 2016 + + + + 12122.5900 + + + + 1.000 + + + + VAT + S + 19.00 + + + 12122.59 + + + + + + + 2 + + + 832 + Abzug + + + + 606.1300 + + + + -1 + + + + VAT + S + 19.00 + + + -606.13 + + + + + + + 16 + + + 870 + zzgl. + + + + 1.5000 + + + + 1.000 + + + + VAT + S + 19.00 + + + 177.41 + + + + + + XXX AG + + 57151520 + + + 10369 + Storkower Straße 207 + Berlin + DE + + + DE37/302/30168 + + + + 10202 + XXX AG + + XXXX + + + 10369 + Storkower Straße 207 + Berlin + DE + + + + + + + + 20160906 + + + + + + 2016166 + EUR + + 30 + + DE12500105170648489890 + + + + 2221.84 + VAT + 11693.87 + S + 19.00 + + + + 20150109 + + + + 11693.87 + 11693.87 + 2221.84 + 13915.71 + 13915.71 + + + + diff --git a/tests/Integration/Examples/CII/CII_business_example_02.xml b/tests/Integration/Examples/CII/CII_business_example_02.xml new file mode 100644 index 0000000..ce07506 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_business_example_02.xml @@ -0,0 +1,193 @@ + + + + + urn:ferd:CrossIndustryDocument:invoice:1p0:comfort + + + + INV000013 + 380 + + 20130825 + + + TEXT + REG + + + + + + + 1 + + + BPW21 + + + + + 1.2605 + + + + 1.0000 + + + + VAT + S + 19.00 + + + 1.26 + + + + + + + 2 + + + Poti 100k + + + + + 1.2605 + + + + 1.0000 + + + + VAT + S + 19.00 + + + 1.26 + + + + + + + 3 + + + LCD Display 3.5 + + + + + 7.4790 + + + + 1.0000 + + + + VAT + S + 19.00 + + + 7.48 + + + + + + + xxxx + + 111111111 + + + + 10369 + Storkower Straße 207 + Berlin + DE + + + DE1111111 + + + + 1111111111 + Buyercompany ltd + + 101 + Anystreet, Building 1 + Anytown + DE + + + + SUBSCR571 + + + + + INV000013 + EUR + + 30 + + DK1212341234123412 + + + + 1.90 + VAT + 10.00 + S + 19.00 + + + + 20130101 + + + 20130401 + + + + + false + + 0.00 + Rabatt + + VAT + S + 19.00 + + + + + 20130510 + + + + 10.00 + 0.00 + 0.00 + 10.00 + 1.90 + 11.90 + 11.90 + + + + diff --git a/tests/Integration/Examples/CII/CII_business_example_Z.xml b/tests/Integration/Examples/CII/CII_business_example_Z.xml new file mode 100644 index 0000000..fdba3a4 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_business_example_Z.xml @@ -0,0 +1,191 @@ + + + + + urn:ferd:CrossIndustryDocument:invoice:1p0:comfort + + + + 2016166 + 380 + + 20150109 + + + This is an example invoice based on data that is used in real business.Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + AAR + + + Sehr geehrter Herr xxx, + + für die Unterstützung im September stellen wir Ihnen gemäß Auftrag foldende Rechnung. + + Für das in uns gesetzte Vertrauen bedanken wir uns auf diesem Wege herzlich. + + + + + + + + 1 + + + 846 + Festpreis + Neues DSL Portfolio 2016 + + + + 12122.5900 + + + + 1.000 + + + + VAT + Z + 0.00 + + + 12122.59 + + + + + + + 2 + + + 832 + Abzug + + + + 606.1300 + + + + -1 + + + + VAT + Z + 0.00 + + + -606.13 + + + + + + + 16 + + + 870 + zzgl. + + + + 1.5000 + + + + 1.000 + + + + VAT + Z + 0.00 + + + 177.41 + + + + + + XXX AG + + 57151520 + + + 10369 + Storkower Straße 207 + Berlin + DE + + + DE37/302/30168 + + + + 10202 + XXX AG + + XXXX + + + 10369 + Storkower Straße 207 + Berlin + DE + + + + + + + + 20160906 + + + + + + 2016166 + EUR + + 30 + + DE12500105170648489890 + + + + 0.00 + VAT + 11693.87 + Z + 0.00 + + + + 20150109 + + + + 11693.87 + 11693.87 + 0.0 + 11693.87 + 11693.87 + + + + diff --git a/tests/Integration/Examples/CII/CII_example1.xml b/tests/Integration/Examples/CII/CII_example1.xml new file mode 100644 index 0000000..3257204 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example1.xml @@ -0,0 +1,636 @@ + + + + + urn:cen.eu:en16931:2017 + + + + 12115118 + 380 + + 20150109 + + + Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85. + AAR + + + + + + 1 + + + 166022 + PATAT FRITES 10MM 10KG + + + + 9.95 + + + + 2 + + + + VAT + S + 6 + + + 19.9 + + + + + + 2 + + + 661813 + KAAS 50PL. JONG BEL. 1KG + + + + 9.85 + + + + 1 + + + + VAT + S + 6 + + + 9.85 + + + + + + 3 + + + 438146 + POT KETCHUP 3 LT + + + + 8.29 + + + + 1 + + + + VAT + S + 6 + + + 8.29 + + + + + + 4 + + + 438103 + FRITESSAUS 3 LRR + + + + 7.23 + + + + 2 + + + + VAT + S + 6 + + + 14.46 + + + + + + 5 + + + 666955 + KOFFIE BLIK 3,5KG SNELF + + + + 35 + + + + 1 + + + + VAT + S + 6 + + + 35 + + + + + + 6 + + + 664871 + KOFFIE 3.5 KG BLIK STAND + + + + 35 + + + + 1 + + + + VAT + S + 6 + + + 35 + + + + + + 7 + + + 350257 + SUIKERKLONT + + + + 10.65 + + + + 1 + + + + VAT + S + 6 + + + 10.65 + + + + + + 8 + + + 350258 + 1 KG UL BLOKJES + + + + 1.55 + + + + 1 + + + + VAT + S + 6 + + + 1.55 + + + + + + 9 + + + 999998 + BLOCKNOTE A5 + + + + 4.79 + + + + 3 + + + + VAT + S + 6 + + + 14.37 + + + + + + 10 + + + 740810 + CHIPS NAT KLEIN ZAKJES + + + + 8.29 + + + + 1 + + + + VAT + S + 6 + + + 8.29 + + + + + + 11 + + + 740829 + CHIPS PAP KLEINE ZAKJES + + + + 8.29 + + + + 2 + + + + VAT + S + 6 + + + 16.58 + + + + + + 12 + + + 740828 + TR KL PAKJES APPELSAP + + + + 9.95 + + + + 1 + + + + VAT + S + 6 + + + 9.95 + + + + + + 13 + + + 740827 + PK CHOCOLADEMELK + + + + 1.65 + + + + 2 + + + + VAT + S + 6 + + + 3.3 + + + + + + 14 + + + 999996 + KRAT BIER + + + + 10.8 + + + + 1 + + + + VAT + S + 21 + + + 10.8 + + + + + + 15 + + + 999995 + STATIEGELD + + + + 3.9 + + + + 1 + + + + VAT + S + 6 + + + 3.9 + + + + + + 16 + + + 102172 + BLEEK 3 X 750 ML + + + + 3.8 + + + + 2 + + + + VAT + S + 21 + + + 7.6 + + + + + + 17 + + + 999994 + WC PAPIER + + + + 4.67 + + + + 2 + + + + VAT + S + 21 + + + 9.34 + + + + + + 18 + + + 999993 + BALPENNEN 50 ST BLAUW + + + + 18.63 + + + + 1 + + + + VAT + S + 21 + + + 18.63 + + + + + + 19 + + + 999992 + EM FRITUURVET + + + + 17.02 + + + + 6 + + + + VAT + S + 6 + + + 102.12 + + + + + + 20 + + + 175137 + FRITUUR VET 10 KG RETOUR + + + + 18.33 + + + + 6 + + + + VAT + S + 6 + + + -109.98 + + + + + + De Koksmaat + + 57151520 + + + 1950 AB + Postbus 7l + Velsen-Noord + NL + + + NL8200.98.395.B.01 + + + + 10202 + ODIN 59 + + Dhr. J BLOKKER + + + 1960 AJ + POSTBUS 367 + HEEMSKERK + NL + + + + + + Deb. 10202 / Fact. 12115118 + EUR + + 30 + + NL57 RABO 0107307510 + + + + 30 + + NL57 RABO 0107307510 + + + + 10.99 + VAT + 183.23 + S + 6 + + + 9.74 + VAT + 46.37 + S + 21 + + + 20150109 + + + 229.6 + 229.6 + 20.73 + 250.33 + 250.33 + + + + diff --git a/tests/Integration/Examples/CII/CII_example2.xml b/tests/Integration/Examples/CII/CII_example2.xml new file mode 100644 index 0000000..5abc78f --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example2.xml @@ -0,0 +1,481 @@ + + + + + P3 + + + urn:cen.eu:en16931:2017 + + + + TOSL108 + 380 + + 20130630 + + + Ordered in our booth at the convention + + + + + + 1 + + Scratch on box + + + + 1234567890128 + JB007 + Laptop computer + Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen 1440x900 + + Color + Black + + + 65434568 + + + DE + + + + + 1 + + + 1498 + 1498 + + + false + + 225 + + + + 1273 + 1273 + + + + 1 + + + + VAT + S + 25 + + + + 20130601 + + + 20130601 + + + + + false + + 12 + Damage + + + + true + + 12 + Testing + + + 1273 + + + BookingCode001 + + + + + + 2 + + Cover is slightly damaged. + + + + 1234567890135 + JB008 + Returned "Advanced computing" book + + 65434567 + + + + + 5 + + + 3.96 + 3.96 + + + + -1 + + + + VAT + S + 15 + + + -3.96 + + + BookingCode002 + + + + + + 3 + + + 1234567890142 + JB009 + "Computing for dummies" book + + 65434566 + + + + + 3 + + + 2.75 + 2.75 + + + false + + 0.275 + + + + 2.48 + 2.48 + + + + 2 + + + + VAT + S + 15 + + + 4.96 + + + BookingCode003 + + + + + + 4 + + + 1234567890159 + JB010 + Returned IBM 5150 desktop + + 65434565 + + + + + 2 + + + 25 + 25 + + + + -1 + + + + VAT + E + 0 + + + -25 + + + BookingCode004 + + + + + + 5 + + + 1234567890166 + JB011 + Network cable + + Type + Cat5 + + + 12344325 + + + + + 4 + + + 0.75 + 0.75 + + + + 250 + + + + VAT + S + 25 + + + 187.5 + + + BookingCode005 + + + + + + 1238764941386 + Salescompany ltd. + + 123456789 + + + Antonio Salesmacher + + 46211230 + + + antonio@salescompany.no + + + + 303 + Main street 34 + Suite 123 + Big city + NO + RegionA + + + NO123456789MVA + + + + 3456789012098 + The Buyercompany + + 987654321 + + + John Doe + + 5121230 + + + john@buyercompany.no + + + + 101 + Anystreet 8 + Back door + Anytown + NO + RegionB + + + NO987654321MVA + + + + Tax handling company AS + + 202 + Regent street + Front door + Newtown + NO + RegionC + + + NO967611265MVA + + + + 123 + + + Contract321 + + + Doc1 + http://www.suppliersite.eu/sheet001.html + 935 + Timesheet + SlZCRVJpMHhMalVOQ2lVTkNqRWdNQ0J2WW1vT3k2SlRaWDliY2dSVnhJVkcuLi50Ykxvc0NoVTJYUmY5eGIvb21zY2dUWS9sWEVoVWI= + + + + + 6754238987643 + + 523427 + Deliverystreet 2 + Side door + DeliveryCity + NO + RegionD + + + + + 20130615 + + + + + 0003434323213231 + NOK + + 2298740918237 + Ebeneser Scrooge AS + + 989823401 + + + + 30 + + NO9386011117947 + + + DNBANOKK + + + + 30 + + NO9386011117947 + + + + 365.13 + VAT + 1460.5 + S + + 20130630 + + 25 + + + 0.15 + VAT + 1 + S + 15 + + + 0 + VAT + Exempt New Means of Transport + -25 + E + 0 + + + + 20130601 + + + 20130630 + + + + + false + + 100 + 95 + Promotion discount + + VAT + S + 25 + + + + + true + + 100 + Freight + + VAT + S + 25 + + + + 2 % discount if paid within 2 days +Penalty percentage 10% from due date + 20130720 + + + 1436.5 + 100 + 100 + 1436.5 + 365.28 + 1801.78 + 1000 + 801.78 + + + Project cost code 123 + + + + diff --git a/tests/Integration/Examples/CII/CII_example3.xml b/tests/Integration/Examples/CII/CII_example3.xml new file mode 100644 index 0000000..94136d0 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example3.xml @@ -0,0 +1,142 @@ + + + + + urn:cen.eu:en16931:2017 + + + + TOSL108 + 380 + + 20130410 + + + Contract was established through our website + + + + + + 1 + + + Paper subscription + Subscription fee 1st quarter + + + + 800 + + + + 1 + + + + VAT + S + 25 + + + 800 + + + + + + SubscriptionSeller + + DK16356706 + + + + antonio@SubscriptionsSeller.dk + + + + 54321 + Main street 2, Building 4 + Big city + DK + + + DK16356706 + + + + 5790000435975 + Buyercompany ltd + + 101 + Anystreet, Building 1 + Anytown + DK + + + + SUBSCR571 + + + + + Payref1 + DKK + + 30 + + DK1212341234123412 + + + + 30 + + DK1212341234123412 + + + + 225 + VAT + 900 + S + 25 + + + + 20130101 + + + 20130401 + + + + + true + + 100 + FC + Freight charge + + VAT + S + 25 + + + + 20130510 + + + 800 + 100 + 900 + 225 + 1125 + 1125 + + + + diff --git a/tests/Integration/Examples/CII/CII_example4.xml b/tests/Integration/Examples/CII/CII_example4.xml new file mode 100644 index 0000000..8805e8a --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example4.xml @@ -0,0 +1,205 @@ + + + + + urn:cen.eu:en16931:2017 + + + + TOSL110 + 380 + + 20130410 + + + Ordered through our website + + + + + + 1 + + + JB007 + Printing paper + Printing paper, 2mm + + + + 1 + + + + 1000 + + + + VAT + S + 25 + + + 1000 + + + + + + 2 + + + JB008 + Parker Pen + Parker Pen, Black, model Sansa + + + + 5 + + + + 100 + + + + VAT + S + 25 + + + 500 + + + + + + 3 + + + JB009 + American Cookies + + + + 5 + + + + 500 + + + + VAT + S + 12 + + + 2500 + + + + + + 5790000436101 + SellerCompany + + DK16356706 + + + Anthon Larsen + + +4598989898 + + + Anthon@SellerCompany.dk + + + + 54321 + Main street 2, Building 4 + Big city + DK + + + DK16356706 + + + + 5790000436057 + Buyercompany ltd + + John Hansen + + + 101 + Anystreet, Building 1 + Anytown + DK + + + + 123 + + + + + + 9000 + Deliverystreet + Deliverycity + DK + + + + + 20130415 + + + + + Payref1 + DKK + + 30 + + DK1212341234123412 + + + + 30 + + DK1212341234123412 + + + + 375 + VAT + 1500 + S + 25 + + + 300 + VAT + 2500 + S + 12 + + + 20130510 + + + 4000 + 4000 + 675 + 4675 + 4675 + + + + diff --git a/tests/Integration/Examples/CII/CII_example5.xml b/tests/Integration/Examples/CII/CII_example5.xml new file mode 100644 index 0000000..7ac221b --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example5.xml @@ -0,0 +1,436 @@ + + + + + P1 + + + urn:cen.eu:en16931:2017 + + + + TOSL110 + 380 + + 20130410 + + + Ordered through our website + AAI + + + + + + 1 + + first line + + + + 1234567890128 + JB007 + BUY123 + Printing paper + Printing paper, 2mm + + Thickness + 2 mm + + + NL + + + + + 1 + + + 1.1 + 1.1 + + + false + + 10 + + + + 1 + 1 + + + + 1000 + + + + VAT + S + 25 + + + + 20130310 + + + 20130310 + + + + + false + + 10 + 1000 + 100 + 95 + Loyal customer + + + + true + + 10 + 1000 + 100 + ABL + Packaging + + + 1000 + + + Object2 + 130 + + + ACC7654 + + + + + + 2 + + Second line + + + + JB008 + Parker Pen + Parker Pen, Black, model Sansa + + NL + + + + + 2 + + + 5 + + + + 100 + + + + VAT + S + 25 + + + + 20130310 + + + 20130310 + + + + 500 + + + Object2 + 130 + + + ACC7654 + + + + + + 3 + + + JB009 + American Cookies + + + + 5 + + + + 500 + + + + VAT + S + 12 + + + 2500 + + + + + qwerty + + 5790000436101 + SellerCompany + Export + + NL16356706 + SelCo + + + Anthon Larsen + + +3198989898 + + + Anthon@Selco.nl + + + + 54321 + Hoofdstraat 4 + Om de hoek + Grootstad + NL + Overijssel + + + info@selco.nl + + + NL16356706 + + + NL16356706 + + + + 5790000436057 + Buyercompany ltd + + DK16356607 + Buyco + + + John Hansen + + +4598989898 + + + john.hansen@buyercompany.dk + + + + 101 + Anystreet, Building 1 + 5th floor + Anytown + DK + Jutland + + + info@buyercompany.dk + + + DK16356607 + + + + Dick Panama + + 101 + Anystreet, Building 1 + 6th floor + Anytown + DK + Jutland + + + DK16356609 + + + + 123 + + + PO4711 + + + 2013-05 + + + Lot567 + + + OBJ999 + + + sales slip + 935 + your sales slip + SlZCRVJpMHhMalVOQ2lVTkNqRWdNQ0J2WW1vT3k2SlRaWDliY2dSVnhJVkcuLi50Ykxvc0NoVTJYUmY5eGIvb21zY2dUWS9sWEVoVWI= + + + Project345 + Project reference + + + + + 5790000436068 + Logistic service Ltd + + 9000 + Deliverystreet + Gate 15 + Deliverycity + DK + Jutland + + + + + 20130415 + + + + 5433 + + + 3544 + + + + DK5678 + Payref1 + EUR + DKK + + DK16356608 + Dagobert Duck + + DK16356608 + + + + 58 + Half prepaid + + DK1212341234123412 + + + + 58 + + + + + + 375 + VAT + 1500 + S + + 20130410 + + 25 + + + 300 + VAT + 2500 + S + 12 + + + + 20130310 + + + 20130410 + + + + + false + + 10 + 1500 + 150 + 95 + Loyal customer + + VAT + S + 25 + + + + + true + + 10 + 1500 + 150 + ABL + Packaging + + VAT + S + 25 + + + + 50% prepaid, 50% within one month + 20130510 + 123456 + + + 4000.00 + 150 + 150 + 4000 + 675.00 + 628.62 + 4675 + 2337.5 + 2337.5 + + + TOSL109 + + 20130310 + + + + 67543 + + + + diff --git a/tests/Integration/Examples/CII/CII_example6.xml b/tests/Integration/Examples/CII/CII_example6.xml new file mode 100644 index 0000000..50f86ce --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example6.xml @@ -0,0 +1,144 @@ + + + + + urn:cen.eu:en16931:2017 + + + + TOSL110 + 380 + + 20130410 + + + + + + 1 + + + Printing paper + + + + 1 + + + + 1000 + + + + VAT + S + 25 + + + 1000 + + + + + + 2 + + + Parker Pen + + + + 5 + + + + 100 + + + + VAT + S + 25 + + + 500 + + + + + + 3 + + + American Cookies + + + + 5 + + + + 500 + + + + VAT + S + 12 + + + 2500 + + + + + + SellerCompany + + DK + + + DK123456789MVA + + + + Buyercompany ltd + + DK + + + + + + DKK + + 375 + VAT + 1500 + S + 25 + + + 300 + VAT + 2500 + S + 12 + + + 20130510 + + + 4000 + 4000 + 675 + 4675 + 4675 + + + + diff --git a/tests/Integration/Examples/CII/CII_example7.xml b/tests/Integration/Examples/CII/CII_example7.xml new file mode 100644 index 0000000..f1acbbb --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example7.xml @@ -0,0 +1,171 @@ + + + + + urn:cen.eu:en16931:2017 + + + + INVOICE_test_7 + 380 + + 20130513 + + + Testscenario 7 + + + + + + 1 + + + RT3000 + Road tax + Weight-based tax, vehicles >3000 KGM + + + + 1 + + + 2500 + + + + 1 + + + + VAT + O + + + 2500 + + + + + + 2 + + + REG + Road Register fee + Annual registration fee + + + + 700 + + + + 1 + + + + VAT + O + + + 700 + + + + + + 5532331183 + The Sellercompany Incorporated + + Civic Service Centre + + + Anthon Larsen + + 4698989898 + + + Anthon@SellerCompany.se + + + + 54321 + Main street 2, Building 4 + Big city + SE + + + + THe Buyercompany + + 3150bdn + + 5121230 + + + john@buyercompany.no + + + + 101 + Anystreet 8 + Back door + Anytown + SE + RegionB + + + + Order_9988_x + + + + + SEK + + 30 + + SE1212341234123412 + + + SEXDABCD + + + + 30 + + SE1212341234123412 + + + + 0 + VAT + Tax + 3200 + O + + + + 20130101 + + + 20131231 + + + + Payment within 30 days + + + 3200 + 3200 + 3200 + 3200 + + + + diff --git a/tests/Integration/Examples/CII/CII_example8.xml b/tests/Integration/Examples/CII/CII_example8.xml new file mode 100644 index 0000000..71e21d0 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example8.xml @@ -0,0 +1,484 @@ + + + + + urn:cen.eu:en16931:2017 + + + + 1100512149 + 380 + + 20141110 + + + Periodieke afrekening +U vindt een toelichting op uw factuur via www.enexis.nl/factuur_grootzakelijk +Op alle diensten en overeenkomsten zijn de algemene voorwaarden aansluiting en +transport grootverbruik elektriciteit, respectievelijk gas van toepassing +www.enexis.nl + + + + + + 1 + + + Getransporteerde kWh’s + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 0.00880 + 0.00880 + + + + 16000 + + + + VAT + S + 21 + + + 140.80 + + + + + + 2 + + + Systeemdiensten + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 0.00101 + 0.00101 + + + + 16000 + + + + VAT + S + 21 + + + 16.16 + + + + + + 3 + + + Contract transportvermogen + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 15.24000 + 15.24000 + + + + 132 + + + + VAT + S + 21 + + + 167.64 + + + + + + 4 + + + Maximaal afgenomen vermogen + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 1.530000 + 1.530000 + + + + 58 + + + + VAT + S + 21 + + + 88.74 + + + + + + 5 + + + Vastrecht Transportdienst + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 441 + 441 + + + + 1 + + + + VAT + S + 21 + + + 36.75 + + + + + + 6 + + + Vastrecht Aansluitdienst + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + + 678 + 678 + + + + 1 + + + + VAT + S + 21 + + + 56.50 + + + + + + 7 + + + Huur Transformatoren + + + + 83.340000 + 83.340000 + + + + 1 + + + + VAT + S + 21 + + + 83.34 + + + + + + 8 + + + Huur Schakelinstallaties + + + + 190.310000 + 190.310000 + + + + 1 + + + + VAT + S + 21 + + + 190.31 + + + + + + 9 + + + Huur Overige Apparaten + + + + 64.210000 + 64.210000 + + + + 1 + + + + VAT + S + 21 + + + 64.21 + + + + + + 10 + + + Huur Meterdiensten + + + + 64.46000 + 64.46000 + + + + 1 + + + + VAT + S + 21 + + + 64.46 + + + + + + Enexis B.V. + + 17131139 + Enexis + + + + klantenservice.zakelijk@enexis.nl + + + + 5223MB + Magistratenlaan 116 + 'S-HERTOGENBOSCH + NL + + + NL809561074B01 + + + + 1081119 + Klant + + 9999 XX + Bedrijfslaan 4 + ONDERNEMERSTAD + NL + + + + 871694831000290806 + 130 + + + + + + 9999 XX + Bedrijfslaan 4, + ONDERNEMERSTAD + NL + + + + + 1100512149 + EUR + + 30 + + NL28RBOS0420242228 + + + + 30 + + NL28RBOS0420242228 + + + + 190.87 + VAT + 908.91 + S + 21 + + + + 20140801 + + + 20140831 + + + + Enexis brengt wettelijke rente in rekening over te laat betaalde +facturen. Kijk voor informatie op www.enexis.nl/rentenota + 20141124 + + + 908.91 + 908.91 + 190.87 + 1099.78 + 1099.78 + + + + diff --git a/tests/Integration/Examples/CII/CII_example9.xml b/tests/Integration/Examples/CII/CII_example9.xml new file mode 100644 index 0000000..9b23503 --- /dev/null +++ b/tests/Integration/Examples/CII/CII_example9.xml @@ -0,0 +1,140 @@ + + + + + urn:cen.eu:en16931:2017 + + + + 20150483 + 380 + + 20150401 + + + Vriendelijk verzoeken wij u ervoor te zorgen dat het bedrag voor de vervaldatum op onze rekening staat onder vermelding van +het factuurnummer. Het bankrekeningnummer is 37.78.15.500, Rabobank, t.n.v. Bluem te Amersfoort. Reclames gaarne binnen +10 dagen. Gelieve bij navraag en correspondentie uw firma naam en factuurnummer vermelden. + + + + + + + 1 + + + IExpress licentiekosten + + Verbruikscategorie + Start + + + + + 49 + 49 + + + + 3 + + + + VAT + S + 21 + + + + 20160401 + + + 20160401 + + + + 147 + + + + + + Bluem BV + + 32081330 Amersfoort + + + + 033-4549055 + + + info@bluem.nl + + + + 3825 AL + Lindeboomseweg 41 + Amersfoort + NL + + + NL809163160B01 + + + + Provide Verzekeringen + + 2402 NR + Henry Dunantweg 42 + Alphen aan den Rijn + NL + + + + iExpress 20110412 + + + + + 2015 0483 0000 0000 + EUR + + 30 + + NL13RABO0377815500 + + + RABONL2U + + + + 30 + + NL13RABO0377815500 + + + + 30.87 + VAT + 147 + S + 21 + + + 20150415 + + + 147 + 147 + 30.87 + 177.87 + 177.87 + + + + diff --git a/tests/Integration/Examples/CII/EN16931_AbweichenderZahlungsempf.xml b/tests/Integration/Examples/CII/EN16931_AbweichenderZahlungsempf.xml index 3f83aa6..6f5e790 100644 --- a/tests/Integration/Examples/CII/EN16931_AbweichenderZahlungsempf.xml +++ b/tests/Integration/Examples/CII/EN16931_AbweichenderZahlungsempf.xml @@ -1,91 +1,9 @@ - - - - - - - + + urn:cen.eu:en16931:2017 @@ -237,7 +155,9 @@ costs, losses or damages could normally have been foreseen.--> 19.00 - Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis 15.03.2018 + Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis + 15.03.2018 + 473.00 diff --git a/tests/Integration/Examples/CII/EN16931_Einfach.xml b/tests/Integration/Examples/CII/EN16931_Einfach.xml index 490c275..dfddf4f 100644 --- a/tests/Integration/Examples/CII/EN16931_Einfach.xml +++ b/tests/Integration/Examples/CII/EN16931_Einfach.xml @@ -1,244 +1,152 @@ - - - - - - - - - - urn:cen.eu:en16931:2017 - - - - 471102 - 380 - - 20180305 - - - Rechnung gemäß Bestellung vom 01.03.2018. - - - Lieferant GmbH - Lieferantenstraße 20 - 80333 München - Deutschland - Geschäftsführer: Hans Muster - Handelsregisternummer: H A 123 - - REG - - - - - - 1 - - - 4012345001235 - TB100A4 - Trennblätter A4 - - - - 9.9000 - - - 9.9000 - - - - 20.0000 - - - - VAT - S - 19.00 - - - 198.00 - - - - - - 2 - - - 4000050986428 - ARNR2 - Joghurt Banane - - - - 5.5000 - - - 5.5000 - - - - 50.0000 - - - - VAT - S - 7.00 - - - 275.00 - - - - - - 549910 - 4000001123452 - Lieferant GmbH - - 80333 - Lieferantenstraße 20 - München - DE - - - 201/113/40209 - - - DE123456789 - - - - GE2020211 - Kunden AG Mitte - - 69876 - Kundenstraße 15 - Frankfurt - DE - - - - - - - 20180305 - - - - - EUR - - 19.25 - VAT - 275.00 - S - 7.00 - - - 37.62 - VAT - 198.00 - S - 19.00 - - - Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis 15.03.2018 - - - 473.00 - 0.00 - 0.00 - 473.00 - 56.87 - 529.87 - 0.00 - 529.87 - - - + + + + + urn:cen.eu:en16931:2017 + + + + 471102 + 380 + + 20180305 + + + Rechnung gemäß Bestellung vom 01.03.2018. + + + + + + 1 + + + 4012345001235 + TB100A4 + Trennblätter A4 + + + + 9.9000 + + + 9.9000 + + + + 20.0000 + + + + VAT + S + 19.00 + + + 198.00 + + + + + + 2 + + + 4000050986428 + ARNR2 + Joghurt Banane + + + + 5.5000 + + + 5.5000 + + + + 50.0000 + + + + VAT + S + 7.00 + + + 275.00 + + + + + + 549910 + 4000001123452 + Lieferant GmbH + + 80333 + Lieferantenstraße 20 + München + DE + + + 201/113/40209 + + + DE123456789 + + + + GE2020211 + Kunden AG Mitte + + 69876 + Kundenstraße 15 + Frankfurt + DE + + + + + + + 20180305 + + + + + EUR + + 19.25 + VAT + 275.00 + S + 7.00 + + + 37.62 + VAT + 198.00 + S + 19.00 + + + Zahlbar innerhalb 30 Tagen netto bis 04.04.2018, 3% Skonto innerhalb 10 Tagen bis 15.03.2018 + + + 473.00 + 0.00 + 0.00 + 473.00 + 56.87 + 529.87 + 0.00 + 529.87 + + + diff --git a/tests/Integration/Examples/CII/EN16931_Gutschrift.xml b/tests/Integration/Examples/CII/EN16931_Gutschrift.xml index 77753b4..fba2a87 100644 --- a/tests/Integration/Examples/CII/EN16931_Gutschrift.xml +++ b/tests/Integration/Examples/CII/EN16931_Gutschrift.xml @@ -1,247 +1,167 @@ - - - - - - - - - - urn:cen.eu:en16931:2017 - - - - 471102 - 389 - - 20180305 - - - Rechnung gemäß Bestellung vom 01.03.2018. - - - Lieferant GmbH - Lieferantenstraße 20 - 80333 München - Deutschland - Geschäftsführer: Hans Muster - Handelsregisternummer: H A 123 - - REG - - - - - - 1 - - - 4012345001235 - TB100A4 - Trennblätter A4 - - - - 9.9000 - - - 9.9000 - - - - 20.0000 - - - - VAT - S - 19.00 - - - 198.00 - - - - - - 2 - - - 4000050986428 - ARNR2 - Joghurt Banane - - - - 5.5000 - - - 5.5000 - - - - 50.0000 - - - - VAT - S - 7.00 - - - 275.00 - - - - - - 549910 - 4000001123452 - Lieferant GmbH - - 80333 - Lieferantenstraße 20 - München - DE - - - 201/113/40209 - - - DE123456789 - - - - GE2020211 - Kunden AG Mitte - - 69876 - Kundenstraße 15 - Frankfurt - DE - - - DE136695976 - - - - - - - 20180305 - - - - - EUR - - 19.25 - VAT - 275.00 - S - 7.00 - - - 37.62 - VAT - 198.00 - S - 19.00 - - - Der Betrag wird ihrem Kundenkonto gutgeschrieben und mit der nächsten Rechnung verrechnet. - - - 473.00 - 0.00 - 0.00 - 473.00 - 56.87 - 529.87 - 0.00 - 529.87 - - - + + + + + urn:cen.eu:en16931:2017 + + + + 471102 + 389 + + 20180305 + + + Rechnung gemäß Bestellung vom 01.03.2018. + + + Lieferant GmbH + Lieferantenstraße 20 + 80333 München + Deutschland + Geschäftsführer: Hans Muster + Handelsregisternummer: H A 123 + + REG + + + + + + 1 + + + 4012345001235 + TB100A4 + Trennblätter A4 + + + + 9.9000 + + + 9.9000 + + + + 20.0000 + + + + VAT + S + 19.00 + + + 198.00 + + + + + + 2 + + + 4000050986428 + ARNR2 + Joghurt Banane + + + + 5.5000 + + + 5.5000 + + + + 50.0000 + + + + VAT + S + 7.00 + + + 275.00 + + + + + + 549910 + 4000001123452 + Lieferant GmbH + + 80333 + Lieferantenstraße 20 + München + DE + + + 201/113/40209 + + + DE123456789 + + + + GE2020211 + Kunden AG Mitte + + 69876 + Kundenstraße 15 + Frankfurt + DE + + + DE136695976 + + + + + + + 20180305 + + + + + EUR + + 19.25 + VAT + 275.00 + S + 7.00 + + + 37.62 + VAT + 198.00 + S + 19.00 + + + Der Betrag wird ihrem Kundenkonto gutgeschrieben und mit der nächsten Rechnung + verrechnet. + + + + 473.00 + 0.00 + 0.00 + 473.00 + 56.87 + 529.87 + 0.00 + 529.87 + + + diff --git a/tests/Integration/Examples/CII/EN16931_Innergemeinschaftliche_Lieferungen.xml b/tests/Integration/Examples/CII/EN16931_Innergemeinschaftliche_Lieferungen.xml index 5c5eb34..acaacf5 100644 --- a/tests/Integration/Examples/CII/EN16931_Innergemeinschaftliche_Lieferungen.xml +++ b/tests/Integration/Examples/CII/EN16931_Innergemeinschaftliche_Lieferungen.xml @@ -1,297 +1,218 @@ - - - - - - - - - Beispielgeschäftsprozess - - - urn:cen.eu:en16931:2017 - - - - 47110818 - 389 - - 20181031 - - - Mitglieder der Geschäftsleitung: - Geschäftsführerin: Johanna Musterfrau - Prokuristin: Isabell Herrlich - HRB Berlin 13086 - REG - - - - - - 1 - - - CO-123/V2A - Toolbox 0815 - Stahlcoil - - DE - - - - - 1000 - 1 - - - 100 - 1 - - - - 10 - - + + + + Beispielgeschäftsprozess + + + urn:cen.eu:en16931:2017 + + + + 47110818 + 389 + + 20181031 + + + Mitglieder der Geschäftsleitung: + Geschäftsführerin: Johanna Musterfrau + Prokuristin: Isabell Herrlich + HRB Berlin 13086 + + REG + + + + + + 1 + + + CO-123/V2A + Toolbox 0815 + Stahlcoil + + DE + + + + + 1000 + 1 + + + 100 + 1 + + + + 10 + + + + VAT + K + 0 + + + + 20181001 + + + 20181031 + + + + 1000 + + + + + + 2 + + + IM-712/A2A + BR-4529-ZF + Stoßfänger + + DE + + + + + 1000 + 1 + + + 100 + 1 + + + + 10 + + + + VAT + K + 0 + + + + 20181001 + + + 20181031 + + + + 1000 + + + + + + 12345676 + Global Supplies Ltd. + + SW1B 3BN + 153 Victoria Street + London + GB + + + GB123456789 + + + + 75969813 + Metallbau Leipzig GmbH & Co. KG + + 12345 + Pappelallee 15 + Hof 3 + Leipzig + DE + + + DE123456789 + + + + Global Supplies Financial Services + + 12345 + Friedrichstraße 165 + Berlin + DE + + + DE987654321 + + + + + + 75969815 + Metallbau Leipzig GmbH & Co. KG + + 12347 + Eichenpromenade 37 + Tor 1 + Metallstadt + DE + + + + + EUR + + 432156789 + Global Supplies Financial Services + + + 58 + + DE12 1234 4321 9876 00 + Global Supplies Financial Services + + - VAT - K - 0 + 0 + VAT + Mehrwertsteuerbefreiung für die innergemeinschaftliche Lieferung von Waren und + Dienstleistungen in der EU + + 2000 + K + 0 - - 20181001 - - - 20181031 - + + 20181001 + + + 20181031 + - - 1000 - - - - - - 2 - - - IM-712/A2A - BR-4529-ZF - Stoßfänger - - DE - - - - - 1000 - 1 - - - 100 - 1 - - - - 10 - - - - VAT - K - 0 - - - - 20181001 - - - 20181031 - - - - 1000 - - - - - - 12345676 - Global Supplies Ltd. - - SW1B 3BN - 153 Victoria Street - London - GB - - - GB123456789 - - - - 75969813 - Metallbau Leipzig GmbH & Co. KG - - 12345 - Pappelallee 15 - Hof 3 - Leipzig - DE - - - DE123456789 - - - - Global Supplies Financial Services - - 12345 - Friedrichstraße 165 - Berlin - DE - - - DE987654321 - - - - - - 75969815 - Metallbau Leipzig GmbH & Co. KG - - 12347 - Eichenpromenade 37 - Tor 1 - Metallstadt - DE - - - - - EUR - - 432156789 - Global Supplies Financial Services - - - 58 - - DE12 1234 4321 9876 00 - Global Supplies Financial Services - - - - 0 - VAT - Mehrwertsteuerbefreiung für die innergemeinschaftliche Lieferung von Waren und Dienstleistungen in der EU - 2000 - K - 0 - - - - 20181001 - - - 20181031 - - - - - 20181130 - - - - 2000.00 - 2000.00 - 0.00 - 2000.00 - 2000.00 - - - + + + 20181130 + + + + 2000.00 + 2000.00 + 0.00 + 2000.00 + 2000.00 + + + diff --git a/tests/Integration/Examples/CII/XRechnung-O.xml b/tests/Integration/Examples/CII/XRechnung-O.xml new file mode 100644 index 0000000..298ca8e --- /dev/null +++ b/tests/Integration/Examples/CII/XRechnung-O.xml @@ -0,0 +1,256 @@ + + + + + + + + urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0 + + + + 150377292 + 380 + + 20210114 + + + + + + 1 + + IndustriePolice + + + + IndustriePolice + + + + 99548.4200 + + + + 1.0000 + + + + VAT + O + + + + 20210101 + + + 20220101 + + + + + true + + 19.0000 + 83654.15 + 15894.27 + ZZZ + Versicherungssteuer + + + 83654.15 + + + 50028642477 + + + + + + 2 + + IndustriePolice + + + + IndustriePolice + + + + 285996.1800 + + + + 1.0000 + + + + VAT + O + + + + 20210101 + + + 20220101 + + + + + true + + 22.0000 + 252646.80 + 33349.38 + ZZZ + Versicherungssteuer + + + 252646.80 + + + 50028642477 + + + + + XX + + XX + + + XX + + + XX + + XX + + + XX + + + + 70376 + XX + XX + 70376 Stuttgart + Stuttgart + DE + + + + XX + + + XX + + + + XX + + + + + XX + + + + + + + + + 51147 + XX + XX + XX + Köln + DE + + + + + + + + 50028642477 + + + + + + + + + + V50028642477 VR00150377292 + EUR + + 30 + Ueberweisung + + XX + XX + + + HELADEFFXXX + + + + 0.00 + VAT + Versicherungen sind von der Umsatzsteuer befreit. + 385544.60 + O + vatex-eu-132-1a + 0.0000 + + + + true + + 19.0000 + 83654.15 + 15894.27 + ZZZ + Versicherungssteuer + + VAT + O + + + + + true + + 22.0000 + 252646.80 + 33349.38 + ZZZ + Versicherungssteuer + + VAT + O + + + + + 20210101 + + + + 336300.95 + 49243.65 + 385544.60 + 385544.60 + 385544.60 + + + + \ No newline at end of file diff --git a/tests/Integration/Examples/UBL/BIS3_Invoice_negativ.XML b/tests/Integration/Examples/UBL/BIS3_Invoice_negativ.XML new file mode 100755 index 0000000..502a6e3 --- /dev/null +++ b/tests/Integration/Examples/UBL/BIS3_Invoice_negativ.XML @@ -0,0 +1,159 @@ + + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 12345 + 2019-01-25 + 2019-02-24 + 380 + text + DKK + n/a + n/a + + 2018-09-01 + 2018-09-30 + + + n/a + + + 12345 + + + + 12345678 + + 12345678 + + + Company A + + + Street + Copenhagen + 1057 + + DK + + + + DK12345678 + + VAT + + + + Company A + 12345678 + + + + + + 87654321 + + 87654321 + + + Company B + + + Bjerkåsholmen 125 + Slemmestad + NO-3470 + + DK + + + + DK87654321 + + VAT + + + + Company B + 87654321 + + + n/a + + + + + 2019-01-25 + + + Street + Copenhagen + 1057 + + DK + + + + + + 58 + 12345667890 + + 1234567891234 + + + + -156435.89 + + -625743.54 + -156435.89 + + S + 25 + + VAT + + + + + + -625743.54 + -625743.54 + -782179.43 + -782179.43 + + + 1 + -1 + -625743.54 + n/a + + 2018-09-01 + 2018-09-30 + + + text + text + + 12345 + + + DK + + + S + 25 + + VAT + + + + + 625743.54 + + + diff --git a/tests/Integration/Examples/UBL/BIS3_Invoice_positive.XML b/tests/Integration/Examples/UBL/BIS3_Invoice_positive.XML new file mode 100755 index 0000000..c6a9836 --- /dev/null +++ b/tests/Integration/Examples/UBL/BIS3_Invoice_positive.XML @@ -0,0 +1,159 @@ + + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 12345 + 2019-01-25 + 2019-02-24 + 380 + text + DKK + n/a + n/a + + 2018-09-01 + 2018-09-30 + + + n/a + + + 12345 + + + + 12345678 + + 12345678 + + + Company A + + + Street + Copenhagen + 1057 + + DK + + + + DK12345678 + + VAT + + + + Company A + 12345678 + + + + + + 87654321 + + 87654321 + + + Company B + + + Bjerkåsholmen 125 + Slemmestad + NO-3470 + + DK + + + + DK87654321 + + VAT + + + + Company B + 87654321 + + + n/a + + + + + 2019-01-25 + + + Street + Copenhagen + 1057 + + DK + + + + + + 58 + 12345667890 + + 1234567891234 + + + + 156435.89 + + 625743.54 + 156435.89 + + S + 25 + + VAT + + + + + + 625743.54 + 625743.54 + 782179.43 + 782179.43 + + + 1 + 1 + 625743.54 + n/a + + 2018-09-01 + 2018-09-30 + + + text + text + + 12345 + + + DK + + + S + 25 + + VAT + + + + + 625743.54 + + + diff --git a/tests/Integration/Examples/UBL/guide-example1.xml b/tests/Integration/Examples/UBL/guide-example1.xml new file mode 100644 index 0000000..b5d9438 --- /dev/null +++ b/tests/Integration/Examples/UBL/guide-example1.xml @@ -0,0 +1,528 @@ + + + + urn:cen.eu:en16931:2017 + 12115118 + 2015-01-09 + 2015-01-09 + 380 + Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85##Delivery terms + EUR + + + + Postbus 7l + Velsen-Noord + 1950 AB + + NL + + + + NL8200.98.395.B.01 + + VAT + + + + De Koksmaat + 57151520 + + + + + + + 10202 + + + POSTBUS 367 + HEEMSKERK + 1960 AJ + + NL + + + + ODIN 59 + + + Dhr. J BLOKKER + + + + + 31 + Deb. 10202 / Fact. 12115118 + + NL57 RABO 0107307510 + + + + 31 + Deb. 10202 / Fact. 12115118 + + NL03 INGB 0004489902 + + + + 20.73 + + 183.23 + 10.99 + + S + 6 + + VAT + + + + + 46.37 + 9.74 + + S + 21 + + VAT + + + + + + 229.60 + 229.60 + 250.33 + 250.33 + + + 1 + 2 + 19.90 + + PATAT FRITES 10MM 10KG + + 166022 + + + S + 6 + + VAT + + + + + 9.95 + + + + 2 + 1 + 9.85 + + PKAAS 50PL. JONG BEL. 1KG + + 661813 + + + S + 6 + + VAT + + + + + 9.85 + + + + 3 + 1 + 8.29 + + POT KETCHUP 3 LT + + 438146 + + + S + 6 + + VAT + + + + + 8.29 + + + + 4 + 2 + 14.46 + + FRITESSAUS 3 LRR + + 438103 + + + S + 6 + + VAT + + + + + 7.23 + + + + 5 + 1 + 35.00 + + KOFFIE BLIK 3,5KG SNELF + + 666955 + + + S + 6 + + VAT + + + + + 35.00 + + + + 6 + 1 + 35.00 + + KOFFIE 3.5 KG BLIK STAND + + 664871 + + + S + 6 + + VAT + + + + + 35.00 + + + + 7 + 1 + 10.65 + + SUIKERKLONT + + 350257 + + + S + 6 + + VAT + + + + + 10.65 + + + + 8 + 1 + 1.55 + + 1 KG UL BLOKJES + + 350258 + + + S + 6 + + VAT + + + + + 1.55 + + + + 9 + 3 + 14.37 + + BLOCKNOTE A5 + + 999998 + + + S + 6 + + VAT + + + + + 4.79 + + + + 10 + 1 + 8.29 + + CHIPS NAT KLEIN ZAKJES + + 740810 + + + S + 6 + + VAT + + + + + 8.29 + + + + 11 + 2 + 16.58 + + CHIPS PAP KLEINE ZAKJES + + 740829 + + + S + 6 + + VAT + + + + + 8.29 + + + + 12 + 1 + 9.95 + + TR KL PAKJES APPELSAP + + 740828 + + + S + 6 + + VAT + + + + + 9.95 + + + + 13 + 2 + 3.30 + + PK CHOCOLADEMEL + + 740827 + + + S + 6 + + VAT + + + + + 1.65 + + + + 14 + 1 + 10.80 + + KRAT BIER + + 999996 + + + S + 21 + + VAT + + + + + 10.80 + + + + 15 + 1 + 3.90 + + STATIEGELD + + 999995 + + + S + 6 + + VAT + + + + + 3.90 + + + + 16 + 2 + 7.60 + + BLEEK 3 X 750 ML + + 102172 + + + S + 21 + + VAT + + + + + 3.80 + + + + 17 + 2 + 9.34 + + WC PAPIER + + 999994 + + + S + 21 + + VAT + + + + + 4.67 + + + + 18 + 1 + 18.63 + + BALPENNEN 50 ST BLAUW + + 999993 + + + S + 21 + + VAT + + + + + 18.63 + + + + 19 + 6 + 102.12 + + EM FRITUURVETxºxxx + + 999992 + + + S + 6 + + VAT + + + + + 17.02 + + + + 20 + 6 + -109.98 + + FRITUUR VET 10 KG RETOUR + + 175137 + + + S + 6 + + VAT + + + + + 18.33 + + + diff --git a/tests/Integration/Examples/UBL/guide-example2.xml b/tests/Integration/Examples/UBL/guide-example2.xml new file mode 100644 index 0000000..60b5252 --- /dev/null +++ b/tests/Integration/Examples/UBL/guide-example2.xml @@ -0,0 +1,445 @@ + + + + urn:cen.eu:en16931:2017 + Invoicing on purchase order + TOSL108 + 2013-06-30 + 2013-07-20 + 380 + Ordered in our booth at the convention + 2013-06-30 + NOK + Project cost code 123 + + 2013-06-01 + 2013-06-30 + + + 123 + + + Contract321 + + + Doc1 + Timesheet + + + http://www.suppliersite.eu/sheet001.html + + + + + Doc2 + EHF specification + + + + + 1238764941386 + + + Main street 34 + Suite 123 + Big city + 303 + RegionA + + NO + + + + NO123456789MVA + + VAT + + + + Salescompany ltd. + 123456789 + + + Antonio Salesmacher + 46211230 + antonio@salescompany.no + + + + + + + 3456789012098 + + + Anystreet 8 + Back door + Anytown + 101 + RegionB + + NO + + + + NO987654321MVA + + VAT + + + + The Buyercompany + 987654321 + + + John Doe + 5121230 + john@buyercompany.no + + + + + + 2298740918237 + + + Ebeneser Scrooge AS + + + 989823401 + + + + + Tax handling company AS + + + Regent street + Front door + Newtown + 202 + RegionC + + NO + + + + NO967611265MVA + + VAT + + + + + 2013-06-15 + + 6754238987643 + + Deliverystreet 2 + Side door + DeliveryCity + 523427 + RegionD + + NO + + + + + + 30 + 0003434323213231 + + NO9386011117947 + + DNBANOKK + + + + + 2 % discount if paid within 2 days Penalty percentage 10% from due date + + + false + 71 + Promotion discount + 100.00 + + S + 25 + + VAT + + + + + true + Freight + 100.00 + + S + 25 + + VAT + + + + + 365.28 + + 1460.50 + 365.13 + + S + 25 + + VAT + + + + + 1.00 + 0.15 + + S + 15 + + VAT + + + + + -25.00 + 0.00 + + E + 0 + Exempt New Means of Transport + + + VAT + + + + + + 1436.50 + 1436.50 + 1801.78 + 100.00 + 100.00 + 1000.00 + 801.78 + + + 1 + Scratch on box + 2 + 1273.00 + BookingCode001 + + 2013-06-01 + 2013-06-30 + + + 1 + + + false + Damage + 12.00 + + + true + Testing + 12.00 + + + Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen + 1440x900 + Laptop computer + + JB007 + + + 1234567890128 + + + DE + + + 65434568 + + + S + 25 + + VAT + + + + Color + Black + + + + 1273.00 + 1 + + false + 225.00 + + + + + 2 + Cover is slightly damaged. + -1 + -3.96 + BookingCode002 + + 5 + + + Returned "Advanced computing" book + + JB008 + + + 1234567890135 + + + + 65434567 + + + S + 15 + + VAT + + + + + 3.96 + 1 + + + + 3 + 2 + 4.96 + BookingCode003 + + 3 + + + "Computing for dummies" book + + JB009 + + + 1234567890135 + + + + 65434567 + + + S + 15 + + VAT + + + + + 2.48 + 1 + + false + 0.75 + 2.75 + + + + + 4 + -1 + -25.00 + BookingCode004 + + 2 + + + Returned IBM 5150 desktop + + JB010 + + + 1234567890159 + + + + 65434565 + + + E + 0 + + VAT + + + + + 25.00 + 1 + + + + 5 + 250 + 187.50 + BookingCode005 + + + + + Network cable + + JB011 + + + 1234567890166 + + + + 65434564 + + + S + 25 + + VAT + + + + Type + Cat5 + + + + 0.75 + 1 + + + diff --git a/tests/Integration/Examples/UBL/guide-example3.xml b/tests/Integration/Examples/UBL/guide-example3.xml new file mode 100644 index 0000000..a27fec5 --- /dev/null +++ b/tests/Integration/Examples/UBL/guide-example3.xml @@ -0,0 +1,152 @@ + + + + urn:cen.eu:en16931:2017 + TOSL108 + 2013-04-10 + 2013-05-10 + 380 + Contract was established through our website + DKK + + 2013-01-01 + 2013-04-01 + + + SUBSCR571 + + + + + 1238764941386 + + + Main street 2, Building 4 + Big city + 54321 + + DK + + + + DK16356706 + + VAT + + + + SubscriptionSeller + DK16356706 + + + antonio@SubscriptionsSeller.dk + + + + + + + 5790000435975 + + + Anystreet, Building 1 + Anytown + 101 + + DK + + + + Buyercompany ltd + + + + + 30 + Payref1 + + DK1212341234123412 + + + + true + Freight charge + 100.00 + + S + 25 + + VAT + + + + + 225.00 + + 900.00 + 225.00 + + S + 25 + + VAT + + + + + + 800.00 + 900.00 + 1125.00 + 100.00 + 1125.00 + + + 1 + 2 + 400.00 + + Subscription fee 1st quarter + Paper subscription + + S + 25 + + VAT + + + + + 800.00 + + + + 2 + 2 + 400.00 + + Subscription fee 1st quarter + Paper subscription + + S + 25.00 + + VAT + + + + + 800.00 + + + + diff --git a/tests/Integration/Examples/UBL/issue116.xml b/tests/Integration/Examples/UBL/issue116.xml new file mode 100644 index 0000000..98eeae0 --- /dev/null +++ b/tests/Integration/Examples/UBL/issue116.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 2018210 + 2018-02-08 + 2018-03-07 + 380 + SEK + Buyer reference + + + 5566778899 + + + AF + + + + SE123456789001 + + VAT + + + + SÄLJARNAMNET + 1234567890 + Säte: Big CIty + + + + + + 1234512345 + + + AF + + + + SE123451234501 + + VAT + + + + Project services AB + 1234512345 + + + + + 30 dagar netto. Dröjsmålsränta:12 % + + + false + Discount2 + 0 + + S + 6 + + VAT + + + + + false + Discount1 + 1 + + E + 0 + + VAT + + + + + true + Standard charge + 1 + + E + 0 + + VAT + + + + + true + Extra charge + 0 + + E + 0 + + VAT + + + + + 130 + + 100 + 6 + + S + 6 + + VAT + + + + + 400 + 100 + + S + 25 + + VAT + + + + + + + 200 + 24 + + S + 12 + + VAT + + + + + 0 + 0 + + E + 0 + Skatteundantag + + VAT + + + + + + 700 + 700 + 830 + 1 + 1 + 0 + 0 + 830 + + + 1 + 1 + 100 + + Newspaper (VAT 6%) + + S + 6 + + VAT + + + + + 100 + + + + 2 + 1 + 50 + + Food (VAT 12%) + + S + 12 + + VAT + + + + + 50 + + + + 3 + 1 + 150 + + Food (VAT 12%) + + S + 12 + + VAT + + + + + 150 + + + + 4 + 1 + 400 + + Petrol (VAT 25%) + + S + 25 + + VAT + + + + + 400 + + + diff --git a/tests/Integration/Examples/UBL/sample-discount-price.xml b/tests/Integration/Examples/UBL/sample-discount-price.xml new file mode 100644 index 0000000..e18c487 --- /dev/null +++ b/tests/Integration/Examples/UBL/sample-discount-price.xml @@ -0,0 +1,125 @@ + + + + urn:cen.eu:en16931:2017 + P1 + test decimal 1 + 2018-02-05 + 2018-02-28 + 380 + HRK + HRK + + + + 46830600751 + + + ULICA 1 + SPLIT + 10000 + + ULICA 1, 10000 SPLIT + + + HR + + + + HR46830600751 + + VAT + + + + HEP SPLIT + 086374645 + + + + + + + 12346830600751 + + + VUKOVARSKA PROMJENA ADRESE + ZAGREB + 10000 + + VUKOVARSKA PROMJENA ADRESE 20, 10000 ZAGREB + + + HR + + + + HR46830600751 + + VAT + + + + HEP-OPERATOR DISTRIBUCIJSKOG SUSTAVA D.O.O. ZA DISTRIBUCIJU I + OPSKRBU ELEKTRICNE ENERGIJE + 08634543 + + + + + 4 + + + 3.03 + + 12.12 + 3.03 + + S + 25 + + VAT + + + + + + 12.12 + 12.12 + 15.15 + 15.15 + + + 1 + 100.000 + 12.12 + + stavka 1 + + HR + + + S + 25 + + VAT + + + + + 0.1212 + 1 + + false + 0.0022 + 0.1234 + + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-creditnote1.xml b/tests/Integration/Examples/UBL/ubl-tc434-creditnote1.xml new file mode 100644 index 0000000..f270d93 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-creditnote1.xml @@ -0,0 +1,136 @@ + + + + urn:cen.eu:en16931:2017 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 018304 / 28865 + 2019-09-23 + 381 + EUR + 018304 / 28865 + + 2019-02-01 + 2019-02-28 + + + + 0000000196 + + My Supplier Company N.V. + + + De Grote Meir 22 + ANTWERPEN + 2000 + + BE + + + + BE0000000196 + + VAT + + + + My Supplier Company + 0000000196 + + + john.doole@mysuppliercompany.be + + + + + + 0000000295 + + My Customer Company S.A. + + + Boulevard Sint Michel 53 + BRUXELLES + 1000 + + BE + + + + BE0000000295 + + VAT + + + + My Customer Company + 0000000295 + + + pete.smith@mycustomercompany.be + + + + + 1 + 010676609538 + + BE91000000143476 + + BPOTBEB1 + + + + + 0.00 + + 100.11 + 0.00 + + E + 0.00 + Taxes are not applicable + + VAT + + + + + + 100.11 + 100.11 + 100.11 + 100.11 + + + 1 + 1.00 + 100.11 + + Exonération du versement du PP + Exonération du versement du PP + + V55 + + + E + 0.00 + + VAT + + + + 2 + Contributions - précompte professionnel + + + + 100.11 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example1.xml b/tests/Integration/Examples/UBL/ubl-tc434-example1.xml new file mode 100644 index 0000000..105fb4f --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example1.xml @@ -0,0 +1,530 @@ + + + + urn:cen.eu:en16931:2017 + 12115118 + 2015-01-09 + 2015-01-09 + 380 + Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85##Delivery terms + EUR + + + + Postbus 7l + Velsen-Noord + 1950 AB + + NL + + + + NL8200.98.395.B.01 + + VAT + + + + De Koksmaat + 57151520 + + + + + + + 10202 + + + POSTBUS 367 + HEEMSKERK + 1960 AJ + + NL + + + + ODIN 59 + + + Dhr. J BLOKKER + + + + + 30 + Deb. 10202 / Fact. 12115118 + + NL57 RABO 0107307510 + + + + 30 + + NL03 INGB 0004489902 + + + + 20.73 + + 183.23 + 10.99 + + S + 6 + + VAT + + + + + + 46.37 + 9.74 + + S + 21 + + VAT + + + + + + 229.60 + 229.60 + 250.33 + 250.33 + + + 1 + 2 + 19.90 + + PATAT FRITES 10MM 10KG + + 166022 + + + S + 6 + + VAT + + + + + 9.95 + + + + 2 + 1 + 9.85 + + PKAAS 50PL. JONG BEL. 1KG + + 661813 + + + S + 6 + + VAT + + + + + 9.85 + + + + 3 + 1 + 8.29 + + POT KETCHUP 3 LT + + 438146 + + + S + 6 + + VAT + + + + + 8.29 + + + + 4 + 2 + 14.46 + + FRITESSAUS 3 LRR + + 438103 + + + S + 6 + + VAT + + + + + 7.23 + + + + 5 + 1 + 35.00 + + KOFFIE BLIK 3,5KG SNELF + + 666955 + + + S + 6 + + VAT + + + + + 35.00 + + + + 6 + 1 + 35.00 + + KOFFIE 3.5 KG BLIK STAND + + 664871 + + + S + 6 + + VAT + + + + + 35.00 + + + + 7 + 1 + 10.65 + + SUIKERKLONT + + 350257 + + + S + 6 + + VAT + + + + + 10.65 + + + + 8 + 1 + 1.55 + + 1 KG UL BLOKJES + + 350258 + + + S + 6 + + VAT + + + + + 1.55 + + + + 9 + 3 + 14.37 + + BLOCKNOTE A5 + + 999998 + + + S + 6 + + VAT + + + + + 4.79 + + + + 10 + 1 + 8.29 + + CHIPS NAT KLEIN ZAKJES + + 740810 + + + S + 6 + + VAT + + + + + 8.29 + + + + 11 + 2 + 16.58 + + CHIPS PAP KLEINE ZAKJES + + 740829 + + + S + 6 + + VAT + + + + + 8.29 + + + + 12 + 1 + 9.95 + + TR KL PAKJES APPELSAP + + 740828 + + + S + 6 + + VAT + + + + + 9.95 + + + + 13 + 2 + 3.30 + + PK CHOCOLADEMEL + + 740827 + + + S + 6 + + VAT + + + + + 1.65 + + + + 14 + 1 + 10.80 + + KRAT BIER + + 999996 + + + S + 21 + + VAT + + + + + 10.80 + + + + 15 + 1 + 3.90 + + STATIEGELD + + 999995 + + + S + 6 + + VAT + + + + + 3.90 + + + + 16 + 2 + 7.60 + + BLEEK 3 X 750 ML + + 102172 + + + S + 21 + + VAT + + + + + 3.80 + + + + 17 + 2 + 9.34 + + WC PAPIER + + 999994 + + + S + 21 + + VAT + + + + + 4.67 + + + + 18 + 1 + 18.63 + + BALPENNEN 50 ST BLAUW + + 999993 + + + S + 21 + + VAT + + + + + 18.63 + + + + 19 + 6 + 102.12 + + EM FRITUURVET + + 999992 + + + S + 6 + + VAT + + + + + 17.02 + + + + 20 + 6 + -109.98 + + FRITUUR VET 10 KG RETOUR + + 175137 + + + S + 6 + + VAT + + + + + 18.33 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example10.xml b/tests/Integration/Examples/UBL/ubl-tc434-example10.xml new file mode 100644 index 0000000..95f0362 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example10.xml @@ -0,0 +1,532 @@ + + + + urn:cen.eu:en16931:2017 + 12115118 + 2015-01-09 + 2015-01-09 + 380 + Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85##Delivery terms + EUR + SEK + + + + Postbus 7l + Velsen-Noord + 1950 AB + + NL + + + + NL8200.98.395.B.01 + + VAT + + + + De Koksmaat + 57151520 + + + + + + + 10202 + + + POSTBUS 367 + HEEMSKERK + 1960 AJ + + NL + + + + ODIN 59 + + + Dhr. J BLOKKER + + + + + 30 + Deb. 10202 / Fact. 12115118 + + NL57 RABO 0107307510 + + + + 30 + Deb. 10202 / Fact. 12115118 + + NL03 INGB 0004489902 + + + + 20.73 + + 183.23 + 10.99 + + S + 6 + + VAT + + + + + 46.37 + 9.74 + + S + 21 + + VAT + + + + + + 2000.73 + + + 229.60 + 229.60 + 250.33 + 250.33 + + + 1 + 2 + 19.90 + + PATAT FRITES 10MM 10KG + + 166022 + + + S + 6 + + VAT + + + + + 9.95 + + + + 2 + 1 + 9.85 + + PKAAS 50PL. JONG BEL. 1KG + + 661813 + + + S + 6 + + VAT + + + + + 9.85 + + + + 3 + 1 + 8.29 + + POT KETCHUP 3 LT + + 438146 + + + S + 6 + + VAT + + + + + 8.29 + + + + 4 + 2 + 14.46 + + FRITESSAUS 3 LRR + + 438103 + + + S + 6 + + VAT + + + + + 7.23 + + + + 5 + 1 + 35.00 + + KOFFIE BLIK 3,5KG SNELF + + 666955 + + + S + 6 + + VAT + + + + + 35.00 + + + + 6 + 1 + 35.00 + + KOFFIE 3.5 KG BLIK STAND + + 664871 + + + S + 6 + + VAT + + + + + 35.00 + + + + 7 + 1 + 10.65 + + SUIKERKLONT + + 350257 + + + S + 6 + + VAT + + + + + 10.65 + + + + 8 + 1 + 1.55 + + 1 KG UL BLOKJES + + 350258 + + + S + 6 + + VAT + + + + + 1.55 + + + + 9 + 3 + 14.37 + + BLOCKNOTE A5 + + 999998 + + + S + 6 + + VAT + + + + + 4.79 + + + + 10 + 1 + 8.29 + + CHIPS NAT KLEIN ZAKJES + + 740810 + + + S + 6 + + VAT + + + + + 8.29 + + + + 11 + 2 + 16.58 + + CHIPS PAP KLEINE ZAKJES + + 740829 + + + S + 6 + + VAT + + + + + 8.29 + + + + 12 + 1 + 9.95 + + TR KL PAKJES APPELSAP + + 740828 + + + S + 6 + + VAT + + + + + 9.95 + + + + 13 + 2 + 3.30 + + PK CHOCOLADEMEL + + 740827 + + + S + 6 + + VAT + + + + + 1.65 + + + + 14 + 1 + 10.80 + + KRAT BIER + + 999996 + + + S + 21 + + VAT + + + + + 10.80 + + + + 15 + 1 + 3.90 + + STATIEGELD + + 999995 + + + S + 6 + + VAT + + + + + 3.90 + + + + 16 + 2 + 7.60 + + BLEEK 3 X 750 ML + + 102172 + + + S + 21 + + VAT + + + + + 3.80 + + + + 17 + 2 + 9.34 + + WC PAPIER + + 999994 + + + S + 21 + + VAT + + + + + 4.67 + + + + 18 + 1 + 18.63 + + BALPENNEN 50 ST BLAUW + + 999993 + + + S + 21 + + VAT + + + + + 18.63 + + + + 19 + 6 + 102.12 + + EM FRITUURVET + + 999992 + + + S + 6 + + VAT + + + + + 17.02 + + + + 20 + 6 + -109.98 + + FRITUUR VET 10 KG RETOUR + + 175137 + + + S + 6 + + VAT + + + + + 18.33 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example2.xml b/tests/Integration/Examples/UBL/ubl-tc434-example2.xml new file mode 100644 index 0000000..339c168 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example2.xml @@ -0,0 +1,460 @@ + + + + urn:cen.eu:en16931:2017 + Invoicing on purchase order + TOSL108 + 2013-06-30 + 2013-07-20 + 380 + Ordered in our booth at the convention + NOK + Project cost code 123 + + 2013-06-01 + 2013-06-30 + 3 + + + 123 + + + Contract321 + + + Doc1 + Timesheet + + + http://www.suppliersite.eu/sheet001.html + + + + + Doc2 + EHF specification + + VGVzdGluZyBCYXNlNjQgZW5jb2Rpbmc= + + + + + + 1238764941386 + + + Main street 34 + Suite 123 + Big city + 303 + RegionA + + NO + + + + NO123456789MVA + + VAT + + + + Salescompany ltd. + 123456789 + + + Antonio Salesmacher + 46211230 + antonio@salescompany.no + + + + + + + 3456789012098 + + + Anystreet 8 + Back door + Anytown + 101 + RegionB + + NO + + + + NO987654321MVA + + VAT + + + + The Buyercompany + 987654321 + + + John Doe + 5121230 + john@buyercompany.no + + + + + + 2298740918237 + + + Ebeneser Scrooge AS + + + 989823401 + + + + + Tax handling company AS + + + Regent street + Front door + Newtown + 202 + RegionC + + NO + + + + NO967611265MVA + + VAT + + + + + 2013-06-15 + + 6754238987643 + + Deliverystreet 2 + Side door + DeliveryCity + 523427 + RegionD + + NO + + + + + + 30 + 0003434323213231 + + NO9386011117947 + + DNBANOKK + + + + + 2 % discount if paid within 2 days + Penalty percentage 10% from due date + + + 0 + 88 + Promotion discount + 100.00 + + S + 25 + + VAT + + + + + true + Freight + 100.00 + + S + 25 + + VAT + + + + + 365.28 + + 1460.50 + 365.13 + + S + 25 + + VAT + + + + + 1.00 + 0.15 + + S + 15 + + VAT + + + + + -25.00 + 0.00 + + E + 0 + Exempt New Means of Transport + + VAT + + + + + + 1436.50 + 1436.50 + 1801.78 + 100.00 + 100.00 + 1000.00 + 801.78 + + + 1 + Scratch on box + 2 + 1273.00 + BookingCode001 + + 2013-06-01 + 2013-06-30 + + + 1 + + + false + Damage + 12.00 + + + true + Testing + 12.00 + + + Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen 1440x900 + Laptop computer + + JB007 + + + 1234567890128 + + + DE + + + 12344321 + + + 65434568 + + + S + 25 + + VAT + + + + Color + Black + + + + 1273.00 + 1 + + false + 225.00 + + + + + 2 + Cover is slightly damaged. + -1 + -3.96 + BookingCode002 + + 5 + + + Returned "Advanced computing" book + + JB008 + + + 1234567890135 + + + 32344324 + + + 65434567 + + + S + 15 + + VAT + + + + + 3.96 + 1 + + + + 3 + 2 + 4.96 + BookingCode003 + + 3 + + + "Computing for dummies" book + + JB009 + + + 1234567890135 + + + 32344324 + + + 65434567 + + + S + 15 + + VAT + + + + + 2.48 + 1 + + false + 0.27 + 2.70 + + + + + 4 + -1 + -25.00 + BookingCode004 + + 2 + + + Returned IBM 5150 desktop + + JB010 + + + 1234567890159 + + + 12344322 + + + 65434565 + + + E + 0 + + VAT + + + + + 25.00 + 1 + + + + 5 + 250 + 187.50 + BookingCode005 + + + + + Network cable + + JB011 + + + 1234567890166 + + + 12344325 + + + 65434564 + + + S + 25 + + VAT + + + + Type + Cat5 + + + + 0.75 + 1 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example3.xml b/tests/Integration/Examples/UBL/ubl-tc434-example3.xml new file mode 100644 index 0000000..8a0df3b --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example3.xml @@ -0,0 +1,171 @@ + + + + urn:cen.eu:en16931:2017 + TOSL108 + 2013-04-10 + 2013-05-10 + 380 + Contract was established through our website + DKK + + 2013-01-01 + 2013-04-01 + + + SUBSCR571 + + + + + 1238764941386 + + + Main street 2, Building 4 + Big city + 54321 + + DK + + + + DK16356706 + + VAT + + + + SubscriptionSeller + DK16356706 + + + antonio@SubscriptionsSeller.dk + + + + + + + 5790000435975 + + + Anystreet, Building 1 + Anytown + 101 + + DK + + + + NO987654321MVA + + VAT + + + + Buyercompany ltd + 987654321 + + + + + 30 + Payref1 + + DK1212341234123412 + + + + true + Freight charge + 100.00 + + S + 25 + + VAT + + + + + 305.00 + + 900.00 + 225.00 + + S + 25 + + VAT + + + + + 800.00 + 80.00 + + S + 10 + + VAT + + + + + + 1600.00 + 1700.00 + 2005.00 + 100.00 + 2005.00 + + + 1 + 2 + 800.00 + + Subscription fee 1st quarter + Paper subscription + + S + 25 + + VAT + + + + + 800.00 + + + + 2 + 2 + 800.00 + + Subscription fee 1st quarter + Paper subscription + + S + 10 + + VAT + + + + + 800.00 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example4.xml b/tests/Integration/Examples/UBL/ubl-tc434-example4.xml new file mode 100644 index 0000000..ffaca70 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example4.xml @@ -0,0 +1,192 @@ + + + + urn:cen.eu:en16931:2017 + TOSL110 + 2013-04-10 + 2013-05-10 + 380 + Ordered through our website + DKK + + 123 + + + + + 5790000436101 + + + Main street 2, Building 4 + Big city + 54321 + + DK + + + + DK16356706 + + VAT + + + + SellerCompany + DK16356706 + + + Anthon Larsen + +4598989898 + antonio@SubscriptionsSeller.dk + + + + + + + 5790000436057 + + + Anystreet, Building 1 + Anytown + 101 + + DK + + + + Buyercompany ltd + + + John Hansen + + + + + 2013-04-15 + + + Deliverystreet + Deliverycity + 9000 + + DK + + + + + + 30 + Payref1 + + DK1212341234123412 + + + + 675.00 + + 1500.00 + 375.00 + + S + 25 + + VAT + + + + + 2500.00 + 300.00 + + S + 12 + + VAT + + + + + + 4000.00 + 4000.00 + 4675.00 + 4675.00 + + + 1 + 1000 + 1000.00 + + Printing paper, 2mm + Printing paper + + JB007 + + + S + 25 + + VAT + + + + + 1.00 + + + + 2 + 100 + 500.00 + + Parker Pen, Black, model Sansa + Parker Pen + + JB008 + + + S + 25 + + VAT + + + + + 5.00 + + + + 3 + 500 + 2500.00 + + American Cookies + + JB009 + + + S + 12 + + VAT + + + + + 5.00 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example5.xml b/tests/Integration/Examples/UBL/ubl-tc434-example5.xml new file mode 100644 index 0000000..5b53c4f --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example5.xml @@ -0,0 +1,410 @@ + + + + urn:cen.eu:en16931:2017 + 1 + TOSL110 + 2013-04-10 + 2013-05-10 + 380 + Ordered through our website#Ordering information + DKK + EUR + 67543 + qwerty + + 2013-03-10 + 2013-04-10 + + + PO4711 + 123 + + + + TOSL109 + 2013-03-10 + + + + 5433 + + + 3544 + + + Lot567 + + + 2013-05 + + + OBJ999 + ATS + + + sales slip + your sales slip + + VGVzdGluZyBCYXNlNjQgZW5jb2Rpbmc= + + + + Project345 + + + + info@selco.nl + + 5790000436101 + + + SelCo + + + Hoofdstraat 4 + Om de hoek + Grootstad + 54321 + Overijssel + + NL + + + + NL16356706 + + VAT + + + + NL16356706 + + LOC + + + + SellerCompany + NL16356706 + Export + + + Anthon Larsen + +3198989898 + Anthon@Selco.nl + + + + + + info@buyercompany.dk + + 5790000436057 + + + Buyco + + + Anystreet, Building 1 + 5th floor + Anytown + 101 + Jutland + + DK + + + + DK16356607 + + VAT + + + + Buyercompany ltd + DK16356607 + + + John Hansen + +4598989898 + john.hansen@buyercompany.dk + + + + + + DK16356608 + + + Dagobert Duck + + + DK16356608 + + + + + Dick Panama + + + Anystreet, Building 1 + 6th floor + Anytown + 101 + Jutland + + DK + + + + DK16356609 + + VAT + + + + + 2013-04-15 + + 5790000436068 + + Deliverystreet + Gate 15 + Deliverycity + 9000 + Jutland + + DK + + + + + + Logistic service Ltd + + + + + 49 + Half prepaid + Payref1 + + 123456 + + DK1212341234123412 + + + + + 50% prepaid, 50% within one month + + + false + 100 + Loyal customer + 10 + 150.00 + 1500.00 + + S + 25 + + VAT + + + + + true + ABL + Packaging + 10 + 150.00 + 1500.00 + + S + 25 + + VAT + + + + + 675.00 + + 1500.00 + 375.00 + + S + 25 + + VAT + + + + + 2500.00 + 300.00 + + S + 12 + + VAT + + + + + + 628.62 + + + 4000.00 + 4000.00 + 4675.00 + 150.00 + 150.00 + 2337.50 + 2337.50 + + + 1 + first line + 1000 + 1000.00 + ACC7654 + + 2013-03-10 + 2013-04-10 + + + 1 + + + Object2 + + + false + 100 + Loyal customer + 10 + 100.00 + 1000.00 + + + true + ABL + Packaging + 10 + 100.00 + 1000.00 + + + Printing paper, 2mm + Printing paper + + BUY123 + + + JB007 + + + 1234567890128 + + + NL + + + 12344321 + + + S + 25 + + VAT + + + + Thickness + 2 mm + + + + 1.00 + 1 + + false + 0.10 + 1.10 + + + + + 2 + second line + 100 + 500.00 + ACC7654 + + 2013-03-10 + 2013-04-10 + + + 2 + + + Object2 + + + Parker Pen, Black, model Sansa + Parker Pen + + JB008 + + + NL + + + S + 25 + + VAT + + + + + 5.00 + + + + 3 + 500 + 2500.00 + + American Cookies + + JB009 + + + S + 12 + + VAT + + + + + 5.00 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example6.xml b/tests/Integration/Examples/UBL/ubl-tc434-example6.xml new file mode 100644 index 0000000..05d8f23 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example6.xml @@ -0,0 +1,136 @@ + + + + urn:cen.eu:en16931:2017 + TOSL110 + 2013-04-10 + 2013-05-10 + 380 + DKK + + + + + DK + + + + DK123456789MVA + + VAT + + + + SellerCompany + + + + + + + + DK + + + + Buyercompany ltd + + + + + 675.00 + + 1500.00 + 375.00 + + S + 25 + + VAT + + + + + 2500.00 + 300.00 + + S + 12 + + VAT + + + + + + 4000.00 + 4000.00 + 4675.00 + 4675.00 + + + 1 + 1000 + 1000.00 + + Printing paper + + S + 25 + + VAT + + + + + 1.00 + + + + 2 + 100 + 500.00 + + Parker Pen + + S + 25 + + VAT + + + + + 5.00 + + + + 3 + 500 + 2500.00 + + American Cookies + + S + 12 + + VAT + + + + + 5.00 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example7.xml b/tests/Integration/Examples/UBL/ubl-tc434-example7.xml new file mode 100644 index 0000000..5f4f920 --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example7.xml @@ -0,0 +1,153 @@ + + + + urn:cen.eu:en16931:2017 + INVOICE_test_7 + 2013-03-11 + 380 + Testscenario 7 + SEK + + 2013-01-01 + 2013-12-31 + + + Order_9988_x + + + + + 5532331183 + + + Civic Service Centre + + + Main street 2, Building 4 + Big city + 54321 + + SE + + + + The Sellercompany Incorporated + + + Anthon Larsen + 4698989898 + Anthon@SellerCompany.se + + + + + + + Anystreet 8 + Back door + Anytown + 101 + RegionB + + SE + + + + THe Buyercompany + + + A3150bdn + 5121230 + john@buyercompany.no + + + + + 30 + + SE1212341234123412 + + SEXDABCD + + + + + Payment within 30 days + + + 0.00 + + 3200.00 + 0.00 + + O + Tax + + VAT + + + + + + 3200.00 + 3200.00 + 3200.00 + 3200.00 + + + 1 + 1 + 2500.00 + + 1 + + + Weight-based tax, vehicles >3000 KGM + Road tax + + RT3000 + + + O + + VAT + + + + + 2500.00 + + + + 2 + 1 + 700.00 + + Annual registration fee + Road Register fee + + REG + + + O + + VAT + + + + + 700.00 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example8.xml b/tests/Integration/Examples/UBL/ubl-tc434-example8.xml new file mode 100644 index 0000000..4b01ece --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example8.xml @@ -0,0 +1,410 @@ + + + + urn:cen.eu:en16931:2017 + 1100512149 + 2014-11-10 + 2014-11-24 + 380 + Periodieke afrekening + U vindt een toelichting op uw factuur via www.enexis.nl/factuur_grootzakelijk + Op alle diensten en overeenkomsten zijn de algemene voorwaarden aansluiting en + transport grootverbruik elektriciteit, respectievelijk gas van toepassing + www.enexis.nl + 2013-06-30 + EUR + + 2014-08-01 + 2014-08-31 + + + 871694831000290806 + ATS + + + + + Enexis + + + Magistratenlaan 116 + 'S-HERTOGENBOSCH + 5223MB + + NL + + + + NL809561074B01 + + VAT + + + + Enexis B.V. + 17131139 + + + klantenservice.zakelijk@enexis.nl + + + + + + + 1081119 + + + Bedrijfslaan 4 + ONDERNEMERSTAD + 9999 XX + + NL + + + + Klant + + + + + + + Bedrijfslaan 4, + ONDERNEMERSTAD + 9999 XX + + NL + + + + + + 30 + 1100512149 + + NL28RBOS0420242228 + + + + Enexis brengt wettelijke rente in rekening over te laat betaalde + facturen. Kijk voor informatie op www.enexis.nl/rentenota + + + 190.87 + + 908.91 + 190.87 + + S + 21 + + VAT + + + + + + 908.91 + 908.91 + 1099.78 + 1099.78 + + + 1 + 16000 + 140.80 + + Getransporteerde kWh’s + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 0.00880 + 1 + + + + 2 + 16000 + 16.16 + + Systeemdiensten + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 0.00101 + 1 + + + + 3 + 132 + 167.64 + + Contract transportvermogen + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 15.24 + 12 + + + + 4 + 58 + 88.74 + + Maximaal afgenomen vermogen + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 1.53 + 1 + + + + 5 + 1 + 36.75 + + Vastrecht Transportdienst + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 441.00 + 12 + + + + 6 + 1 + 56.50 + + Vastrecht Aansluitdienst + + S + 21 + + VAT + + + + contract transportvermogen + 132,00 kW + + + transporttarief + Netvlak MSD Enexis + + + netvlak + MS-D + + + correctiefactor + 1,0130 + + + + 678.00 + 12 + + + + 7 + 1 + 83.34 + + Huur Transformatoren + + S + 21 + + VAT + + + + + 83.34 + 1 + + + + 8 + 1 + 190.31 + + Huur Schakelinstallaties + + S + 21 + + VAT + + + + + 190.31 + 1 + + + + 9 + 1 + 64.21 + + Huur Overige Apparaten + + S + 21 + + VAT + + + + + 64.21 + 1 + + + + 10 + 1 + 64.46 + + Huur Meterdiensten + + S + 21 + + VAT + + + + + 64.46 + 1 + + + diff --git a/tests/Integration/Examples/UBL/ubl-tc434-example9.xml b/tests/Integration/Examples/UBL/ubl-tc434-example9.xml new file mode 100644 index 0000000..8c0b54f --- /dev/null +++ b/tests/Integration/Examples/UBL/ubl-tc434-example9.xml @@ -0,0 +1,126 @@ + + + + urn:cen.eu:en16931:2017 + 20150483 + 2015-04-01 + 2015-04-14 + 380 + Vriendelijk verzoeken wij u ervoor te zorgen dat het bedrag voor de vervaldatum op onze rekening staat onder vermelding van + het factuurnummer. Het bankrekeningnummer is 37.78.15.500, Rabobank, t.n.v. Bluem te Amersfoort. Reclames gaarne binnen + 10 dagen. Gelieve bij navraag en correspondentie uw firma naam en factuurnummer vermelden. + + EUR + + 2016-04-01 + 2016-06-30 + + + iExpress 20110412 + + + + + Lindeboomseweg 41 + Amersfoort + 3825 AL + + NL + + + + NL809163160B01 + + VAT + + + + Bluem BV + 32081330 Amersfoort + + + 033-4549055 + info@bluem.nl + + + + + + + Henry Dunantweg 42 + Alphen aan den Rijn + 2402 NR + + NL + + + + Provide Verzekeringen + + + + + 30 + 2015 0483 0000 0000 + + NL13RABO0377815500 + + RABONL2U + + + + + 30.87 + + 147.00 + 30.87 + + S + 21 + + VAT + + + + + + 147.00 + 147.00 + 177.87 + 177.87 + + + 1 + 3 + 147.00 + + IExpress licentiekosten + + S + 21 + + VAT + + + + Verbruikscategorie + Start + + + + 49.00 + 1 + + + diff --git a/tests/Integration/UBLTest.php b/tests/Integration/UBLTest.php index 5664dfe..830bc98 100644 --- a/tests/Integration/UBLTest.php +++ b/tests/Integration/UBLTest.php @@ -4,7 +4,14 @@ namespace easybill\eInvoicingTests\Integration\XRechnung3\UBL; +use easybill\eInvoicing\Enums\CountryCode; +use easybill\eInvoicing\Enums\CurrencyCode; +use easybill\eInvoicing\Enums\DocumentType; +use easybill\eInvoicing\Enums\ElectronicAddressScheme; +use easybill\eInvoicing\Enums\UnitCode; +use easybill\eInvoicing\Reader; use easybill\eInvoicing\Transformer; +use easybill\eInvoicing\UBL\Documents\UblAbstractDocument; use easybill\eInvoicing\UBL\Documents\UblInvoice; use easybill\eInvoicing\UBL\Models\AccountingParty; use easybill\eInvoicing\UBL\Models\Address; @@ -12,6 +19,7 @@ use easybill\eInvoicing\UBL\Models\CommodityClassification; use easybill\eInvoicing\UBL\Models\Contact; use easybill\eInvoicing\UBL\Models\Country; +use easybill\eInvoicing\UBL\Models\EndpointId; use easybill\eInvoicing\UBL\Models\Id; use easybill\eInvoicing\UBL\Models\Identification; use easybill\eInvoicing\UBL\Models\InvoiceLine; @@ -31,7 +39,6 @@ use easybill\eInvoicing\UBL\Models\Period; use easybill\eInvoicing\UBL\Models\Price; use easybill\eInvoicing\UBL\Models\Quantity; -use easybill\eInvoicing\UBL\Models\SellersItemIdentification; use easybill\eInvoicing\UBL\Models\TaxCategory; use easybill\eInvoicing\UBL\Models\TaxScheme; use easybill\eInvoicing\UBL\Models\TaxSubtotal; @@ -51,8 +58,8 @@ function (string $pathToXmlExample) { $invoice->profileId = 'urn:fdc:peppol.eu:2017:poacc:billing:01:1.0'; $invoice->id = '123456XX'; $invoice->issueDate = '2016-04-04'; - $invoice->invoiceTypeCode = 380; - $invoice->documentCurrencyCode = 'EUR'; + $invoice->invoiceTypeCode = DocumentType::COMMERCIAL_INVOICE; + $invoice->documentCurrencyCode = CurrencyCode::EUR; $invoice->buyerReference = '04011000-12345-03'; // Notes @@ -61,8 +68,8 @@ function (string $pathToXmlExample) { // Supplier $supplierParty = new Party(); - $supplierParty->endpointId = new Id(); - $supplierParty->endpointId->schemeID = 'EM'; + $supplierParty->endpointId = new EndpointId(); + $supplierParty->endpointId->schemeID = ElectronicAddressScheme::ELECTRONIC_MAIL; $supplierParty->endpointId->value = 'seller@email.de'; $supplierParty->partyName = new PartyName(); $supplierParty->partyName->name = '[Seller trading name]'; @@ -71,7 +78,7 @@ function (string $pathToXmlExample) { $supplierParty->postalAddress->cityName = '[Seller city]'; $supplierParty->postalAddress->postalZone = '12345'; $supplierParty->postalAddress->country = new Country(); - $supplierParty->postalAddress->country->identificationCode = 'DE'; + $supplierParty->postalAddress->country->identificationCode = CountryCode::DE; $partyTaxScheme = new PartyTaxScheme(); $partyTaxScheme->companyId = 'DE 123456789'; @@ -94,8 +101,8 @@ function (string $pathToXmlExample) { // Customer $customerParty = new Party(); - $customerParty->endpointId = new Id(); - $customerParty->endpointId->schemeID = 'EM'; + $customerParty->endpointId = new EndpointId(); + $customerParty->endpointId->schemeID = ElectronicAddressScheme::ELECTRONIC_MAIL; $customerParty->endpointId->value = 'buyer@info.de'; $customerParty->partyIdentification = new Identification(); $customerParty->partyIdentification->id = new Id(); @@ -105,7 +112,7 @@ function (string $pathToXmlExample) { $customerParty->postalAddress->cityName = '[Buyer city]'; $customerParty->postalAddress->postalZone = '12345'; $customerParty->postalAddress->country = new Country(); - $customerParty->postalAddress->country->identificationCode = 'DE'; + $customerParty->postalAddress->country->identificationCode = CountryCode::DE; $customerParty->partyLegalEntity = new PartyLegalEntity(); $customerParty->partyLegalEntity->registrationName = '[Buyer name]'; @@ -128,20 +135,20 @@ function (string $pathToXmlExample) { // Tax Total $taxTotal = new TaxTotal(); $taxTotal->taxAmount = new Amount(); - $taxTotal->taxAmount->currencyID = 'EUR'; + $taxTotal->taxAmount->currencyID = CurrencyCode::EUR; $taxTotal->taxAmount->value = '22.04'; $taxSubtotal = new TaxSubtotal(); $taxSubtotal->taxableAmount = new Amount(); - $taxSubtotal->taxableAmount->currencyID = 'EUR'; + $taxSubtotal->taxableAmount->currencyID = CurrencyCode::EUR; $taxSubtotal->taxableAmount->value = '314.86'; $taxSubtotal->taxAmount = new Amount(); - $taxSubtotal->taxAmount->currencyID = 'EUR'; + $taxSubtotal->taxAmount->currencyID = CurrencyCode::EUR; $taxSubtotal->taxAmount->value = '22.04'; $taxSubtotal->taxCategory = new TaxCategory(); $taxSubtotal->taxCategory->id = new Id(); $taxSubtotal->taxCategory->id->value = 'S'; - $taxSubtotal->taxCategory->percent = 7; + $taxSubtotal->taxCategory->percent = '7'; $taxSubtotal->taxCategory->taxScheme = new TaxScheme(); $taxSubtotal->taxCategory->taxScheme->id = 'VAT'; @@ -151,16 +158,16 @@ function (string $pathToXmlExample) { // LegalMonetaryTotal $invoice->legalMonetaryTotal = new LegalMonetaryTotal(); $invoice->legalMonetaryTotal->lineExtensionAmount = new Amount(); - $invoice->legalMonetaryTotal->lineExtensionAmount->currencyID = 'EUR'; + $invoice->legalMonetaryTotal->lineExtensionAmount->currencyID = CurrencyCode::EUR; $invoice->legalMonetaryTotal->lineExtensionAmount->value = '314.86'; $invoice->legalMonetaryTotal->taxExclusiveAmount = new Amount(); - $invoice->legalMonetaryTotal->taxExclusiveAmount->currencyID = 'EUR'; + $invoice->legalMonetaryTotal->taxExclusiveAmount->currencyID = CurrencyCode::EUR; $invoice->legalMonetaryTotal->taxExclusiveAmount->value = '314.86'; $invoice->legalMonetaryTotal->taxInclusiveAmount = new Amount(); - $invoice->legalMonetaryTotal->taxInclusiveAmount->currencyID = 'EUR'; + $invoice->legalMonetaryTotal->taxInclusiveAmount->currencyID = CurrencyCode::EUR; $invoice->legalMonetaryTotal->taxInclusiveAmount->value = '336.9'; $invoice->legalMonetaryTotal->payableAmount = new Amount(); - $invoice->legalMonetaryTotal->payableAmount->currencyID = 'EUR'; + $invoice->legalMonetaryTotal->payableAmount->currencyID = CurrencyCode::EUR; $invoice->legalMonetaryTotal->payableAmount->value = '336.9'; // Invoice Lines @@ -172,10 +179,10 @@ function (string $pathToXmlExample) { $invoiceLine1->id->value = 'Zeitschrift [...]'; $invoiceLine1->note = 'Die letzte Lieferung im Rahmen des abgerechneten Abonnements erfolgt in 12/2016 Lieferung erfolgt / erfolgte direkt vom Verlag'; $invoiceLine1->invoicedQuantity = new Quantity(); - $invoiceLine1->invoicedQuantity->unitCode = 'XPP'; + $invoiceLine1->invoicedQuantity->unitCode = UnitCode::XPP; $invoiceLine1->invoicedQuantity->value = '1'; $invoiceLine1->lineExtensionAmount = new Amount(); - $invoiceLine1->lineExtensionAmount->currencyID = 'EUR'; + $invoiceLine1->lineExtensionAmount->currencyID = CurrencyCode::EUR; $invoiceLine1->lineExtensionAmount->value = '288.79'; $invoiceLine1->invoicePeriod = new Period(); $invoiceLine1->invoicePeriod->startDate = '2016-01-01'; @@ -188,23 +195,23 @@ function (string $pathToXmlExample) { $invoiceLine1->item[] = $item1 = new Item(); $item1->description = 'Zeitschrift Inland'; $item1->name = 'Zeitschrift [...]'; - $item1->sellersItemIdentification = new SellersItemIdentification(); + $item1->sellersItemIdentification = new Identification(); $item1->sellersItemIdentification->id = new Id(); $item1->sellersItemIdentification->id->value = '246'; - $item1->commodityClassification = new CommodityClassification(); - $item1->commodityClassification->itemClassificationCode = new ItemClassificationCode(); - $item1->commodityClassification->itemClassificationCode->listId = 'IB'; - $item1->commodityClassification->itemClassificationCode->value = '0721-880X'; + $item1->commodityClassification[] = $commodityClassification = new CommodityClassification(); + $commodityClassification->itemClassificationCode = new ItemClassificationCode(); + $commodityClassification->itemClassificationCode->listId = 'IB'; + $commodityClassification->itemClassificationCode->value = '0721-880X'; $item1->classifiedTaxCategory = new TaxCategory(); $item1->classifiedTaxCategory->id = new Id(); $item1->classifiedTaxCategory->id->value = 'S'; - $item1->classifiedTaxCategory->percent = 7; + $item1->classifiedTaxCategory->percent = '7'; $item1->classifiedTaxCategory->taxScheme = new TaxScheme(); $item1->classifiedTaxCategory->taxScheme->id = 'VAT'; $invoiceLine1->price = new Price(); $invoiceLine1->price->priceAmount = new Amount(); - $invoiceLine1->price->priceAmount->currencyID = 'EUR'; + $invoiceLine1->price->priceAmount->currencyID = CurrencyCode::EUR; $invoiceLine1->price->priceAmount->value = '288.79'; // Invoice Line 2 @@ -212,10 +219,10 @@ function (string $pathToXmlExample) { $invoiceLine2->id = new Id(); $invoiceLine2->id->value = 'Porto + Versandkosten'; $invoiceLine2->invoicedQuantity = new Quantity(); - $invoiceLine2->invoicedQuantity->unitCode = 'XPP'; + $invoiceLine2->invoicedQuantity->unitCode = UnitCode::XPP; $invoiceLine2->invoicedQuantity->value = '1'; $invoiceLine2->lineExtensionAmount = new Amount(); - $invoiceLine2->lineExtensionAmount->currencyID = 'EUR'; + $invoiceLine2->lineExtensionAmount->currencyID = CurrencyCode::EUR; $invoiceLine2->lineExtensionAmount->value = '26.07'; // Item 2 @@ -224,12 +231,12 @@ function (string $pathToXmlExample) { $item2->classifiedTaxCategory = new TaxCategory(); $item2->classifiedTaxCategory->id = new Id(); $item2->classifiedTaxCategory->id->value = 'S'; - $item2->classifiedTaxCategory->percent = 7; + $item2->classifiedTaxCategory->percent = '7'; $item2->classifiedTaxCategory->taxScheme = new TaxScheme(); $item2->classifiedTaxCategory->taxScheme->id = 'VAT'; $invoiceLine2->price = new Price(); $invoiceLine2->price->priceAmount = new Amount(); - $invoiceLine2->price->priceAmount->currencyID = 'EUR'; + $invoiceLine2->price->priceAmount->currencyID = CurrencyCode::EUR; $invoiceLine2->price->priceAmount->value = '26.07'; $xml = Transformer::create()->transformToXml($invoice); @@ -241,3 +248,56 @@ function (string $pathToXmlExample) { )->with([ __DIR__ . '/Examples/UBL/01.01a-INVOICE_ubl.xml', ]); + +test( + 'That reading the ubl examples and transforming to the object representation and back to xml is identical to the source', + function (string $pathToXmlExample) { + $xml = file_get_contents($pathToXmlExample); + + expect($xml)->not->toBeFalse(); + + $xml = $this->fixUblRootNode($xml); + + $reader = Reader::create()->read($xml); + + expect($reader->isSuccess())->toBeTrue(); + expect($reader->getDocument())->toBeInstanceOf(UblAbstractDocument::class); + + $document = $reader->getDocument(); + + assert($document instanceof UblAbstractDocument); + + $xmlFromObject = Transformer::create()->transformToXml($document); + + $this->assertSame($this->reformatXml($xml), $this->reformatXml($xmlFromObject)); + } +)->with([ + __DIR__ . '/Examples/UBL/01.01a-INVOICE_ubl.xml', + __DIR__ . '/Examples/UBL/Allowance-example.xml', + __DIR__ . '/Examples/UBL/base-creditnote-correction.xml', + __DIR__ . '/Examples/UBL/base-example.xml', + __DIR__ . '/Examples/UBL/base-negative-inv-correction.xml', + __DIR__ . '/Examples/UBL/BIS3_Invoice_negativ.XML', + __DIR__ . '/Examples/UBL/BIS3_Invoice_positive.XML', + __DIR__ . '/Examples/UBL/guide-example1.xml', + __DIR__ . '/Examples/UBL/guide-example2.xml', + __DIR__ . '/Examples/UBL/guide-example3.xml', + __DIR__ . '/Examples/UBL/issue116.xml', + __DIR__ . '/Examples/UBL/sales-order-example.xml', + __DIR__ . '/Examples/UBL/sample-discount-price.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-creditnote1.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example1.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example2.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example3.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example4.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example5.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example6.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example7.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example8.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example9.xml', + __DIR__ . '/Examples/UBL/ubl-tc434-example10.xml', + __DIR__ . '/Examples/UBL/vat-category-E.xml', + __DIR__ . '/Examples/UBL/vat-category-O.xml', + __DIR__ . '/Examples/UBL/Vat-category-S.xml', + __DIR__ . '/Examples/UBL/vat-category-Z.xml', +]); diff --git a/tests/TestCase.php b/tests/TestCase.php index 2af7ef6..1abf150 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,14 +6,14 @@ use easybill\eInvoicingTests\Validators\Traits\AssertXmlOutputTrait; use easybill\eInvoicingTests\Validators\Traits\ReformatXmlTrait; -use easybill\eInvoicingTests\Validators\Traits\RemoveXmlMutatesTrait; use easybill\eInvoicingTests\Validators\Traits\ValidatorTrait; +use easybill\eInvoicingTests\Validators\Traits\XmlHelperTrait; use PHPUnit\Framework\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use ReformatXmlTrait; - use RemoveXmlMutatesTrait; + use XmlHelperTrait; use ValidatorTrait; use AssertXmlOutputTrait; } diff --git a/tests/Validators/Traits/RemoveXmlMutatesTrait.php b/tests/Validators/Traits/RemoveXmlMutatesTrait.php deleted file mode 100644 index 1f3d1bb..0000000 --- a/tests/Validators/Traits/RemoveXmlMutatesTrait.php +++ /dev/null @@ -1,13 +0,0 @@ -+/m', '', $xml, limit: -1); - } -} diff --git a/tests/Validators/Traits/ValidatorTrait.php b/tests/Validators/Traits/ValidatorTrait.php index 1fbde4a..b529863 100644 --- a/tests/Validators/Traits/ValidatorTrait.php +++ b/tests/Validators/Traits/ValidatorTrait.php @@ -5,7 +5,6 @@ namespace easybill\eInvoicingTests\Validators\Traits; use easybill\eInvoicingTests\Validators\KositValidator; -use easybill\eInvoicingTests\Validators\PeppolValidator; trait ValidatorTrait { @@ -17,13 +16,4 @@ public function validateWithKositValidator(string $xml): void self::assertNull($errors, $errors ?? ''); } - - public function validateWithPeppolValidator(string $xml): void - { - $validator = new PeppolValidator(); - - $errors = $validator->validate($xml); - - self::assertNull($errors, $errors ?? ''); - } } diff --git a/tests/Validators/Traits/XmlHelperTrait.php b/tests/Validators/Traits/XmlHelperTrait.php new file mode 100644 index 0000000..2a7ec2b --- /dev/null +++ b/tests/Validators/Traits/XmlHelperTrait.php @@ -0,0 +1,23 @@ ++/m', '', $xml, limit: -1); + } + + public static function fixUblRootNode(string $xml): string + { + $fixedCreditNoteNode = ''; + $fixedInvoiceNoteNode = ''; + $xml = preg_replace('/]*>/', $fixedCreditNoteNode, $xml); + $xml = preg_replace('/<\/CreditNote>/', '', $xml); + $xml = preg_replace('/<\/Invoice>/', '', $xml); + return preg_replace('/]*>/', $fixedInvoiceNoteNode, $xml); + } +} diff --git a/tools/Generators/CountryCodeEnumGenerator.php b/tools/Generators/CountryCodeEnumGenerator.php new file mode 100644 index 0000000..493aecf --- /dev/null +++ b/tools/Generators/CountryCodeEnumGenerator.php @@ -0,0 +1,44 @@ + */ +function parseCSVFile(string $filename): array +{ + $countries = []; + if (($handle = fopen($filename, 'r')) !== false) { + while (($data = fgetcsv($handle, 1000, ';')) !== false) { + if (count($data) >= 2) { + $countries[trim($data[0])] = trim($data[1]); + } + } + fclose($handle); + } + return $countries; +} + +/** @param array $countries */ +function generateEnum(array $countries): string +{ + $lines = [ + 'declare(strict_types=1);', + 'namespace easybill\eInvoicing\Enums;', + "enum CountryCode: string\n{\n", + ]; + + $enumCode = implode("\n\n", $lines); + foreach ($countries as $name => $code) { + $enumCode .= ' // ' . $name . "\n"; + $enumCode .= ' case ' . $code . " = '" . $code . "';\n\n"; + } + $enumCode .= "}\n"; + return $enumCode; +} + +$csvFilePath = __DIR__ . '/input/CountryCodes.csv'; + +$countries = parseCSVFile($csvFilePath); + +$enumCode = generateEnum($countries); + +file_put_contents(__DIR__ . '/../../src/Enums/CountryCode.php', " */ +function parseCSVFile(string $filename): array +{ + $countries = []; + if (($handle = fopen($filename, 'r')) !== false) { + while (($data = fgetcsv($handle, 1000, ';')) !== false) { + if (count($data) >= 2) { + $countries[trim($data[0])] = trim($data[1]); + } + } + fclose($handle); + } + return $countries; +} + +/** @param array $countries */ +function generateEnum(array $countries): string +{ + $lines = [ + 'declare(strict_types=1);', + 'namespace easybill\eInvoicing\Enums;', + "enum CurrencyCode: string\n{\n", + ]; + + $enumCode = implode("\n\n", $lines); + foreach ($countries as $name => $code) { + $enumCode .= ' // ' . $name . "\n"; + $enumCode .= ' case ' . $code . " = '" . $code . "';\n\n"; + } + $enumCode .= "}\n"; + return $enumCode; +} + +$csvFilePath = __DIR__ . '/input/CurrencyCodes.csv'; + +$countries = parseCSVFile($csvFilePath); + +$enumCode = generateEnum($countries); + +file_put_contents(__DIR__ . '/../../src/Enums/CurrencyCode.php', " */ +function parseCSVFile(string $filename): array +{ + $countries = []; + if (($handle = fopen($filename, 'r')) !== false) { + while (($data = fgetcsv($handle, 1000, ';')) !== false) { + if (count($data) >= 2) { + $countries[trim($data[0])] = trim($data[1]); + } + } + fclose($handle); + } + return $countries; +} + +/** @param array $values */ +function generateEnum(array $values): string +{ + $lines = [ + 'declare(strict_types=1);', + 'namespace easybill\eInvoicing\Enums;', + "enum ElectronicAddressScheme: string\n{\n", + ]; + + $enumCode = implode("\n\n", $lines); + foreach ($values as $code => $name) { + // Generate a valid PHP identifier for the case + $case = preg_replace('/[^a-zA-Z0-9]+/', '_', $name); + $case = strtoupper((string)$case); + $case = rtrim($case, '_'); + + // Truncate case name if it's too long + if (strlen($case) > 64) { + $case = substr($case, 0, 64); + } + + // Remove duplicate underscores + $case = preg_replace('/_+/', '_', $case); + + $enumCode .= " case {$case} = '{$code}';\n"; + } + $enumCode .= "}\n"; + return $enumCode; +} + +$csvFilePath = __DIR__ . '/Input/ElectronicAddressSchemeCodes.csv'; + +$countries = parseCSVFile($csvFilePath); + +$enumCode = generateEnum($countries); + +file_put_contents(__DIR__ . '/../../src/Enums/ElectronicAddressScheme.php', " 10 kpa +XWH;Intermediate bulk container, aluminium, pressurised > 10 kpa +XWJ;Intermediate bulk container, metal, pressure 10 kpa +XWK;Intermediate bulk container, steel, liquid +XWL;Intermediate bulk container, aluminium, liquid +XWM;Intermediate bulk container, metal, liquid +XWN;Intermediate bulk container, woven plastic, without coat/liner +XWP;Intermediate bulk container, woven plastic, coated +XWQ;Intermediate bulk container, woven plastic, with liner +XWR;Intermediate bulk container, woven plastic, coated and liner +XWS;Intermediate bulk container, plastic film +XWT;Intermediate bulk container, textile with out coat/liner +XWU;Intermediate bulk container, natural wood, with inner liner +XWV;Intermediate bulk container, textile, coated +XWW;Intermediate bulk container, textile, with liner +XWX;Intermediate bulk container, textile, coated and liner +XWY;Intermediate bulk container, plywood, with inner liner +XWZ;Intermediate bulk container, reconstituted wood, with inner liner +XXA;Bag, woven plastic, without inner coat/liner +XXB;Bag, woven plastic, sift proof +XXC;Bag, woven plastic, water resistant +XXD;Bag, plastics film +XXF;Bag, textile, without inner coat/liner +XXG;Bag, textile, sift proof +XXH;Bag, textile, water resistant +XXJ;Bag, paper, multi-wall +XXK;Bag, paper, multi-wall, water resistant +XYA;Composite packaging, plastic receptacle in steel drum +XYB;Composite packaging, plastic receptacle in steel crate box +XYC;Composite packaging, plastic receptacle in aluminium drum +XYD;Composite packaging, plastic receptacle in aluminium crate +XYF;Composite packaging, plastic receptacle in wooden box +XYG;Composite packaging, plastic receptacle in plywood drum +XYH;Composite packaging, plastic receptacle in plywood box +XYJ;Composite packaging, plastic receptacle in fibre drum +XYK;Composite packaging, plastic receptacle in fibreboard box +XYL;Composite packaging, plastic receptacle in plastic drum +XYM;Composite packaging, plastic receptacle in solid plastic box +XYN;Composite packaging, glass receptacle in steel drum +XYP;Composite packaging, glass receptacle in steel crate box +XYQ;Composite packaging, glass receptacle in aluminium drum +XYR;Composite packaging, glass receptacle in aluminium crate +XYS;Composite packaging, glass receptacle in wooden box +XYT;Composite packaging, glass receptacle in plywood drum +XYV;Composite packaging, glass receptacle in wickerwork hamper +XYW;Composite packaging, glass receptacle in fibre drum +XYX;Composite packaging, glass receptacle in fibreboard box +XYY;Composite packaging, glass receptacle in expandable plastic pack +XYZ;Composite packaging, glass receptacle in solid plastic pack +XZA;Intermediate bulk container, paper, multi-wall +XZB;Bag, large +XZC;Intermediate bulk container, paper, multi-wall, water resistant +XZD;Intermediate bulk container, rigid plastic, with structural equipment, solids +XZF;Intermediate bulk container, rigid plastic, freestanding, solids +XZG;Intermediate bulk container, rigid plastic, with structural equipment, pressurised +XZH;Intermediate bulk container, rigid plastic, freestanding, pressurised +XZJ;Intermediate bulk container, rigid plastic, with structural equipment, liquids +XZK;Intermediate bulk container, rigid plastic, freestanding, liquids +XZL;Intermediate bulk container, composite, rigid plastic, solids +XZM;Intermediate bulk container, composite, flexible plastic, solids +XZN;Intermediate bulk container, composite, rigid plastic, pressurised +XZP;Intermediate bulk container, composite, flexible plastic, pressurised +XZQ;Intermediate bulk container, composite, rigid plastic, liquids +XZR;Intermediate bulk container, composite, flexible plastic, liquids +XZS;Intermediate bulk container, composite +XZT;Intermediate bulk container, fibreboard +XZU;Intermediate bulk container, flexible +XZV;Intermediate bulk container, metal, other than steel +XZW;Intermediate bulk container, natural wood +XZX;Intermediate bulk container, plywood +XZY;Intermediate bulk container, reconstituted wood +XZZ;Mutually defined \ No newline at end of file diff --git a/tools/Generators/ReferenceQualifierEnumGenerator.php b/tools/Generators/ReferenceQualifierEnumGenerator.php new file mode 100644 index 0000000..84c2924 --- /dev/null +++ b/tools/Generators/ReferenceQualifierEnumGenerator.php @@ -0,0 +1,44 @@ + */ +function parseCSVFile(string $filename): array +{ + $countries = []; + if (($handle = fopen($filename, 'r')) !== false) { + while (($data = fgetcsv($handle, 1000, ';')) !== false) { + if (count($data) >= 2) { + $countries[trim($data[0])] = trim($data[1]); + } + } + fclose($handle); + } + return $countries; +} + +/** @param array $references */ +function generateEnum(array $references): string +{ + $lines = [ + 'declare(strict_types=1);', + 'namespace easybill\eInvoicing\Enums;', + "enum ReferenceQualifier: string\n{\n", + ]; + + $enumCode = implode("\n\n", $lines); + foreach ($references as $code => $name) { + $enumCode .= ' // ' . $name . "\n"; + $enumCode .= ' case ' . $code . " = '" . $code . "';\n\n"; + } + $enumCode .= "}\n"; + return $enumCode; +} + +$csvFilePath = __DIR__ . '/input/ReferenceQualifier.csv'; + +$countries = parseCSVFile($csvFilePath); + +$enumCode = generateEnum($countries); + +file_put_contents(__DIR__ . '/../../src/Enums/ReferenceQualifier.php', " */ +function parseCSVFile(string $filename): array +{ + $countries = []; + if (($handle = fopen($filename, 'r')) !== false) { + while (($data = fgetcsv($handle, 1000, ';')) !== false) { + if (count($data) >= 2) { + $countries[trim($data[0])] = trim($data[1]); + } + } + fclose($handle); + } + return $countries; +} + +/** @param array $references */ +function generateEnum(array $references): string +{ + $lines = [ + 'declare(strict_types=1);', + 'namespace easybill\eInvoicing\Enums;', + "enum UnitCode: string\n{\n", + ]; + + $enumCode = implode("\n\n", $lines); + foreach ($references as $code => $name) { + if (is_numeric(substr((string)$code, 0, 1))) { + $codeName = '_' . $code; + } else { + $codeName = $code; + } + + $enumCode .= ' // ' . $name . "\n"; + $enumCode .= ' case ' . $codeName . " = '" . $code . "';\n\n"; + } + $enumCode .= "}\n"; + return $enumCode; +} + +$csvFilePath = __DIR__ . '/input/UnitCodes.csv'; + +$countries = parseCSVFile($csvFilePath); + +$enumCode = generateEnum($countries); + +file_put_contents(__DIR__ . '/../../src/Enums/UnitCode.php', "