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$
|
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\""
|
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
||||||
// + " xsi:schemaLocation=\"urn:ferd:CrossIndustryDocument:invoice:1p0 ../Schema/ZUGFeRD1p0.xsd\""
|
// + " xsi:schemaLocation=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100 ../Schema/ZUGFeRD1p0.xsd\""
|
||||||
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12\""
|
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
|
||||||
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15\">\n" //$NON-NLS-1$
|
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
|
||||||
+ " <rsm:SpecifiedExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
+ " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
||||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\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:ID>urn:ferd:CrossIndustryDocument:invoice:1p0:comfort</ram:ID>\n" //$NON-NLS-1$
|
||||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||||
+ " </rsm:SpecifiedExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
+ " <rsm:HeaderExchangedDocument>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID>"+trans.getNumber()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ID>"+trans.getNumber()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
+ " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
@@ -212,9 +212,61 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
// + " </Content>\n"
|
// + " </Content>\n"
|
||||||
// + " <SubjectCode>AAK</SubjectCode>\n"
|
// + " <SubjectCode>AAK</SubjectCode>\n"
|
||||||
// + " </IncludedNote>\n"
|
// + " </IncludedNote>\n"
|
||||||
+ " </rsm:HeaderExchangedDocument>\n" //$NON-NLS-1$
|
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||||
+ " <rsm:SpecifiedSupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
|
||||||
+ " <ram:ApplicableSupplyChainTradeAgreement>\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"
|
// + " <BuyerReference>AB-312</BuyerReference>\n"
|
||||||
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
||||||
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
||||||
@@ -253,8 +305,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
|
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
|
||||||
// + " <ID>2013-471331</ID>\n"
|
// + " <ID>2013-471331</ID>\n"
|
||||||
// + " </BuyerOrderReferencedDocument>\n"
|
// + " </BuyerOrderReferencedDocument>\n"
|
||||||
+ " </ram:ApplicableSupplyChainTradeAgreement>\n" //$NON-NLS-1$
|
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ApplicableSupplyChainTradeDelivery>\n"
|
+ " <ram:ApplicableHeaderTradeDelivery>\n"
|
||||||
+ " <ram:ActualDeliverySupplyChainEvent>\n"
|
+ " <ram:ActualDeliverySupplyChainEvent>\n"
|
||||||
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDeliveryDate())+"</udt:DateTimeString></ram:OccurrenceDateTime>\n"
|
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDeliveryDate())+"</udt:DateTimeString></ram:OccurrenceDateTime>\n"
|
||||||
+ " </ram:ActualDeliverySupplyChainEvent>\n"
|
+ " </ram:ActualDeliverySupplyChainEvent>\n"
|
||||||
@@ -263,8 +315,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
|
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
|
||||||
+ " <ID>2013-51112</ID>\n"
|
+ " <ID>2013-51112</ID>\n"
|
||||||
+ " </DeliveryNoteReferencedDocument>\n" */
|
+ " </DeliveryNoteReferencedDocument>\n" */
|
||||||
+ " </ram:ApplicableSupplyChainTradeDelivery>\n"
|
+ " </ram:ApplicableHeaderTradeDelivery>\n"
|
||||||
+ " <ram:ApplicableSupplyChainTradeSettlement>\n" //$NON-NLS-1$
|
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:PaymentReference>"+trans.getNumber()+"</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:PaymentReference>"+trans.getNumber()+"</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
|
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\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:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:BasisAmount currencyID=\"EUR\">"+currencyFormat(amount.getBasis())+"</ram:BasisAmount>\n"
|
+ " <ram:BasisAmount currencyID=\"EUR\">"+currencyFormat(amount.getBasis())+"</ram:BasisAmount>\n"
|
||||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
+ " <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$
|
+ " </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: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: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: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: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:ChargeTotalAmount currencyID=\"EUR\">0.00</ram:ChargeTotalAmount>\n" //$NON-NLS-1$
|
||||||
+ " <ram:AllowanceTotalAmount currencyID=\"EUR\">0.00</ram:AllowanceTotalAmount>\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$
|
+ " <ram:GrandTotalAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross())+"</ram:GrandTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
|
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
|
||||||
+ " <ram:DuePayableAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross())+"</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:DuePayableAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross())+"</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTradeSettlementMonetarySummation>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
||||||
+ " </ram:ApplicableSupplyChainTradeSettlement>\n"; //$NON-NLS-1$
|
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
|
||||||
// + " <IncludedSupplyChainTradeLineItem>\n"
|
// + " <IncludedSupplyChainTradeLineItem>\n"
|
||||||
// + " <AssociatedDocumentLineDocument>\n"
|
// + " <AssociatedDocumentLineDocument>\n"
|
||||||
// + " <IncludedNote>\n"
|
// + " <IncludedNote>\n"
|
||||||
@@ -356,61 +408,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
// + " </IncludedSupplyChainTradeLineItem>\n";
|
// + " </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:SupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
||||||
}
|
+ "</rsm:CrossIndustryInvoice>"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
xml=xml + " </rsm:SpecifiedSupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
|
||||||
+ "</rsm:CrossIndustryDocument>"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
byte[] zugferdRaw;
|
byte[] zugferdRaw;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -33,15 +33,14 @@ import org.xml.sax.SAXException;
|
|||||||
|
|
||||||
public class ZUGFeRDImporter {
|
public class ZUGFeRDImporter {
|
||||||
/*
|
/*
|
||||||
call extract(importFilename).
|
* call extract(importFilename). containsMeta() will return if ZUGFeRD data has
|
||||||
containsMeta() will return if ZUGFeRD data has been found,
|
* been found, afterwards you can call getBIC(), getIBAN() etc.
|
||||||
afterwards you can call getBIC(), getIBAN() etc.
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
*/
|
/** @var if metadata has been found */
|
||||||
|
private boolean containsMeta = false;
|
||||||
/**@var if metadata has been found */
|
/** @var the reference (i.e. invoice number) of the sender */
|
||||||
private boolean containsMeta=false;
|
|
||||||
/**@var the reference (i.e. invoice number) of the sender */
|
|
||||||
private String foreignReference;
|
private String foreignReference;
|
||||||
private String BIC;
|
private String BIC;
|
||||||
private String IBAN;
|
private String IBAN;
|
||||||
@@ -49,12 +48,11 @@ public class ZUGFeRDImporter {
|
|||||||
private String amount;
|
private String amount;
|
||||||
private String dueDate;
|
private String dueDate;
|
||||||
/** Raw XML form of the extracted data - may be directly obtained. */
|
/** Raw XML form of the extracted data - may be directly obtained. */
|
||||||
private byte[] rawXML=null;
|
private byte[] rawXML = null;
|
||||||
private String bankName;
|
private String bankName;
|
||||||
private boolean amountFound;
|
private boolean amountFound;
|
||||||
private boolean extracted=false;
|
private boolean extracted = false;
|
||||||
private boolean parsed=false;
|
private boolean parsed = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
||||||
@@ -69,13 +67,13 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts a ZUGFeRD invoice from a PDF document represented by an input stream.
|
* Extracts a ZUGFeRD invoice from a PDF document represented by an input
|
||||||
* Errors are reported via exception handling.
|
* stream. Errors are reported via exception handling.
|
||||||
*/
|
*/
|
||||||
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
||||||
PDEmbeddedFilesNameTreeNode etn;
|
PDEmbeddedFilesNameTreeNode etn;
|
||||||
try (PDDocument doc = PDDocument.load(pdfStream)) {
|
try (PDDocument doc = PDDocument.load(pdfStream)) {
|
||||||
// PDDocumentInformation info = doc.getDocumentInformation();
|
// PDDocumentInformation info = doc.getDocumentInformation();
|
||||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
||||||
etn = names.getEmbeddedFiles();
|
etn = names.getEmbeddedFiles();
|
||||||
if (etn == null) {
|
if (etn == null) {
|
||||||
@@ -86,10 +84,10 @@ public class ZUGFeRDImporter {
|
|||||||
// String filePath = "/tmp/";
|
// String filePath = "/tmp/";
|
||||||
for (String filename : efMap.keySet()) {
|
for (String filename : efMap.keySet()) {
|
||||||
/**
|
/**
|
||||||
* currently (in the release candidate of version 1) only one
|
* currently (in the release candidate of version 1) only one attached file with
|
||||||
* attached file with the name ZUGFeRD-invoice.xml is allowed
|
* the name ZUGFeRD-invoice.xml is allowed
|
||||||
* */
|
*/
|
||||||
if ((filename.equals("ZUGFeRD-invoice.xml")||filename.equals("factur-x.xml"))) { //$NON-NLS-1$
|
if ((filename.equals("ZUGFeRD-invoice.xml") || filename.equals("factur-x.xml"))) { //$NON-NLS-1$
|
||||||
containsMeta = true;
|
containsMeta = true;
|
||||||
|
|
||||||
PDComplexFileSpecification fileSpec = efMap.get(filename);
|
PDComplexFileSpecification fileSpec = efMap.get(filename);
|
||||||
@@ -103,7 +101,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
rawXML = embeddedFile.toByteArray();
|
rawXML = embeddedFile.toByteArray();
|
||||||
setMeta(new String(rawXML));
|
setMeta(new String(rawXML));
|
||||||
extracted=true;
|
extracted = true;
|
||||||
// fos.write(embeddedFile.getByteArray());
|
// fos.write(embeddedFile.getByteArray());
|
||||||
// fos.close();
|
// fos.close();
|
||||||
}
|
}
|
||||||
@@ -121,7 +119,8 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
factory = DocumentBuilderFactory.newInstance();
|
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 {
|
try {
|
||||||
builder = factory.newDocumentBuilder();
|
builder = factory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException ex3) {
|
} catch (ParserConfigurationException ex3) {
|
||||||
@@ -137,179 +136,139 @@ public class ZUGFeRDImporter {
|
|||||||
} catch (IOException ex2) {
|
} catch (IOException ex2) {
|
||||||
ex2.printStackTrace();
|
ex2.printStackTrace();
|
||||||
}
|
}
|
||||||
NodeList ndList ;
|
NodeList ndList;
|
||||||
|
|
||||||
// rootNode = document.getDocumentElement();
|
// rootNode = document.getDocumentElement();
|
||||||
// ApplicableSupplyChainTradeSettlement
|
// ApplicableSupplyChainTradeSettlement
|
||||||
ndList = document.getDocumentElement()
|
ndList = document.getDocumentElement().getElementsByTagNameNS("*", "PaymentReference"); //$NON-NLS-1$
|
||||||
.getElementsByTagNameNS("*","PaymentReference"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||||
.getLength(); bookingIndex++) {
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// if there is a attribute in the tag number:value
|
// if there is a attribute in the tag number:value
|
||||||
|
|
||||||
setForeignReference(booking.getTextContent());
|
setForeignReference(booking.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
ndList = document
|
* ndList = document .getElementsByTagName("GermanBankleitzahlID");
|
||||||
.getElementsByTagName("GermanBankleitzahlID"); //$NON-NLS-1$
|
* //$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>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
ndList = document.getElementsByTagNameNS("*", "PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||||
.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
|
|
||||||
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++) {
|
|
||||||
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// there are many "name" elements, so get the one below
|
// there are many "name" elements, so get the one below
|
||||||
// SellerTradeParty
|
// SellerTradeParty
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
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);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
||||||
setIBAN(detail.getTextContent());
|
setIBAN(detail.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ndList = document.getElementsByTagNameNS("*", "PayeeSpecifiedCreditorFinancialInstitution");// ZF1 //$NON-NLS-1$
|
||||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCICreditorFinancialInstitution");//ZF2 //$NON-NLS-1$
|
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||||
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++) {
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// there are many "name" elements, so get the one below
|
// there are many "name" elements, so get the one below
|
||||||
// SellerTradeParty
|
// SellerTradeParty
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||||
.getLength(); detailIndex++) {
|
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
||||||
setBIC(detail.getTextContent());
|
setBIC(detail.getTextContent());
|
||||||
}
|
}
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
setBankName(detail.getTextContent());
|
setBankName(detail.getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ndList = document.getElementsByTagNameNS("*", "SellerTradeParty"); //$NON-NLS-1$
|
||||||
|
|
||||||
ndList = document.getElementsByTagNameNS("*","SellerCITradeParty"); //ZF2
|
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||||
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++) {
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// there are many "name" elements, so get the one below
|
// there are many "name" elements, so get the one below
|
||||||
// SellerTradeParty
|
// SellerTradeParty
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||||
.getLength(); detailIndex++) {
|
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
setHolder(detail.getTextContent());
|
setHolder(detail.getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ndList = document.getElementsByTagNameNS("*","DuePayableAmount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*", "DuePayableAmount"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||||
.getLength(); bookingIndex++) {
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// if there is a attribute in the tag number:value
|
// if there is a attribute in the tag number:value
|
||||||
amountFound=true;
|
amountFound = true;
|
||||||
setAmount(booking.getTextContent());
|
setAmount(booking.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!amountFound) {
|
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$
|
ndList = document.getElementsByTagNameNS("*", "GrandTotalAmount"); //$NON-NLS-1$
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
|
||||||
.getLength(); bookingIndex++) {
|
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// if there is a attribute in the tag number:value
|
// if there is a attribute in the tag number:value
|
||||||
amountFound=true;
|
amountFound = true;
|
||||||
setAmount(booking.getTextContent());
|
setAmount(booking.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ndList = document.getElementsByTagNameNS("*","SpecifiedTradePaymentTerms"); //$NON-NLS-1$
|
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);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// there are many "name" elements, so get the one below
|
// there are many "name" elements, so get the one below
|
||||||
// SellerTradeParty
|
// SellerTradeParty
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
|
||||||
.getLength(); detailIndex++) {
|
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("DueDateDateTime"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("DueDateDateTime"))) { //$NON-NLS-1$
|
||||||
setDueDate(detail.getTextContent().trim());
|
setDueDate(detail.getTextContent().trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parsed=true;
|
parsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean containsMeta() {
|
public boolean containsMeta() {
|
||||||
return containsMeta;
|
return containsMeta;
|
||||||
}
|
}
|
||||||
@@ -321,14 +280,10 @@ public class ZUGFeRDImporter {
|
|||||||
return foreignReference;
|
return foreignReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setForeignReference(String foreignReference) {
|
private void setForeignReference(String foreignReference) {
|
||||||
this.foreignReference = foreignReference;
|
this.foreignReference = foreignReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getBIC() {
|
public String getBIC() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
@@ -336,24 +291,18 @@ public class ZUGFeRDImporter {
|
|||||||
return BIC;
|
return BIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setBIC(String bic) {
|
private void setBIC(String bic) {
|
||||||
this.BIC = bic;
|
this.BIC = bic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setDueDate(String dueDate) {
|
private void setDueDate(String dueDate) {
|
||||||
this.dueDate = dueDate;
|
this.dueDate = dueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setBankName(String bankname) {
|
private void setBankName(String bankname) {
|
||||||
this.bankName = bankname;
|
this.bankName = bankname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getIBAN() {
|
public String getIBAN() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
@@ -361,7 +310,6 @@ public class ZUGFeRDImporter {
|
|||||||
return IBAN;
|
return IBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getBankName() {
|
public String getBankName() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
@@ -369,38 +317,30 @@ public class ZUGFeRDImporter {
|
|||||||
return bankName;
|
return bankName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setIBAN(String IBAN) {
|
private void setIBAN(String IBAN) {
|
||||||
this.IBAN = IBAN;
|
this.IBAN = IBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getHolder() {
|
public String getHolder() {
|
||||||
if (rawXML==null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
}
|
}
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void setHolder(String holder) {
|
private void setHolder(String holder) {
|
||||||
this.holder = holder;
|
this.holder = holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getAmount() {
|
public String getAmount() {
|
||||||
if (rawXML==null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDueDate() {
|
public String getDueDate() {
|
||||||
if (rawXML==null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use parse() before requesting a value");
|
throw new RuntimeException("use parse() before requesting a value");
|
||||||
}
|
}
|
||||||
return dueDate;
|
return dueDate;
|
||||||
@@ -411,34 +351,34 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMeta(String meta) {
|
public void setMeta(String meta) {
|
||||||
this.rawXML=meta.getBytes();
|
this.rawXML = meta.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMeta() {
|
public String getMeta() {
|
||||||
if (rawXML==null){
|
if (rawXML == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String(rawXML);
|
return new String(rawXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||||
*/
|
*/
|
||||||
public byte[] getRawXML()
|
public byte[] getRawXML() {
|
||||||
{
|
|
||||||
return rawXML;
|
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() {
|
public boolean canParse() {
|
||||||
|
|
||||||
|
// SpecifiedExchangedDocumentContext is in the schema, so a relatively good
|
||||||
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
// indication if zugferd is present - better than just invoice
|
||||||
String meta=getMeta();
|
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())) {
|
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="";
|
String selectedAnswer="";
|
||||||
try {
|
try {
|
||||||
selectedAnswer=buffer.readLine();
|
selectedAnswer=buffer.readLine();
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
@@ -432,7 +434,6 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
String iban = null;
|
String iban = null;
|
||||||
String holder = null;
|
String holder = null;
|
||||||
String ref = null;
|
String ref = null;
|
||||||
|
|
||||||
if (zi.canParse())
|
if (zi.canParse())
|
||||||
{
|
{
|
||||||
zi.parse();
|
zi.parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user