Merged release-1.0c into release-2.0

This commit is contained in:
Heng Sin Low 2013-12-05 18:10:32 +08:00
commit 83bf6f7e36
14 changed files with 166 additions and 18 deletions

View File

@ -0,0 +1,18 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-337 zkwebui - Improve Info Product window
UPDATE M_Product_PO po
SET IsCurrentVendor='N'
WHERE po.IsActive='Y'
AND po.IsCurrentVendor='Y'
AND po.C_BPartner_ID NOT IN (
SELECT MAX(ppo.C_BPartner_ID)
FROM M_Product_PO ppo
WHERE ppo.IsActive='Y'
AND ppo.IsCurrentVendor='Y'
AND ppo.M_Product_ID = po.M_Product_ID
);
SELECT register_migration_script('201312051535_IDEMPIERE-337') FROM dual
;

View File

@ -0,0 +1,15 @@
-- IDEMPIERE-337 zkwebui - Improve Info Product window
UPDATE M_Product_PO po
SET IsCurrentVendor='N'
WHERE po.IsActive='Y'
AND po.IsCurrentVendor='Y'
AND po.C_BPartner_ID NOT IN (
SELECT MAX(ppo.C_BPartner_ID)
FROM M_Product_PO ppo
WHERE ppo.IsActive='Y'
AND ppo.IsCurrentVendor='Y'
AND ppo.M_Product_ID = po.M_Product_ID
);
SELECT register_migration_script('201312051535_IDEMPIERE-337') FROM dual
;

View File

@ -510,6 +510,8 @@ public class CalloutInvoice extends CalloutEngine
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID); int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID);
MPriceList pl = new MPriceList(ctx, M_PriceList_ID, null);
boolean isEnforcePriceLimit = pl.isEnforcePriceLimit();
BigDecimal QtyEntered, QtyInvoiced, PriceEntered, PriceActual, PriceLimit, Discount, PriceList; BigDecimal QtyEntered, QtyInvoiced, PriceEntered, PriceActual, PriceLimit, Discount, PriceList;
// get values // get values
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
@ -630,7 +632,7 @@ public class CalloutInvoice extends CalloutEngine
// Check PriceLimit // Check PriceLimit
String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit"); String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit");
boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && epl.equals("Y"); boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && !epl.equals("") ? epl.equals("Y") : isEnforcePriceLimit;
if (enforce && MRole.getDefault().isOverwritePriceLimit()) if (enforce && MRole.getDefault().isOverwritePriceLimit())
enforce = false; enforce = false;
// Check Price Limit? // Check Price Limit?

View File

@ -1038,6 +1038,8 @@ public class CalloutOrder extends CalloutEngine
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID); int StdPrecision = MPriceList.getStandardPrecision(ctx, M_PriceList_ID);
MPriceList pl = new MPriceList(ctx, M_PriceList_ID, null);
boolean isEnforcePriceLimit = pl.isEnforcePriceLimit();
BigDecimal QtyEntered, QtyOrdered, PriceEntered, PriceActual, PriceLimit, Discount, PriceList; BigDecimal QtyEntered, QtyOrdered, PriceEntered, PriceActual, PriceLimit, Discount, PriceList;
// get values // get values
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered"); QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
@ -1158,7 +1160,7 @@ public class CalloutOrder extends CalloutEngine
// Check PriceLimit // Check PriceLimit
String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit"); String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit");
boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && epl.equals("Y"); boolean enforce = Env.isSOTrx(ctx, WindowNo) && epl != null && !epl.equals("") ? epl.equals("Y") : isEnforcePriceLimit;
if (enforce && MRole.getDefault().isOverwritePriceLimit()) if (enforce && MRole.getDefault().isOverwritePriceLimit())
enforce = false; enforce = false;
// Check Price Limit? // Check Price Limit?

View File

@ -20,6 +20,8 @@ import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.EventObject; import java.util.EventObject;
import org.idempiere.fa.util.Util;
/** /**
* Data Status Event * Data Status Event
* <p> * <p>
@ -337,4 +339,17 @@ public final class DataStatusEvent extends EventObject implements Serializable
return m_confirmed; return m_confirmed;
} // isConfirmed } // isConfirmed
public boolean isEqual(DataStatusEvent e) {
if (e == null) return false;
return e.m_changed == m_changed &&
e.m_inserting == m_inserting &&
e.m_isError == m_isError &&
e.m_isWarning == m_isWarning &&
Util.equals(e.m_AD_Message, m_AD_Message) &&
e.m_changedColumn == m_changedColumn &&
Util.equals(e.m_columnName, m_columnName) &&
e.m_currentRow == m_currentRow;
}
} // DataStatusEvent } // DataStatusEvent

View File

@ -2251,7 +2251,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
* @param e event * @param e event
*/ */
public void dataStatusChanged (DataStatusEvent e) public void dataStatusChanged (DataStatusEvent e)
{ {
if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo + " - " + e.toString()); if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo + " - " + e.toString());
int oldCurrentRow = e.getCurrentRow(); int oldCurrentRow = e.getCurrentRow();
m_DataStatusEvent = e; // save it m_DataStatusEvent = e; // save it
@ -2262,6 +2262,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
// set current row // set current row
m_DataStatusEvent = e; // setCurrentRow clear it, need to save again m_DataStatusEvent = e; // setCurrentRow clear it, need to save again
m_DataStatusEvent.setCurrentRow(m_currentRow); m_DataStatusEvent.setCurrentRow(m_currentRow);
// Same row - update value // Same row - update value
if (oldCurrentRow == m_currentRow) if (oldCurrentRow == m_currentRow)
{ {
@ -2272,8 +2273,25 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
field.setValue(value, m_mTable.isInserting()); field.setValue(value, m_mTable.isInserting());
} }
} }
else // Redistribute Info with current row info else
fireDataStatusChanged(m_DataStatusEvent); {
// Redistribute Info with current row info
// Avoid firing of duplicate event
boolean fire = true;
if (m_lastDataStatusEvent != null)
{
if (System.currentTimeMillis() - m_lastDataStatusEventTime < 200)
{
if (m_lastDataStatusEvent.isEqual(m_DataStatusEvent))
{
fire = false;
}
}
}
if (fire)
fireDataStatusChanged(m_DataStatusEvent);
}
//reset //reset
m_lastDataStatusEventTime = System.currentTimeMillis(); m_lastDataStatusEventTime = System.currentTimeMillis();

View File

@ -860,6 +860,19 @@ public class MInvoiceLine extends X_C_InvoiceLine
&& Env.ZERO.compareTo(getPriceActual()) == 0 && Env.ZERO.compareTo(getPriceActual()) == 0
&& Env.ZERO.compareTo(getPriceList()) == 0) && Env.ZERO.compareTo(getPriceList()) == 0)
setPrice(); setPrice();
// IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating
// Check PriceLimit
boolean enforce = m_IsSOTrx && m_parent.getM_PriceList().isEnforcePriceLimit();
if (enforce && MRole.getDefault().isOverwritePriceLimit())
enforce = false;
// Check Price Limit?
if (enforce && getPriceLimit() != Env.ZERO
&& getPriceActual().compareTo(getPriceLimit()) < 0)
{
log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit());
return false;
}
//
} }
// Set Tax // Set Tax

View File

@ -870,6 +870,19 @@ public class MOrderLine extends X_C_OrderLine
// Check if on Price list // Check if on Price list
if (m_productPrice == null) if (m_productPrice == null)
getProductPricing(m_M_PriceList_ID); getProductPricing(m_M_PriceList_ID);
// IDEMPIERE-1574 Sales Order Line lets Price under the Price Limit when updating
// Check PriceLimit
boolean enforce = m_IsSOTrx && m_parent.getM_PriceList().isEnforcePriceLimit();
if (enforce && MRole.getDefault().isOverwritePriceLimit())
enforce = false;
// Check Price Limit?
if (enforce && getPriceLimit() != Env.ZERO
&& getPriceActual().compareTo(getPriceLimit()) < 0)
{
log.saveError("UnderLimitPrice", "PriceEntered=" + getPriceEntered() + ", PriceLimit=" + getPriceLimit());
return false;
}
//
if (!m_productPrice.isCalculated()) if (!m_productPrice.isCalculated())
{ {
throw new ProductNotOnPriceListException(m_productPrice, getLine()); throw new ProductNotOnPriceListException(m_productPrice, getLine());

View File

@ -19,6 +19,9 @@ package org.compiere.model;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
/** /**
* Product PO Model * Product PO Model
@ -31,8 +34,7 @@ public class MProductPO extends X_M_Product_PO
/** /**
* *
*/ */
private static final long serialVersionUID = -747761340543484440L; private static final long serialVersionUID = -1883198806060209516L;
/** /**
* Get current PO of Product * Get current PO of Product
@ -84,4 +86,34 @@ public class MProductPO extends X_M_Product_PO
super(ctx, rs, trxName); super(ctx, rs, trxName);
} // MProductPO } // MProductPO
/**
* Before Save
* @param newRecord new
* @return true
*/
@Override
protected boolean beforeSave(boolean newRecord)
{
if ((newRecord && isActive() && isCurrentVendor()) ||
(!newRecord &&
(
(is_ValueChanged("IsActive") && isActive()) // now active
|| (is_ValueChanged("IsCurrentVendor") && isCurrentVendor()) // now current vendor
|| is_ValueChanged("C_BPartner_ID")
|| is_ValueChanged("M_Product_ID")
)
)
)
{
if (isActive() && isCurrentVendor())
{
String sql = "UPDATE M_Product_PO SET IsCurrentVendor='N' WHERE IsActive='Y' AND IsCurrentVendor='Y' AND C_BPartner_ID!=? AND M_Product_ID=?";
int no = DB.executeUpdate(sql, new Object[] {getC_BPartner_ID(), getM_Product_ID()}, false, get_TrxName());
if (log.isLoggable(Level.FINEST)) log.finest("Updated M_Product_PO.IsCurrentVendor #" + no);
}
}
return true;
}
} // MProductPO } // MProductPO

View File

@ -29,6 +29,11 @@ public class PoExporter {
private void addTextElement(String qName, String text, AttributesImpl atts) { private void addTextElement(String qName, String text, AttributesImpl atts) {
try { try {
//default trim to false for print item label since trailing space is commonly use
//for formatting purpose
if (qName.equalsIgnoreCase("PrintName")) {
atts.addAttribute("", "", "trim", "CDATA", "false");
}
transformerHandler.startElement("", "", qName, atts); transformerHandler.startElement("", "", qName, atts);
append(text); append(text);
transformerHandler.endElement("", "", qName); transformerHandler.endElement("", "", qName);

View File

@ -28,6 +28,7 @@ import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.zhtml.Text; import org.zkoss.zhtml.Text;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
@ -244,7 +245,20 @@ public class Messagebox extends Window implements EventListener<Event>
this.setSizable(true); this.setSizable(true);
this.setVisible(true); this.setVisible(true);
this.setId("MessageBox_"+AdempiereIdGenerator.escapeId(title)); String id = "MessageBox_"+AdempiereIdGenerator.escapeId(title);
//make sure id is unique
Page page = AEnv.getDesktop().getFirstPage();
Component fellow = page.getFellowIfAny(id);
if (fellow != null) {
int count = 0;
String newId = null;
while (fellow != null) {
newId = id + "_" + ++count;
fellow = page.getFellowIfAny(newId);
}
id = newId;
}
this.setId(id);
AEnv.showCenterScreen(this); AEnv.showCenterScreen(this);
return returnValue; return returnValue;

View File

@ -195,9 +195,9 @@ public class GridTabDataBinder implements ValueChangeListener {
for (int i = 0; i < values.length; i++) for (int i = 0; i < values.length; i++)
{ {
if (!gridTab.dataNew(true)) if (!gridTab.dataNew(false))
{ {
throw new IllegalStateException("Could not clone tab"); throw new IllegalStateException("Could not create new row");
} }
gridTab.setValue(columnName, values[i]); gridTab.setValue(columnName, values[i]);
@ -209,10 +209,9 @@ public class GridTabDataBinder implements ValueChangeListener {
if (!gridTab.dataSave(false)) if (!gridTab.dataSave(false))
{ {
throw new IllegalStateException("Could not update tab"); throw new IllegalStateException("Could not update row");
} }
gridTab.setCurrentRow(oldRow);
} }
gridTab.setCurrentRow(oldRow);
} }
} }

View File

@ -62,7 +62,7 @@ public class FDialog
if (message != null && message.length() > 0) if (message != null && message.length() > 0)
{ {
out.append("\n").append(message); out.append("<br>").append(message);
} }
return out; return out;

View File

@ -30,6 +30,7 @@ import org.compiere.model.MAllocationLine;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
import org.compiere.model.MPayment; import org.compiere.model.MPayment;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.process.DocAction; import org.compiere.process.DocAction;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -422,8 +423,9 @@ public class Allocation
{ {
if ( applied.signum() == -open.signum() ) if ( applied.signum() == -open.signum() )
applied = applied.negate(); applied = applied.negate();
if ( open.abs().compareTo( applied.abs() ) < 0 ) if (! MSysConfig.getBooleanValue("ALLOW_OVER_APPLIED_PAYMENT", false, Env.getAD_Client_ID(Env.getCtx())))
applied = open; if ( open.abs().compareTo( applied.abs() ) < 0 )
applied = open;
} }
payment.setValueAt(applied, row, i_payment); payment.setValueAt(applied, row, i_payment);