From 03fda3693492d3cca83bfcbefe0f3e2ffed80032 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 24 Jun 2020 11:51:52 +0200 Subject: [PATCH] IDEMPIERE-4340 NPE in Auto Allocation (#129) --- .../src/org/compiere/process/AllocationAuto.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java b/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java index e8c6b71059..b0b947750e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java +++ b/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java @@ -649,6 +649,8 @@ public class AllocationAuto extends SvrProcess if (payment.getC_Currency_ID() != C_Currency_ID) continue; BigDecimal allocatedAmt = payment.getAllocatedAmt(); + if (allocatedAmt == null) + allocatedAmt = Env.ZERO; if (log.isLoggable(Level.INFO)) log.info(payment + ", Allocated=" + allocatedAmt); BigDecimal availableAmt = payment.getPayAmt() .add(payment.getDiscountAmt()) @@ -709,6 +711,8 @@ public class AllocationAuto extends SvrProcess if (payment.getC_Currency_ID() != C_Currency_ID) continue; BigDecimal allocatedAmt = payment.getAllocatedAmt(); + if (allocatedAmt == null) + allocatedAmt = Env.ZERO; // comment following lines to allow partial allocation // if (allocatedAmt != null && allocatedAmt.signum() != 0) // continue; @@ -841,7 +845,7 @@ public class AllocationAuto extends SvrProcess else m_allocation.saveEx(); String message = Msg.parseTranslation(getCtx(), "@AllocationProcessed@ " + m_allocation.getDescription()); - addLog(0, m_allocation.getDateAcct(), null, message); + addLog(0, m_allocation.getDateAcct(), null, message, MAllocationHdr.Table_ID, m_allocation.getC_AllocationHdr_ID()); m_allocation = null; return success; } // processAllocation