updated importer and exporter to ZF2
This commit is contained in:
@@ -184,17 +184,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
|
||||
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
||||
|
||||
+ "<rsm:CrossIndustryDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:ferd:CrossIndustryDocument:invoice:1p0\""
|
||||
// + " xsi:schemaLocation=\"urn:ferd:CrossIndustryDocument:invoice:1p0 ../Schema/ZUGFeRD1p0.xsd\""
|
||||
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12\""
|
||||
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15\">\n" //$NON-NLS-1$
|
||||
+ " <rsm:SpecifiedExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
||||
// + " xsi:schemaLocation=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100 ../Schema/ZUGFeRD1p0.xsd\""
|
||||
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
|
||||
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
|
||||
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||
+ " <ram:ID>urn:ferd:CrossIndustryDocument:invoice:1p0:comfort</ram:ID>\n" //$NON-NLS-1$
|
||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||
+ " </rsm:SpecifiedExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||
+ " <rsm:HeaderExchangedDocument>\n" //$NON-NLS-1$
|
||||
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||
+ " <ram:ID>"+trans.getNumber()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
||||
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
||||
@@ -212,9 +212,61 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
// + " </Content>\n"
|
||||
// + " <SubjectCode>AAK</SubjectCode>\n"
|
||||
// + " </IncludedNote>\n"
|
||||
+ " </rsm:HeaderExchangedDocument>\n" //$NON-NLS-1$
|
||||
+ " <rsm:SpecifiedSupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicableSupplyChainTradeAgreement>\n" //$NON-NLS-1$
|
||||
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
|
||||
int lineID=0;
|
||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||
lineID++;
|
||||
|
||||
LineCalc lc=new LineCalc(currentItem);
|
||||
xml=xml+ " <ram:IncludedSupplyChainTradeLineItem>\n"+ //$NON-NLS-1$
|
||||
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||
+ " <ram:LineID>"+lineID+"</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
||||
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
||||
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
||||
+ " <ram:Name>"+currentItem.getProduct().getName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:Description>"+currentItem.getProduct().getDescription()+"</ram:Description>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||
|
||||
+ " <ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
||||
+ " <ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:ChargeAmount currencyID=\"EUR\">"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// + " <AppliedTradeAllowanceCharge>\n"
|
||||
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
||||
// + " <Reason>Rabatt</Reason>\n"
|
||||
// + " </AppliedTradeAllowanceCharge>\n"
|
||||
+ " </ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:ChargeAmount currencyID=\"EUR\">"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " </ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
||||
|
||||
+ " <ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
||||
+ " <ram:BilledQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">"+quantityFormat(currentItem.getQuantity())+"</ram:BilledQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ " </ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:RateApplicablePercent>"+vatFormat(currentItem.getProduct().getVATPercent())+"</ram:RateApplicablePercent>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " <ram:LineTotalAmount currencyID=\"EUR\">"+currencyFormat(lc.getItemTotalNetAmount())+"</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " </ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " </ram:IncludedSupplyChainTradeLineItem>\n"; //$NON-NLS-1$
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
xml=xml+ " <ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
||||
// + " <BuyerReference>AB-312</BuyerReference>\n"
|
||||
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
||||
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
||||
@@ -253,8 +305,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
|
||||
// + " <ID>2013-471331</ID>\n"
|
||||
// + " </BuyerOrderReferencedDocument>\n"
|
||||
+ " </ram:ApplicableSupplyChainTradeAgreement>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicableSupplyChainTradeDelivery>\n"
|
||||
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicableHeaderTradeDelivery>\n"
|
||||
+ " <ram:ActualDeliverySupplyChainEvent>\n"
|
||||
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDeliveryDate())+"</udt:DateTimeString></ram:OccurrenceDateTime>\n"
|
||||
+ " </ram:ActualDeliverySupplyChainEvent>\n"
|
||||
@@ -263,8 +315,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
|
||||
+ " <ID>2013-51112</ID>\n"
|
||||
+ " </DeliveryNoteReferencedDocument>\n" */
|
||||
+ " </ram:ApplicableSupplyChainTradeDelivery>\n"
|
||||
+ " <ram:ApplicableSupplyChainTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " </ram:ApplicableHeaderTradeDelivery>\n"
|
||||
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " <ram:PaymentReference>"+trans.getNumber()+"</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
|
||||
@@ -290,7 +342,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:BasisAmount currencyID=\"EUR\">"+currencyFormat(amount.getBasis())+"</ram:BasisAmount>\n"
|
||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicablePercent>"+vatFormat(currentTaxPercent)+"</ram:ApplicablePercent>\n" //$NON-NLS-1$
|
||||
+ " <ram:RateApplicablePercent>"+vatFormat(currentTaxPercent)+"</ram:RateApplicablePercent>\n" //$NON-NLS-1$
|
||||
+ " </ram:ApplicableTradeTax>\n"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -334,7 +386,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <ram:Description>Zahlbar ohne Abzug bis "+germanDateFormat.format(trans.getDueDate())+"</ram:Description>\n"
|
||||
+ " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDueDate())+"</udt:DateTimeString></ram:DueDateDateTime>\n"//20130704 //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeSettlementMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " <ram:LineTotalAmount currencyID=\"EUR\">"+currencyFormat(getTotal())+"</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:ChargeTotalAmount currencyID=\"EUR\">0.00</ram:ChargeTotalAmount>\n" //$NON-NLS-1$
|
||||
+ " <ram:AllowanceTotalAmount currencyID=\"EUR\">0.00</ram:AllowanceTotalAmount>\n" //$NON-NLS-1$
|
||||
@@ -345,8 +397,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ " <ram:GrandTotalAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross())+"</ram:GrandTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
|
||||
+ " <ram:DuePayableAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross())+"</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradeSettlementMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " </ram:ApplicableSupplyChainTradeSettlement>\n"; //$NON-NLS-1$
|
||||
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
|
||||
// + " <IncludedSupplyChainTradeLineItem>\n"
|
||||
// + " <AssociatedDocumentLineDocument>\n"
|
||||
// + " <IncludedNote>\n"
|
||||
@@ -356,61 +408,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
// + " </IncludedSupplyChainTradeLineItem>\n";
|
||||
|
||||
|
||||
int lineID=0;
|
||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||
lineID++;
|
||||
|
||||
LineCalc lc=new LineCalc(currentItem);
|
||||
xml=xml+ " <ram:IncludedSupplyChainTradeLineItem>\n"+ //$NON-NLS-1$
|
||||
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||
+ " <ram:LineID>"+lineID+"</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||
|
||||
+ " <ram:SpecifiedSupplyChainTradeAgreement>\n" //$NON-NLS-1$
|
||||
+ " <ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:ChargeAmount currencyID=\"EUR\">"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// + " <AppliedTradeAllowanceCharge>\n"
|
||||
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
||||
// + " <Reason>Rabatt</Reason>\n"
|
||||
// + " </AppliedTradeAllowanceCharge>\n"
|
||||
+ " </ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " <ram:ChargeAmount currencyID=\"EUR\">"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||
+ " </ram:SpecifiedSupplyChainTradeAgreement>\n" //$NON-NLS-1$
|
||||
|
||||
+ " <ram:SpecifiedSupplyChainTradeDelivery>\n" //$NON-NLS-1$
|
||||
+ " <ram:BilledQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">"+quantityFormat(currentItem.getQuantity())+"</ram:BilledQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ " </ram:SpecifiedSupplyChainTradeDelivery>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedSupplyChainTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
||||
+ " <ram:ApplicablePercent>"+vatFormat(currentItem.getProduct().getVATPercent())+"</ram:ApplicablePercent>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeSettlementMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " <ram:LineTotalAmount currencyID=\"EUR\">"+currencyFormat(lc.getItemTotalNetAmount())+"</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradeSettlementMonetarySummation>\n" //$NON-NLS-1$
|
||||
+ " </ram:SpecifiedSupplyChainTradeSettlement>\n" //$NON-NLS-1$
|
||||
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
||||
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
||||
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
||||
+ " <ram:Name>"+currentItem.getProduct().getName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " <ram:Description>"+currentItem.getProduct().getDescription()+"</ram:Description>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||
+ " </ram:IncludedSupplyChainTradeLineItem>\n"; //$NON-NLS-1$
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
xml=xml + " </rsm:SpecifiedSupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
||||
+ "</rsm:CrossIndustryDocument>"; //$NON-NLS-1$
|
||||
xml=xml + " </rsm:SupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
||||
+ "</rsm:CrossIndustryInvoice>"; //$NON-NLS-1$
|
||||
|
||||
byte[] zugferdRaw;
|
||||
try {
|
||||
|
||||
@@ -33,10 +33,9 @@ import org.xml.sax.SAXException;
|
||||
|
||||
public class ZUGFeRDImporter {
|
||||
/*
|
||||
call extract(importFilename).
|
||||
containsMeta() will return if ZUGFeRD data has been found,
|
||||
afterwards you can call getBIC(), getIBAN() etc.
|
||||
|
||||
* call extract(importFilename). containsMeta() will return if ZUGFeRD data has
|
||||
* been found, afterwards you can call getBIC(), getIBAN() etc.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @var if metadata has been found */
|
||||
@@ -55,7 +54,6 @@ public class ZUGFeRDImporter {
|
||||
private boolean extracted = false;
|
||||
private boolean parsed = false;
|
||||
|
||||
|
||||
/**
|
||||
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
||||
* Errors are just logged to STDOUT.
|
||||
@@ -69,8 +67,8 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a ZUGFeRD invoice from a PDF document represented by an input stream.
|
||||
* Errors are reported via exception handling.
|
||||
* Extracts a ZUGFeRD invoice from a PDF document represented by an input
|
||||
* stream. Errors are reported via exception handling.
|
||||
*/
|
||||
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
||||
PDEmbeddedFilesNameTreeNode etn;
|
||||
@@ -86,9 +84,9 @@ public class ZUGFeRDImporter {
|
||||
// String filePath = "/tmp/";
|
||||
for (String filename : efMap.keySet()) {
|
||||
/**
|
||||
* currently (in the release candidate of version 1) only one
|
||||
* attached file with the name ZUGFeRD-invoice.xml is allowed
|
||||
* */
|
||||
* currently (in the release candidate of version 1) only one attached file with
|
||||
* the name ZUGFeRD-invoice.xml is allowed
|
||||
*/
|
||||
if ((filename.equals("ZUGFeRD-invoice.xml") || filename.equals("factur-x.xml"))) { //$NON-NLS-1$
|
||||
containsMeta = true;
|
||||
|
||||
@@ -121,7 +119,8 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
|
||||
factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true); //otherwise we can not act namespace independently, i.e. use document.getElementsByTagNameNS("*",...
|
||||
factory.setNamespaceAware(true); // otherwise we can not act namespace independently, i.e. use
|
||||
// document.getElementsByTagNameNS("*",...
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException ex3) {
|
||||
@@ -141,11 +140,9 @@ public class ZUGFeRDImporter {
|
||||
|
||||
// rootNode = document.getDocumentElement();
|
||||
// ApplicableSupplyChainTradeSettlement
|
||||
ndList = document.getDocumentElement()
|
||||
.getElementsByTagNameNS("*","PaymentReference"); //$NON-NLS-1$
|
||||
ndList = document.getDocumentElement().getElementsByTagNameNS("*", "PaymentReference"); //$NON-NLS-1$
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// if there is a attribute in the tag number:value
|
||||
|
||||
@@ -153,52 +150,38 @@ public class ZUGFeRDImporter {
|
||||
|
||||
}
|
||||
/*
|
||||
ndList = document
|
||||
.getElementsByTagName("GermanBankleitzahlID"); //$NON-NLS-1$
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// if there is a attribute in the tag number:value
|
||||
setBIC(booking.getTextContent());
|
||||
|
||||
}
|
||||
|
||||
ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// if there is a attribute in the tag number:value
|
||||
setIBAN(booking.getTextContent());
|
||||
|
||||
}
|
||||
<ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:IBANID>DE1234</ram:IBANID>
|
||||
</ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
<ram:BICID>DE5656565</ram:BICID>
|
||||
<ram:Name>Commerzbank</ram:Name>
|
||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
|
||||
* ndList = document .getElementsByTagName("GermanBankleitzahlID");
|
||||
* //$NON-NLS-1$
|
||||
*
|
||||
* for (int bookingIndex = 0; bookingIndex < ndList .getLength();
|
||||
* bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a
|
||||
* attribute in the tag number:value setBIC(booking.getTextContent());
|
||||
*
|
||||
* }
|
||||
*
|
||||
* ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$
|
||||
*
|
||||
* for (int bookingIndex = 0; bookingIndex < ndList .getLength();
|
||||
* bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a
|
||||
* attribute in the tag number:value setIBAN(booking.getTextContent());
|
||||
*
|
||||
* } <ram:PayeePartyCreditorFinancialAccount> <ram:IBANID>DE1234</ram:IBANID>
|
||||
* </ram:PayeePartyCreditorFinancialAccount>
|
||||
* <ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
* <ram:BICID>DE5656565</ram:BICID> <ram:Name>Commerzbank</ram:Name>
|
||||
* </ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
*
|
||||
*/
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","PayeePartyCICreditorFinancialAccount"); //ZF2
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*", "PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||
}
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// there are many "name" elements, so get the one below
|
||||
// SellerTradeParty
|
||||
NodeList bookingDetails = booking.getChildNodes();
|
||||
|
||||
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||
.getLength(); detailIndex++) {
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||
Node detail = bookingDetails.item(detailIndex);
|
||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
||||
setIBAN(detail.getTextContent());
|
||||
@@ -207,20 +190,13 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCICreditorFinancialInstitution");//ZF2 //$NON-NLS-1$
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*", "PayeeSpecifiedCreditorFinancialInstitution");// ZF1 //$NON-NLS-1$
|
||||
}
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// there are many "name" elements, so get the one below
|
||||
// SellerTradeParty
|
||||
NodeList bookingDetails = booking.getChildNodes();
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||
.getLength(); detailIndex++) {
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||
Node detail = bookingDetails.item(detailIndex);
|
||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
||||
setBIC(detail.getTextContent());
|
||||
@@ -232,21 +208,14 @@ public class ZUGFeRDImporter {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","SellerCITradeParty"); //ZF2
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*", "SellerTradeParty"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// there are many "name" elements, so get the one below
|
||||
// SellerTradeParty
|
||||
NodeList bookingDetails = booking.getChildNodes();
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||
.getLength(); detailIndex++) {
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||
Node detail = bookingDetails.item(detailIndex);
|
||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||
setHolder(detail.getTextContent());
|
||||
@@ -257,8 +226,7 @@ public class ZUGFeRDImporter {
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*", "DuePayableAmount"); //$NON-NLS-1$
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// if there is a attribute in the tag number:value
|
||||
amountFound = true;
|
||||
@@ -266,14 +234,13 @@ public class ZUGFeRDImporter {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!amountFound) {
|
||||
/* there is apparently no requirement to mention DuePayableAmount,,
|
||||
* if it's not there, check for GrandTotalAmount
|
||||
/*
|
||||
* there is apparently no requirement to mention DuePayableAmount,, if it's not
|
||||
* there, check for GrandTotalAmount
|
||||
*/
|
||||
ndList = document.getElementsByTagNameNS("*", "GrandTotalAmount"); //$NON-NLS-1$
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// if there is a attribute in the tag number:value
|
||||
amountFound = true;
|
||||
@@ -284,20 +251,13 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*", "SpecifiedTradePaymentTerms"); //$NON-NLS-1$
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*","SpecifiedCITradePaymentTerms"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||
Node booking = ndList.item(bookingIndex);
|
||||
// there are many "name" elements, so get the one below
|
||||
// SellerTradeParty
|
||||
NodeList bookingDetails = booking.getChildNodes();
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||
.getLength(); detailIndex++) {
|
||||
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||
Node detail = bookingDetails.item(detailIndex);
|
||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("DueDateDateTime"))) { //$NON-NLS-1$
|
||||
setDueDate(detail.getTextContent().trim());
|
||||
@@ -309,7 +269,6 @@ public class ZUGFeRDImporter {
|
||||
parsed = true;
|
||||
}
|
||||
|
||||
|
||||
public boolean containsMeta() {
|
||||
return containsMeta;
|
||||
}
|
||||
@@ -321,14 +280,10 @@ public class ZUGFeRDImporter {
|
||||
return foreignReference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setForeignReference(String foreignReference) {
|
||||
this.foreignReference = foreignReference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getBIC() {
|
||||
if (!parsed) {
|
||||
throw new RuntimeException("use parse() before requesting a value");
|
||||
@@ -336,24 +291,18 @@ public class ZUGFeRDImporter {
|
||||
return BIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setBIC(String bic) {
|
||||
this.BIC = bic;
|
||||
}
|
||||
|
||||
|
||||
private void setDueDate(String dueDate) {
|
||||
this.dueDate = dueDate;
|
||||
}
|
||||
|
||||
|
||||
private void setBankName(String bankname) {
|
||||
this.bankName = bankname;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getIBAN() {
|
||||
if (!parsed) {
|
||||
throw new RuntimeException("use parse() before requesting a value");
|
||||
@@ -361,7 +310,6 @@ public class ZUGFeRDImporter {
|
||||
return IBAN;
|
||||
}
|
||||
|
||||
|
||||
public String getBankName() {
|
||||
if (!parsed) {
|
||||
throw new RuntimeException("use parse() before requesting a value");
|
||||
@@ -369,14 +317,10 @@ public class ZUGFeRDImporter {
|
||||
return bankName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setIBAN(String IBAN) {
|
||||
this.IBAN = IBAN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getHolder() {
|
||||
if (rawXML == null) {
|
||||
throw new RuntimeException("use parse() before requesting a value");
|
||||
@@ -384,14 +328,10 @@ public class ZUGFeRDImporter {
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setHolder(String holder) {
|
||||
this.holder = holder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getAmount() {
|
||||
if (rawXML == null) {
|
||||
throw new RuntimeException("use parse() before requesting a value");
|
||||
@@ -422,23 +362,23 @@ public class ZUGFeRDImporter {
|
||||
return new String(rawXML);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||
*/
|
||||
public byte[] getRawXML()
|
||||
{
|
||||
public byte[] getRawXML() {
|
||||
return rawXML;
|
||||
}
|
||||
|
||||
/**
|
||||
* will return true if the metadata (just extract-ed or set with setMeta) contains ZUGFeRD XML
|
||||
* */
|
||||
* will return true if the metadata (just extract-ed or set with setMeta)
|
||||
* contains ZUGFeRD XML
|
||||
*/
|
||||
public boolean canParse() {
|
||||
|
||||
|
||||
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
||||
// SpecifiedExchangedDocumentContext is in the schema, so a relatively good
|
||||
// indication if zugferd is present - better than just invoice
|
||||
String meta = getMeta();
|
||||
return (meta!=null)&&( meta.length()>0)&&(( meta.contains("SpecifiedExchangedDocumentContext")/*ZF1*/||meta.contains("CIExchangedDocumentContext"))); //$NON-NLS-1$
|
||||
return (meta != null) && (meta.length() > 0) && ((meta.contains("SpecifiedExchangedDocumentContext") //$NON-NLS-1$
|
||||
/* ZF1 */ || meta.contains("ExchangedDocumentContext") /*ZF2*/));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Toecount {
|
||||
}
|
||||
|
||||
if (!selectedName.toLowerCase().endsWith(expectedExtension.toLowerCase())) {
|
||||
System.err.println("Expected "+expectedExtension+" extension, this may corrupt your file. Do you still want to continue?");
|
||||
System.err.println("Expected "+expectedExtension+" extension, this may corrupt your file. Do you still want to continue?(Y|N)");
|
||||
String selectedAnswer="";
|
||||
try {
|
||||
selectedAnswer=buffer.readLine();
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
@@ -432,7 +434,6 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
||||
String iban = null;
|
||||
String holder = null;
|
||||
String ref = null;
|
||||
|
||||
if (zi.canParse())
|
||||
{
|
||||
zi.parse();
|
||||
|
||||
Reference in New Issue
Block a user