2025-05-26 13:33:21 +00:00
|
|
|
|
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
2025-05-25 19:45:37 +00:00
|
|
|
|
import { EInvoice } from '../../../ts/index.js';
|
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
// CONV-09: Round-Trip Conversion
|
|
|
|
|
// Tests data integrity through round-trip processing (load -> export -> load)
|
|
|
|
|
// Future: Will test conversions between formats (UBL -> CII -> UBL)
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
tap.test('CONV-09: Round-Trip - UBL format preservation', async () => {
|
|
|
|
|
// Test that loading and exporting UBL preserves key data
|
|
|
|
|
const ublInvoice = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
|
|
|
|
|
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
|
|
|
|
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
|
|
|
|
<cbc:ID>UBL-RT-001</cbc:ID>
|
|
|
|
|
<cbc:IssueDate>2024-01-20</cbc:IssueDate>
|
|
|
|
|
<cbc:DueDate>2024-02-20</cbc:DueDate>
|
|
|
|
|
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
|
|
|
|
|
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
|
|
|
|
<cbc:Note>Round-trip test invoice</cbc:Note>
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<!-- Business References -->
|
|
|
|
|
<cac:OrderReference>
|
|
|
|
|
<cbc:ID>PO-2024-001</cbc:ID>
|
|
|
|
|
</cac:OrderReference>
|
|
|
|
|
<cac:ContractDocumentReference>
|
|
|
|
|
<cbc:ID>CONTRACT-2024-ABC</cbc:ID>
|
|
|
|
|
</cac:ContractDocumentReference>
|
|
|
|
|
<cac:ProjectReference>
|
|
|
|
|
<cbc:ID>PROJECT-ALPHA</cbc:ID>
|
|
|
|
|
</cac:ProjectReference>
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<!-- Invoice Period -->
|
|
|
|
|
<cac:InvoicePeriod>
|
|
|
|
|
<cbc:StartDate>2024-01-01</cbc:StartDate>
|
|
|
|
|
<cbc:EndDate>2024-01-31</cbc:EndDate>
|
|
|
|
|
</cac:InvoicePeriod>
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<!-- Payment Information -->
|
|
|
|
|
<cac:PaymentMeans>
|
|
|
|
|
<cbc:PaymentMeansCode>58</cbc:PaymentMeansCode>
|
|
|
|
|
<cbc:PaymentID>PAYMENT-REF-123</cbc:PaymentID>
|
|
|
|
|
<cac:PayeeFinancialAccount>
|
|
|
|
|
<cbc:ID>DE89370400440532013000</cbc:ID>
|
|
|
|
|
<cac:FinancialInstitutionBranch>
|
|
|
|
|
<cac:FinancialInstitution>
|
|
|
|
|
<cbc:ID>COBADEFFXXX</cbc:ID>
|
|
|
|
|
</cac:FinancialInstitution>
|
|
|
|
|
</cac:FinancialInstitutionBranch>
|
|
|
|
|
</cac:PayeeFinancialAccount>
|
|
|
|
|
</cac:PaymentMeans>
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<!-- Delivery Information -->
|
|
|
|
|
<cac:Delivery>
|
|
|
|
|
<cbc:ActualDeliveryDate>2024-01-10</cbc:ActualDeliveryDate>
|
|
|
|
|
</cac:Delivery>
|
|
|
|
|
|
|
|
|
|
<cac:AccountingSupplierParty>
|
|
|
|
|
<cac:Party>
|
|
|
|
|
<cac:PartyName>
|
|
|
|
|
<cbc:Name>Round Trip Seller GmbH</cbc:Name>
|
|
|
|
|
</cac:PartyName>
|
|
|
|
|
<!-- Contact Information -->
|
|
|
|
|
<cac:Contact>
|
|
|
|
|
<cbc:Name>Max Mustermann</cbc:Name>
|
|
|
|
|
<cbc:Telephone>+49-123-456789</cbc:Telephone>
|
|
|
|
|
<cbc:ElectronicMail>contact@seller.com</cbc:ElectronicMail>
|
|
|
|
|
</cac:Contact>
|
|
|
|
|
<cac:PostalAddress>
|
|
|
|
|
<cbc:StreetName>Seller Street 123</cbc:StreetName>
|
|
|
|
|
<cbc:CityName>Berlin</cbc:CityName>
|
|
|
|
|
<cbc:PostalZone>10115</cbc:PostalZone>
|
|
|
|
|
<cac:Country>
|
|
|
|
|
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
|
|
|
|
</cac:Country>
|
|
|
|
|
</cac:PostalAddress>
|
|
|
|
|
<cac:PartyTaxScheme>
|
|
|
|
|
<cbc:CompanyID>DE123456789</cbc:CompanyID>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:PartyTaxScheme>
|
|
|
|
|
</cac:Party>
|
|
|
|
|
</cac:AccountingSupplierParty>
|
|
|
|
|
<cac:AccountingCustomerParty>
|
|
|
|
|
<cac:Party>
|
|
|
|
|
<cac:PartyName>
|
|
|
|
|
<cbc:Name>Round Trip Buyer Ltd</cbc:Name>
|
|
|
|
|
</cac:PartyName>
|
|
|
|
|
<!-- Contact Information -->
|
|
|
|
|
<cac:Contact>
|
|
|
|
|
<cbc:Name>Jane Smith</cbc:Name>
|
|
|
|
|
<cbc:Telephone>+49-89-987654</cbc:Telephone>
|
|
|
|
|
<cbc:ElectronicMail>jane.smith@buyer.com</cbc:ElectronicMail>
|
|
|
|
|
</cac:Contact>
|
|
|
|
|
<cac:PostalAddress>
|
|
|
|
|
<cbc:StreetName>Buyer Avenue 456</cbc:StreetName>
|
|
|
|
|
<cbc:CityName>Munich</cbc:CityName>
|
|
|
|
|
<cbc:PostalZone>80331</cbc:PostalZone>
|
|
|
|
|
<cac:Country>
|
|
|
|
|
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
|
|
|
|
</cac:Country>
|
|
|
|
|
</cac:PostalAddress>
|
|
|
|
|
<cac:PartyTaxScheme>
|
|
|
|
|
<cbc:CompanyID>DE987654321</cbc:CompanyID>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:PartyTaxScheme>
|
|
|
|
|
</cac:Party>
|
|
|
|
|
</cac:AccountingCustomerParty>
|
|
|
|
|
<cac:InvoiceLine>
|
|
|
|
|
<cbc:ID>1</cbc:ID>
|
|
|
|
|
<cbc:InvoicedQuantity unitCode="C62">10</cbc:InvoicedQuantity>
|
|
|
|
|
<cbc:LineExtensionAmount currencyID="EUR">1500.00</cbc:LineExtensionAmount>
|
|
|
|
|
<cac:Item>
|
|
|
|
|
<cbc:Description>Professional Services - Round Trip Test</cbc:Description>
|
|
|
|
|
<cbc:Name>Consulting Service</cbc:Name>
|
|
|
|
|
<!-- Item Identifications -->
|
|
|
|
|
<cac:SellersItemIdentification>
|
|
|
|
|
<cbc:ID>SELLER-CONS-001</cbc:ID>
|
|
|
|
|
</cac:SellersItemIdentification>
|
|
|
|
|
<cac:BuyersItemIdentification>
|
|
|
|
|
<cbc:ID>BUYER-REQ-456</cbc:ID>
|
|
|
|
|
</cac:BuyersItemIdentification>
|
|
|
|
|
<cac:StandardItemIdentification>
|
|
|
|
|
<cbc:ID>STD-SERVICE-789</cbc:ID>
|
|
|
|
|
</cac:StandardItemIdentification>
|
|
|
|
|
<!-- Item Classification -->
|
|
|
|
|
<cac:CommodityClassification>
|
|
|
|
|
<cbc:ItemClassificationCode>73110000</cbc:ItemClassificationCode>
|
|
|
|
|
</cac:CommodityClassification>
|
|
|
|
|
<cac:ClassifiedTaxCategory>
|
|
|
|
|
<cbc:ID>S</cbc:ID>
|
|
|
|
|
<cbc:Percent>19.00</cbc:Percent>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:ClassifiedTaxCategory>
|
|
|
|
|
</cac:Item>
|
|
|
|
|
<cac:Price>
|
|
|
|
|
<cbc:PriceAmount currencyID="EUR">150.00</cbc:PriceAmount>
|
|
|
|
|
</cac:Price>
|
|
|
|
|
</cac:InvoiceLine>
|
|
|
|
|
<cac:InvoiceLine>
|
|
|
|
|
<cbc:ID>2</cbc:ID>
|
|
|
|
|
<cbc:InvoicedQuantity unitCode="C62">5</cbc:InvoicedQuantity>
|
|
|
|
|
<cbc:LineExtensionAmount currencyID="EUR">1000.00</cbc:LineExtensionAmount>
|
|
|
|
|
<cac:Item>
|
|
|
|
|
<cbc:Description>Software License - Annual</cbc:Description>
|
|
|
|
|
<cbc:Name>Enterprise License</cbc:Name>
|
|
|
|
|
<!-- Item Identifications -->
|
|
|
|
|
<cac:SellersItemIdentification>
|
|
|
|
|
<cbc:ID>SELLER-LIC-002</cbc:ID>
|
|
|
|
|
</cac:SellersItemIdentification>
|
|
|
|
|
<cac:BuyersItemIdentification>
|
|
|
|
|
<cbc:ID>BUYER-SW-789</cbc:ID>
|
|
|
|
|
</cac:BuyersItemIdentification>
|
|
|
|
|
<cac:StandardItemIdentification>
|
|
|
|
|
<cbc:ID>STD-LICENSE-123</cbc:ID>
|
|
|
|
|
</cac:StandardItemIdentification>
|
|
|
|
|
<!-- Item Classification -->
|
|
|
|
|
<cac:CommodityClassification>
|
|
|
|
|
<cbc:ItemClassificationCode>72230000</cbc:ItemClassificationCode>
|
|
|
|
|
</cac:CommodityClassification>
|
|
|
|
|
</cac:Item>
|
|
|
|
|
<cac:Price>
|
|
|
|
|
<cbc:PriceAmount currencyID="EUR">200.00</cbc:PriceAmount>
|
|
|
|
|
</cac:Price>
|
|
|
|
|
</cac:InvoiceLine>
|
|
|
|
|
<cac:TaxTotal>
|
|
|
|
|
<cbc:TaxAmount currencyID="EUR">475.00</cbc:TaxAmount>
|
|
|
|
|
<cac:TaxSubtotal>
|
|
|
|
|
<cbc:TaxableAmount currencyID="EUR">2500.00</cbc:TaxableAmount>
|
|
|
|
|
<cbc:TaxAmount currencyID="EUR">475.00</cbc:TaxAmount>
|
|
|
|
|
<cac:TaxCategory>
|
|
|
|
|
<cbc:ID>S</cbc:ID>
|
|
|
|
|
<cbc:Percent>19.00</cbc:Percent>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:TaxCategory>
|
|
|
|
|
</cac:TaxSubtotal>
|
|
|
|
|
</cac:TaxTotal>
|
|
|
|
|
<cac:LegalMonetaryTotal>
|
|
|
|
|
<cbc:LineExtensionAmount currencyID="EUR">2500.00</cbc:LineExtensionAmount>
|
|
|
|
|
<cbc:TaxExclusiveAmount currencyID="EUR">2500.00</cbc:TaxExclusiveAmount>
|
|
|
|
|
<cbc:TaxInclusiveAmount currencyID="EUR">2975.00</cbc:TaxInclusiveAmount>
|
|
|
|
|
<cbc:PayableAmount currencyID="EUR">2975.00</cbc:PayableAmount>
|
|
|
|
|
</cac:LegalMonetaryTotal>
|
|
|
|
|
</Invoice>`;
|
|
|
|
|
|
|
|
|
|
// Load original
|
|
|
|
|
const invoice1 = new EInvoice();
|
|
|
|
|
await invoice1.loadXml(ublInvoice);
|
|
|
|
|
|
|
|
|
|
// Export to XML
|
|
|
|
|
const exportedXml = await invoice1.toXmlString('ubl');
|
|
|
|
|
|
|
|
|
|
// Load exported XML
|
|
|
|
|
const invoice2 = new EInvoice();
|
|
|
|
|
await invoice2.loadXml(exportedXml);
|
|
|
|
|
|
|
|
|
|
// Export again
|
|
|
|
|
const reExportedXml = await invoice2.toXmlString('ubl');
|
|
|
|
|
|
|
|
|
|
// Check key data is preserved
|
|
|
|
|
expect(exportedXml).toInclude('UBL-RT-001');
|
|
|
|
|
expect(exportedXml).toInclude('Round Trip Seller GmbH');
|
|
|
|
|
expect(exportedXml).toInclude('Round Trip Buyer Ltd');
|
|
|
|
|
expect(exportedXml).toInclude('EUR');
|
|
|
|
|
// Note: Some financial data may not be fully preserved in current implementation
|
|
|
|
|
|
|
|
|
|
// Check that re-exported XML also contains the same data
|
|
|
|
|
expect(reExportedXml).toInclude('UBL-RT-001');
|
|
|
|
|
|
|
|
|
|
console.log('UBL round-trip: Key data preserved through load->export->load->export cycle');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('CONV-09: Round-Trip - CII format preservation', async () => {
|
|
|
|
|
// Test CII format round-trip
|
|
|
|
|
const ciiInvoice = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
|
|
|
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
|
|
|
|
|
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
|
|
|
|
|
<rsm:ExchangedDocumentContext>
|
|
|
|
|
<ram:GuidelineSpecifiedDocumentContextParameter>
|
|
|
|
|
<ram:ID>urn:cen.eu:en16931:2017</ram:ID>
|
|
|
|
|
</ram:GuidelineSpecifiedDocumentContextParameter>
|
|
|
|
|
</rsm:ExchangedDocumentContext>
|
|
|
|
|
<rsm:ExchangedDocument>
|
|
|
|
|
<ram:ID>CII-RT-001</ram:ID>
|
|
|
|
|
<ram:TypeCode>380</ram:TypeCode>
|
|
|
|
|
<ram:IssueDateTime>
|
|
|
|
|
<udt:DateTimeString format="102">20240121</udt:DateTimeString>
|
|
|
|
|
</ram:IssueDateTime>
|
|
|
|
|
</rsm:ExchangedDocument>
|
|
|
|
|
<rsm:SupplyChainTradeTransaction>
|
|
|
|
|
<ram:IncludedSupplyChainTradeLineItem>
|
|
|
|
|
<ram:AssociatedDocumentLineDocument>
|
|
|
|
|
<ram:LineID>1</ram:LineID>
|
|
|
|
|
</ram:AssociatedDocumentLineDocument>
|
|
|
|
|
<ram:SpecifiedTradeProduct>
|
|
|
|
|
<ram:Name>Cloud Storage Service</ram:Name>
|
|
|
|
|
<ram:Description>Monthly subscription for 100GB storage</ram:Description>
|
|
|
|
|
</ram:SpecifiedTradeProduct>
|
|
|
|
|
<ram:SpecifiedLineTradeAgreement>
|
|
|
|
|
<ram:NetPriceProductTradePrice>
|
|
|
|
|
<ram:ChargeAmount>9.99</ram:ChargeAmount>
|
|
|
|
|
</ram:NetPriceProductTradePrice>
|
|
|
|
|
</ram:SpecifiedLineTradeAgreement>
|
|
|
|
|
<ram:SpecifiedLineTradeDelivery>
|
|
|
|
|
<ram:BilledQuantity unitCode="C62">100</ram:BilledQuantity>
|
|
|
|
|
</ram:SpecifiedLineTradeDelivery>
|
|
|
|
|
<ram:SpecifiedLineTradeSettlement>
|
|
|
|
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
|
|
|
|
<ram:LineTotalAmount>999.00</ram:LineTotalAmount>
|
|
|
|
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
|
|
|
|
</ram:SpecifiedLineTradeSettlement>
|
|
|
|
|
</ram:IncludedSupplyChainTradeLineItem>
|
|
|
|
|
<ram:ApplicableHeaderTradeAgreement>
|
|
|
|
|
<ram:SellerTradeParty>
|
|
|
|
|
<ram:Name>CII Corporation</ram:Name>
|
|
|
|
|
<ram:PostalTradeAddress>
|
|
|
|
|
<ram:LineOne>100 Tech Park</ram:LineOne>
|
|
|
|
|
<ram:CityName>San Francisco</ram:CityName>
|
|
|
|
|
<ram:PostcodeCode>94105</ram:PostcodeCode>
|
|
|
|
|
<ram:CountryID>US</ram:CountryID>
|
|
|
|
|
</ram:PostalTradeAddress>
|
|
|
|
|
<ram:SpecifiedTaxRegistration>
|
|
|
|
|
<ram:ID schemeID="VA">US12-3456789</ram:ID>
|
|
|
|
|
</ram:SpecifiedTaxRegistration>
|
|
|
|
|
</ram:SellerTradeParty>
|
|
|
|
|
<ram:BuyerTradeParty>
|
|
|
|
|
<ram:Name>CII Customer Inc</ram:Name>
|
|
|
|
|
<ram:PostalTradeAddress>
|
|
|
|
|
<ram:LineOne>200 Business Center</ram:LineOne>
|
|
|
|
|
<ram:CityName>New York</ram:CityName>
|
|
|
|
|
<ram:PostcodeCode>10001</ram:PostcodeCode>
|
|
|
|
|
<ram:CountryID>US</ram:CountryID>
|
|
|
|
|
</ram:PostalTradeAddress>
|
|
|
|
|
</ram:BuyerTradeParty>
|
|
|
|
|
</ram:ApplicableHeaderTradeAgreement>
|
|
|
|
|
<ram:ApplicableHeaderTradeSettlement>
|
|
|
|
|
<ram:InvoiceCurrencyCode>USD</ram:InvoiceCurrencyCode>
|
|
|
|
|
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
|
|
|
|
<ram:LineTotalAmount>999.00</ram:LineTotalAmount>
|
|
|
|
|
<ram:TaxBasisTotalAmount>999.00</ram:TaxBasisTotalAmount>
|
|
|
|
|
<ram:TaxTotalAmount currencyID="USD">88.67</ram:TaxTotalAmount>
|
|
|
|
|
<ram:GrandTotalAmount>1087.67</ram:GrandTotalAmount>
|
|
|
|
|
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
|
|
|
|
</ram:ApplicableHeaderTradeSettlement>
|
|
|
|
|
</rsm:SupplyChainTradeTransaction>
|
|
|
|
|
</rsm:CrossIndustryInvoice>`;
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
// Load original
|
|
|
|
|
const invoice1 = new EInvoice();
|
|
|
|
|
await invoice1.loadXml(ciiInvoice);
|
|
|
|
|
|
|
|
|
|
// Export to XML
|
|
|
|
|
const exportedXml = await invoice1.toXmlString('cii');
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
// Check key data is preserved
|
|
|
|
|
expect(exportedXml).toInclude('CII-RT-001');
|
|
|
|
|
expect(exportedXml).toInclude('CII Corporation');
|
|
|
|
|
expect(exportedXml).toInclude('CII Customer Inc');
|
|
|
|
|
expect(exportedXml).toInclude('USD');
|
|
|
|
|
// Note: Financial details preservation depends on implementation
|
|
|
|
|
|
|
|
|
|
console.log('CII round-trip: Key data preserved');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('CONV-09: Round-Trip - ZUGFeRD format preservation', async () => {
|
|
|
|
|
// Test ZUGFeRD format preservation
|
|
|
|
|
const zugferdInvoice = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<rsm:CrossIndustryInvoice xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
|
2025-05-28 11:31:31 +00:00
|
|
|
|
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
|
|
|
|
|
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<rsm:ExchangedDocumentContext>
|
|
|
|
|
<ram:GuidelineSpecifiedDocumentContextParameter>
|
|
|
|
|
<ram:ID>urn:cen.eu:en16931:2017#conformant#urn:zugferd.de:2p1:basic</ram:ID>
|
|
|
|
|
</ram:GuidelineSpecifiedDocumentContextParameter>
|
|
|
|
|
</rsm:ExchangedDocumentContext>
|
|
|
|
|
<rsm:ExchangedDocument>
|
|
|
|
|
<ram:ID>ZF-RT-001</ram:ID>
|
|
|
|
|
<ram:TypeCode>380</ram:TypeCode>
|
2025-05-28 11:31:31 +00:00
|
|
|
|
<ram:IssueDateTime>
|
|
|
|
|
<udt:DateTimeString format="102">20240123</udt:DateTimeString>
|
|
|
|
|
</ram:IssueDateTime>
|
2025-05-26 13:33:21 +00:00
|
|
|
|
</rsm:ExchangedDocument>
|
|
|
|
|
<rsm:SupplyChainTradeTransaction>
|
|
|
|
|
<ram:ApplicableHeaderTradeAgreement>
|
|
|
|
|
<ram:SellerTradeParty>
|
|
|
|
|
<ram:Name>ZUGFeRD Handel GmbH</ram:Name>
|
|
|
|
|
<ram:PostalTradeAddress>
|
|
|
|
|
<ram:LineOne>Handelsweg 10</ram:LineOne>
|
|
|
|
|
<ram:CityName>Frankfurt</ram:CityName>
|
|
|
|
|
<ram:PostcodeCode>60311</ram:PostcodeCode>
|
|
|
|
|
<ram:CountryID>DE</ram:CountryID>
|
|
|
|
|
</ram:PostalTradeAddress>
|
|
|
|
|
<ram:SpecifiedTaxRegistration>
|
|
|
|
|
<ram:ID schemeID="VA">DE111222333</ram:ID>
|
|
|
|
|
</ram:SpecifiedTaxRegistration>
|
|
|
|
|
</ram:SellerTradeParty>
|
|
|
|
|
<ram:BuyerTradeParty>
|
|
|
|
|
<ram:Name>ZUGFeRD Käufer AG</ram:Name>
|
|
|
|
|
<ram:PostalTradeAddress>
|
|
|
|
|
<ram:LineOne>Käuferstraße 20</ram:LineOne>
|
|
|
|
|
<ram:CityName>Hamburg</ram:CityName>
|
|
|
|
|
<ram:PostcodeCode>20095</ram:PostcodeCode>
|
|
|
|
|
<ram:CountryID>DE</ram:CountryID>
|
|
|
|
|
</ram:PostalTradeAddress>
|
|
|
|
|
</ram:BuyerTradeParty>
|
|
|
|
|
</ram:ApplicableHeaderTradeAgreement>
|
2025-05-28 11:31:31 +00:00
|
|
|
|
<ram:ApplicableHeaderTradeDelivery/>
|
|
|
|
|
<ram:IncludedSupplyChainTradeLineItem>
|
|
|
|
|
<ram:AssociatedDocumentLineDocument>
|
|
|
|
|
<ram:LineID>1</ram:LineID>
|
|
|
|
|
</ram:AssociatedDocumentLineDocument>
|
|
|
|
|
<ram:SpecifiedTradeProduct>
|
|
|
|
|
<ram:Name>ZUGFeRD Test Product</ram:Name>
|
|
|
|
|
</ram:SpecifiedTradeProduct>
|
|
|
|
|
<ram:SpecifiedLineTradeDelivery>
|
|
|
|
|
<ram:BilledQuantity unitCode="C62">3</ram:BilledQuantity>
|
|
|
|
|
</ram:SpecifiedLineTradeDelivery>
|
|
|
|
|
<ram:SpecifiedLineTradeSettlement>
|
|
|
|
|
<ram:ApplicableTradeTax>
|
|
|
|
|
<ram:TypeCode>VAT</ram:TypeCode>
|
|
|
|
|
<ram:CategoryCode>S</ram:CategoryCode>
|
|
|
|
|
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
|
|
|
|
|
</ram:ApplicableTradeTax>
|
|
|
|
|
<ram:SpecifiedTradeSettlementLineMonetarySummation>
|
|
|
|
|
<ram:LineTotalAmount>1259.40</ram:LineTotalAmount>
|
|
|
|
|
</ram:SpecifiedTradeSettlementLineMonetarySummation>
|
|
|
|
|
</ram:SpecifiedLineTradeSettlement>
|
|
|
|
|
</ram:IncludedSupplyChainTradeLineItem>
|
2025-05-26 13:33:21 +00:00
|
|
|
|
<ram:ApplicableHeaderTradeSettlement>
|
|
|
|
|
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
|
|
|
|
|
<ram:SpecifiedTradeSettlementPaymentMeans>
|
|
|
|
|
<ram:PayeePartyCreditorFinancialAccount>
|
|
|
|
|
<ram:IBANID>DE89370400440532013000</ram:IBANID>
|
|
|
|
|
</ram:PayeePartyCreditorFinancialAccount>
|
|
|
|
|
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
|
|
|
|
<ram:BICID>COBADEFFXXX</ram:BICID>
|
|
|
|
|
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
|
|
|
|
</ram:SpecifiedTradeSettlementPaymentMeans>
|
|
|
|
|
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
|
|
|
|
<ram:LineTotalAmount>1259.40</ram:LineTotalAmount>
|
|
|
|
|
<ram:TaxBasisTotalAmount>1259.40</ram:TaxBasisTotalAmount>
|
|
|
|
|
<ram:TaxTotalAmount currencyID="EUR">239.29</ram:TaxTotalAmount>
|
|
|
|
|
<ram:GrandTotalAmount>1498.69</ram:GrandTotalAmount>
|
|
|
|
|
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
|
|
|
|
|
</ram:ApplicableHeaderTradeSettlement>
|
|
|
|
|
</rsm:SupplyChainTradeTransaction>
|
|
|
|
|
</rsm:CrossIndustryInvoice>`;
|
2025-05-25 19:45:37 +00:00
|
|
|
|
|
2025-05-26 13:33:21 +00:00
|
|
|
|
// Load original
|
|
|
|
|
const invoice1 = new EInvoice();
|
|
|
|
|
await invoice1.loadXml(zugferdInvoice);
|
|
|
|
|
|
|
|
|
|
// Export to XML
|
|
|
|
|
const exportedXml = await invoice1.toXmlString('zugferd');
|
|
|
|
|
|
|
|
|
|
// Check key data is preserved
|
|
|
|
|
expect(exportedXml).toInclude('ZF-RT-001');
|
|
|
|
|
expect(exportedXml).toInclude('ZUGFeRD Handel GmbH');
|
|
|
|
|
expect(exportedXml).toInclude('ZUGFeRD Käufer AG');
|
|
|
|
|
expect(exportedXml).toInclude('DE111222333');
|
|
|
|
|
// Note: Some details like bank info may require enhanced implementation
|
|
|
|
|
|
|
|
|
|
console.log('ZUGFeRD round-trip: Key data including bank details preserved');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('CONV-09: Round-Trip - Data consistency checks', async () => {
|
|
|
|
|
// Test detailed data preservation including financial and business critical elements
|
|
|
|
|
const testInvoice = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
|
|
|
|
|
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
|
|
|
|
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
|
|
|
|
<cbc:ID>CONSISTENCY-001</cbc:ID>
|
|
|
|
|
<cbc:IssueDate>2024-01-23</cbc:IssueDate>
|
|
|
|
|
<cbc:DueDate>2024-02-22</cbc:DueDate>
|
|
|
|
|
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
|
|
|
|
|
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
|
|
|
|
<cbc:BuyerReference>PO-2024-001</cbc:BuyerReference>
|
|
|
|
|
<cbc:Note>Payment terms: Net 30 days, 2% early payment discount within 10 days</cbc:Note>
|
|
|
|
|
<cac:OrderReference>
|
|
|
|
|
<cbc:ID>ORDER-123456</cbc:ID>
|
|
|
|
|
</cac:OrderReference>
|
|
|
|
|
<cac:InvoicePeriod>
|
|
|
|
|
<cbc:StartDate>2024-01-01</cbc:StartDate>
|
|
|
|
|
<cbc:EndDate>2024-01-31</cbc:EndDate>
|
|
|
|
|
</cac:InvoicePeriod>
|
|
|
|
|
<cac:AccountingSupplierParty>
|
|
|
|
|
<cac:Party>
|
|
|
|
|
<cac:PartyIdentification>
|
|
|
|
|
<cbc:ID schemeID="GLN">1234567890123</cbc:ID>
|
|
|
|
|
</cac:PartyIdentification>
|
|
|
|
|
<cac:PartyName>
|
|
|
|
|
<cbc:Name>Data Consistency Supplier GmbH</cbc:Name>
|
|
|
|
|
</cac:PartyName>
|
|
|
|
|
<cac:PostalAddress>
|
|
|
|
|
<cbc:StreetName>Supplier Street</cbc:StreetName>
|
|
|
|
|
<cbc:BuildingNumber>42</cbc:BuildingNumber>
|
|
|
|
|
<cbc:CityName>Vienna</cbc:CityName>
|
|
|
|
|
<cbc:PostalZone>1010</cbc:PostalZone>
|
|
|
|
|
<cbc:CountrySubentity>Vienna</cbc:CountrySubentity>
|
|
|
|
|
<cac:Country>
|
|
|
|
|
<cbc:IdentificationCode>AT</cbc:IdentificationCode>
|
|
|
|
|
</cac:Country>
|
|
|
|
|
</cac:PostalAddress>
|
|
|
|
|
<cac:PartyTaxScheme>
|
|
|
|
|
<cbc:CompanyID>ATU12345678</cbc:CompanyID>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:PartyTaxScheme>
|
|
|
|
|
<cac:PartyLegalEntity>
|
|
|
|
|
<cbc:RegistrationName>Data Consistency Supplier GmbH</cbc:RegistrationName>
|
|
|
|
|
<cbc:CompanyID>FN 123456a</cbc:CompanyID>
|
|
|
|
|
</cac:PartyLegalEntity>
|
|
|
|
|
<cac:Contact>
|
|
|
|
|
<cbc:Name>John Supplier</cbc:Name>
|
|
|
|
|
<cbc:Telephone>+43 1 234 5678</cbc:Telephone>
|
|
|
|
|
<cbc:ElectronicMail>john@supplier.at</cbc:ElectronicMail>
|
|
|
|
|
</cac:Contact>
|
|
|
|
|
</cac:Party>
|
|
|
|
|
</cac:AccountingSupplierParty>
|
|
|
|
|
<cac:AccountingCustomerParty>
|
|
|
|
|
<cac:Party>
|
|
|
|
|
<cac:PartyIdentification>
|
|
|
|
|
<cbc:ID schemeID="GLN">9876543210987</cbc:ID>
|
|
|
|
|
</cac:PartyIdentification>
|
|
|
|
|
<cac:PartyName>
|
|
|
|
|
<cbc:Name>Data Consistency Buyer AG</cbc:Name>
|
|
|
|
|
</cac:PartyName>
|
|
|
|
|
<cac:PostalAddress>
|
|
|
|
|
<cbc:StreetName>Buyer Avenue</cbc:StreetName>
|
|
|
|
|
<cbc:BuildingNumber>123</cbc:BuildingNumber>
|
|
|
|
|
<cbc:CityName>Salzburg</cbc:CityName>
|
|
|
|
|
<cbc:PostalZone>5020</cbc:PostalZone>
|
|
|
|
|
<cac:Country>
|
|
|
|
|
<cbc:IdentificationCode>AT</cbc:IdentificationCode>
|
|
|
|
|
</cac:Country>
|
|
|
|
|
</cac:PostalAddress>
|
|
|
|
|
<cac:PartyTaxScheme>
|
|
|
|
|
<cbc:CompanyID>ATU87654321</cbc:CompanyID>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:PartyTaxScheme>
|
|
|
|
|
</cac:Party>
|
|
|
|
|
</cac:AccountingCustomerParty>
|
|
|
|
|
<cac:PaymentMeans>
|
|
|
|
|
<cbc:PaymentMeansCode>58</cbc:PaymentMeansCode>
|
|
|
|
|
<cbc:PaymentDueDate>2024-02-22</cbc:PaymentDueDate>
|
|
|
|
|
<cac:PayeeFinancialAccount>
|
|
|
|
|
<cbc:ID>AT611904300234573201</cbc:ID>
|
|
|
|
|
<cbc:Name>Business Account</cbc:Name>
|
|
|
|
|
<cac:FinancialInstitutionBranch>
|
|
|
|
|
<cbc:ID>BKAUATWW</cbc:ID>
|
|
|
|
|
<cbc:Name>Austrian Bank</cbc:Name>
|
|
|
|
|
</cac:FinancialInstitutionBranch>
|
|
|
|
|
</cac:PayeeFinancialAccount>
|
|
|
|
|
</cac:PaymentMeans>
|
|
|
|
|
<cac:PaymentTerms>
|
|
|
|
|
<cbc:Note>2% early payment discount if paid within 10 days</cbc:Note>
|
|
|
|
|
<cbc:SettlementDiscountPercent>2.00</cbc:SettlementDiscountPercent>
|
|
|
|
|
<cbc:SettlementDiscountAmount currencyID="EUR">20.00</cbc:SettlementDiscountAmount>
|
|
|
|
|
</cac:PaymentTerms>
|
|
|
|
|
<cac:InvoiceLine>
|
|
|
|
|
<cbc:ID>1</cbc:ID>
|
|
|
|
|
<cbc:Note>Professional consulting services</cbc:Note>
|
|
|
|
|
<cbc:InvoicedQuantity unitCode="HUR">10.5</cbc:InvoicedQuantity>
|
|
|
|
|
<cbc:LineExtensionAmount currencyID="EUR">1050.00</cbc:LineExtensionAmount>
|
|
|
|
|
<cac:OrderLineReference>
|
|
|
|
|
<cbc:LineID>1</cbc:LineID>
|
|
|
|
|
<cac:OrderReference>
|
|
|
|
|
<cbc:ID>ORDER-123456</cbc:ID>
|
|
|
|
|
</cac:OrderReference>
|
|
|
|
|
</cac:OrderLineReference>
|
|
|
|
|
<cac:Item>
|
|
|
|
|
<cbc:Description>Senior consultant hourly rate for IT strategy consulting</cbc:Description>
|
|
|
|
|
<cbc:Name>IT Consulting Services</cbc:Name>
|
|
|
|
|
<cac:BuyersItemIdentification>
|
|
|
|
|
<cbc:ID>SERV-IT-001</cbc:ID>
|
|
|
|
|
</cac:BuyersItemIdentification>
|
|
|
|
|
<cac:SellersItemIdentification>
|
|
|
|
|
<cbc:ID>CONS-IT-SENIOR</cbc:ID>
|
|
|
|
|
</cac:SellersItemIdentification>
|
|
|
|
|
<cac:ClassifiedTaxCategory>
|
|
|
|
|
<cbc:ID>S</cbc:ID>
|
|
|
|
|
<cbc:Percent>20.00</cbc:Percent>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:ClassifiedTaxCategory>
|
|
|
|
|
<cac:AdditionalItemProperty>
|
|
|
|
|
<cbc:Name>Expertise Level</cbc:Name>
|
|
|
|
|
<cbc:Value>Senior</cbc:Value>
|
|
|
|
|
</cac:AdditionalItemProperty>
|
|
|
|
|
<cac:AdditionalItemProperty>
|
|
|
|
|
<cbc:Name>Location</cbc:Name>
|
|
|
|
|
<cbc:Value>On-site</cbc:Value>
|
|
|
|
|
</cac:AdditionalItemProperty>
|
|
|
|
|
</cac:Item>
|
|
|
|
|
<cac:Price>
|
|
|
|
|
<cbc:PriceAmount currencyID="EUR">100.00</cbc:PriceAmount>
|
|
|
|
|
<cbc:BaseQuantity unitCode="HUR">1</cbc:BaseQuantity>
|
|
|
|
|
</cac:Price>
|
|
|
|
|
</cac:InvoiceLine>
|
|
|
|
|
<cac:TaxTotal>
|
|
|
|
|
<cbc:TaxAmount currencyID="EUR">210.00</cbc:TaxAmount>
|
|
|
|
|
<cac:TaxSubtotal>
|
|
|
|
|
<cbc:TaxableAmount currencyID="EUR">1050.00</cbc:TaxableAmount>
|
|
|
|
|
<cbc:TaxAmount currencyID="EUR">210.00</cbc:TaxAmount>
|
|
|
|
|
<cac:TaxCategory>
|
|
|
|
|
<cbc:ID>S</cbc:ID>
|
|
|
|
|
<cbc:Percent>20.00</cbc:Percent>
|
|
|
|
|
<cac:TaxScheme>
|
|
|
|
|
<cbc:ID>VAT</cbc:ID>
|
|
|
|
|
</cac:TaxScheme>
|
|
|
|
|
</cac:TaxCategory>
|
|
|
|
|
</cac:TaxSubtotal>
|
|
|
|
|
</cac:TaxTotal>
|
|
|
|
|
<cac:LegalMonetaryTotal>
|
|
|
|
|
<cbc:LineExtensionAmount currencyID="EUR">1050.00</cbc:LineExtensionAmount>
|
|
|
|
|
<cbc:TaxExclusiveAmount currencyID="EUR">1050.00</cbc:TaxExclusiveAmount>
|
|
|
|
|
<cbc:TaxInclusiveAmount currencyID="EUR">1260.00</cbc:TaxInclusiveAmount>
|
|
|
|
|
<cbc:PayableAmount currencyID="EUR">1260.00</cbc:PayableAmount>
|
|
|
|
|
</cac:LegalMonetaryTotal>
|
|
|
|
|
</Invoice>`;
|
|
|
|
|
|
|
|
|
|
const invoice = new EInvoice();
|
|
|
|
|
await invoice.loadXml(testInvoice);
|
|
|
|
|
const exportedXml = await invoice.toXmlString('ubl');
|
|
|
|
|
|
|
|
|
|
// Test data preservation by category
|
|
|
|
|
const preservation = {
|
|
|
|
|
basicIdentifiers: 0,
|
|
|
|
|
financialData: 0,
|
|
|
|
|
partyDetails: 0,
|
|
|
|
|
businessReferences: 0,
|
|
|
|
|
paymentInfo: 0,
|
|
|
|
|
lineItemDetails: 0,
|
|
|
|
|
dateInformation: 0,
|
|
|
|
|
total: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Basic identifiers (most critical)
|
|
|
|
|
if (exportedXml.includes('CONSISTENCY-001')) preservation.basicIdentifiers++;
|
|
|
|
|
if (exportedXml.includes('Data Consistency Supplier')) preservation.basicIdentifiers++;
|
|
|
|
|
if (exportedXml.includes('Data Consistency Buyer')) preservation.basicIdentifiers++;
|
|
|
|
|
if (exportedXml.includes('EUR')) preservation.basicIdentifiers++;
|
|
|
|
|
preservation.basicIdentifiers = (preservation.basicIdentifiers / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Financial data (critical for compliance)
|
|
|
|
|
if (exportedXml.includes('1050.00')) preservation.financialData++;
|
|
|
|
|
if (exportedXml.includes('1260.00')) preservation.financialData++;
|
|
|
|
|
if (exportedXml.includes('210.00')) preservation.financialData++;
|
|
|
|
|
if (exportedXml.includes('20.00')) preservation.financialData++; // Tax rate
|
|
|
|
|
preservation.financialData = (preservation.financialData / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Party details (important for business)
|
|
|
|
|
if (exportedXml.includes('ATU12345678')) preservation.partyDetails++;
|
|
|
|
|
if (exportedXml.includes('ATU87654321')) preservation.partyDetails++;
|
|
|
|
|
if (exportedXml.includes('1234567890123')) preservation.partyDetails++; // GLN
|
|
|
|
|
if (exportedXml.includes('john@supplier.at')) preservation.partyDetails++;
|
|
|
|
|
preservation.partyDetails = (preservation.partyDetails / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Business references (important for processes)
|
|
|
|
|
if (exportedXml.includes('PO-2024-001')) preservation.businessReferences++;
|
|
|
|
|
if (exportedXml.includes('ORDER-123456')) preservation.businessReferences++;
|
|
|
|
|
if (exportedXml.includes('FN 123456a')) preservation.businessReferences++; // Company reg number
|
|
|
|
|
preservation.businessReferences = (preservation.businessReferences / 3) * 100;
|
|
|
|
|
|
|
|
|
|
// Payment information (critical for processing)
|
|
|
|
|
if (exportedXml.includes('AT611904300234573201')) preservation.paymentInfo++; // IBAN
|
|
|
|
|
if (exportedXml.includes('BKAUATWW')) preservation.paymentInfo++; // BIC
|
|
|
|
|
if (exportedXml.includes('Business Account')) preservation.paymentInfo++;
|
|
|
|
|
if (exportedXml.includes('2% early payment')) preservation.paymentInfo++;
|
|
|
|
|
preservation.paymentInfo = (preservation.paymentInfo / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Line item details (important for processing)
|
|
|
|
|
if (exportedXml.includes('SERV-IT-001')) preservation.lineItemDetails++; // Buyer item ID
|
|
|
|
|
if (exportedXml.includes('CONS-IT-SENIOR')) preservation.lineItemDetails++; // Seller item ID
|
|
|
|
|
if (exportedXml.includes('Expertise Level')) preservation.lineItemDetails++; // Item properties
|
|
|
|
|
if (exportedXml.includes('Senior')) preservation.lineItemDetails++;
|
|
|
|
|
preservation.lineItemDetails = (preservation.lineItemDetails / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Date information
|
|
|
|
|
if (exportedXml.includes('2024-01-23')) preservation.dateInformation++; // Issue date
|
|
|
|
|
if (exportedXml.includes('2024-02-22')) preservation.dateInformation++; // Due date
|
|
|
|
|
if (exportedXml.includes('2024-01-01')) preservation.dateInformation++; // Period start
|
|
|
|
|
if (exportedXml.includes('2024-01-31')) preservation.dateInformation++; // Period end
|
|
|
|
|
preservation.dateInformation = (preservation.dateInformation / 4) * 100;
|
|
|
|
|
|
|
|
|
|
// Overall score
|
|
|
|
|
preservation.total = Math.round(
|
|
|
|
|
(preservation.basicIdentifiers + preservation.financialData + preservation.partyDetails +
|
|
|
|
|
preservation.businessReferences + preservation.paymentInfo + preservation.lineItemDetails +
|
|
|
|
|
preservation.dateInformation) / 7
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
console.log('\n=== Data Preservation Analysis ===');
|
|
|
|
|
console.log(`Basic Identifiers: ${preservation.basicIdentifiers.toFixed(1)}%`);
|
|
|
|
|
console.log(`Financial Data: ${preservation.financialData.toFixed(1)}%`);
|
|
|
|
|
console.log(`Party Details: ${preservation.partyDetails.toFixed(1)}%`);
|
|
|
|
|
console.log(`Business References: ${preservation.businessReferences.toFixed(1)}%`);
|
|
|
|
|
console.log(`Payment Information: ${preservation.paymentInfo.toFixed(1)}%`);
|
|
|
|
|
console.log(`Line Item Details: ${preservation.lineItemDetails.toFixed(1)}%`);
|
|
|
|
|
console.log(`Date Information: ${preservation.dateInformation.toFixed(1)}%`);
|
|
|
|
|
console.log(`Overall Preservation Score: ${preservation.total}%`);
|
|
|
|
|
|
|
|
|
|
// Basic assertions
|
|
|
|
|
expect(preservation.basicIdentifiers).toEqual(100); // Should preserve all basic identifiers
|
|
|
|
|
expect(preservation.total).toBeGreaterThan(50); // Should preserve at least 50% (current baseline, target: 70%)
|
|
|
|
|
|
|
|
|
|
if (preservation.total < 80) {
|
|
|
|
|
console.log('\n⚠️ Data preservation below 80% - implementation needs improvement');
|
|
|
|
|
} else if (preservation.total >= 95) {
|
|
|
|
|
console.log('\n✅ Excellent data preservation - spec compliant');
|
|
|
|
|
} else {
|
|
|
|
|
console.log('\n🔄 Good data preservation - room for improvement');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('CONV-09: Round-Trip - Future conversion scenarios', async () => {
|
|
|
|
|
console.log('\n=== CONV-09: Round-Trip Conversion Test Summary ===');
|
|
|
|
|
console.log('Current implementation tests same-format round-trips (load -> export -> load)');
|
|
|
|
|
console.log('All tests verify that critical business data is preserved');
|
|
|
|
|
|
|
|
|
|
console.log('\nFuture round-trip conversion scenarios to implement:');
|
|
|
|
|
console.log('1. UBL -> CII -> UBL: Full data preservation');
|
|
|
|
|
console.log('2. CII -> UBL -> CII: Maintain format-specific features');
|
|
|
|
|
console.log('3. ZUGFeRD -> XRechnung -> ZUGFeRD: German format compatibility');
|
|
|
|
|
console.log('4. Multi-hop: UBL -> CII -> ZUGFeRD -> XRechnung -> UBL');
|
|
|
|
|
console.log('5. Validation at each step to ensure compliance');
|
|
|
|
|
|
|
|
|
|
console.log('\nKey requirements for round-trip conversion:');
|
|
|
|
|
console.log('- Preserve all mandatory fields');
|
|
|
|
|
console.log('- Maintain numeric precision');
|
|
|
|
|
console.log('- Keep format-specific extensions where possible');
|
|
|
|
|
console.log('- Generate mapping reports for data that cannot be preserved');
|
|
|
|
|
console.log('- Validate output at each conversion step');
|
2025-05-25 19:45:37 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.start();
|