|
package SL::XMLInvoice::CrossIndustryInvoice;
|
|
use parent qw(SL::XMLInvoice);
|
|
|
|
=head1 NAME
|
|
|
|
SL::XMLInvoice::FakturX - XML parser for UN/CEFACT Cross Industry Invoice
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
C<SL::XMLInvoice::CrossIndustryInvoice> parses XML invoices in UN/CEFACT Cross
|
|
Industry Invoice format and makes their data available through the interface
|
|
defined by C<SL::XMLInvoice>. Refer to L<SL::XMLInvoice> for a detailed
|
|
description of that interface.
|
|
|
|
See L<https://unece.org/trade/uncefact/xml-schemas> for that format's
|
|
specification.
|
|
|
|
=head1 OPERATION
|
|
|
|
This module is fairly simple. It keeps two hashes of XPath statements exposed
|
|
by methods:
|
|
|
|
=over 4
|
|
|
|
=item scalar_xpaths()
|
|
|
|
This hash is keyed by the keywords C<data_keys> mandates. Values are XPath
|
|
statements specifying the location of this field in the invoice XML document.
|
|
|
|
=item item_xpaths()
|
|
|
|
This hash is keyed by the keywords C<item_keys> mandates. Values are XPath
|
|
statements specifying the location of this field inside a line item.
|
|
|
|
=back
|
|
|
|
When invoked by the C<SL::XMLInvoice> constructor, C<parse_xml()> will first
|
|
use the XPath statements from the C<scalar_xpaths()> hash to populate the hash
|
|
returned by the C<metadata()> method.
|
|
|
|
After that, it will use the XPath statements from the C<scalar_xpaths()> hash
|
|
to iterate over the invoice's line items and populate the array of hashes
|
|
returned by the C<items()> method.
|
|
|
|
=head1 AUTHOR
|
|
|
|
Johannes Grassler <info@computer-grassler.de>
|
|
|
|
=cut
|
|
|
|
use strict;
|
|
use constant ITEMS_XPATH => '//ram:IncludedSupplyChainTradeLineItem';
|
|
|
|
# XML XPath expressions for global metadata
|
|
sub scalar_xpaths {
|
|
return {
|
|
currency => '//ram:InvoiceCurrencyCode',
|
|
direct_debit => '//ram:SpecifiedTradeSettlementPaymentMeans/ram:TypeCode',
|
|
duedate => '//ram:DueDateDateTime/udt:DateTimeString',
|
|
gross_total => '//ram:DuePayableAmount',
|
|
iban => '//ram:SpecifiedTradeSettlementPaymentMeans/ram:PayeePartyCreditorFinancialAccount/ram:IBANID',
|
|
invnumber => '//rsm:ExchangedDocument/ram:ID',
|
|
net_total => '//ram:SpecifiedTradeSettlementHeaderMonetarySummation' . '//ram:TaxBasisTotalAmount',
|
|
transdate => '//ram:IssueDateTime/udt:DateTimeString',
|
|
taxnumber => '//ram:SellerTradeParty/ram:SpecifiedTaxRegistration/ram:ID[@schemeID="FC"]',
|
|
type => '//rsm:ExchangedDocument/ram:TypeCode',
|
|
ustid => '//ram:SellerTradeParty/ram:SpecifiedTaxRegistration/ram:ID[@schemeID="VA"]',
|
|
vendor_name => '//ram:SellerTradeParty/ram:Name',
|
|
};
|
|
}
|
|
|
|
sub item_xpaths {
|
|
return {
|
|
'currency' => undef, # Only global currency in CrossIndustryInvoice
|
|
'price' => './ram:SpecifiedLineTradeAgreement/ram:NetPriceProductTradePrice',
|
|
'description' => './ram:SpecifiedTradeProduct/ram:Name',
|
|
'quantity' => ' |