From 08bae5f01ba87a0811d94b9c17c07080c778bc5b Mon Sep 17 00:00:00 2001 From: AlexanderSchmidt Date: Fri, 20 Nov 2015 11:40:04 +0100 Subject: [PATCH] fix item calc in case allowance and charges are null --- .../org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java b/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java index 350e2edf..d200b757 100644 --- a/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java +++ b/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java @@ -87,12 +87,16 @@ public class ZUGFeRDExporter { BigDecimal totalAllowance = BigDecimal.ZERO; BigDecimal totalCharge = BigDecimal.ZERO; - for(IZUGFeRDAllowanceCharge itemAllowance : currentItem.getItemAllowances()){ - totalAllowance = itemAllowance.getTotalAmount().add(totalAllowance); + if(currentItem.getItemAllowances() != null){ + for(IZUGFeRDAllowanceCharge itemAllowance : currentItem.getItemAllowances()){ + totalAllowance = itemAllowance.getTotalAmount().add(totalAllowance); + } } - for(IZUGFeRDAllowanceCharge itemCharge : currentItem.getItemCharges()){ - totalCharge = itemCharge.getTotalAmount().add(totalCharge); + if(currentItem.getItemCharges() != null){ + for(IZUGFeRDAllowanceCharge itemCharge : currentItem.getItemCharges()){ + totalCharge = itemCharge.getTotalAmount().add(totalCharge); + } } BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP).add(BigDecimal.ONE);