Merge pull request #130 from CSSAG/master

IZUGFeRDExportableContact to default-Methods; added ShipToTradeParty and BuyerOrderReferencedDocument
This commit is contained in:
Jochen Staerk
2019-08-12 13:18:22 +02:00
committed by GitHub
3 changed files with 145 additions and 6 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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();
@@ -875,7 +941,8 @@ class ZUGFeRDTransactionModelConverter {
VATAmount itemVATAmount = new VATAmount(
headerAllowance.getTotalAmount(), headerAllowance
.getTotalAmount().multiply(percent)
.divide(new BigDecimal(100)), trans.getDocumentCode());
.divide(new BigDecimal(100)),
trans.getDocumentCode());
VATAmount current = hm.get(percent);
if (current == null) {
hm.put(percent, itemVATAmount);