improved migration
This commit is contained in:
@@ -87,7 +87,7 @@ public class Toecount {
|
|||||||
printHelp();
|
printHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((directoryName!= null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
|
if (((directoryName != null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
|
||||||
|
|
||||||
StatRun sr = new StatRun();
|
StatRun sr = new StatRun();
|
||||||
if (ignoreFileExt) {
|
if (ignoreFileExt) {
|
||||||
@@ -137,8 +137,7 @@ public class Toecount {
|
|||||||
} else if (combineRequested) {
|
} else if (combineRequested) {
|
||||||
/*
|
/*
|
||||||
* ZUGFeRDExporter ze= new ZUGFeRDExporterFromA1Factory()
|
* ZUGFeRDExporter ze= new ZUGFeRDExporterFromA1Factory()
|
||||||
* .setProducer("toecount")
|
* .setProducer("toecount") .setCreator(System.getProperty("user.name"))
|
||||||
* .setCreator(System.getProperty("user.name"))
|
|
||||||
* .loadFromPDFA1("invoice.pdf");
|
* .loadFromPDFA1("invoice.pdf");
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
@@ -168,58 +167,113 @@ public class Toecount {
|
|||||||
|
|
||||||
} else if (upgradeRequested) {
|
} else if (upgradeRequested) {
|
||||||
try {
|
try {
|
||||||
String xml=new String(Files.readAllBytes(Paths.get("./ZUGFeRD-invoice.xml")),StandardCharsets.UTF_8);
|
String xml = new String(Files.readAllBytes(Paths.get("./ZUGFeRD-invoice.xml")), StandardCharsets.UTF_8);
|
||||||
// todo: attributes may also be in single quotes, this one hardcodedly expects double ones
|
// todo: attributes may also be in single quotes, this one hardcodedly expects
|
||||||
xml=xml.replace("\"urn:ferd:CrossIndustryDocument:invoice:1p0", "\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:13");
|
// double ones
|
||||||
xml=xml.replace("urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12", "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:20");
|
xml = xml.replace("\"urn:ferd:CrossIndustryDocument:invoice:1p0",
|
||||||
xml=xml.replace("urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15", "urn:un:unece:uncefact:data:standard:UnqualifiedDataType:20");
|
"\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:13");
|
||||||
xml=xml.replace("rsm:CrossIndustryDocument", "rsm:CrossIndustryInvoice");
|
xml = xml.replace("urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12",
|
||||||
xml=xml.replace("rsm:SpecifiedExchangedDocumentContext", "rsm:CIExchangedDocumentContext");
|
"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:20");
|
||||||
xml=xml.replace("rsm:HeaderExchangedDocument", "rsm:CIIHExchangedDocument");
|
xml = xml.replace("urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15",
|
||||||
xml=xml.replace("SpecifiedSupplyChainTradeTransaction", "CIIHSupplyChainTradeTransaction");
|
"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:20");
|
||||||
xml=xml.replace("ram:GuidelineSpecifiedDocumentContextParameter", "ram:GuidelineSpecifiedCIDocumentContextParameter");
|
xml = xml.replace("rsm:CrossIndustryDocument", "rsm:CrossIndustryInvoice");
|
||||||
xml=xml.replace("ram:IncludedNote", "ram:IncludedCINote");
|
xml = xml.replace("rsm:SpecifiedExchangedDocumentContext", "rsm:CIExchangedDocumentContext");
|
||||||
xml=xml.replace("ram:ApplicableSupplyChainTradeAgreement", "ram:ApplicableCIIHSupplyChainTradeAgreement");
|
xml = xml.replace("rsm:HeaderExchangedDocument", "rsm:CIIHExchangedDocument");
|
||||||
xml=xml.replace("ram:SellerTradeParty", "ram:SellerCITradeParty");
|
xml = xml.replace("SpecifiedSupplyChainTradeTransaction", "CIIHSupplyChainTradeTransaction");
|
||||||
xml=xml.replace("ram:BuyerTradeParty", "ram:BuyerCITradeParty");
|
xml = xml.replace("ram:GuidelineSpecifiedDocumentContextParameter",
|
||||||
xml=xml.replace("ram:ApplicableSupplyChainTradeDelivery", "ram:ApplicableCIIHSupplyChainTradeDelivery");
|
"ram:GuidelineSpecifiedCIDocumentContextParameter");
|
||||||
xml=xml.replace("ram:ApplicableSupplyChainTradeSettlement", "ram:ApplicableCIIHSupplyChainTradeSettlement");
|
xml = xml.replace("ram:IncludedNote", "ram:IncludedCINote");
|
||||||
xml=xml.replace("ram:IncludedSupplyChainTradeLineItem", "ram:IncludedCIILSupplyChainTradeLineItem");
|
xml = xml.replace("ram:ApplicableSupplyChainTradeAgreement",
|
||||||
xml=xml.replace("ram:AssociatedDocumentLineDocument", "ram:AssociatedCIILDocumentLineDocument");
|
"ram:ApplicableCIIHSupplyChainTradeAgreement");
|
||||||
xml=xml.replace("ram:SpecifiedSupplyChainTradeDelivery", "ram:SpecifiedCIILSupplyChainTradeDelivery");
|
xml = xml.replace("ram:SellerTradeParty", "ram:SellerCITradeParty");
|
||||||
xml=xml.replace("ram:SpecifiedSupplyChainTradeSettlement", "ram:SpecifiedCIILSupplyChainTradeSettlement");
|
xml = xml.replace("ram:BuyerTradeParty", "ram:BuyerCITradeParty");
|
||||||
xml=xml.replace("ram:SpecifiedTradeProduct", "ram:SpecifiedCITradeProduct");
|
xml = xml.replace("ram:ApplicableSupplyChainTradeDelivery",
|
||||||
xml=xml.replace("ram:ActualDeliverySupplyChainEvent", "ram:ActualDeliveryCISupplyChainEvent");
|
"ram:ApplicableCIIHSupplyChainTradeDelivery");
|
||||||
xml=xml.replace("ram:SpecifiedTradeSettlementPaymentMeans", "ram:SpecifiedCITradeSettlementPaymentMeans");
|
xml = xml.replace("ram:ApplicableSupplyChainTradeSettlement",
|
||||||
xml=xml.replace("ram:PayeePartyCreditorFinancialAccount", "ram:PayeePartyCICreditorFinancialAccount");
|
"ram:ApplicableCIIHSupplyChainTradeSettlement");
|
||||||
xml=xml.replace("ram:PayeeSpecifiedCreditorFinancialInstitution", "ram:PayeeSpecifiedCICreditorFinancialInstitution");
|
xml = xml.replace("ram:IncludedSupplyChainTradeLineItem", "ram:IncludedCIILSupplyChainTradeLineItem");
|
||||||
xml=xml.replace("ram:ApplicableTradeTax", "ram:ApplicableCITradeTax");
|
xml = xml.replace("ram:AssociatedDocumentLineDocument", "ram:AssociatedCIILDocumentLineDocument");
|
||||||
xml=xml.replace("ram:ApplicablePercent", "ram:RateApplicablePercent");
|
xml = xml.replace("ram:SpecifiedSupplyChainTradeDelivery", "ram:SpecifiedCIILSupplyChainTradeDelivery");
|
||||||
xml=xml.replace("ram:PostalTradeAddress", "ram:PostalCITradeAddress");
|
xml = xml.replace("ram:SpecifiedSupplyChainTradeSettlement",
|
||||||
xml=xml.replace("ram:SpecifiedTaxRegistration", "ram:SpecifiedCITaxRegistration");
|
"ram:SpecifiedCIILSupplyChainTradeSettlement");
|
||||||
xml=xml.replace("ram:PostalTradeAddress", "ram:PostalCITradeAddress");
|
xml = xml.replace("ram:SpecifiedTradeProduct", "ram:SpecifiedCITradeProduct");
|
||||||
xml=xml.replace("ram:SpecifiedTradePaymentTerms", "ram:SpecifiedCITradePaymentTerms");
|
xml = xml.replace("ram:ActualDeliverySupplyChainEvent", "ram:ActualDeliveryCISupplyChainEvent");
|
||||||
xml=xml.replace("ram:SpecifiedSupplyChainTradeAgreement", "ram:SpecifiedCIILSupplyChainTradeAgreement");
|
xml = xml.replace("ram:SpecifiedTradeSettlementPaymentMeans",
|
||||||
xml=xml.replace("ram:GrossPriceProductTradePrice", "ram:GrossPriceProductCITradePrice");
|
"ram:SpecifiedCITradeSettlementPaymentMeans");
|
||||||
xml=xml.replace("ram:NetPriceProductTradePrice", "ram:NetPriceProductCITradePrice");
|
xml = xml.replace("ram:PayeePartyCreditorFinancialAccount", "ram:PayeePartyCICreditorFinancialAccount");
|
||||||
xml=xml.replaceAll("(?s)\\<ram:TestIndicator.*\\/ram:TestIndicator>", "");
|
xml = xml.replace("ram:PayeeSpecifiedCreditorFinancialInstitution",
|
||||||
//remove manually for the time being: xml=xml.replaceAll("ram:TestIndicator>(.*?)/ram:TestIndicator>", "");
|
"ram:PayeeSpecifiedCICreditorFinancialInstitution");
|
||||||
// one ram:SpecifiedCIILTradeSettlementMonetarySummation will have to be ram:SpecifiedCIIHTradeSettlementMonetarySummation afterwards
|
xml = xml.replace("ram:ApplicableTradeTax", "ram:ApplicableCITradeTax");
|
||||||
|
xml = xml.replace("ram:ApplicablePercent", "ram:RateApplicablePercent");
|
||||||
|
xml = xml.replace("ram:PostalTradeAddress", "ram:PostalCITradeAddress");
|
||||||
|
|
||||||
String summationClose="</ram:SpecifiedTradeSettlementMonetarySummation>";
|
xml = xml.replace("ram:ApplicableTradePaymentDiscountTerms",
|
||||||
int posFirstSummation=xml.indexOf(summationClose)+summationClose.length();
|
"ram:ApplicableCITradePaymentDiscountTerms");
|
||||||
String xmlAfterFirstSummation=xml.substring(posFirstSummation);
|
xml = xml.replace("ram:ApplicableProductCharacteristic", "ram:ApplicableCIProductCharacteristic");
|
||||||
String xmlBeforeIncludingFirstSummation=xml.substring(0, posFirstSummation);
|
xml = xml.replace("ram:ShipToTradeParty", "ram:ShipToCITradeParty");
|
||||||
// replace only once the header
|
xml = xml.replace("ram:ShipFromTradeParty", "ram:ShipFromCITradeParty");
|
||||||
|
xml = xml.replace("ram:ReceivableSpecifiedTradeAccountingAccount",
|
||||||
|
"ram:ReceivableSpecifiedCITradeAccountingAccount");
|
||||||
|
xml = xml.replace("ram:ContractReferencedDocument", "ram:ContractReferencedCIReferencedDocument");
|
||||||
|
// "ram:SpecifiedTradeAccountingAccount ram:SalesSpecifiedTradeAccountingAccount
|
||||||
|
// oder ReceivablesSpecifiedTradeAccountingAccount oder
|
||||||
|
// PurchaseSpecifiedTradeAccountingAccount
|
||||||
|
xml = xml.replace("ram:AdditionalReferencedDocument", "ram:AdditionalReferencedCIReferencedDocument");
|
||||||
|
xml = xml.replace("ram:TelephoneUniversalCommunication", "ram:TelephoneCIUniversalCommunication");
|
||||||
|
xml = xml.replace("ram:EmailURIUniversalCommunication", "ram:EmailURICIUniversalCommunication");
|
||||||
|
xml = xml.replace("ram:AdditionalReferencedDocument", "ram:AdditionalReferencedCIReferencedDocument");
|
||||||
|
xml = xml.replace("ram:IncludedReferencedProduct", "ram:IncludedReferencedProduct");
|
||||||
|
|
||||||
xmlBeforeIncludingFirstSummation=xmlBeforeIncludingFirstSummation.replace ("ram:SpecifiedTradeSettlementMonetarySummation", "ram:SpecifiedCIIHTradeSettlementMonetarySummation");
|
xml = xml.replace("ram:DefinedTradeContact", "ram:DefinedCITradeContact");
|
||||||
xml=xmlBeforeIncludingFirstSummation+xmlAfterFirstSummation;
|
xml = xml.replace("ram:BillingSpecifiedPeriod", "ram:BillingCISpecifiedPeriod");
|
||||||
|
xml = xml.replace("ram:BuyerOrderReferencedDocument", "ram:BuyerOrderReferencedCIReferencedDocument");
|
||||||
|
xml = xml.replace("ram:DeliveryNoteReferencedDocument",
|
||||||
|
"ram:DeliveryNoteReferencedCIReferencedDocument");
|
||||||
|
xml = xml.replace("ram:SpecifiedTradeAllowanceCharge", "ram:SpecifiedCITradeAllowanceCharge");
|
||||||
|
xml = xml.replace("ram:SpecifiedLogisticsServiceCharge", "ram:SpecifiedCILogisticsServiceCharge");
|
||||||
|
xml = xml.replace("ram:AppliedTradeAllowanceCharge", "ram:AppliedCITradeAllowanceCharge");
|
||||||
|
xml = xml.replace("ram:InvoiceeTradeParty", "ram:InvoiceeCITradeParty");
|
||||||
|
xml = xml.replace("ram:CategoryTradeTax", "ram:CategoryCITradeTax");
|
||||||
|
xml = xml.replace("ram:SpecifiedTaxRegistration", "ram:SpecifiedCITaxRegistration");
|
||||||
|
xml = xml.replace("ram:PostalTradeAddress", "ram:PostalCITradeAddress");
|
||||||
|
xml = xml.replace("ram:SpecifiedTradePaymentTerms", "ram:SpecifiedCITradePaymentTerms");
|
||||||
|
xml = xml.replace("ram:SpecifiedSupplyChainTradeAgreement",
|
||||||
|
"ram:SpecifiedCIILSupplyChainTradeAgreement");
|
||||||
|
xml = xml.replace("ram:GrossPriceProductTradePrice", "ram:GrossPriceProductCITradePrice");
|
||||||
|
xml = xml.replace("ram:NetPriceProductTradePrice", "ram:NetPriceProductCITradePrice");
|
||||||
|
xml = xml.replaceAll("(?s)\\<ram:TestIndicator.*\\/ram:TestIndicator>", "");
|
||||||
|
// remove manually for the time being:
|
||||||
|
// xml=xml.replaceAll("ram:TestIndicator>(.*?)/ram:TestIndicator>", "");
|
||||||
|
// one ram:SpecifiedCIILTradeSettlementMonetarySummation will have to be
|
||||||
|
// ram:SpecifiedCIIHTradeSettlementMonetarySummation afterwards
|
||||||
|
|
||||||
xml=xml.replace ("ram:SpecifiedTradeSettlementMonetarySummation", "ram:SpecifiedCIILTradeSettlementMonetarySummation");
|
String summationClose = "</ram:SpecifiedTradeSettlementMonetarySummation>";
|
||||||
|
int posFirstSummation = xml.indexOf(summationClose) + summationClose.length();
|
||||||
|
// if ram:SpecifiedTradeSettlementMonetarySummation were not found indexOf would
|
||||||
|
// return -1, therefore,
|
||||||
|
// to check if it
|
||||||
|
if (posFirstSummation > summationClose.length()) {
|
||||||
|
String xmlAfterFirstSummation = xml.substring(posFirstSummation);
|
||||||
|
String xmlBeforeIncludingFirstSummation = xml.substring(0, posFirstSummation);
|
||||||
|
// replace only once the header
|
||||||
|
|
||||||
// the rest of the ram:SpecifiedTradeSettlementMonetarySummation should be in ram:ApplicableSupplyChainTradeSettlement
|
xmlBeforeIncludingFirstSummation = xmlBeforeIncludingFirstSummation.replace(
|
||||||
//xml=xml.replaceAll(Pattern.quote("ram:SpecifiedTradeSettlementMonetarySummation"), "ram:SpecifiedCIILTradeSettlementMonetarySummation");
|
"ram:SpecifiedTradeSettlementMonetarySummation",
|
||||||
|
"ram:SpecifiedCIIHTradeSettlementMonetarySummation");
|
||||||
|
// reconstruct the document now with a replaced first
|
||||||
|
// ram:SpecifiedTradeSettlementMonetarySummation to SpecifiedCIIH...
|
||||||
|
xml = xmlBeforeIncludingFirstSummation + xmlAfterFirstSummation;
|
||||||
|
|
||||||
|
}
|
||||||
|
// replace the rest of the ram:SpecifiedTradeSettlementMonetarySummation with
|
||||||
|
// the line value SpecifiedCIIL...
|
||||||
|
xml = xml.replace("ram:SpecifiedTradeSettlementMonetarySummation",
|
||||||
|
"ram:SpecifiedCIILTradeSettlementMonetarySummation");
|
||||||
|
|
||||||
|
// the rest of the ram:SpecifiedTradeSettlementMonetarySummation should be in
|
||||||
|
// ram:ApplicableSupplyChainTradeSettlement
|
||||||
|
// xml=xml.replaceAll(Pattern.quote("ram:SpecifiedTradeSettlementMonetarySummation"),
|
||||||
|
// "ram:SpecifiedCIILTradeSettlementMonetarySummation");
|
||||||
|
|
||||||
Files.write(Paths.get("./ZUGFeRD-2-invoice.xml"), xml.getBytes());
|
Files.write(Paths.get("./ZUGFeRD-2-invoice.xml"), xml.getBytes());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user