From 1c69f47e9f2aaf3418994554d529300f55f91afd Mon Sep 17 00:00:00 2001 From: Pierre Barke Date: Mon, 12 Aug 2019 13:36:42 +0200 Subject: [PATCH] remove unsed Methode; IssuedDateTime only if not null remove @getBuyerOrderReferencedDocument: not used after merge; only setIssueDateTime if not null to avoid empty tag with NULL value --- .../IZUGFeRDExportableTransaction.java | 40 ++++---- .../ZUGFeRDTransactionModelConverter.java | 92 +++++++++++++------ 2 files changed, 86 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java index 20b18006..ef636764 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java @@ -27,21 +27,23 @@ package org.mustangproject.ZUGFeRD; * */ - import java.math.BigDecimal; import java.util.Date; + import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; public interface IZUGFeRDExportableTransaction { /** * appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name + * * @return Name of document */ default String getDocumentName() { return "RECHNUNG"; } + /** * * @@ -93,6 +95,7 @@ public interface IZUGFeRDExportableTransaction { return null; } + /** * who processed the order * @@ -125,7 +128,7 @@ public interface IZUGFeRDExportableTransaction { /** * the creditors payment informations - * + * * @return an array of IZUGFeRDTradeSettlementPayment */ IZUGFeRDTradeSettlementPayment[] getTradeSettlementPayment(); @@ -248,15 +251,6 @@ public interface IZUGFeRDExportableTransaction { return null; } - /** - * get reference number of the purchase order this invoice is based on - * - * @return the ID of the purchase order this document refers to - */ - default String getOrderReferenceNumber() { - return null; - } - /** * consignee identification (identification of the organisation the goods are shipped to [assigned by the costumer]) @@ -317,23 +311,33 @@ public interface IZUGFeRDExportableTransaction { return null; } + /** * get the ID of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement + * * @return the ID of the document */ - default String getBuyerOrderReferencedDocumentID() { return null; } + default String getBuyerOrderReferencedDocumentID() { + return null; + } + /** * get the issue timestamp of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement + * * @return the IssueDateTime in format CCYY-MM-DDTHH:MM:SS */ - default String getBuyerOrderReferencedDocumentIssueDateTime() { return null; } + default String getBuyerOrderReferencedDocumentIssueDateTime() { + return null; + } + /** - * get the TotalPrepaidAmount located in SpecifiedTradeSettlementMonetarySummation (v1) or - * SpecifiedTradeSettlementHeaderMonetarySummation (v2) - * @return the total sum (incl. VAT) of prepayments, i.e. the difference between GrandTotalAmount - * and DuePayableAmount + * get the TotalPrepaidAmount located in SpecifiedTradeSettlementMonetarySummation (v1) or SpecifiedTradeSettlementHeaderMonetarySummation (v2) + * + * @return the total sum (incl. VAT) of prepayments, i.e. the difference between GrandTotalAmount and DuePayableAmount */ - default BigDecimal getTotalPrepaidAmount() { return BigDecimal.ZERO; } + default BigDecimal getTotalPrepaidAmount() { + return BigDecimal.ZERO; + } } diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java index d4172098..17331cac 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java @@ -20,17 +20,59 @@ package org.mustangproject.ZUGFeRD; import java.math.BigDecimal; import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import javax.xml.bind.JAXBElement; -import org.mustangproject.ZUGFeRD.model.*; + +import org.mustangproject.ZUGFeRD.model.AmountType; +import org.mustangproject.ZUGFeRD.model.CodeType; +import org.mustangproject.ZUGFeRD.model.CountryIDType; +import org.mustangproject.ZUGFeRD.model.CreditorFinancialAccountType; +import org.mustangproject.ZUGFeRD.model.CreditorFinancialInstitutionType; +import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType; +import org.mustangproject.ZUGFeRD.model.DateTimeType; +import org.mustangproject.ZUGFeRD.model.DateTimeTypeConstants; +import org.mustangproject.ZUGFeRD.model.DocumentCodeType; +import org.mustangproject.ZUGFeRD.model.DocumentContextParameterType; +import org.mustangproject.ZUGFeRD.model.DocumentLineDocumentType; +import org.mustangproject.ZUGFeRD.model.ExchangedDocumentContextType; +import org.mustangproject.ZUGFeRD.model.ExchangedDocumentType; +import org.mustangproject.ZUGFeRD.model.IDType; +import org.mustangproject.ZUGFeRD.model.IndicatorType; +import org.mustangproject.ZUGFeRD.model.LogisticsServiceChargeType; +import org.mustangproject.ZUGFeRD.model.NoteType; +import org.mustangproject.ZUGFeRD.model.NoteTypeConstants; +import org.mustangproject.ZUGFeRD.model.ObjectFactory; +import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeType; +import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeTypeConstants; +import org.mustangproject.ZUGFeRD.model.PercentType; +import org.mustangproject.ZUGFeRD.model.QuantityType; +import org.mustangproject.ZUGFeRD.model.ReferencedDocumentType; +import org.mustangproject.ZUGFeRD.model.SupplyChainEventType; +import org.mustangproject.ZUGFeRD.model.SupplyChainTradeAgreementType; +import org.mustangproject.ZUGFeRD.model.SupplyChainTradeDeliveryType; +import org.mustangproject.ZUGFeRD.model.SupplyChainTradeLineItemType; +import org.mustangproject.ZUGFeRD.model.SupplyChainTradeSettlementType; +import org.mustangproject.ZUGFeRD.model.SupplyChainTradeTransactionType; +import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeType; +import org.mustangproject.ZUGFeRD.model.TaxRegistrationType; +import org.mustangproject.ZUGFeRD.model.TaxRegistrationTypeConstants; +import org.mustangproject.ZUGFeRD.model.TaxTypeCodeType; +import org.mustangproject.ZUGFeRD.model.TaxTypeCodeTypeConstants; +import org.mustangproject.ZUGFeRD.model.TextType; +import org.mustangproject.ZUGFeRD.model.TradeAddressType; +import org.mustangproject.ZUGFeRD.model.TradeAllowanceChargeType; +import org.mustangproject.ZUGFeRD.model.TradePartyType; +import org.mustangproject.ZUGFeRD.model.TradePaymentTermsType; +import org.mustangproject.ZUGFeRD.model.TradePriceType; +import org.mustangproject.ZUGFeRD.model.TradeProductType; +import org.mustangproject.ZUGFeRD.model.TradeSettlementMonetarySummationType; +import org.mustangproject.ZUGFeRD.model.TradeSettlementPaymentMeansType; +import org.mustangproject.ZUGFeRD.model.TradeTaxType; class ZUGFeRDTransactionModelConverter { private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); @@ -161,7 +203,11 @@ class ZUGFeRDTransactionModelConverter { IDType id = xmlFactory.createIDType(); id.setValue(trans.getBuyerOrderReferencedDocumentID()); refdoc.getID().add(id); - refdoc.setIssueDateTime(trans.getBuyerOrderReferencedDocumentIssueDateTime()); + + if (trans.getBuyerOrderReferencedDocumentIssueDateTime() != null) { + refdoc.setIssueDateTime(trans.getBuyerOrderReferencedDocumentIssueDateTime()); + } + tradeAgreement.getBuyerOrderReferencedDocument().add(refdoc); } @@ -169,21 +215,6 @@ class ZUGFeRDTransactionModelConverter { } - private ReferencedDocumentType getBuyerOrderReferencedDocument() { - if (trans.getOrderReferenceNumber() == null) { - return null; - } - - ReferencedDocumentType buyerOrderReferencedDocument = xmlFactory.createReferencedDocumentType(); - - IDType orderID = xmlFactory.createIDType(); - orderID.setValue(trans.getOrderReferenceNumber()); - buyerOrderReferencedDocument.getID().add(orderID); - - return buyerOrderReferencedDocument; - } - - private TradePartyType getBuyer() { TradePartyType buyerTradeParty = xmlFactory.createTradePartyType(); @@ -888,25 +919,24 @@ class ZUGFeRDTransactionModelConverter { private BigDecimal vatFormat(BigDecimal value) { return value.setScale(2, RoundingMode.HALF_UP); - } + } private BigDecimal currencyFormat(BigDecimal value) { return value.setScale(2, RoundingMode.HALF_UP); - } + } private BigDecimal priceFormat(BigDecimal value) { return value.setScale(4, RoundingMode.HALF_UP); - } + } private BigDecimal quantityFormat(BigDecimal value) { return value.setScale(4, RoundingMode.HALF_UP); - } + } - /** * which taxes have been used with which amounts in this transaction, empty for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable to 19% VAT * (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT) 190 Eur @@ -959,7 +989,8 @@ class ZUGFeRDTransactionModelConverter { VATAmount itemVATAmount = new VATAmount( logisticsServiceCharge.getTotalAmount(), logisticsServiceCharge.getTotalAmount() - .multiply(percent).divide(new BigDecimal(100)), logisticsServiceCharge.getCategoryCode()); + .multiply(percent).divide(new BigDecimal(100)), + logisticsServiceCharge.getCategoryCode()); VATAmount current = hm.get(percent); if (current == null) { hm.put(percent, itemVATAmount); @@ -974,7 +1005,8 @@ class ZUGFeRDTransactionModelConverter { BigDecimal percent = charge.getTaxPercent(); VATAmount itemVATAmount = new VATAmount( charge.getTotalAmount(), charge.getTotalAmount() - .multiply(percent).divide(new BigDecimal(100)), charge.getCategoryCode()); + .multiply(percent).divide(new BigDecimal(100)), + charge.getCategoryCode()); VATAmount current = hm.get(percent); if (current == null) { hm.put(percent, itemVATAmount); @@ -993,6 +1025,7 @@ class ZUGFeRDTransactionModelConverter { return this; } + public ZUGFeRDTransactionModelConverter withProfile(String profile) { this.profile = profile; return this; @@ -1065,7 +1098,10 @@ class ZUGFeRDTransactionModelConverter { return itemNetAmount; } - public String getCategoryCode() { return categoryCode; } + + public String getCategoryCode() { + return categoryCode; + } }