diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java index 4704ab4f..289fa0c9 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableContact.java @@ -62,7 +62,9 @@ public interface IZUGFeRDExportableContact { * * @return First and last name of the recipient */ - String getName(); + default String getName() { + return null; + } default String getPhone() { return null; diff --git a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java index 9d3306aa..20b18006 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableTransaction.java @@ -27,10 +27,10 @@ package org.mustangproject.ZUGFeRD; * */ -import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; import java.math.BigDecimal; import java.util.Date; +import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants; public interface IZUGFeRDExportableTransaction { @@ -51,6 +51,7 @@ public interface IZUGFeRDExportableTransaction { return DocumentCodeTypeConstants.INVOICE; } + /** * Number, typically invoice number of the invoice * @@ -247,6 +248,75 @@ 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]) + * + * @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; + } + /** * get the ID of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement * @return the ID of the document diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java index e8ca6841..d4172098 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java @@ -30,7 +30,6 @@ import java.util.HashMap; import java.util.List; import javax.xml.bind.JAXBElement; - import org.mustangproject.ZUGFeRD.model.*; class ZUGFeRDTransactionModelConverter { @@ -170,6 +169,21 @@ 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(); @@ -279,10 +293,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() { SupplyChainTradeDeliveryType tradeDelivery = xmlFactory .createSupplyChainTradeDeliveryType(); + + if (getShipToParty() != null) { + tradeDelivery.setShipToTradeParty(getShipToParty()); + } + SupplyChainEventType deliveryEvent = xmlFactory .createSupplyChainEventType(); DateTimeType deliveryDate = xmlFactory.createDateTimeType(); @@ -852,7 +918,7 @@ class ZUGFeRDTransactionModelConverter { } - private HashMap getVATPercentAmountMap(Boolean itemOnly) { + private HashMap getVATPercentAmountMap(Boolean itemOnly) { HashMap hm = new HashMap<>(); for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) { @@ -874,8 +940,9 @@ class ZUGFeRDTransactionModelConverter { BigDecimal percent = headerAllowance.getTaxPercent(); VATAmount itemVATAmount = new VATAmount( headerAllowance.getTotalAmount(), headerAllowance - .getTotalAmount().multiply(percent) - .divide(new BigDecimal(100)), trans.getDocumentCode()); + .getTotalAmount().multiply(percent) + .divide(new BigDecimal(100)), + trans.getDocumentCode()); VATAmount current = hm.get(percent); if (current == null) { hm.put(percent, itemVATAmount);