Merge release-7.1 into master

This commit is contained in:
Carlos Ruiz 2020-04-01 15:27:45 +02:00
commit e10a5c9425
4 changed files with 61 additions and 30 deletions

View File

@ -845,7 +845,10 @@ public class Doc_AllocationHdr extends Doc
if (valuesInv != null) {
if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID())
{
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) {
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo())) {
invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr
invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr
} else {
@ -855,7 +858,10 @@ public class Doc_AllocationHdr extends Doc
}
else
{
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) {
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo())) {
invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr
invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr
} else {
@ -912,7 +918,10 @@ public class Doc_AllocationHdr extends Doc
MAccount loss = MAccount.get (as.getCtx(), as.getAcctSchemaDefault().getRealizedLoss_Acct());
//
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo()))
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo()))
{
FactLine fl = fact.createLine (line, loss, gain, as.getC_Currency_ID(), acctDifference);
fl.setDescription(description.toString());
@ -1080,7 +1089,10 @@ public class Doc_AllocationHdr extends Doc
BigDecimal invoiceAccounted = null;
if (invoice.getReversal_ID() == 0 || invoice.get_ID() < invoice.getReversal_ID())
{
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) {
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo())) {
invoiceSource = (BigDecimal) valuesInv.get(0); // AmtSourceDr
invoiceAccounted = (BigDecimal) valuesInv.get(1); // AmtAcctDr
} else {
@ -1090,7 +1102,10 @@ public class Doc_AllocationHdr extends Doc
}
else
{
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo())) {
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo())) {
invoiceSource = (BigDecimal) valuesInv.get(2); // AmtSourceCr
invoiceAccounted = (BigDecimal) valuesInv.get(3); // AmtAcctCr
} else {
@ -1199,12 +1214,12 @@ public class Doc_AllocationHdr extends Doc
{
if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0)
{
allocateSource = allocateSource.add(totalAmtSourceDr);
allocateSource = allocateSource.add(totalAmtSourceDr).subtract(totalAmtSourceCr);
allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr);
}
else
{
allocateSource = allocateSource.add(totalAmtSourceCr);
allocateSource = allocateSource.add(totalAmtSourceCr).subtract(totalAmtSourceDr);
allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr);
}
}
@ -1335,12 +1350,15 @@ public class Doc_AllocationHdr extends Doc
if (acctDifference == null || acctDifference.signum() == 0)
{
log.fine("No Difference");
return null;
continue;
}
//
Integer C_AllocationLine_ID = htInvAllocLine.get(invoice.getC_Invoice_ID());
if ((invoice.isSOTrx() && !invoice.isCreditMemo()) || (!invoice.isSOTrx() && invoice.isCreditMemo()))
if ((invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && !invoice.isCreditMemo())
|| (invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() >= 0 && invoice.isCreditMemo())
|| (!invoice.isSOTrx() && invoice.getGrandTotal().signum() < 0 && !invoice.isCreditMemo()))
{
FactLine fl = fact.createLine (null, acct, as.getC_Currency_ID(), acctDifference);
fl.setDescription(description.toString());
@ -1525,12 +1543,12 @@ public class Doc_AllocationHdr extends Doc
{
if (totalAmtAcctDr.compareTo(totalAmtAcctCr) > 0)
{
allocateSource = allocateSource.add(totalAmtSourceDr);
allocateSource = allocateSource.add(totalAmtSourceDr).subtract(totalAmtSourceCr);
allocateAccounted = allocateAccounted.add(totalAmtAcctDr).subtract(totalAmtAcctCr);
}
else
{
allocateSource = allocateSource.add(totalAmtSourceCr);
allocateSource = allocateSource.add(totalAmtSourceCr).subtract(totalAmtSourceDr);
allocateAccounted = allocateAccounted.add(totalAmtAcctCr).subtract(totalAmtAcctDr);
}
}
@ -1665,7 +1683,7 @@ public class Doc_AllocationHdr extends Doc
if (acctDifference == null || acctDifference.signum() == 0)
{
log.fine("No Difference");
return null;
continue;
}
//

View File

@ -20,12 +20,11 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.Vector;
import java.util.logging.Level;
import org.compiere.Adempiere;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.TimeUtil;
import org.compiere.util.WebUtil;
@ -58,16 +57,15 @@ public class MSession extends X_AD_Session
{
int AD_Session_ID = Env.getContextAsInt(ctx, "#AD_Session_ID");
MSession session = null;
if (AD_Session_ID > 0)
session = (MSession)s_sessions.get(Integer.valueOf(AD_Session_ID));
// Try to load
if (session == null && AD_Session_ID > 0)
if (AD_Session_ID > 0 && s_sessions.contains(AD_Session_ID))
{
session = new MSession(ctx, AD_Session_ID, null);
if (session.get_ID() != AD_Session_ID) {
Env.setContext (ctx, "#AD_Session_ID", AD_Session_ID);
if (session.get_ID() != AD_Session_ID)
{
session = null;
s_sessions.remove(AD_Session_ID);
}
s_sessions.put(AD_Session_ID, session);
}
// Create New
if (session == null && createNew)
@ -76,7 +74,7 @@ public class MSession extends X_AD_Session
session.saveEx();
AD_Session_ID = session.getAD_Session_ID();
Env.setContext (ctx, "#AD_Session_ID", AD_Session_ID);
s_sessions.put (Integer.valueOf(AD_Session_ID), session);
s_sessions.add (Integer.valueOf(AD_Session_ID));
}
return session;
} // get
@ -93,23 +91,29 @@ public class MSession extends X_AD_Session
{
int AD_Session_ID = Env.getContextAsInt(ctx, "#AD_Session_ID");
MSession session = null;
if (AD_Session_ID > 0)
session = (MSession)s_sessions.get(Integer.valueOf(AD_Session_ID));
// Try to load
if (AD_Session_ID > 0 && s_sessions.contains(AD_Session_ID))
{
session = new MSession(ctx, AD_Session_ID, null);
if (session.get_ID() != AD_Session_ID)
{
session = null;
s_sessions.remove(AD_Session_ID);
}
}
if (session == null)
{
session = new MSession (ctx, Remote_Addr, Remote_Host, WebSession, null); // remote session
session.saveEx();
AD_Session_ID = session.getAD_Session_ID();
Env.setContext(ctx, "#AD_Session_ID", AD_Session_ID);
s_sessions.put(Integer.valueOf(AD_Session_ID), session);
}
s_sessions.add(Integer.valueOf(AD_Session_ID));
}
return session;
} // get
/** Sessions */
private static CCache<Integer, MSession> s_sessions = Ini.isClient()
? new CCache<Integer, MSession>(null, "AD_Session_ID", 1, 0, false) // one client session
: new CCache<Integer, MSession>(null, "AD_Session_ID", 30, 0, false); // no time-out
private static Vector<Integer> s_sessions = new Vector<>();
/**************************************************************************

View File

@ -81,6 +81,8 @@ import org.zkoss.zul.Window;
*/
public class AdempiereWebUI extends Window implements EventListener<Event>, IWebClient
{
public static final String DESKTOP_SESSION_INVALIDATED_ATTR = "DesktopSessionInvalidated";
/**
*
*/
@ -569,9 +571,11 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
//redirect must happens before removeDesktop below, otherwise you get NPE
Executions.getCurrent().sendRedirect("index.zul");
//remove old desktop
if (desktopCache != null)
//remove old desktop
if (desktopCache != null) {
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE);
desktopCache.removeDesktop(desktop);
}
}
@Override

View File

@ -237,6 +237,11 @@ public class SessionContextListener implements ExecutionInit,
return;
}
Object sessionInvalidated = desktop.getAttribute(AdempiereWebUI.DESKTOP_SESSION_INVALIDATED_ATTR);
if (sessionInvalidated != null) {
return;
}
if (ServerContext.getCurrentInstance().isEmpty() || !isContextValid())
{
setupExecutionContextFromSession(Executions.getCurrent());