switched IZUGFeRDExportableContact to default-Methods; added
ShipToTradeParty: if the merchandies is not shipped to the same address as stated in the invoide; added BuyerOrderReferencedDocument: the ID of the purchase order the invoice ist based on
This commit is contained in:
@@ -44,7 +44,9 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return First and last name of the recipient
|
* @return First and last name of the recipient
|
||||||
*/
|
*/
|
||||||
String getName();
|
default String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +54,9 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return Postal code of the recipient
|
* @return Postal code of the recipient
|
||||||
*/
|
*/
|
||||||
String getZIP();
|
default String getZIP() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +64,9 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
||||||
*/
|
*/
|
||||||
String getVATID();
|
default String getVATID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +74,9 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return two-letter iso country code of the contact
|
* @return two-letter iso country code of the contact
|
||||||
*/
|
*/
|
||||||
String getCountry();
|
default String getCountry() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +84,9 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return Returns the city of the recipient
|
* @return Returns the city of the recipient
|
||||||
*/
|
*/
|
||||||
String getLocation();
|
default String getLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,6 +94,8 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*
|
*
|
||||||
* @return street address (street+number) of the contact
|
* @return street address (street+number) of the contact
|
||||||
*/
|
*/
|
||||||
String getStreet();
|
default String getStreet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
|
||||||
public interface IZUGFeRDExportableTransaction {
|
public interface IZUGFeRDExportableTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +42,7 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
return DocumentCodeTypeConstants.INVOICE;
|
return DocumentCodeTypeConstants.INVOICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number, typically invoice number of the invoice
|
* Number, typically invoice number of the invoice
|
||||||
*
|
*
|
||||||
@@ -281,4 +282,74 @@ 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])
|
||||||
|
*
|
||||||
|
* @return the sender's identification
|
||||||
|
*/
|
||||||
|
default String getShipToOrganisationID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* consignee name (name of the organisation the goods are shipped to)
|
||||||
|
*
|
||||||
|
* @return the consignee's organisation name
|
||||||
|
*/
|
||||||
|
default String getShipToOrganisationName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* consignee street address (street of the organisation the goods are shipped to)
|
||||||
|
*
|
||||||
|
* @return consignee street address
|
||||||
|
*/
|
||||||
|
default String getShipToStreet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* consignee street postal code (postal code of the organisation the goods are shipped to)
|
||||||
|
*
|
||||||
|
* @return consignee postal code
|
||||||
|
*/
|
||||||
|
default String getShipToZIP() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* consignee city (city of the organisation the goods are shipped to)
|
||||||
|
*
|
||||||
|
* @return the consignee's city
|
||||||
|
*/
|
||||||
|
default String getShipToLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* consignee two digit country code (country code of the organisation the goods are shipped to)
|
||||||
|
*
|
||||||
|
* @return the consignee's two character country iso code
|
||||||
|
*/
|
||||||
|
default String getShipToCountry() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType;
|
|||||||
import org.mustangproject.ZUGFeRD.model.DateTimeType;
|
import org.mustangproject.ZUGFeRD.model.DateTimeType;
|
||||||
import org.mustangproject.ZUGFeRD.model.DateTimeTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.DateTimeTypeConstants;
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeType;
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeType;
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterType;
|
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterType;
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterTypeConstants;
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentLineDocumentType;
|
import org.mustangproject.ZUGFeRD.model.DocumentLineDocumentType;
|
||||||
@@ -55,6 +54,7 @@ import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeType;
|
|||||||
import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeTypeConstants;
|
||||||
import org.mustangproject.ZUGFeRD.model.PercentType;
|
import org.mustangproject.ZUGFeRD.model.PercentType;
|
||||||
import org.mustangproject.ZUGFeRD.model.QuantityType;
|
import org.mustangproject.ZUGFeRD.model.QuantityType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.ReferencedDocumentType;
|
||||||
import org.mustangproject.ZUGFeRD.model.SupplyChainEventType;
|
import org.mustangproject.ZUGFeRD.model.SupplyChainEventType;
|
||||||
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeAgreementType;
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeAgreementType;
|
||||||
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeDeliveryType;
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeDeliveryType;
|
||||||
@@ -62,7 +62,6 @@ import org.mustangproject.ZUGFeRD.model.SupplyChainTradeLineItemType;
|
|||||||
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeSettlementType;
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeSettlementType;
|
||||||
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeTransactionType;
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeTransactionType;
|
||||||
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeType;
|
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeType;
|
||||||
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants;
|
|
||||||
import org.mustangproject.ZUGFeRD.model.TaxRegistrationType;
|
import org.mustangproject.ZUGFeRD.model.TaxRegistrationType;
|
||||||
import org.mustangproject.ZUGFeRD.model.TaxRegistrationTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.TaxRegistrationTypeConstants;
|
||||||
import org.mustangproject.ZUGFeRD.model.TaxTypeCodeType;
|
import org.mustangproject.ZUGFeRD.model.TaxTypeCodeType;
|
||||||
@@ -201,10 +200,29 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
tradeAgreement.setBuyerTradeParty(getBuyer());
|
tradeAgreement.setBuyerTradeParty(getBuyer());
|
||||||
tradeAgreement.setSellerTradeParty(getSeller());
|
tradeAgreement.setSellerTradeParty(getSeller());
|
||||||
|
|
||||||
|
if (getBuyerOrderReferencedDocument() != null) {
|
||||||
|
tradeAgreement.getBuyerOrderReferencedDocument().add(getBuyerOrderReferencedDocument());
|
||||||
|
}
|
||||||
|
|
||||||
return tradeAgreement;
|
return tradeAgreement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
@@ -308,10 +326,62 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the ship-to party (e.g. in the case of international transactions) or, in the case of virtual goods, the recipient has to be shown separately on an
|
||||||
|
* invoice, then this is done by adding the ShipToTradeParty
|
||||||
|
*/
|
||||||
|
private TradePartyType getShipToParty() {
|
||||||
|
if (trans.getShipToOrganisationName() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TradePartyType shipToParty = xmlFactory.createTradePartyType();
|
||||||
|
|
||||||
|
if (trans.getShipToOrganisationID() != null) {
|
||||||
|
IDType sellerID = xmlFactory.createIDType();
|
||||||
|
sellerID.setValue(trans.getShipToOrganisationID());
|
||||||
|
shipToParty.getID().add(sellerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextType shipToName = xmlFactory.createTextType();
|
||||||
|
shipToName.setValue(trans.getShipToOrganisationName());
|
||||||
|
shipToParty.setName(shipToName);
|
||||||
|
|
||||||
|
if (trans.getShipToLocation() != null) {
|
||||||
|
TradeAddressType shipToAddressType = xmlFactory
|
||||||
|
.createTradeAddressType();
|
||||||
|
TextType shipToCityName = xmlFactory.createTextType();
|
||||||
|
shipToCityName.setValue(trans.getShipToLocation());
|
||||||
|
shipToAddressType.setCityName(shipToCityName);
|
||||||
|
|
||||||
|
CountryIDType shipToCountryId = xmlFactory.createCountryIDType();
|
||||||
|
shipToCountryId.setValue(trans.getShipToCountry());
|
||||||
|
shipToAddressType.setCountryID(shipToCountryId);
|
||||||
|
|
||||||
|
TextType shipToAddress = xmlFactory.createTextType();
|
||||||
|
shipToAddress.setValue(trans.getShipToStreet());
|
||||||
|
shipToAddressType.setLineOne(shipToAddress);
|
||||||
|
|
||||||
|
CodeType shipToPostcode = xmlFactory.createCodeType();
|
||||||
|
shipToPostcode.setValue(trans.getShipToZIP());
|
||||||
|
shipToAddressType.getPostcodeCode().add(shipToPostcode);
|
||||||
|
|
||||||
|
shipToParty.setPostalTradeAddress(shipToAddressType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shipToParty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private SupplyChainTradeDeliveryType getTradeDelivery() {
|
private SupplyChainTradeDeliveryType getTradeDelivery() {
|
||||||
|
|
||||||
SupplyChainTradeDeliveryType tradeDelivery = xmlFactory
|
SupplyChainTradeDeliveryType tradeDelivery = xmlFactory
|
||||||
.createSupplyChainTradeDeliveryType();
|
.createSupplyChainTradeDeliveryType();
|
||||||
|
|
||||||
|
if (getShipToParty() != null) {
|
||||||
|
tradeDelivery.setShipToTradeParty(getShipToParty());
|
||||||
|
}
|
||||||
|
|
||||||
SupplyChainEventType deliveryEvent = xmlFactory
|
SupplyChainEventType deliveryEvent = xmlFactory
|
||||||
.createSupplyChainEventType();
|
.createSupplyChainEventType();
|
||||||
DateTimeType deliveryDate = xmlFactory.createDateTimeType();
|
DateTimeType deliveryDate = xmlFactory.createDateTimeType();
|
||||||
@@ -916,7 +986,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(Boolean itemOnly) {
|
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(Boolean itemOnly) {
|
||||||
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
@@ -938,8 +1008,9 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
BigDecimal percent = headerAllowance.getTaxPercent();
|
BigDecimal percent = headerAllowance.getTaxPercent();
|
||||||
VATAmount itemVATAmount = new VATAmount(
|
VATAmount itemVATAmount = new VATAmount(
|
||||||
headerAllowance.getTotalAmount(), headerAllowance
|
headerAllowance.getTotalAmount(), headerAllowance
|
||||||
.getTotalAmount().multiply(percent)
|
.getTotalAmount().multiply(percent)
|
||||||
.divide(new BigDecimal(100)), trans.getDocumentCode());
|
.divide(new BigDecimal(100)),
|
||||||
|
trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -956,7 +1027,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)), trans.getDocumentCode());
|
.multiply(percent).divide(new BigDecimal(100)),
|
||||||
|
trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -971,7 +1043,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)), trans.getDocumentCode());
|
.multiply(percent).divide(new BigDecimal(100)),
|
||||||
|
trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
|
|||||||
Reference in New Issue
Block a user