some work on schemedids, including class

This commit is contained in:
jstaerk
2022-07-25 11:48:21 +02:00
parent 66ab7b549c
commit 83f4b710fb
9 changed files with 328 additions and 11 deletions

View File

@@ -12,8 +12,9 @@ import java.math.BigDecimal;
public class Product implements IZUGFeRDExportableProduct {
protected String unit, name, description, sellerAssignedID, buyerAssignedID;
protected BigDecimal VATPercent;
protected boolean isReverseCharge=false;
protected boolean isIntraCommunitySupply=false;
protected boolean isReverseCharge = false;
protected boolean isIntraCommunitySupply = false;
protected SchemedID globalId = null;
/***
* default constructor
@@ -38,6 +39,29 @@ public class Product implements IZUGFeRDExportableProduct {
}
@Override
public String getGlobalID() {
if (globalId == null) {
return null;
} else {
return globalId.getID();
}
}
@Override
public String getGlobalIDScheme() {
if (globalId == null) {
return null;
} else {
return globalId.getScheme();
}
}
public Product addGlobalID(SchemedID schemedID) {
globalId = schemedID;
return this;
}
public String getSellerAssignedID() {
return sellerAssignedID;
@@ -82,7 +106,7 @@ public class Product implements IZUGFeRDExportableProduct {
* @return fluent setter
*/
public Product setReverseCharge() {
isReverseCharge=true;
isReverseCharge = true;
setVATPercent(BigDecimal.ZERO);
return this;
}
@@ -93,7 +117,7 @@ public class Product implements IZUGFeRDExportableProduct {
* @return fluent setter
*/
public Product setIntraCommunitySupply() {
isIntraCommunitySupply=true;
isIntraCommunitySupply = true;
setVATPercent(BigDecimal.ZERO);
return this;
}
@@ -120,6 +144,7 @@ public class Product implements IZUGFeRDExportableProduct {
/**
* name of the product
*
* @param name short name
* @return fluent setter
*/
@@ -135,6 +160,7 @@ public class Product implements IZUGFeRDExportableProduct {
/**
* description of the product (required)
*
* @param description long name
* @return fluent setter
*/

View File

@@ -0,0 +1,34 @@
package org.mustangproject;
public class SchemedID {
protected String scheme;
protected String id;
public String getScheme() {
return scheme;
}
public SchemedID setScheme(String scheme) {
this.scheme = scheme;
return this;
}
public String getID() {
return id;
}
public SchemedID setId(String id) {
this.id = id;
return this;
}
public SchemedID() {
}
public SchemedID(String scheme, String id) {
setScheme(scheme);
setId(id);
}
}

View File

@@ -24,6 +24,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
protected List<IZUGFeRDTradeSettlementDebit> debitDetails = new ArrayList<>();
protected Contact contact = null;
protected LegalOrganisation legalOrg = null;
protected SchemedID globalId=null;
/**
* Default constructor.
@@ -150,6 +151,26 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
return ID;
}
@Override
public String getGlobalID() {
if (globalId!=null) {
return globalId.getID();
}
return null;
}
@Override
public String getGlobalIDScheme() {
if (globalId!=null) {
return globalId.getScheme();
}
return null;
}
/**
* if it's a customer, this can e.g. be the customer ID
*
@@ -172,6 +193,11 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
return this;
}
public TradeParty addGlobalID(SchemedID schemedID) {
globalId=schemedID;
return this;
}
/***
* required (for senders, if payment is not debit): the BIC and IBAN
* @param s bank credentials

View File

@@ -128,6 +128,26 @@ public interface IZUGFeRDExportableProduct {
}
}
/**
* customer global identification assigned by the seller
*
* @return customer identification
*/
default String getGlobalID() {
return null;
}
/**
* customer global identification scheme
*
* @return customer identification
*/
default String getGlobalIDScheme() {
return null;
}
default String getTaxExemptionReason() {
if (isIntraCommunitySupply()) {
return "Intra-community supply";

View File

@@ -359,7 +359,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ "</ram:AssociatedDocumentLineDocument>"
+ "<ram:SpecifiedTradeProduct>";
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>"
if ((currentItem.getProduct().getGlobalIDScheme() != null) && (currentItem.getProduct().getGlobalID() != null)) {
xml += "<ram:GlobalID schemeID=\""+XMLTools.encodeXML(currentItem.getProduct().getGlobalIDScheme())+"\">"+XMLTools.encodeXML(currentItem.getProduct().getGlobalID())+"</ram:GlobalID>";
}
if (currentItem.getProduct().getSellerAssignedID() != null) {
xml += "<ram:SellerAssignedID>"
+ XMLTools.encodeXML(currentItem.getProduct().getSellerAssignedID()) + "</ram:SellerAssignedID>";