Merge pull request #131 from CSSAG/master

removed unsed Methode; IssuedDateTime only if not null
This commit is contained in:
Jochen Staerk
2019-08-27 03:47:39 +02:00
committed by GitHub
2 changed files with 86 additions and 46 deletions

View File

@@ -27,21 +27,23 @@ package org.mustangproject.ZUGFeRD;
* */ * */
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
public interface IZUGFeRDExportableTransaction { public interface IZUGFeRDExportableTransaction {
/** /**
* appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name * appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name
*
* @return Name of document * @return Name of document
*/ */
default String getDocumentName() { default String getDocumentName() {
return "RECHNUNG"; return "RECHNUNG";
} }
/** /**
* *
* *
@@ -93,6 +95,7 @@ public interface IZUGFeRDExportableTransaction {
return null; return null;
} }
/** /**
* who processed the order * who processed the order
* *
@@ -125,7 +128,7 @@ public interface IZUGFeRDExportableTransaction {
/** /**
* the creditors payment informations * the creditors payment informations
* *
* @return an array of IZUGFeRDTradeSettlementPayment * @return an array of IZUGFeRDTradeSettlementPayment
*/ */
IZUGFeRDTradeSettlementPayment[] getTradeSettlementPayment(); IZUGFeRDTradeSettlementPayment[] getTradeSettlementPayment();
@@ -248,15 +251,6 @@ public interface IZUGFeRDExportableTransaction {
return null; 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]) * consignee identification (identification of the organisation the goods are shipped to [assigned by the costumer])
@@ -317,23 +311,33 @@ public interface IZUGFeRDExportableTransaction {
return null; return null;
} }
/** /**
* get the ID of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement * get the ID of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement
*
* @return the ID of the document * @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 * get the issue timestamp of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement
*
* @return the IssueDateTime in format CCYY-MM-DDTHH:MM:SS * @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 * get the TotalPrepaidAmount located in SpecifiedTradeSettlementMonetarySummation (v1) or SpecifiedTradeSettlementHeaderMonetarySummation (v2)
* SpecifiedTradeSettlementHeaderMonetarySummation (v2) *
* @return the total sum (incl. VAT) of prepayments, i.e. the difference between GrandTotalAmount * @return the total sum (incl. VAT) of prepayments, i.e. the difference between GrandTotalAmount and DuePayableAmount
* and DuePayableAmount
*/ */
default BigDecimal getTotalPrepaidAmount() { return BigDecimal.ZERO; } default BigDecimal getTotalPrepaidAmount() {
return BigDecimal.ZERO;
}
} }

View File

@@ -20,17 +20,59 @@ package org.mustangproject.ZUGFeRD;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import javax.xml.bind.JAXBElement; 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 { class ZUGFeRDTransactionModelConverter {
private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
@@ -161,7 +203,11 @@ class ZUGFeRDTransactionModelConverter {
IDType id = xmlFactory.createIDType(); IDType id = xmlFactory.createIDType();
id.setValue(trans.getBuyerOrderReferencedDocumentID()); id.setValue(trans.getBuyerOrderReferencedDocumentID());
refdoc.getID().add(id); refdoc.getID().add(id);
refdoc.setIssueDateTime(trans.getBuyerOrderReferencedDocumentIssueDateTime());
if (trans.getBuyerOrderReferencedDocumentIssueDateTime() != null) {
refdoc.setIssueDateTime(trans.getBuyerOrderReferencedDocumentIssueDateTime());
}
tradeAgreement.getBuyerOrderReferencedDocument().add(refdoc); 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() { private TradePartyType getBuyer() {
TradePartyType buyerTradeParty = xmlFactory.createTradePartyType(); TradePartyType buyerTradeParty = xmlFactory.createTradePartyType();
@@ -888,25 +919,24 @@ class ZUGFeRDTransactionModelConverter {
private BigDecimal vatFormat(BigDecimal value) { private BigDecimal vatFormat(BigDecimal value) {
return value.setScale(2, RoundingMode.HALF_UP); return value.setScale(2, RoundingMode.HALF_UP);
} }
private BigDecimal currencyFormat(BigDecimal value) { private BigDecimal currencyFormat(BigDecimal value) {
return value.setScale(2, RoundingMode.HALF_UP); return value.setScale(2, RoundingMode.HALF_UP);
} }
private BigDecimal priceFormat(BigDecimal value) { private BigDecimal priceFormat(BigDecimal value) {
return value.setScale(4, RoundingMode.HALF_UP); return value.setScale(4, RoundingMode.HALF_UP);
} }
private BigDecimal quantityFormat(BigDecimal value) { private BigDecimal quantityFormat(BigDecimal value) {
return value.setScale(4, RoundingMode.HALF_UP); 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 * 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 * (=>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( VATAmount itemVATAmount = new VATAmount(
logisticsServiceCharge.getTotalAmount(), logisticsServiceCharge.getTotalAmount(),
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); VATAmount current = hm.get(percent);
if (current == null) { if (current == null) {
hm.put(percent, itemVATAmount); hm.put(percent, itemVATAmount);
@@ -974,7 +1005,8 @@ class ZUGFeRDTransactionModelConverter {
BigDecimal percent = charge.getTaxPercent(); BigDecimal percent = charge.getTaxPercent();
VATAmount itemVATAmount = new VATAmount( VATAmount itemVATAmount = new VATAmount(
charge.getTotalAmount(), charge.getTotalAmount() 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); VATAmount current = hm.get(percent);
if (current == null) { if (current == null) {
hm.put(percent, itemVATAmount); hm.put(percent, itemVATAmount);
@@ -993,6 +1025,7 @@ class ZUGFeRDTransactionModelConverter {
return this; return this;
} }
public ZUGFeRDTransactionModelConverter withProfile(String profile) { public ZUGFeRDTransactionModelConverter withProfile(String profile) {
this.profile = profile; this.profile = profile;
return this; return this;
@@ -1065,7 +1098,10 @@ class ZUGFeRDTransactionModelConverter {
return itemNetAmount; return itemNetAmount;
} }
public String getCategoryCode() { return categoryCode; }
public String getCategoryCode() {
return categoryCode;
}
} }