Merge head 10016 and 10026
This commit is contained in:
commit
5af80ab13d
|
@ -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
|
||||
;
|
|
@ -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
|
||||
;
|
|
@ -510,6 +510,8 @@ public class CalloutInvoice extends CalloutEngine
|
|||
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
||||
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "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;
|
||||
// get values
|
||||
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
|
||||
|
@ -630,7 +632,7 @@ public class CalloutInvoice extends CalloutEngine
|
|||
|
||||
// Check PriceLimit
|
||||
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())
|
||||
enforce = false;
|
||||
// Check Price Limit?
|
||||
|
|
|
@ -1038,6 +1038,8 @@ public class CalloutOrder extends CalloutEngine
|
|||
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
||||
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "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;
|
||||
// get values
|
||||
QtyEntered = (BigDecimal)mTab.getValue("QtyEntered");
|
||||
|
@ -1158,7 +1160,7 @@ public class CalloutOrder extends CalloutEngine
|
|||
|
||||
// Check PriceLimit
|
||||
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())
|
||||
enforce = false;
|
||||
// Check Price Limit?
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.io.Serializable;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.EventObject;
|
||||
|
||||
import org.idempiere.fa.util.Util;
|
||||
|
||||
/**
|
||||
* Data Status Event
|
||||
* <p>
|
||||
|
@ -337,4 +339,17 @@ public final class DataStatusEvent extends EventObject implements Serializable
|
|||
return m_confirmed;
|
||||
} // 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
|
||||
|
|
|
@ -2251,7 +2251,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
* @param e event
|
||||
*/
|
||||
public void dataStatusChanged (DataStatusEvent e)
|
||||
{
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine("#" + m_vo.TabNo + " - " + e.toString());
|
||||
int oldCurrentRow = e.getCurrentRow();
|
||||
m_DataStatusEvent = e; // save it
|
||||
|
@ -2262,6 +2262,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
// set current row
|
||||
m_DataStatusEvent = e; // setCurrentRow clear it, need to save again
|
||||
m_DataStatusEvent.setCurrentRow(m_currentRow);
|
||||
|
||||
// Same row - update value
|
||||
if (oldCurrentRow == m_currentRow)
|
||||
{
|
||||
|
@ -2272,8 +2273,25 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
field.setValue(value, m_mTable.isInserting());
|
||||
}
|
||||
}
|
||||
else // Redistribute Info with current row info
|
||||
fireDataStatusChanged(m_DataStatusEvent);
|
||||
else
|
||||
{
|
||||
// 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
|
||||
m_lastDataStatusEventTime = System.currentTimeMillis();
|
||||
|
|
|
@ -860,6 +860,19 @@ public class MInvoiceLine extends X_C_InvoiceLine
|
|||
&& Env.ZERO.compareTo(getPriceActual()) == 0
|
||||
&& Env.ZERO.compareTo(getPriceList()) == 0)
|
||||
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
|
||||
|
|
|
@ -870,6 +870,19 @@ public class MOrderLine extends X_C_OrderLine
|
|||
// Check if on Price list
|
||||
if (m_productPrice == null)
|
||||
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())
|
||||
{
|
||||
throw new ProductNotOnPriceListException(m_productPrice, getLine());
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.compiere.model;
|
|||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -84,4 +86,34 @@ public class MProductPO extends X_M_Product_PO
|
|||
super(ctx, rs, trxName);
|
||||
} // 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
|
||||
|
|
|
@ -29,6 +29,11 @@ public class PoExporter {
|
|||
|
||||
private void addTextElement(String qName, String text, AttributesImpl atts) {
|
||||
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);
|
||||
append(text);
|
||||
transformerHandler.endElement("", "", qName);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.zkoss.zhtml.Text;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
@ -244,7 +245,20 @@ public class Messagebox extends Window implements EventListener<Event>
|
|||
this.setSizable(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);
|
||||
|
||||
return returnValue;
|
||||
|
|
|
@ -195,9 +195,9 @@ public class GridTabDataBinder implements ValueChangeListener {
|
|||
|
||||
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]);
|
||||
|
@ -209,10 +209,9 @@ public class GridTabDataBinder implements ValueChangeListener {
|
|||
|
||||
if (!gridTab.dataSave(false))
|
||||
{
|
||||
throw new IllegalStateException("Could not update tab");
|
||||
}
|
||||
|
||||
gridTab.setCurrentRow(oldRow);
|
||||
throw new IllegalStateException("Could not update row");
|
||||
}
|
||||
}
|
||||
gridTab.setCurrentRow(oldRow);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ public class FDialog
|
|||
|
||||
if (message != null && message.length() > 0)
|
||||
{
|
||||
out.append("\n").append(message);
|
||||
out.append("<br>").append(message);
|
||||
}
|
||||
|
||||
return out;
|
||||
|
|
|
@ -124,7 +124,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3901459797939709594L;
|
||||
private static final long serialVersionUID = -1264106685431608207L;
|
||||
|
||||
// values and label for history combo
|
||||
private static final String HISTORY_DAY_ALL = "All";
|
||||
|
@ -167,6 +167,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
//
|
||||
/** List of WEditors */
|
||||
private ArrayList<WEditor> m_sEditors = new ArrayList<WEditor>();
|
||||
private ArrayList<ToolBarButton> m_sEditorsFlag = new ArrayList<ToolBarButton>();
|
||||
private ArrayList<WEditor> m_sEditorsTo = new ArrayList<WEditor>();
|
||||
/** For Grid Controller */
|
||||
public static final int TABNO = 99;
|
||||
/** Length of Fields on first tab */
|
||||
|
@ -532,13 +534,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
btnSave.setAttribute("name","btnSaveAdv");
|
||||
btnSave.setImage(ThemeManager.getThemeResource("images/Save24.png"));
|
||||
btnSave.addEventListener(Events.ON_CLICK, this);
|
||||
btnSave.setDisabled(true);
|
||||
btnSave.setId("btnSave");
|
||||
btnSave.setStyle("vertical-align: middle;");
|
||||
|
||||
fQueryName = new Combobox();
|
||||
fQueryName.setTooltiptext(Msg.getMsg(Env.getCtx(),"QueryName"));
|
||||
fQueryName.setReadonly(true);
|
||||
fQueryName.setId("savedQueryCombo");
|
||||
|
||||
//user query
|
||||
|
@ -1052,7 +1052,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
editor.setMandatory(false);
|
||||
editor.setReadWrite(true);
|
||||
editor.dynamicDisplay();
|
||||
editor.fillHorizontal();
|
||||
Label label = editor.getLabel();
|
||||
Component fieldEditor = editor.getComponent();
|
||||
|
||||
|
@ -1060,10 +1059,51 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
if (displayLength > 0) // set it back
|
||||
mField.setDisplayLength(displayLength);
|
||||
//
|
||||
|
||||
WEditor editorTo = null;
|
||||
Component fieldEditorTo = null;
|
||||
if ( DisplayType.isDate(mField.getDisplayType())
|
||||
|| DisplayType.isNumeric(mField.getDisplayType())) {
|
||||
// Editor To
|
||||
editorTo = WebEditorFactory.getEditor(mField, true);
|
||||
editorTo.setMandatory(false);
|
||||
editorTo.setReadWrite(true);
|
||||
editorTo.dynamicDisplay();
|
||||
//
|
||||
if (displayLength > 0) // set it back
|
||||
mField.setDisplayLength(displayLength);
|
||||
fieldEditorTo = editorTo.getComponent();
|
||||
fieldEditorTo.addEventListener(Events.ON_OK,this);
|
||||
}
|
||||
|
||||
Row panel = new Row();
|
||||
panel.appendChild(label);
|
||||
panel.appendChild(fieldEditor);
|
||||
Div div = new Div();
|
||||
panel.appendChild(div);
|
||||
div.appendChild(fieldEditor);
|
||||
if (editorTo != null) {
|
||||
ToolBarButton editorFlag = new ToolBarButton();
|
||||
editorFlag.setLabel(".. " + Msg.getMsg(Env.getCtx(), "search.result.to") + " ..");
|
||||
editorFlag.setStyle("margin-left: 5px; margin-right: 5px;");
|
||||
m_sEditorsFlag.add(editorFlag);
|
||||
editorFlag.setMode("toggle");
|
||||
div.appendChild(editorFlag);
|
||||
div.appendChild(fieldEditorTo);
|
||||
fieldEditorTo.setVisible(false);
|
||||
final Component editorRef = fieldEditorTo;
|
||||
editorFlag.addEventListener(Events.ON_CHECK, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
ToolBarButton btn = (ToolBarButton) event.getTarget();
|
||||
editorRef.setVisible(btn.isChecked());
|
||||
}
|
||||
});
|
||||
m_sEditorsTo.add(editorTo);
|
||||
} else {
|
||||
m_sEditorsFlag.add(null);
|
||||
m_sEditorsTo.add(null);
|
||||
editor.fillHorizontal();
|
||||
}
|
||||
panel.appendChild(new Space());
|
||||
if (group != null)
|
||||
panel.setGroup(group);
|
||||
|
@ -1172,7 +1212,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
|
||||
else if ("btnSaveAdv".equals(button.getAttribute("name").toString()))
|
||||
{
|
||||
cmd_save(true);
|
||||
if (winMain.getComponent().getSelectedIndex() == 1) {
|
||||
cmd_saveAdvanced(true);
|
||||
} else {
|
||||
cmd_saveSimple(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Confirm panel actions
|
||||
|
@ -1222,27 +1266,30 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
dispose();
|
||||
}
|
||||
// Check simple panel fields
|
||||
for (WEditor editor : m_sEditors)
|
||||
for (int i = 0; i < m_sEditors.size(); i++)
|
||||
{
|
||||
WEditor editor = (WEditor)m_sEditors.get(i);
|
||||
if (editor.getComponent() == event.getTarget())
|
||||
{
|
||||
cmd_ok_Simple();
|
||||
dispose();
|
||||
}
|
||||
WEditor editorTo = (WEditor)m_sEditorsTo.get(i);
|
||||
if (editorTo != null && editor.getComponent() == event.getTarget())
|
||||
{
|
||||
cmd_ok_Simple();
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // onEvent
|
||||
|
||||
private void onSimpleTabSelected() {
|
||||
fQueryName.setReadonly(true);
|
||||
btnSave.setDisabled(true);
|
||||
historyCombo.setDisabled(false);
|
||||
}
|
||||
|
||||
private void onAdvanceTabSelected() {
|
||||
fQueryName.setReadonly(false);
|
||||
btnSave.setDisabled(m_AD_Tab_ID <= 0);
|
||||
historyCombo.setSelectedItem(null);
|
||||
if (advancedPanel.getItems().size() == 0) {
|
||||
createFields();
|
||||
|
@ -1377,7 +1424,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
|
||||
} // parseValue
|
||||
|
||||
private void cmd_save(boolean saveQuery)
|
||||
private void cmd_saveAdvanced(boolean saveQuery)
|
||||
{
|
||||
//
|
||||
m_query = new MQuery(m_tableName);
|
||||
|
@ -1453,21 +1500,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
{
|
||||
m_query.addRestriction(ColumnSQL, Operator, null,
|
||||
infoName, null, and, openBrackets);
|
||||
if (code.length() > 0)
|
||||
code.append(SEGMENT_SEPARATOR);
|
||||
code.append(ColumnName)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(Operator)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append("")
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append("")
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(andOr)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(lBrackets)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(rBrackets);
|
||||
appendCode(code, ColumnName, Operator, "", "", andOr, lBrackets, rBrackets);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -1522,22 +1555,35 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
m_query.addRestriction(ColumnSQL, Operator, parsedValue,
|
||||
infoName, infoDisplay, and, openBrackets);
|
||||
|
||||
if (code.length() > 0)
|
||||
code.append(SEGMENT_SEPARATOR);
|
||||
code.append(ColumnName)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(Operator)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(value.toString())
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(value2 != null ? value2.toString() : "")
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(andOr)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(lBrackets)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(rBrackets);
|
||||
appendCode(code, ColumnName, Operator, value.toString(), value2 != null ? value2.toString() : "", andOr, lBrackets, rBrackets);
|
||||
}
|
||||
|
||||
saveQuery(saveQuery, code);
|
||||
|
||||
} // cmd_saveAdvanced
|
||||
|
||||
private void appendCode(StringBuilder code, String columnName,
|
||||
String operator, String value1, String value2, String andOr,
|
||||
String lBrackets, String rBrackets) {
|
||||
if (code.length() > 0)
|
||||
code.append(SEGMENT_SEPARATOR);
|
||||
code.append(columnName)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(operator)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(value1)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(value2)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(andOr)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(lBrackets)
|
||||
.append(FIELD_SEPARATOR)
|
||||
.append(rBrackets);
|
||||
}
|
||||
|
||||
private void saveQuery(boolean saveQuery, StringBuilder code) {
|
||||
|
||||
String selected = fQueryName.getValue();
|
||||
if (selected != null) {
|
||||
String name = selected;
|
||||
|
@ -1594,8 +1640,108 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
//
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // cmd_save
|
||||
private void cmd_saveSimple(boolean saveQuery)
|
||||
{
|
||||
// Create Query String
|
||||
m_query = new MQuery(m_tableName);
|
||||
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
|
||||
StringBuilder code = new StringBuilder();
|
||||
// Special Editors
|
||||
for (int i = 0; i < m_sEditors.size(); i++)
|
||||
{
|
||||
WEditor wed = (WEditor)m_sEditors.get(i);
|
||||
Object value = wed.getValue();
|
||||
String ColumnName = wed.getColumnName();
|
||||
WEditor wedTo = (WEditor)m_sEditorsTo.get(i);
|
||||
Object valueTo = null;
|
||||
if (wedTo != null && wedTo.getComponent().isVisible())
|
||||
valueTo = wedTo.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
{
|
||||
if (valueTo != null && valueTo.toString().length() > 0) {
|
||||
// range
|
||||
StringBuilder msglog = new StringBuilder(ColumnName).append(">=").append(value).append("<=").append(valueTo);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
||||
GridField field = getTargetMField(ColumnName);
|
||||
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
||||
m_query.addRangeRestriction(ColumnSQL.toString(), value, valueTo,
|
||||
ColumnName, wed.getDisplay(), wedTo.getDisplay(), true, 0);
|
||||
appendCode(code, ColumnName, MQuery.BETWEEN, value.toString(), valueTo.toString(), "AND", "", "");
|
||||
} else {
|
||||
StringBuilder msglog = new StringBuilder(ColumnName).append("=").append(value);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
||||
// globalqss - Carlos Ruiz - 20060711
|
||||
// fix a bug with virtualColumn + isSelectionColumn not yielding results
|
||||
GridField field = getTargetMField(ColumnName);
|
||||
// add encryption here if the field is encrypted.
|
||||
if (field.isEncryptedColumn()) {
|
||||
value = SecureEngine.encrypt(value, Env.getAD_Client_ID(Env.getCtx()));
|
||||
}
|
||||
|
||||
boolean isProductCategoryField = isProductCategoryField(field.getColumnName());
|
||||
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
||||
//
|
||||
// Be more permissive for String columns
|
||||
if (isSearchLike(field))
|
||||
{
|
||||
StringBuilder valueStr = new StringBuilder(value.toString().toUpperCase());
|
||||
if (!valueStr.toString().endsWith("%"))
|
||||
valueStr.append("%");
|
||||
//
|
||||
ColumnSQL = new StringBuilder("UPPER(").append(ColumnSQL).append(")");
|
||||
value = valueStr.toString();
|
||||
}
|
||||
//
|
||||
if (value.toString().indexOf('%') != -1) {
|
||||
m_query.addRestriction(ColumnSQL.toString(), MQuery.LIKE, value, ColumnName, wed.getDisplay());
|
||||
appendCode(code, ColumnName, MQuery.LIKE, value.toString(), "", "AND", "", "");
|
||||
} else if (isProductCategoryField && value instanceof Integer) {
|
||||
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
|
||||
appendCode(code, ColumnName, MQuery.EQUAL, value.toString(), "", "AND", "", "");
|
||||
} else {
|
||||
String oper = MQuery.EQUAL;
|
||||
if (wedTo != null) {
|
||||
ToolBarButton wedFlag = m_sEditorsFlag.get(i);
|
||||
if (wedFlag.isChecked())
|
||||
oper = MQuery.GREATER_EQUAL;
|
||||
}
|
||||
m_query.addRestriction(ColumnSQL.toString(), oper, value, ColumnName, wed.getDisplay());
|
||||
appendCode(code, ColumnName, oper, value.toString(), "", "AND", "", "");
|
||||
}
|
||||
|
||||
/*
|
||||
if (value.toString().indexOf('%') != -1)
|
||||
m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
|
||||
else
|
||||
m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
|
||||
*/
|
||||
// end globalqss patch
|
||||
}
|
||||
} else if (valueTo != null && valueTo.toString().length() > 0) {
|
||||
// filled upper limit without filling lower limit
|
||||
StringBuilder msglog = new StringBuilder(ColumnName).append("<=").append(valueTo);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
||||
GridField field = getTargetMField(ColumnName);
|
||||
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
||||
//
|
||||
m_query.addRestriction(ColumnSQL.toString(), MQuery.LESS_EQUAL, valueTo, ColumnName, wed.getDisplay());
|
||||
appendCode(code, ColumnName, MQuery.LESS_EQUAL, valueTo.toString(), "", "AND", "", "");
|
||||
}
|
||||
} // editors
|
||||
|
||||
if(historyCombo.getSelectedItem()!=null)
|
||||
{
|
||||
addHistoryRestriction(historyCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
saveQuery(saveQuery, code);
|
||||
|
||||
} // cmd_saveSimple
|
||||
|
||||
private void refreshUserQueries()
|
||||
{
|
||||
|
@ -1818,65 +1964,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
**/
|
||||
private void cmd_ok_Simple()
|
||||
{
|
||||
// Create Query String
|
||||
m_query = new MQuery(m_tableName);
|
||||
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
|
||||
// Special Editors
|
||||
for (int i = 0; i < m_sEditors.size(); i++)
|
||||
{
|
||||
WEditor wed = (WEditor)m_sEditors.get(i);
|
||||
Object value = wed.getValue();
|
||||
if (value != null && value.toString().length() > 0)
|
||||
{
|
||||
String ColumnName = wed.getColumnName();
|
||||
StringBuilder msglog = new StringBuilder(ColumnName).append("=").append(value);
|
||||
if (log.isLoggable(Level.FINE)) log.fine(msglog.toString());
|
||||
|
||||
// globalqss - Carlos Ruiz - 20060711
|
||||
// fix a bug with virtualColumn + isSelectionColumn not yielding results
|
||||
GridField field = getTargetMField(ColumnName);
|
||||
// add encryption here if the field is encrypted.
|
||||
if (field.isEncryptedColumn()) {
|
||||
value = SecureEngine.encrypt(value, Env.getAD_Client_ID(Env.getCtx()));
|
||||
}
|
||||
|
||||
boolean isProductCategoryField = isProductCategoryField(field.getColumnName());
|
||||
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
||||
//
|
||||
// Be more permissive for String columns
|
||||
if (isSearchLike(field))
|
||||
{
|
||||
StringBuilder valueStr = new StringBuilder(value.toString().toUpperCase());
|
||||
if (!valueStr.toString().endsWith("%"))
|
||||
valueStr.append("%");
|
||||
//
|
||||
ColumnSQL = new StringBuilder("UPPER(").append(ColumnSQL).append(")");
|
||||
value = valueStr.toString();
|
||||
}
|
||||
//
|
||||
if (value.toString().indexOf('%') != -1)
|
||||
m_query.addRestriction(ColumnSQL.toString(), MQuery.LIKE, value, ColumnName, wed.getDisplay());
|
||||
else if (isProductCategoryField && value instanceof Integer)
|
||||
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
|
||||
else
|
||||
m_query.addRestriction(ColumnSQL.toString(), MQuery.EQUAL, value, ColumnName, wed.getDisplay());
|
||||
|
||||
/*
|
||||
if (value.toString().indexOf('%') != -1)
|
||||
m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
|
||||
else
|
||||
m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
|
||||
*/
|
||||
// end globalqss patch
|
||||
}
|
||||
} // editors
|
||||
|
||||
if(historyCombo.getSelectedItem()!=null)
|
||||
{
|
||||
addHistoryRestriction(historyCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
m_isCancel = false; // teo_sarca [ 1708717 ]
|
||||
// save pending
|
||||
cmd_saveSimple(false);
|
||||
|
||||
// Test for no records
|
||||
if (getNoOfRecords(m_query, true) != 0)
|
||||
dispose();
|
||||
|
@ -1945,7 +2036,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
|||
{
|
||||
m_isCancel = false; // teo_sarca [ 1708717 ]
|
||||
// save pending
|
||||
cmd_save(false);
|
||||
cmd_saveAdvanced(false);
|
||||
|
||||
if(historyCombo.getSelectedItem()!=null)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.compiere.model.MAllocationLine;
|
|||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -422,8 +423,9 @@ public class Allocation
|
|||
{
|
||||
if ( applied.signum() == -open.signum() )
|
||||
applied = applied.negate();
|
||||
if ( open.abs().compareTo( applied.abs() ) < 0 )
|
||||
applied = open;
|
||||
if (! MSysConfig.getBooleanValue("ALLOW_OVER_APPLIED_PAYMENT", false, Env.getAD_Client_ID(Env.getCtx())))
|
||||
if ( open.abs().compareTo( applied.abs() ) < 0 )
|
||||
applied = open;
|
||||
}
|
||||
|
||||
payment.setValueAt(applied, row, i_payment);
|
||||
|
|
Loading…
Reference in New Issue