From 0fc80586b826be374433cac2393cd8eeeab01ed5 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Thu, 22 Jan 2009 10:50:25 +0000 Subject: [PATCH] BF [ 2528220 ] Posting commitment release issues https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2528220&group_id=176962 --- base/src/org/compiere/acct/Doc_Order.java | 31 +++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/base/src/org/compiere/acct/Doc_Order.java b/base/src/org/compiere/acct/Doc_Order.java index 322c9173a8..1e1fbb8fbe 100644 --- a/base/src/org/compiere/acct/Doc_Order.java +++ b/base/src/org/compiere/acct/Doc_Order.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -596,15 +596,20 @@ public class Doc_Order extends Doc Fact fact = new Fact(doc, as, Fact.POST_Commitment); DocLine[] commitments = Doc_Order.getCommitments(doc, Qty, C_InvoiceLine_ID); + if (commitments.length == 0) + { + return fact; + } BigDecimal total = Env.ZERO; - FactLine fl = null; int C_Currency_ID = -1; for (int i = 0; i < commitments.length; i++) { DocLine line = commitments[i]; if (C_Currency_ID == -1) + { C_Currency_ID = line.getC_Currency_ID(); + } else if (C_Currency_ID != line.getC_Currency_ID()) { doc.p_Error = "Different Currencies of Order Lines"; @@ -616,8 +621,7 @@ public class Doc_Order extends Doc // Account MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as); - fl = fact.createLine (line, expense, - C_Currency_ID, null, cost); + fact.createLine (line, expense, C_Currency_ID, null, cost); } // Offset MAccount offset = doc.getAccount(ACCTTYPE_CommitmentOffset, as); @@ -627,8 +631,7 @@ public class Doc_Order extends Doc s_log.log(Level.SEVERE, doc.p_Error); return null; } - fact.createLine (null, offset, - C_Currency_ID, total, null); + fact.createLine (null, offset, C_Currency_ID, total, null); return fact; } // getCommitmentRelease @@ -734,17 +737,21 @@ public class Doc_Order extends Doc BigDecimal Qty, int M_InOutLine_ID, BigDecimal multiplier) { Fact fact = new Fact(doc, as, Fact.POST_Commitment); - DocLine[] commitments = Doc_Order.getCommitmentsSales(doc, Qty, - M_InOutLine_ID); + DocLine[] commitments = Doc_Order.getCommitmentsSales(doc, Qty, M_InOutLine_ID); + if (commitments.length == 0) + { + return fact; + } BigDecimal total = Env.ZERO; - FactLine fl = null; int C_Currency_ID = -1; for (int i = 0; i < commitments.length; i++) { DocLine line = commitments[i]; if (C_Currency_ID == -1) + { C_Currency_ID = line.getC_Currency_ID(); + } else if (C_Currency_ID != line.getC_Currency_ID()) { doc.p_Error = "Different Currencies of Order Lines"; @@ -756,8 +763,7 @@ public class Doc_Order extends Doc // Account MAccount revenue = line.getAccount(ProductCost.ACCTTYPE_P_Revenue, as); - fl = fact.createLine (line, revenue, - C_Currency_ID, cost, null); + fact.createLine (line, revenue, C_Currency_ID, cost, null); } // Offset MAccount offset = doc.getAccount(ACCTTYPE_CommitmentOffsetSales, as); @@ -767,8 +773,7 @@ public class Doc_Order extends Doc s_log.log(Level.SEVERE, doc.p_Error); return null; } - fact.createLine (null, offset, - C_Currency_ID, null, total); + fact.createLine (null, offset, C_Currency_ID, null, total); return fact; } // getCommitmentSalesRelease