BF [ 1831997 ] Cash journal allocation reversed
This commit is contained in:
parent
e84a90cf0c
commit
34f30961d5
|
@ -29,6 +29,9 @@ import org.compiere.util.*;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MCash.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
* @version $Id: MCash.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>BF [ 1831997 ] Cash journal allocation reversed
|
||||||
*/
|
*/
|
||||||
public class MCash extends X_C_Cash implements DocAction
|
public class MCash extends X_C_Cash implements DocAction
|
||||||
{
|
{
|
||||||
|
@ -501,37 +504,23 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
//
|
//
|
||||||
log.info(toString());
|
log.info(toString());
|
||||||
|
|
||||||
// Allocation Header
|
|
||||||
MAllocationHdr alloc = new MAllocationHdr(getCtx(), false,
|
|
||||||
getDateAcct(), getC_Currency_ID(),
|
|
||||||
Msg.translate(getCtx(), "C_Cash_ID") + ": " + getName(), get_TrxName());
|
|
||||||
alloc.setAD_Org_ID(getAD_Org_ID());
|
|
||||||
if (!alloc.save())
|
|
||||||
{
|
|
||||||
m_processMsg = "Could not create Allocation Hdr";
|
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
MCashLine[] lines = getLines(false);
|
MCashLine[] lines = getLines(false);
|
||||||
for (int i = 0; i < lines.length; i++)
|
for (int i = 0; i < lines.length; i++)
|
||||||
{
|
{
|
||||||
MCashLine line = lines[i];
|
MCashLine line = lines[i];
|
||||||
if (MCashLine.CASHTYPE_Invoice.equals(line.getCashType()))
|
if (MCashLine.CASHTYPE_Invoice.equals(line.getCashType()))
|
||||||
{
|
{
|
||||||
boolean differentCurrency = getC_Currency_ID() != line.getC_Currency_ID();
|
String name = Msg.translate(getCtx(), "C_Cash_ID") + ": " + getName()
|
||||||
MAllocationHdr hdr = alloc;
|
+ " - " + Msg.translate(getCtx(), "Line") + " " + line.getLine();
|
||||||
if (differentCurrency)
|
MAllocationHdr hdr = new MAllocationHdr(getCtx(), false,
|
||||||
{
|
|
||||||
hdr = new MAllocationHdr(getCtx(), false,
|
|
||||||
getDateAcct(), line.getC_Currency_ID(),
|
getDateAcct(), line.getC_Currency_ID(),
|
||||||
Msg.translate(getCtx(), "C_Cash_ID") + ": " + getName(), get_TrxName());
|
name, get_TrxName());
|
||||||
hdr.setAD_Org_ID(getAD_Org_ID());
|
hdr.setAD_Org_ID(getAD_Org_ID());
|
||||||
if (!hdr.save())
|
if (!hdr.save())
|
||||||
{
|
{
|
||||||
m_processMsg = "Could not create Allocation Hdr";
|
m_processMsg = "Could not create Allocation Hdr";
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Allocation Line
|
// Allocation Line
|
||||||
MAllocationLine aLine = new MAllocationLine (hdr, line.getAmount(),
|
MAllocationLine aLine = new MAllocationLine (hdr, line.getAmount(),
|
||||||
line.getDiscountAmt(), line.getWriteOffAmt(), Env.ZERO);
|
line.getDiscountAmt(), line.getWriteOffAmt(), Env.ZERO);
|
||||||
|
@ -542,11 +531,14 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
m_processMsg = "Could not create Allocation Line";
|
m_processMsg = "Could not create Allocation Line";
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
if (differentCurrency)
|
|
||||||
{
|
|
||||||
// Should start WF
|
// Should start WF
|
||||||
hdr.processIt(DocAction.ACTION_Complete);
|
if(!hdr.processIt(DocAction.ACTION_Complete)) {
|
||||||
hdr.save();
|
m_processMsg = CLogger.retrieveErrorString("Could not process Allocation");
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
if (!hdr.save()) {
|
||||||
|
m_processMsg = CLogger.retrieveErrorString("Could not save Allocation");
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MCashLine.CASHTYPE_BankAccountTransfer.equals(line.getCashType()))
|
else if (MCashLine.CASHTYPE_BankAccountTransfer.equals(line.getCashType()))
|
||||||
|
@ -578,9 +570,6 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Should start WF
|
|
||||||
alloc.processIt(DocAction.ACTION_Complete);
|
|
||||||
alloc.save();
|
|
||||||
|
|
||||||
// User Validation
|
// User Validation
|
||||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||||
|
|
Loading…
Reference in New Issue