merge development into zk7

This commit is contained in:
Carlos Ruiz 2014-11-19 19:34:42 -05:00
commit 322a4a3b3e
30 changed files with 307 additions and 85 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- 14/11/2014 08:54:12 AM COT
-- IDEMPIERE-2315 Performance issue: Bill BPartner in Purchase Order as Table (full list)
UPDATE AD_Field SET AD_Reference_ID=30,Updated=TO_DATE('2014-11-14 08:54:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6505
;
SELECT register_migration_script('201411140854_IDEMPIERE-2315.sql') FROM dual
;

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Nov 17, 2014 6:27:47 PM IST
-- IDEMPIERE-2318: Handling NPE for Attribute not set on product and Batch level costing used
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated) VALUES ('E','No attribute set configured on product ',200328,'D','b8793354-b3b6-4106-8d8a-32d511d5b5d9','NoAttributeSet','Y',100,100,0,0,TO_DATE('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'))
;
SELECT register_migration_script('201411170824_IDEMPIERE-2318.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- 14/11/2014 08:54:12 AM COT
-- IDEMPIERE-2315 Performance issue: Bill BPartner in Purchase Order as Table (full list)
UPDATE AD_Field SET AD_Reference_ID=30,Updated=TO_TIMESTAMP('2014-11-14 08:54:12','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6505
;
SELECT register_migration_script('201411140854_IDEMPIERE-2315.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- Nov 17, 2014 6:27:47 PM IST
-- IDEMPIERE-2318: Handling NPE for Attribute not set on product and Batch level costing used
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated) VALUES ('E','No attribute set configured on product ',200328,'D','b8793354-b3b6-4106-8d8a-32d511d5b5d9','NoAttributeSet','Y',100,100,0,0,TO_TIMESTAMP('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2014-11-17 18:27:46','YYYY-MM-DD HH24:MI:SS'))
;
SELECT register_migration_script('201411170824_IDEMPIERE-2318.sql') FROM dual
;

View File

@ -513,7 +513,7 @@ public class CostUpdate extends SvrProcess
}
if (retValue == null)
{
MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID());
MProduct product = new MProduct(getCtx(), cost.getM_Product_ID(), get_TrxName());
MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID());
retValue = MCost.getLastInvoicePrice(product,
cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID());
@ -532,7 +532,7 @@ public class CostUpdate extends SvrProcess
}
if (retValue == null)
{
MProduct product = MProduct.get(getCtx(), cost.getM_Product_ID());
MProduct product = new MProduct(getCtx(), cost.getM_Product_ID(), get_TrxName());
MAcctSchema as = MAcctSchema.get(getCtx(), cost.getC_AcctSchema_ID());
retValue = MCost.getLastPOPrice(product,
cost.getM_AttributeSetInstance_ID(), cost.getAD_Org_ID(), as.getC_Currency_ID());

View File

@ -23,6 +23,8 @@ import java.sql.Timestamp;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.ImportValidator;
import org.adempiere.process.ImportProcess;
import org.compiere.model.I_C_DocType;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MAttributeSet;
@ -32,6 +34,7 @@ import org.compiere.model.MInventory;
import org.compiere.model.MInventoryLine;
import org.compiere.model.MProduct;
import org.compiere.model.MProductCategoryAcct;
import org.compiere.model.ModelValidationEngine;
import org.compiere.model.PO;
import org.compiere.model.X_I_Inventory;
import org.compiere.util.AdempiereUserError;
@ -50,8 +53,9 @@ import org.compiere.util.ValueNamePair;
*
* Contributor:
* Carlos Ruiz - globalqss - IDEMPIERE-281 Extend Import Inventory to support also internal use
* Deepak Pansheriya - logilite - IDEMPIERE-2314 Making import inventory process extendible
*/
public class ImportInventory extends SvrProcess
public class ImportInventory extends SvrProcess implements ImportProcess
{
/** Client to be imported to */
private int p_AD_Client_ID = 0;
@ -184,6 +188,8 @@ public class ImportInventory extends SvrProcess
no = DB.executeUpdate (sql.toString (), get_TrxName());
if (log.isLoggable(Level.INFO)) log.info ("Reset=" + no);
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_BEFORE_VALIDATE);
sql = new StringBuilder ("UPDATE I_Inventory o ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Org, '")
.append("WHERE (AD_Org_ID IS NULL OR AD_Org_ID=0")
@ -330,6 +336,8 @@ public class ImportInventory extends SvrProcess
if (no != 0)
log.warning ("Required charge=" + no);
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE);
commitEx();
/*********************************************************************/
@ -354,6 +362,8 @@ public class ImportInventory extends SvrProcess
int x_C_DocType_ID = -1;
Timestamp x_MovementDate = null;
int x_isInternalUse = -1;
X_I_Inventory lastImp=null;
while (rs.next())
{
X_I_Inventory imp = new X_I_Inventory (getCtx (), rs, get_TrxName());
@ -367,6 +377,9 @@ public class ImportInventory extends SvrProcess
|| isInternalUse != x_isInternalUse)
{
if (inventory != null) {
ModelValidationEngine.get().fireImportValidate(this, lastImp, inventory, ImportValidator.TIMING_AFTER_IMPORT);
if (m_docAction != null && m_docAction.length() > 0) {
if (!inventory.processIt(m_docAction)) {
log.warning("Inventory Process Failed: " + inventory + " - " + inventory.getProcessMsg());
@ -383,6 +396,8 @@ public class ImportInventory extends SvrProcess
inventory.setDescription("I " + imp.getM_Warehouse_ID() + " " + MovementDate);
inventory.setM_Warehouse_ID(imp.getM_Warehouse_ID());
inventory.setMovementDate(MovementDate);
ModelValidationEngine.get().fireImportValidate(this, imp, inventory, ImportValidator.TIMING_BEFORE_IMPORT);
//
if (!inventory.save())
{
@ -400,25 +415,10 @@ public class ImportInventory extends SvrProcess
x_isInternalUse = isInternalUse;
noInsert++;
}
MProduct product = MProduct.get(getCtx(), imp.getM_Product_ID());
MProduct product = new MProduct(getCtx(), imp.getM_Product_ID(), get_TrxName());
// Line
int M_AttributeSetInstance_ID = 0;
if ((imp.getLot() != null && imp.getLot().length() > 0) || (imp.getSerNo() != null && imp.getSerNo().length() > 0))
{
if (product.isInstanceAttribute())
{
MAttributeSet mas = product.getAttributeSet();
MAttributeSetInstance masi = new MAttributeSetInstance(getCtx(), 0, mas.getM_AttributeSet_ID(), get_TrxName());
if (mas.isLot() && imp.getLot() != null)
masi.setLot(imp.getLot(), imp.getM_Product_ID());
if (mas.isSerNo() && imp.getSerNo() != null)
masi.setSerNo(imp.getSerNo());
masi.setDescription();
masi.saveEx();
M_AttributeSetInstance_ID = masi.getM_AttributeSetInstance_ID();
}
}
int M_AttributeSetInstance_ID = generateASI(product,imp);
MInventoryLine line = new MInventoryLine (inventory,
imp.getM_Locator_ID(), imp.getM_Product_ID(), M_AttributeSetInstance_ID,
imp.getQtyBook(), imp.getQtyCount(), imp.getQtyInternalUse());
@ -428,6 +428,9 @@ public class ImportInventory extends SvrProcess
else
line.setInventoryType(MInventoryLine.INVENTORYTYPE_InventoryDifference);
line.setC_Charge_ID(imp.getC_Charge_ID());
ModelValidationEngine.get().fireImportValidate(this, imp, line, ImportValidator.TIMING_BEFORE_IMPORT);
if (line.save())
{
imp.setI_IsImported(true);
@ -450,6 +453,9 @@ public class ImportInventory extends SvrProcess
log.log(Level.SEVERE, "Inventory Line not saved");
break;
}
ModelValidationEngine.get().fireImportValidate(this, imp, line, ImportValidator.TIMING_AFTER_IMPORT);
lastImp = imp;
}
if (inventory != null) {
if (m_docAction != null && m_docAction.length() > 0) {
@ -499,8 +505,28 @@ public class ImportInventory extends SvrProcess
return "";
} // doIt
protected int generateASI(MProduct product,X_I_Inventory imp){
int M_AttributeSetInstance_ID = 0;
if ((imp.getLot() != null && imp.getLot().length() > 0) || (imp.getSerNo() != null && imp.getSerNo().length() > 0))
{
if (product.isInstanceAttribute())
{
MAttributeSet mas = product.getAttributeSet();
MAttributeSetInstance masi = new MAttributeSetInstance(getCtx(), 0, mas.getM_AttributeSet_ID(), get_TrxName());
if (mas.isLot() && imp.getLot() != null)
masi.setLot(imp.getLot(), imp.getM_Product_ID());
if (mas.isSerNo() && imp.getSerNo() != null)
masi.setSerNo(imp.getSerNo());
masi.setDescription();
masi.saveEx();
M_AttributeSetInstance_ID = masi.getM_AttributeSetInstance_ID();
}
}
return M_AttributeSetInstance_ID;
}
private void updateCosting(X_I_Inventory imp, MProduct product,
protected void updateCosting(X_I_Inventory imp, MProduct product,
MInventoryLine line) {
String costingLevel = null;
if(product.getM_Product_Category_ID() > 0){
@ -519,10 +545,13 @@ public class ImportInventory extends SvrProcess
costASI = 0;
} else if (MAcctSchema.COSTINGLEVEL_Organization.equals(costingLevel)) {
costASI = 0;
} else if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(costingLevel)) {
costOrgID = 0;
}
MCost cost = MCost.get (MProduct.get(getCtx(), imp.getM_Product_ID()), costASI
MCost cost = MCost.get (product, costASI
, acctSchema, costOrgID, p_M_CostElement_ID, get_TrxName());
if (cost.is_new())
cost.saveEx();
if (costingDoc == null) {
costingDoc = new MInventory(getCtx(), 0, get_TrxName());
costingDoc.setC_DocType_ID(p_C_DocType_ID);
@ -539,10 +568,23 @@ public class ImportInventory extends SvrProcess
costingLine.setNewCostPrice(imp.getCurrentCostPrice());
costingLine.setM_Locator_ID(0);
costingLine.setAD_Org_ID(imp.getAD_Org_ID());
costingLine.saveEx();
costingLine.setM_AttributeSetInstance_ID(costASI);
costingLine.saveEx();
imp.setM_CostingLine_ID(costingLine.getM_InventoryLine_ID());
imp.saveEx();
}
@Override
public String getImportTableName() {
return X_I_Inventory.Table_Name;
}
@Override
public String getWhereClause() {
StringBuilder msgreturn = new StringBuilder(" AND AD_Client_ID=").append(p_AD_Client_ID);
return msgreturn.toString();
}
} // ImportInventory

View File

@ -324,7 +324,7 @@ public class MAsset extends X_A_Asset
// Copy fields from C_BPartner_Location
if (is_ValueChanged(COLUMNNAME_C_BPartner_Location_ID) && getC_BPartner_Location_ID() > 0)
{
// Goodwill BF: Error: org.compiere.model.MAsset cannot be cast to org.compiere.model.SetGetModel
// Goodwill BF: Error: org.compiere.model.MAsset cannot be cast to org.compiere.model.SetGetModel
SetGetUtil.copyValues(SetGetUtil.wrap(this), MBPartnerLocation.Table_Name, getC_BPartner_Location_ID(),
new String[]{MBPartnerLocation.COLUMNNAME_C_Location_ID}
);

View File

@ -731,7 +731,7 @@ public class MClient extends X_AD_Client
msg = email.send();
}
//
X_AD_UserMail um = new X_AD_UserMail(getCtx(), 0, null);
X_AD_UserMail um = new X_AD_UserMail(getCtx(), 0, to.get_TrxName());
um.setClientOrg(this);
um.setAD_User_ID(to.getAD_User_ID());
um.setSubject(email.getSubject());

View File

@ -55,14 +55,10 @@ import org.compiere.util.Trx;
*/
public class MCost extends X_M_Cost
{
/**
*
*/
private static final long serialVersionUID = -127982599769472918L;
/**
*
*/
private static final long serialVersionUID = -8904980122276406878L;
/**
* Retrieve/Calculate Current Cost Price
@ -1520,6 +1516,19 @@ public class MCost extends X_M_Cost
setCurrentQty(getCurrentQty().add(qty));
} // setWeightedAverage
/**
* @param amt unit amt
*/
public void setWeightedAverageInitial (BigDecimal amtUnit)
{
BigDecimal cost = amtUnit;
if (cost.scale() > (getPrecision()*2))
{
cost = cost.setScale((getPrecision()*2), BigDecimal.ROUND_HALF_UP);
}
setCurrentCostPrice(cost);
} // setWeightedAverageInitial
/**
* Get Costing Precision
* @return precision (6)

View File

@ -833,7 +833,7 @@ public class MCostDetail extends X_M_CostDetail
// get costing level for product
MAcctSchema as = MAcctSchema.get(getCtx(), getC_AcctSchema_ID());
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName());
String CostingLevel = product.getCostingLevel(as);
// Org Element
int Org_ID = getAD_Org_ID();
@ -1152,7 +1152,12 @@ public class MCostDetail extends X_M_CostDetail
costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
if (MCostElement.COSTINGMETHOD_AverageInvoice.equals(costingMethod))
{
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
if (cost.getCurrentQty().signum() == 0 && qty.signum() == 0) {
// IDEMPIERE-2057 - this is a cost adjustment when there is no qty - setting the initial cost
cost.setWeightedAverageInitial(amt);
} else {
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
}
}
}
else if (addition)
@ -1177,7 +1182,12 @@ public class MCostDetail extends X_M_CostDetail
costingMethod = getM_InventoryLine().getM_Inventory().getCostingMethod();
if (MCostElement.COSTINGMETHOD_AveragePO.equals(costingMethod))
{
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
if (cost.getCurrentQty().signum() == 0 && qty.signum() == 0) {
// IDEMPIERE-2057 - this is a cost adjustment when there is no qty - setting the initial cost
cost.setWeightedAverageInitial(amt);
} else {
cost.setWeightedAverage(amt.multiply(cost.getCurrentQty()), qty);
}
}
}
else if (addition)

View File

@ -1190,6 +1190,11 @@ public class MInOut extends X_M_InOut implements DocAction
continue;
if (product != null && product.isASIMandatory(isSOTrx()))
{
if(product.getAttributeSet()==null){
m_processMsg = "@NoAttributeSet@=" + product.getValue();
return DocAction.STATUS_Invalid;
}
if (! product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) {
m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() +
", @M_Product_ID@=" + product.getValue() + ")";

View File

@ -268,6 +268,10 @@ public class MInventoryLine extends X_M_InventoryLine
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
if (product != null && product.isASIMandatory(isSOTrx()))
{
if(product.getAttributeSet()==null){
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, isSOTrx())) {
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
return false;
@ -353,7 +357,7 @@ public class MInventoryLine extends X_M_InventoryLine
}
int M_ASI_ID = getM_AttributeSetInstance_ID();
MProduct product = getProduct();
MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName());
MClient client = MClient.get(getCtx());
MAcctSchema as = client.getAcctSchema();
String costingLevel = product.getCostingLevel(as);

View File

@ -323,23 +323,25 @@ public final class MLocatorLookup extends Lookup implements Serializable
int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error
int local_only_product_id = getOnly_Product_ID();
StringBuilder sql = new StringBuilder("SELECT * FROM M_Locator ")
.append(" WHERE IsActive='Y'");
StringBuilder sql = new StringBuilder("SELECT M_Locator.* FROM M_Locator ")
.append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ")
.append(" WHERE M_Locator.IsActive='Y' ")
.append(" AND wh.IsActive='Y'");
if (local_only_warehouse_id != 0)
sql.append(" AND M_Warehouse_ID=?");
sql.append(" AND M_Locator.M_Warehouse_ID=?");
if (local_only_product_id != 0)
sql.append(" AND (IsDefault='Y' ") // Default Locator
sql.append(" AND (M_Locator.IsDefault='Y' ") // Default Locator
.append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator
.append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)")
.append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator
.append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))");
sql.append(" ORDER BY ");
if (local_only_warehouse_id == 0)
sql.append("(SELECT wh.Name FROM M_Warehouse wh WHERE wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID),");
sql.append("wh.Name,");
sql.append("M_Locator.Value");
String finalSql = MRole.getDefault(m_ctx, false).addAccessSQL(
sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
sql.toString(), "M_Locator", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
if (isInterrupted())
{
log.log(Level.SEVERE, "Interrupted");

View File

@ -211,6 +211,10 @@ public class MMovementLine extends X_M_MovementLine
// Mandatory Instance
MProduct product = getProduct();
if (getM_AttributeSetInstance_ID() == 0) {
if (product != null && product.getAttributeSet()==null) {
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (product != null && product.isASIMandatory(true)) {
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true /*outgoing*/)) {
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
@ -227,6 +231,10 @@ public class MMovementLine extends X_M_MovementLine
setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID());
}
if (product != null && product.getAttributeSet()==null) {
log.saveError("NoAttributeSet", product.getValue());
return false;
}
if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0)
{
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false /*incoming*/)) {

View File

@ -1338,6 +1338,11 @@ public class MOrder extends X_C_Order implements DocAction
if (line.getM_Product_ID() > 0 && line.getM_AttributeSetInstance_ID() == 0) {
MProduct product = line.getProduct();
if (product.isASIMandatory(isSOTrx())) {
if(product.getAttributeSet()==null){
m_processMsg = "@NoAttributeSet@=" + product.getValue();
return DocAction.STATUS_Invalid;
}
if (! product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) {
StringBuilder msg = new StringBuilder("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #")
.append(line.getLine())

View File

@ -83,7 +83,7 @@ public class MPayment extends X_C_Payment
/**
*
*/
private static final long serialVersionUID = -3426445843281140181L;
private static final long serialVersionUID = -7646717328867858897L;
/**
* Get Payments Of BPartner
@ -654,6 +654,22 @@ public class MPayment extends X_C_Payment
*/
protected boolean beforeSave (boolean newRecord)
{
if (isComplete() &&
( is_ValueChanged(COLUMNNAME_C_BankAccount_ID)
|| is_ValueChanged(COLUMNNAME_C_BPartner_ID)
|| is_ValueChanged(COLUMNNAME_C_Charge_ID)
|| is_ValueChanged(COLUMNNAME_C_Currency_ID)
|| is_ValueChanged(COLUMNNAME_C_DocType_ID)
|| is_ValueChanged(COLUMNNAME_C_Invoice_ID)
|| is_ValueChanged(COLUMNNAME_C_Order_ID)
|| is_ValueChanged(COLUMNNAME_DateAcct)
|| is_ValueChanged(COLUMNNAME_DateTrx)
|| is_ValueChanged(COLUMNNAME_DiscountAmt)
|| is_ValueChanged(COLUMNNAME_PayAmt)
|| is_ValueChanged(COLUMNNAME_WriteOffAmt))) {
log.saveError("PaymentAlreadyProcessed", Msg.translate(getCtx(), "C_Payment_ID"));
return false;
}
// @Trifon - CashPayments
//if ( getTenderType().equals("X") ) {
if ( isCashbookTrx()) {
@ -781,7 +797,19 @@ public class MPayment extends X_C_Payment
return true;
} // beforeSave
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
/**
* Get Allocated Amt in Payment Currency
* @return amount or null

View File

@ -910,7 +910,7 @@ public class MProduct extends X_M_Product
if (ce == null) {
return null;
}
MCost cost = MCost.get(this, M_ASI_ID, as, AD_Org_ID, ce.getM_CostElement_ID(), (String)null);
MCost cost = MCost.get(this, M_ASI_ID, as, AD_Org_ID, ce.getM_CostElement_ID(), get_TrxName());
return cost.is_new() ? null : cost;
}
} // MProduct

View File

@ -1145,7 +1145,7 @@ class Restriction implements Serializable
if (Code instanceof String)
sb.append(DB.TO_STRING(Code.toString()));
else if (Code instanceof Timestamp)
sb.append(DB.TO_DATE((Timestamp)Code));
sb.append(DB.TO_DATE((Timestamp)Code, false));
else
sb.append(Code);
@ -1157,7 +1157,7 @@ class Restriction implements Serializable
if (Code_to instanceof String)
sb.append(DB.TO_STRING(Code_to.toString()));
else if (Code_to instanceof Timestamp)
sb.append(DB.TO_DATE((Timestamp)Code_to));
sb.append(DB.TO_DATE((Timestamp)Code_to, false));
else
sb.append(Code_to);
}

View File

@ -41,6 +41,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.Trx;
import org.compiere.util.Util;
/**
* Sequence Model.
@ -519,15 +520,23 @@ public class MSequence extends X_AD_Sequence
// create DocumentNo
StringBuilder doc = new StringBuilder();
if (prefix != null && prefix.length() > 0)
doc.append(Env.parseVariable(prefix, po, trxName, false));
if (prefix != null && prefix.length() > 0) {
String prefixValue = Env.parseVariable(prefix, po, trxName, false);
if (!Util.isEmpty(prefixValue))
doc.append(prefixValue);
}
if (decimalPattern != null && decimalPattern.length() > 0)
doc.append(new DecimalFormat(decimalPattern).format(next));
else
doc.append(next);
if (suffix != null && suffix.length() > 0)
doc.append(Env.parseVariable(suffix, po, trxName, false));
if (suffix != null && suffix.length() > 0) {
String suffixValue = Env.parseVariable(suffix, po, trxName, false);
if (!Util.isEmpty(suffixValue))
doc.append(suffixValue);
}
String documentNo = doc.toString();
if (s_log.isLoggable(Level.FINER)) s_log.finer (documentNo + " (" + incrementNo + ")"
+ " - Sequence=" + AD_Sequence_ID + " [" + trx + "]");

View File

@ -39,10 +39,10 @@ import org.compiere.util.DisplayType;
*/
public class MSysConfig extends X_AD_SysConfig
{
/**
/**
*
*/
private static final long serialVersionUID = -5043918406658386237L;
private static final long serialVersionUID = 8965976274227777648L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -78,6 +78,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String DOCACTIONBUTTON_SHOWACTIONNAME = "DOCACTIONBUTTON_SHOWACTIONNAME";
public static final String DPVIEWS_SHOWINFOACCOUNT = "DPViews_ShowInfoAccount";
public static final String DPVIEWS_SHOWINFOSCHEDULE = "DPViews_ShowInfoSchedule";
public static final String ENABLE_PAYMENTBOX_BUTTON = "ENABLE_PAYMENTBOX_BUTTON";
public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS";
public static final String Invoice_ReverseUseNewNumber = "Invoice_ReverseUseNewNumber";
public static final String JASPER_SWAP_MAX_PAGES = "JASPER_SWAP_MAX_PAGES";

View File

@ -48,7 +48,7 @@ public class ProductCost
{
m_M_Product_ID = M_Product_ID;
if (m_M_Product_ID != 0)
m_product = MProduct.get (ctx, M_Product_ID);
m_product = new MProduct(ctx, M_Product_ID, trxName);
m_M_AttributeSetInstance_ID = M_AttributeSetInstance_ID;
m_trxName = trxName;
} // ProductCost

View File

@ -1480,8 +1480,12 @@ public final class Env
String v = Env.getContext(ctx, token);
if (v != null && v.length() > 0)
outStr.append(v);
else if (keepUnparseable)
outStr.append("@"+token+"@");
else if (keepUnparseable) {
outStr.append("@").append(token);
if (!Util.isEmpty(format))
outStr.append("<").append(format).append(">");
outStr.append("@");
}
} else if (po != null) {
//take from po
if (po.get_ColumnIndex(token) >= 0) {
@ -1525,7 +1529,10 @@ public final class Env
}
}
} else if (keepUnparseable) {
outStr.append("@"+token+"@");
outStr.append("@").append(token);
if (!Util.isEmpty(format))
outStr.append("<").append(format).append(">");
outStr.append("@");
}
}

View File

@ -1691,7 +1691,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
{
if (AD_User_ID != 0)
{
MUser user = MUser.get(getCtx(), AD_User_ID);
MUser user = new MUser(getCtx(), AD_User_ID, get_TrxName());
email = user.getEMail();
if (email != null && email.length() > 0)
{

View File

@ -56,19 +56,21 @@ public class Actions {
}
if (aImage != null)
return aImage;
String path = ACTION_IMAGES_PATH + actionId + "24.png";
InputStream inputStream = Actions.class.getClassLoader().getResourceAsStream(path);
if (inputStream != null) {
try {
aImage = new AImage(actionId, inputStream);
} catch (IOException e) {
}
}
if (aImage != null) {
synchronized (imageCache) {
imageCache.put(actionId, aImage);
IServiceHolder<IAction> action = Service.locator().locate(IAction.class, actionId, null);
if (action.getService() != null) {
String path = ACTION_IMAGES_PATH + actionId + "24.png";
InputStream inputStream = action.getService().getClass().getClassLoader().getResourceAsStream(path);
if (inputStream != null) {
try {
aImage = new AImage(actionId, inputStream);
} catch (IOException e) {
}
}
if (aImage != null)
synchronized (imageCache) {
imageCache.put(actionId, aImage);
}
}
return aImage;
}

View File

@ -34,7 +34,6 @@ import org.adempiere.webui.window.FDialog;
import org.compiere.grid.PaymentFormCash;
import org.compiere.model.GridTab;
import org.compiere.model.MConversionRate;
import org.compiere.model.MInvoice;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;

View File

@ -17,6 +17,8 @@ import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.adempiere.webui.LayoutUtils;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Comboitem;
@ -77,6 +79,8 @@ public class Paymentbox extends Div {
}
public void setEnabled(boolean isComboEnabled, boolean isBtnEnabled) {
if (! MSysConfig.getBooleanValue(MSysConfig.ENABLE_PAYMENTBOX_BUTTON, true, Env.getAD_Client_ID(Env.getCtx())))
isBtnEnabled = false;
combo.setEnabled(isComboEnabled);
combo.setButtonVisible(isComboEnabled);
btn.setEnabled(isBtnEnabled);

View File

@ -16,15 +16,19 @@ package org.adempiere.webui.editor;
import javax.swing.event.ListDataListener;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.ValuePreference;
import org.adempiere.webui.adwindow.ADTabpanel;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.form.WPaymentFormFactory;
import org.adempiere.webui.apps.form.WPaymentFormWindow;
import org.adempiere.webui.component.Paymentbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.ContextMenuEvent;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.WFieldRecordInfo;
import org.compiere.grid.IPaymentForm;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
@ -45,7 +49,7 @@ import org.zkoss.zul.Comboitem;
* @author Elaine
*
*/
public class WPaymentEditor extends WEditor implements ListDataListener {
public class WPaymentEditor extends WEditor implements ListDataListener, ContextMenuListener {
public final static String ON_SAVE_PAYMENT = "onSavePayment";
@ -79,6 +83,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener {
lookup.refresh();
refreshList();
}
popupMenu = new WEditorPopupMenu(false, true, isShowPreference());
addChangeLogMenu(popupMenu);
}
@Override
@ -181,6 +187,8 @@ public class WPaymentEditor extends WEditor implements ListDataListener {
if (!m_onlyRule // Only order has Warehouse
&& !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null)
m_onlyRule = true;
if (!m_onlyRule && m_mTab.needSave(true, false)) // don't show button until change on payment rule is saved
m_onlyRule = true;
}
getComponent().setEnabled(readWrite, readWrite && !m_onlyRule);
@ -347,4 +355,41 @@ public class WPaymentEditor extends WEditor implements ListDataListener {
public String[] getEvents() {
return LISTENER_EVENTS;
}
@Override
public void onMenu(ContextMenuEvent evt)
{
if (WEditorPopupMenu.REQUERY_EVENT.equals(evt.getContextEvent()))
{
actionRefresh();
}
else if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
{
if (isShowPreference())
ValuePreference.start (getComponent(), this.getGridField(), getValue());
return;
}
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
{
WFieldRecordInfo.start(gridField);
}
}
public void actionRefresh()
{
if (lookup != null)
{
Object curValue = getValue();
if (isReadWrite())
lookup.refresh();
else
refreshList();
if (curValue != null)
{
setValue(curValue);
}
}
}
}

View File

@ -1390,7 +1390,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
} else if (keyEvent.getKeyCode() == VK_ENTER) { // Enter
// enter in contentpanel to select
//when user push enter keyboard at input parameter field
if (contentPanel.getSelectedIndex() >= 0) {
if (m_lookup && contentPanel.getSelectedIndex() >= 0) {
onOk();
} else {
onUserQuery();

View File

@ -1661,8 +1661,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
{
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());
if (log.isLoggable(Level.FINE)) {
StringBuilder msglog = new StringBuilder(ColumnName).append(">=").append(value).append("<=").append(valueTo);
log.fine(msglog.toString());
}
GridField field = getTargetMField(ColumnName);
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
@ -1670,8 +1672,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
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());
if (log.isLoggable(Level.FINE)) {
StringBuilder msglog = new StringBuilder(ColumnName).append("=").append(value);
log.fine(msglog.toString());
}
// globalqss - Carlos Ruiz - 20060711
// fix a bug with virtualColumn + isSelectionColumn not yielding results
@ -1722,8 +1726,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
} 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());
if (log.isLoggable(Level.FINE)) {
StringBuilder msglog = new StringBuilder(ColumnName).append("<=").append(valueTo);
log.fine(msglog.toString());
}
GridField field = getTargetMField(ColumnName);
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));

View File

@ -208,11 +208,11 @@ public abstract class PaymentFormCheck extends PaymentForm {
if (invoice == null && C_Order_ID != 0)
order = new MOrder (Env.getCtx(), C_Order_ID, null);
BigDecimal payAmount = m_Amount;
BigDecimal payAmount = amount;
if (negateAmt)
payAmount = m_Amount.negate();
payAmount = amount.negate();
// Info
if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID + ", C_Invoice_ID=" + C_Invoice_ID + ", NegateAmt=" + negateAmt);