Merge branch 'ZUGFeRD:master' into master
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
595
|
||||||
|
591
|
||||||
|
577
|
||||||
|
575
|
||||||
|
573
|
||||||
|
601
|
||||||
|
|
||||||
2.15.1
|
2.15.1
|
||||||
=======
|
=======
|
||||||
- #566 Failed to parse PDF - Could not reproduce the invoice
|
- #566 Failed to parse PDF - Could not reproduce the invoice
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ public class FileChecker {
|
|||||||
if ((!isPDF) && (!thisRun.shallIgnoreFileExt())) {
|
if ((!isPDF) && (!thisRun.shallIgnoreFileExt())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(filename);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
|
zi.doIgnoreCalculationErrors();
|
||||||
|
zi.setPDFFilename(filename);
|
||||||
try {
|
try {
|
||||||
if (zi.canParse()) {
|
if (zi.canParse()) {
|
||||||
thisRun.incZUGFeRDCount(zi.getVersion());
|
thisRun.incZUGFeRDCount(zi.getVersion());
|
||||||
|
|||||||
@@ -72,11 +72,6 @@ public class IncludedNote {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IncludedNote setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubjectCode getSubjectCode() {
|
public SubjectCode getSubjectCode() {
|
||||||
return subjectCode;
|
return subjectCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -304,7 +302,11 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
public Product setVATPercent(BigDecimal VATPercent) {
|
public Product setVATPercent(BigDecimal VATPercent) {
|
||||||
|
if (VATPercent == null) {
|
||||||
|
this.VATPercent = BigDecimal.ZERO;
|
||||||
|
} else {
|
||||||
this.VATPercent = VATPercent;
|
this.VATPercent = VATPercent;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,18 @@ 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);
|
||||||
|
|
||||||
|
BigDecimal quantity=BigDecimal.ZERO;
|
||||||
|
if ((currentItem!=null)&&(currentItem.getQuantity()!=null)) {
|
||||||
|
quantity=currentItem.getQuantity();
|
||||||
|
}
|
||||||
|
|
||||||
// Division/Zero occurred here.
|
// Division/Zero occurred here.
|
||||||
// Used the setScale only because that's also done in getBasisQuantity
|
// Used the setScale only because that's also done in getBasisQuantity
|
||||||
BigDecimal basisQuantity = currentItem.getBasisQuantity().compareTo(BigDecimal.ZERO) == 0
|
BigDecimal basisQuantity = currentItem.getBasisQuantity().compareTo(BigDecimal.ZERO) == 0
|
||||||
? BigDecimal.ONE.setScale(4)
|
? BigDecimal.ONE.setScale(4)
|
||||||
: currentItem.getBasisQuantity();
|
: currentItem.getBasisQuantity();
|
||||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(basisQuantity, 18, RoundingMode.HALF_UP)
|
itemTotalNetAmount = quantity.multiply(getPrice()).divide(basisQuantity, 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(),
|
||||||
|
|||||||
@@ -558,7 +558,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);
|
||||||
@@ -777,7 +780,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);
|
||||||
|
|||||||
@@ -106,7 +106,14 @@ public class NodeMap {
|
|||||||
* @return the text content of the matching node, converted to BigDecimal
|
* @return the text content of the matching node, converted to BigDecimal
|
||||||
*/
|
*/
|
||||||
public Optional<BigDecimal> getAsBigDecimal(String... localNames) {
|
public Optional<BigDecimal> getAsBigDecimal(String... localNames) {
|
||||||
return getNode(localNames).map(Node::getTextContent).map(s->new BigDecimal(s.trim()));
|
return getNode(localNames).map(Node::getTextContent).map(s->{
|
||||||
|
try {
|
||||||
|
return new BigDecimal(s.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user