corrected possible exceptions
This commit is contained in:
@@ -23,9 +23,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Product implements IZUGFeRDExportableProduct {
|
public class Product implements IZUGFeRDExportableProduct {
|
||||||
protected String unit, name, sellerAssignedID, buyerAssignedID;
|
protected String unit, name, sellerAssignedID, buyerAssignedID;
|
||||||
protected String description="";
|
protected String description = "";
|
||||||
protected String taxExemptionReason=null;
|
protected String taxExemptionReason = null;
|
||||||
protected String taxCategoryCode=null;
|
protected String taxCategoryCode = null;
|
||||||
protected BigDecimal VATPercent;
|
protected BigDecimal VATPercent;
|
||||||
protected boolean isReverseCharge = false;
|
protected boolean isReverseCharge = false;
|
||||||
protected boolean isIntraCommunitySupply = false;
|
protected boolean isIntraCommunitySupply = false;
|
||||||
@@ -61,8 +61,6 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID);
|
nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID);
|
||||||
nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID);
|
nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID);
|
||||||
nodeMap.getAsString("Name").ifPresent(this::setName);
|
nodeMap.getAsString("Name").ifPresent(this::setName);
|
||||||
@@ -155,7 +153,7 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
* @param taxExemptionReasonText String e.g. Kleinunternehmer gemäß §19 UStG https://github.com/ZUGFeRD/mustangproject/issues/463
|
* @param taxExemptionReasonText String e.g. Kleinunternehmer gemäß §19 UStG https://github.com/ZUGFeRD/mustangproject/issues/463
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
public Product setTaxExemptionReason(String taxExemptionReasonText) {
|
public Product setTaxExemptionReason(String taxExemptionReasonText) {
|
||||||
taxExemptionReason = taxExemptionReasonText;
|
taxExemptionReason = taxExemptionReasonText;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -177,7 +175,7 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
* @param code e.g. S (normal tax), Z=zero rated, E (e.g. small business) or K (intrra community supply) see also https://github.com/ZUGFeRD/mustangproject/issues/463
|
* @param code e.g. S (normal tax), Z=zero rated, E (e.g. small business) or K (intrra community supply) see also https://github.com/ZUGFeRD/mustangproject/issues/463
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
public Product setTaxCategoryCode(String code) {
|
public Product setTaxCategoryCode(String code) {
|
||||||
taxCategoryCode = code;
|
taxCategoryCode = code;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -304,18 +302,22 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
public Product setVATPercent(BigDecimal VATPercent) {
|
public Product setVATPercent(BigDecimal VATPercent) {
|
||||||
this.VATPercent = VATPercent;
|
if (VATPercent == null) {
|
||||||
|
this.VATPercent = BigDecimal.ZERO;
|
||||||
|
} else {
|
||||||
|
this.VATPercent = VATPercent;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCountryOfOrigin() {
|
public String getCountryOfOrigin() {
|
||||||
return this.countryOfOrigin;
|
return this.countryOfOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product setCountryOfOrigin(String countryOfOrigin) {
|
public Product setCountryOfOrigin(String countryOfOrigin) {
|
||||||
this.countryOfOrigin = countryOfOrigin;
|
this.countryOfOrigin = countryOfOrigin;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -328,16 +330,16 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Product setAttributes(Map<String, String> attributes) {
|
public Product setAttributes(Map<String, String> attributes) {
|
||||||
this.attributes.clear();
|
this.attributes.clear();
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
this.attributes.putAll(attributes);
|
this.attributes.putAll(attributes);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product addAttribute(String name, String value ) {
|
public Product addAttribute(String name, String value) {
|
||||||
this.attributes.put(name, value);
|
this.attributes.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,7 +44,13 @@ public class LineCalculator {
|
|||||||
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100));
|
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100));
|
||||||
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
||||||
price = priceGross.subtract(allowance).add(charge);
|
price = priceGross.subtract(allowance).add(charge);
|
||||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity(), 18, RoundingMode.HALF_UP)
|
|
||||||
|
BigDecimal quantity=BigDecimal.ZERO;
|
||||||
|
if ((currentItem!=null)&&(currentItem.getQuantity()!=null)) {
|
||||||
|
quantity=currentItem.getQuantity();
|
||||||
|
}
|
||||||
|
|
||||||
|
itemTotalNetAmount = quantity.multiply(getPrice()).divide(currentItem.getBasisQuantity(), 18, RoundingMode.HALF_UP)
|
||||||
.subtract(allowanceItemTotal).setScale(2, RoundingMode.HALF_UP);
|
.subtract(allowanceItemTotal).setScale(2, RoundingMode.HALF_UP);
|
||||||
itemTotalVATAmount = itemTotalNetAmount.multiply(multiplicator);
|
itemTotalVATAmount = itemTotalNetAmount.multiply(multiplicator);
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,11 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
final String vatDueDateTypeCode = trans.getVATDueDateTypeCode();
|
final String vatDueDateTypeCode = trans.getVATDueDateTypeCode();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
BigDecimal percent = null;
|
||||||
|
if (currentItem.getProduct()!=null)
|
||||||
|
{
|
||||||
|
percent=currentItem.getProduct().getVATPercent();
|
||||||
|
}
|
||||||
if (percent != null) {
|
if (percent != null) {
|
||||||
LineCalculator lc = new LineCalculator(currentItem);
|
LineCalculator lc = new LineCalculator(currentItem);
|
||||||
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
|
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
|
||||||
|
|||||||
@@ -556,7 +556,10 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
// UBL...
|
// UBL...
|
||||||
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
||||||
typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
|
typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
|
||||||
issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim());
|
String issueDateStr = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim();
|
||||||
|
if (issueDateStr.length()>0) {
|
||||||
|
issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr);
|
||||||
|
}
|
||||||
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
|
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
|
||||||
if (dueDt.length() > 0) {
|
if (dueDt.length() > 0) {
|
||||||
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
|
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
|
||||||
@@ -775,7 +778,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate).setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number).setDocumentCode(typeCode);
|
zpp.setIssueDate(issueDate).setDueDate(dueDate).setDeliveryDate(deliveryDate).setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number).setDocumentCode(typeCode);
|
||||||
|
|
||||||
if ((directDebitMandateID != null) && (IBAN != null)) {
|
if ((directDebitMandateID != null) && (IBAN != null)) {
|
||||||
DirectDebit d = new DirectDebit(IBAN, directDebitMandateID);
|
DirectDebit d = new DirectDebit(IBAN, directDebitMandateID);
|
||||||
|
|||||||
Reference in New Issue
Block a user