Recommit to recover history on files modified integrating libero

This commit is contained in:
Carlos Ruiz 2008-05-30 04:00:21 +00:00
parent 3b762965b1
commit 089bfcd9b5
50 changed files with 7336 additions and 5769 deletions

View File

@ -178,6 +178,9 @@ public class RoleElementHandler extends AbstractElementHandler {
m_Role.setAllow_Info_Product(Boolean.valueOf(atts.getValue("AllowInfoProduct"))); m_Role.setAllow_Info_Product(Boolean.valueOf(atts.getValue("AllowInfoProduct")));
m_Role.setAllow_Info_Resource(Boolean.valueOf(atts.getValue("AllowInfoResource"))); m_Role.setAllow_Info_Resource(Boolean.valueOf(atts.getValue("AllowInfoResource")));
m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoSchedule"))); m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoSchedule")));
m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoCRP")));
m_Role.setAllow_Info_Schedule(Boolean.valueOf(atts.getValue("AllowInfoMRP")));
if (m_Role.save(getTrxName(ctx)) == true) { if (m_Role.save(getTrxName(ctx)) == true) {
@ -504,6 +507,8 @@ public class RoleElementHandler extends AbstractElementHandler {
atts.addAttribute("", "", "AllowInfoProduct", "CDATA", Boolean.toString(m_Role.isAllow_Info_Product())); atts.addAttribute("", "", "AllowInfoProduct", "CDATA", Boolean.toString(m_Role.isAllow_Info_Product()));
atts.addAttribute("", "", "AllowInfoResource", "CDATA", Boolean.toString(m_Role.isAllow_Info_Resource())); atts.addAttribute("", "", "AllowInfoResource", "CDATA", Boolean.toString(m_Role.isAllow_Info_Resource()));
atts.addAttribute("", "", "AllowInfoSchedule", "CDATA", Boolean.toString(m_Role.isAllow_Info_Schedule())); atts.addAttribute("", "", "AllowInfoSchedule", "CDATA", Boolean.toString(m_Role.isAllow_Info_Schedule()));
atts.addAttribute("", "", "AllowInfoCRP", "CDATA", Boolean.toString(m_Role.isAllow_Info_CRP()));
atts.addAttribute("", "", "AllowInfoMRP", "CDATA", Boolean.toString(m_Role.isAllow_Info_MRP()));
return atts; return atts;
} }

View File

@ -40,6 +40,7 @@ import org.compiere.util.Msg;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MAllocationHdr.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ * @version $Id: MAllocationHdr.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
* @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
*/ */
public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
{ {
@ -119,6 +120,54 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
return retValue; return retValue;
} // getOfInvoice } // getOfInvoice
//FR [ 1866214 ]
/**
* Get Allocations of Cash
* @param ctx context
* @param C_Cash_ID Cash ID
* @return allocations of payment
* @param trxName transaction
*/
public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName)
{
String sql = "SELECT a.C_AllocationHdr_ID FROM C_Cash c "
+ " INNER JOIN C_Cashline cl ON (c.C_Cash_ID= cl.C_Cash_ID) "
+ " INNER JOIN C_AllocationLine al ON (al.C_Cashline_ID=cl.C_Cashline_ID) "
+ " INNER JOIN C_AllocationHdr a ON(al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) "
+ " WHERE c.C_Cash_ID=? GROUP BY a.C_AllocationHdr_ID";
ArrayList<MAllocationHdr> list = new ArrayList<MAllocationHdr>();
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, C_Cash_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add (new MAllocationHdr(ctx, rs.getInt(1), trxName));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MAllocationHdr[] retValue = new MAllocationHdr[list.size()];
list.toArray(retValue);
return retValue;
} // getOfInvoice
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger(MAllocationHdr.class); private static CLogger s_log = CLogger.getCLogger(MAllocationHdr.class);

View File

@ -39,7 +39,7 @@ import org.compiere.util.TimeUtil;
* *
* @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 victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1831997 ] Cash journal allocation reversed * <li>BF [ 1831997 ] Cash journal allocation reversed
* <li>BF [ 1894524 ] Pay an reversed invoice * <li>BF [ 1894524 ] Pay an reversed invoice
@ -567,6 +567,13 @@ public class MCash extends X_C_Cash implements DocAction
m_processMsg = CLogger.retrieveErrorString("Could not create Payment"); m_processMsg = CLogger.retrieveErrorString("Could not create Payment");
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
line.setC_Payment_ID(pay.getC_Payment_ID());
if (!line.save())
{
m_processMsg = "Could not update Cash Line";
return DocAction.STATUS_Invalid;
}
} }
} }
@ -595,17 +602,107 @@ public class MCash extends X_C_Cash implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID);
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
//FR [ 1866214 ]
boolean retValue = reverseIt();
if (retValue) {
// After Void // After Void
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID);
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
return false; }
return retValue;
} // voidIt } // voidIt
//FR [ 1866214 ]
/**************************************************************************
* Reverse Cash
* Period needs to be open
* @return true if reversed
*/
private boolean reverseIt()
{
if (DOCSTATUS_Closed.equals(getDocStatus())
|| DOCSTATUS_Reversed.equals(getDocStatus())
|| DOCSTATUS_Voided.equals(getDocStatus()))
{
m_processMsg = "Document Closed: " + getDocStatus();
setDocAction(DOCACTION_None);
return false;
}
// Can we delete posting
if (!MPeriod.isOpen(getCtx(), this.getDateAcct(), MPeriodControl.DOCBASETYPE_CashJournal))
throw new IllegalStateException("@PeriodClosed@");
// Reverse Allocations
MAllocationHdr[] allocations = MAllocationHdr.getOfCash(getCtx(), getC_Cash_ID(), get_TrxName());
for(MAllocationHdr allocation : allocations)
{
allocation.reverseCorrectIt();
if(!allocation.save())
throw new IllegalStateException("Cannot reverse allocations");
}
MCashLine[] cashlines = getLines(true);
for (MCashLine cashline : cashlines )
{
BigDecimal oldAmount = cashline.getAmount();
BigDecimal oldDiscount = cashline.getDiscountAmt();
BigDecimal oldWriteOff = cashline.getWriteOffAmt();
cashline.setAmount(Env.ZERO);
cashline.setDiscountAmt(Env.ZERO);
cashline.setWriteOffAmt(Env.ZERO);
cashline.addDescription(Msg.getMsg(getCtx(), "Voided")
+ " (Amount=" + oldAmount + ", Discount=" + oldDiscount
+ ", WriteOff=" + oldWriteOff + ", )");
if (MCashLine.CASHTYPE_BankAccountTransfer.equals(cashline.getCashType()))
{
if (cashline.getC_Payment_ID() == 0)
throw new IllegalStateException("Cannot reverse payment");
MPayment payment = new MPayment(getCtx(), cashline.getC_Payment_ID(),get_TrxName());
payment.reverseCorrectIt();
if (!payment.save())
throw new IllegalStateException("Cannot reverse payment");
}
}
setName(getName()+"^");
addDescription(Msg.getMsg(getCtx(), "Voided"));
setDocStatus(DOCSTATUS_Reversed); // for direct calls
setProcessed(true);
setDocAction(DOCACTION_None);
if (!save())
throw new IllegalStateException("Cannot save journal cash");
// Delete Posting
String sql = "DELETE FROM Fact_Acct WHERE AD_Table_ID=" + MCash.Table_ID
+ " AND Record_ID=" + getC_Cash_ID();
int no = DB.executeUpdate(sql, get_TrxName());
log.fine("Fact_Acct deleted #" + no);
return true;
} // reverse
/**
* Add to Description
* @param description text
*/
public void addDescription (String description)
{
String desc = getDescription();
if (desc == null)
setDescription(description);
else
setDescription(desc + " | " + description);
} // addDescription
/** /**
* Close Document. * Close Document.
* Cancel not delivered Qunatities * Cancel not delivered Quantities
* @return true if success * @return true if success
*/ */
public boolean closeIt() public boolean closeIt()
@ -636,12 +733,17 @@ public class MCash extends X_C_Cash implements DocAction
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
//FR [ 1866214 ]
boolean retValue = reverseIt();
if (retValue) {
// After reverseCorrect // After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
}
return false; return retValue;
} // reverseCorrectionIt } // reverseCorrectionIt
/** /**

View File

@ -34,6 +34,9 @@ import org.compiere.util.*;
* Modifications: Added the RMA functionality (Ashley Ramdass) * Modifications: Added the RMA functionality (Ashley Ramdass)
* @author Karsten Thiemann, Schaeffer AG * @author Karsten Thiemann, Schaeffer AG
* <li>Bug [ 1759431 ] Problems with VCreateFrom * <li>Bug [ 1759431 ] Problems with VCreateFrom
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
*/ */
public class MInOut extends X_M_InOut implements DocAction public class MInOut extends X_M_InOut implements DocAction
{ {
@ -1224,11 +1227,14 @@ public class MInOut extends X_M_InOut implements DocAction
log.info("Line=" + sLine.getLine() + " - Qty=" + sLine.getMovementQty()); log.info("Line=" + sLine.getLine() + " - Qty=" + sLine.getMovementQty());
checkMaterialPolicy(sLine);
// Stock Movement - Counterpart MOrder.reserveStock // Stock Movement - Counterpart MOrder.reserveStock
if (product != null if (product != null
&& product.isStocked() ) && product.isStocked() )
{ {
//Ignore the Material Policy when is Reverse Correction
if(!isReversal())
checkMaterialPolicy(sLine);
log.fine("Material Transaction"); log.fine("Material Transaction");
MTransaction mtrx = null; MTransaction mtrx = null;
//same warehouse in order and receipt? //same warehouse in order and receipt?
@ -1546,27 +1552,37 @@ public class MInOut extends X_M_InOut implements DocAction
String MovementType = getMovementType(); String MovementType = getMovementType();
boolean inTrx = MovementType.charAt(1) == '+'; // V+ Vendor Receipt boolean inTrx = MovementType.charAt(1) == '+'; // V+ Vendor Receipt
boolean needSave = false; boolean needSave = false;
BigDecimal qtyASI = Env.ZERO ;
MProduct product = line.getProduct(); MProduct product = line.getProduct();
// Need to have Location // Need to have Location
if (product != null if (product != null
&& line.getM_Locator_ID() == 0) && line.getM_Locator_ID() == 0)
{ {
//MWarehouse w = MWarehouse.get(getCtx(), getM_Warehouse_ID());
line.setM_Warehouse_ID(getM_Warehouse_ID()); line.setM_Warehouse_ID(getM_Warehouse_ID());
line.setM_Locator_ID(inTrx ? Env.ZERO : line.getMovementQty()); // default Locator line.setM_Locator_ID(inTrx ? Env.ZERO : line.getMovementQty()); // default Locator
needSave = true; needSave = true;
} }
// Attribute Set Instance // Attribute Set Instance
if (product != null // Create an Attribute Set Instance to any receipt FIFO/LIFO
&& line.getM_AttributeSetInstance_ID() == 0) if (product != null && line.getM_AttributeSetInstance_ID() == 0)
{ {
if (inTrx) //Validate Transaction
//if (inTrx)
if (getMovementType().compareTo(MInOut.MOVEMENTTYPE_CustomerReturns) == 0 || getMovementType().compareTo(MInOut.MOVEMENTTYPE_VendorReceipts) == 0 )
{ {
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName()); MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName());
asi.setClientOrg(getAD_Client_ID(), 0); asi.setClientOrg(getAD_Client_ID(), 0);
asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID()); asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID());
if (!asi.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
if (asi.save()) if (asi.save())
{ {
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID()); line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
@ -1574,14 +1590,15 @@ public class MInOut extends X_M_InOut implements DocAction
needSave = true; needSave = true;
} }
} }
else // Outgoing Trx // Create consume the Attribute Set Instance using policy FIFO/LIFO
else if(getMovementType().compareTo(MInOut.MOVEMENTTYPE_VendorReturns) == 0 || getMovementType().compareTo(MInOut.MOVEMENTTYPE_CustomerShipment) == 0)
{ {
String MMPolicy = product.getMMPolicy(); String MMPolicy = product.getMMPolicy();
MStorage[] storages = MStorage.getAllWithASI(getCtx(), MStorage[] storages = MStorage.getAllWithASI(getCtx(),
line.getM_Product_ID(), line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_Locator_ID(),
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName()); MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
BigDecimal qtyToDeliver = line.getMovementQty(); BigDecimal qtyToDeliver = line.getMovementQty();
for (int ii = 0; ii < storages.length; ii++) /*for (int ii = 0; ii < storages.length; ii++)
{ {
MStorage storage = storages[ii]; MStorage storage = storages[ii];
if (ii == 0) if (ii == 0)
@ -1624,12 +1641,47 @@ public class MInOut extends X_M_InOut implements DocAction
if (qtyToDeliver.signum() == 0) if (qtyToDeliver.signum() == 0)
break; break;
} // for all storages } // for all storages
*/
// No AttributeSetInstance found for remainder for (MStorage storage: storages)
if (qtyToDeliver.signum() != 0) {
//consume ASI Zero
if (storage.getM_AttributeSetInstance_ID() == 0)
{
qtyASI = qtyASI.add(storage.getQtyOnHand());
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
continue;
}
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
{ {
MInOutLineMA ma = new MInOutLineMA (line, MInOutLineMA ma = new MInOutLineMA (line,
0, qtyToDeliver); storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = Env.ZERO;
}
else
{
MInOutLineMA ma = new MInOutLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
}
}
// No AttributeSetInstance found for remainder
if (qtyToDeliver.signum() != 0 || qtyASI.signum() != 0)
{
MInOutLineMA ma = new MInOutLineMA (line, 0, qtyToDeliver.add(qtyASI));
if (!ma.save()) if (!ma.save())
; ;
log.fine("##: " + ma); log.fine("##: " + ma);
@ -1905,6 +1957,8 @@ public class MInOut extends X_M_InOut implements DocAction
return false; return false;
} }
reversal.closeIt(); reversal.closeIt();
//FR1948157
reversal.setReversal_ID(getM_InOut_ID());
reversal.setProcessing (false); reversal.setProcessing (false);
reversal.setDocStatus(DOCSTATUS_Reversed); reversal.setDocStatus(DOCSTATUS_Reversed);
reversal.setDocAction(DOCACTION_None); reversal.setDocAction(DOCACTION_None);
@ -1918,6 +1972,8 @@ public class MInOut extends X_M_InOut implements DocAction
return false; return false;
m_processMsg = reversal.getDocumentNo(); m_processMsg = reversal.getDocumentNo();
//FR1948157
this.setReversal_ID(reversal.getM_InOut_ID());
setProcessed(true); setProcessed(true);
setDocStatus(DOCSTATUS_Reversed); // may come from void setDocStatus(DOCSTATUS_Reversed); // may come from void
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);

View File

@ -29,6 +29,9 @@ import org.compiere.util.*;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MInventory.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $ * @version $Id: MInventory.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
*/ */
public class MInventory extends X_M_Inventory implements DocAction public class MInventory extends X_M_Inventory implements DocAction
{ {
@ -389,7 +392,7 @@ public class MInventory extends X_M_Inventory implements DocAction
log.info(toString()); log.info(toString());
//vpj-cd begin e-evolution recalculate the attribute instances and qty. //vpj-cd begin e-evolution recalculate the attribute instances and qty.
MInventoryLine[] linesup = getLines(false); /*MInventoryLine[] linesup = getLines(false);
for (int i = 0; i < linesup.length; i++) for (int i = 0; i < linesup.length; i++)
{ {
MInventoryLine line = linesup[i]; MInventoryLine line = linesup[i];
@ -444,8 +447,9 @@ public class MInventory extends X_M_Inventory implements DocAction
{ {
pstmt = null; pstmt = null;
} }
} }*/
//vpj-cd e-evolution recalculate the attribute instances and qty END. //vpj-cd e-evolution recalculate the attribute instances and qty END.
/*
// //
MInventoryLine[] lines = getLines(false); MInventoryLine[] lines = getLines(false);
for (int i = 0; i < lines.length; i++) for (int i = 0; i < lines.length; i++)
@ -543,7 +547,6 @@ public class MInventory extends X_M_Inventory implements DocAction
} }
} // negative qty } // negative qty
} }
// Fallback // Fallback
if (trx == null) if (trx == null)
{ {
@ -584,6 +587,138 @@ public class MInventory extends X_M_Inventory implements DocAction
} }
} // Fallback } // Fallback
*/
MInventoryLine[] lines = getLines(false);
for (MInventoryLine line : lines)
{
if (!line.isActive())
continue;
MProduct product = line.getProduct();
//Get Quantity to Inventory Inernal Use
BigDecimal qtyDiff = line.getQtyInternalUse().negate();
//If Quantity to Inventory Internal Use = Zero Then is Physical Inventory Else is Inventory Internal Use
if (qtyDiff.signum() == 0)
qtyDiff = line.getQtyCount().subtract(line.getQtyBook());
//Ignore the Material Policy when is Reverse Correction
if(!isReversal())
checkMaterialPolicy(line, qtyDiff);
// Stock Movement - Counterpart MOrder.reserveStock
if (product != null
&& product.isStocked() )
{
log.fine("Material Transaction");
MTransaction mtrx = null;
//If AttributeSetInstance = Zero then create new AttributeSetInstance use Inventory Line MA else use current AttributeSetInstance
if (line.getM_AttributeSetInstance_ID() == 0 || qtyDiff.compareTo(Env.ZERO) == 0)
{
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
line.getM_InventoryLine_ID(), get_TrxName());
for (int j = 0; j < mas.length; j++)
{
MInventoryLineMA ma = mas[j];
BigDecimal QtyMA = ma.getMovementQty();
BigDecimal QtyNew = QtyMA.add(qtyDiff);
log.fine("Diff=" + qtyDiff
+ " - Instance OnHand=" + QtyMA + "->" + QtyNew);
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), 0,
QtyMA.negate(), Env.ZERO, Env.ZERO, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
// Only Update Date Last Inventory if is a Physical Inventory
if(line.getQtyInternalUse().compareTo(Env.ZERO) == 0)
{
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
{
m_processMsg = "Storage not updated(2)";
return DocAction.STATUS_Invalid;
}
}
String m_MovementType =null;
if(QtyMA.negate().compareTo(Env.ZERO) > 0 )
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
else
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
// Transaction
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
line.getM_Locator_ID(), line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
QtyMA.negate(), getMovementDate(), get_TrxName());
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
if (!mtrx.save())
{
m_processMsg = "Transaction not inserted(2)";
return DocAction.STATUS_Invalid;
}
qtyDiff = QtyNew;
}
}
//sLine.getM_AttributeSetInstance_ID() != 0
// Fallback
if (mtrx == null)
{
//Fallback: Update Storage - see also VMatch.createMatchRecord
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(), 0,
qtyDiff, Env.ZERO, Env.ZERO, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
// Only Update Date Last Inventory if is a Physical Inventory
if(line.getQtyInternalUse().compareTo(Env.ZERO) == 0)
{
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName());
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
{
m_processMsg = "Storage not updated(2)";
return DocAction.STATUS_Invalid;
}
}
String m_MovementType =null;
if(qtyDiff.compareTo(Env.ZERO) > 0 )
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
else
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
// Transaction
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
qtyDiff, getMovementDate(), get_TrxName());
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
if (!mtrx.save())
{
m_processMsg = "Transaction not inserted(2)";
return DocAction.STATUS_Invalid;
}
} // Fallback
} // stock movement
} // for all lines } // for all lines
// User Validation // User Validation
@ -623,33 +758,29 @@ public class MInventory extends X_M_Inventory implements DocAction
* (NOT USED) * (NOT USED)
* Sets line ASI * Sets line ASI
*/ */
private void checkMaterialPolicy() private void checkMaterialPolicy(MInventoryLine line, BigDecimal qtyDiff)
{ {
int no = MInventoryLineMA.deleteInventoryMA(getM_Inventory_ID(), get_TrxName()); int no = MInventoryLineMA.deleteInventoryMA(line.getM_InventoryLine_ID(), get_TrxName());
if (no > 0) if (no > 0)
log.config("Delete old #" + no); log.config("Delete old #" + no);
MInventoryLine[] lines = getLines(false);
// Check Lines
for (int i = 0; i < lines.length; i++) // Check Line
{
MInventoryLine line = lines[i];
boolean needSave = false; boolean needSave = false;
BigDecimal qtyASI = Env.ZERO ;
// Attribute Set Instance // Attribute Set Instance
if (line.getM_AttributeSetInstance_ID() == 0) if (line.getM_AttributeSetInstance_ID() == 0)
{ {
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID()); MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
BigDecimal qtyDiff = line.getQtyInternalUse().negate();
if (Env.ZERO.compareTo(qtyDiff) == 0)
qtyDiff = line.getQtyCount().subtract(line.getQtyBook());
log.fine("Count=" + line.getQtyCount()
+ ",Book=" + line.getQtyBook() + ", Difference=" + qtyDiff);
if (qtyDiff.signum() > 0) // Incoming Trx if (qtyDiff.signum() > 0) // Incoming Trx
{ {
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName()); MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName());
asi.setClientOrg(getAD_Client_ID(), 0); asi.setClientOrg(getAD_Client_ID(), 0);
asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID()); asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID());
if (!asi.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
if (asi.save()) if (asi.save())
{ {
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID()); line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
@ -663,7 +794,8 @@ public class MInventory extends X_M_Inventory implements DocAction
line.getM_Product_ID(), line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_Locator_ID(),
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName()); MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
BigDecimal qtyToDeliver = qtyDiff.negate(); BigDecimal qtyToDeliver = qtyDiff.negate();
for (int ii = 0; ii < storages.length; ii++)
/*for (int ii = 0; ii < storages.length; ii++)
{ {
MStorage storage = storages[ii]; MStorage storage = storages[ii];
if (ii == 0) if (ii == 0)
@ -706,18 +838,55 @@ public class MInventory extends X_M_Inventory implements DocAction
if (qtyToDeliver.signum() == 0) if (qtyToDeliver.signum() == 0)
break; break;
} // for all storages } // for all storages
*/
// No AttributeSetInstance found for remainder for (MStorage storage: storages)
if (qtyToDeliver.signum() != 0) {
//cosume ASI Zero
if (storage.getM_AttributeSetInstance_ID() == 0)
{
qtyASI = qtyASI.add(storage.getQtyOnHand());
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
continue;
}
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
{ {
MInventoryLineMA ma = new MInventoryLineMA (line, MInventoryLineMA ma = new MInventoryLineMA (line,
0, qtyToDeliver.negate()); storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = Env.ZERO;
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
//return;
}
else
{
MInventoryLineMA ma = new MInventoryLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
}
}
// No AttributeSetInstance found for remainder
if (qtyToDeliver.signum() != 0 || qtyASI.signum() != 0)
{
MInventoryLineMA ma = new MInventoryLineMA (line, 0 , qtyToDeliver.add(qtyASI));
if (!ma.save()) if (!ma.save())
; ;
log.fine("##: " + ma); log.fine("##: " + ma);
} }
} // outgoing Trx } // outgoing Trx
} // attributeSetInstance
if (needSave && !line.save()) if (needSave && !line.save())
log.severe("NOT saved " + line); log.severe("NOT saved " + line);
@ -831,11 +1000,14 @@ public class MInventory extends X_M_Inventory implements DocAction
reversal.setPosted(false); reversal.setPosted(false);
reversal.setProcessed(false); reversal.setProcessed(false);
reversal.addDescription("{->" + getDocumentNo() + ")"); reversal.addDescription("{->" + getDocumentNo() + ")");
//FR1948157
reversal.setReversal_ID(getM_Inventory_ID());
if (!reversal.save()) if (!reversal.save())
{ {
m_processMsg = "Could not create Inventory Reversal"; m_processMsg = "Could not create Inventory Reversal";
return false; return false;
} }
reversal.setReversal(true);
// Reverse Line Qty // Reverse Line Qty
MInventoryLine[] oLines = getLines(true); MInventoryLine[] oLines = getLines(true);
@ -850,11 +1022,27 @@ public class MInventory extends X_M_Inventory implements DocAction
rLine.setQtyBook (oLine.getQtyCount()); // switch rLine.setQtyBook (oLine.getQtyCount()); // switch
rLine.setQtyCount (oLine.getQtyBook()); rLine.setQtyCount (oLine.getQtyBook());
rLine.setQtyInternalUse (oLine.getQtyInternalUse().negate()); rLine.setQtyInternalUse (oLine.getQtyInternalUse().negate());
if (!rLine.save()) if (!rLine.save())
{ {
m_processMsg = "Could not create Inventory Reversal Line"; m_processMsg = "Could not create Inventory Reversal Line";
return false; return false;
} }
//We need to copy MA
if (rLine.getM_AttributeSetInstance_ID() == 0)
{
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
oLines[i].getM_InventoryLine_ID(), get_TrxName());
for (int j = 0; j < mas.length; j++)
{
MInventoryLineMA ma = new MInventoryLineMA (rLine,
mas[j].getM_AttributeSetInstance_ID(),
mas[j].getMovementQty().negate());
if (!ma.save())
;
}
}
} }
// //
if (!reversal.processIt(DocAction.ACTION_Complete)) if (!reversal.processIt(DocAction.ACTION_Complete))
@ -875,6 +1063,8 @@ public class MInventory extends X_M_Inventory implements DocAction
if (m_processMsg != null) if (m_processMsg != null)
return false; return false;
setProcessed(true); setProcessed(true);
//FR1948157
setReversal_ID(reversal.getM_Inventory_ID());
setDocStatus(DOCSTATUS_Reversed); // may come from void setDocStatus(DOCSTATUS_Reversed); // may come from void
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
@ -969,4 +1159,24 @@ public class MInventory extends X_M_Inventory implements DocAction
return 0; return 0;
} // getC_Currency_ID } // getC_Currency_ID
/** Reversal Flag */
private boolean m_reversal = false;
/**
* Set Reversal
* @param reversal reversal
*/
private void setReversal(boolean reversal)
{
m_reversal = reversal;
} // setReversal
/**
* Is Reversal
* @return reversal
*/
private boolean isReversal()
{
return m_reversal;
} // isReversal
} // MInventory } // MInventory

View File

@ -364,9 +364,9 @@ public class MInventoryLine extends X_M_InventoryLine
return false; return false;
// Create MA // Create MA
if (newRecord && success //if (newRecord && success
&& m_isManualEntry && getM_AttributeSetInstance_ID() == 0) // && m_isManualEntry && getM_AttributeSetInstance_ID() == 0)
createMA(); // createMA();
return true; return true;
} // afterSave } // afterSave

View File

@ -80,11 +80,11 @@ public class MInventoryLineMA extends X_M_InventoryLineMA
* @param trxName transaction * @param trxName transaction
* @return number of rows deleted or -1 for error * @return number of rows deleted or -1 for error
*/ */
public static int deleteInventoryMA (int M_Inventory_ID, String trxName) public static int deleteInventoryMA (int M_InventoryLine_ID, String trxName)
{ {
String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS " String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS "
+ "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID" + "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID"
+ " AND M_Inventory_ID=" + M_Inventory_ID + ")"; + " AND M_InventoryLine_ID=" + M_InventoryLine_ID + ")";
return DB.executeUpdate(sql, trxName); return DB.executeUpdate(sql, trxName);
} // deleteInventoryMA } // deleteInventoryMA

View File

@ -24,6 +24,8 @@ import java.util.logging.*;
import org.compiere.print.*; import org.compiere.print.*;
import org.compiere.process.*; import org.compiere.process.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.eevolution.model.MPPProductBOM;
import org.eevolution.model.MPPProductBOMLine;
/** /**
@ -34,7 +36,8 @@ import org.compiere.util.*;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MInvoice.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ * @version $Id: MInvoice.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
* * @author victor.perez@e-evolution.com
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
* Modifications: Added RMA functionality (Ashley Ramdass) * Modifications: Added RMA functionality (Ashley Ramdass)
*/ */
public class MInvoice extends X_C_Invoice implements DocAction public class MInvoice extends X_C_Invoice implements DocAction
@ -1463,7 +1466,30 @@ public class MInvoice extends X_C_Invoice implements DocAction
log.fine(product.getName()); log.fine(product.getName());
// New Lines // New Lines
int lineNo = line.getLine (); int lineNo = line.getLine ();
MProductBOM[] boms = MProductBOM.getBOMLines (product);
//find default BOM with valid dates and to this product
MPPProductBOM bom = MPPProductBOM.get(product, getAD_Org_ID(),getDateInvoiced(), get_TrxName());
if(bom != null)
{
MPPProductBOMLine[] bomlines = bom.getLines(getDateInvoiced());
for (int j = 0; j < bomlines.length; j++)
{
MPPProductBOMLine bomline = bomlines[j];
MInvoiceLine newLine = new MInvoiceLine (this);
newLine.setLine (++lineNo);
newLine.setM_Product_ID (bomline.getM_Product_ID ());
newLine.setC_UOM_ID (bomline.getC_UOM_ID ());
newLine.setQty (line.getQtyInvoiced().multiply(
bomline.getQtyBOM ())); // Invoiced/Entered
if (bomline.getDescription () != null)
newLine.setDescription (bomline.getDescription ());
//
newLine.setPrice ();
newLine.save (get_TrxName());
}
}
/*MProductBOM[] boms = MProductBOM.getBOMLines (product);
for (int j = 0; j < boms.length; j++) for (int j = 0; j < boms.length; j++)
{ {
MProductBOM bom = boms[j]; MProductBOM bom = boms[j];
@ -1478,7 +1504,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
// //
newLine.setPrice (); newLine.setPrice ();
newLine.save (get_TrxName()); newLine.save (get_TrxName());
} }*/
// Convert into Comment Line // Convert into Comment Line
line.setM_Product_ID (0); line.setM_Product_ID (0);
line.setM_AttributeSetInstance_ID (0); line.setM_AttributeSetInstance_ID (0);
@ -2160,6 +2187,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
return false; return false;
} }
reversal.setC_Payment_ID(0); reversal.setC_Payment_ID(0);
//FR1948157
reversal.setReversal_ID(getC_Invoice_ID());
reversal.setIsPaid(true); reversal.setIsPaid(true);
reversal.closeIt(); reversal.closeIt();
reversal.setProcessing (false); reversal.setProcessing (false);
@ -2186,6 +2215,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
} }
} }
setProcessed(true); setProcessed(true);
//FR1948157
setReversal_ID(reversal.getC_Invoice_ID());
setDocStatus(DOCSTATUS_Reversed); // may come from void setDocStatus(DOCSTATUS_Reversed); // may come from void
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
setC_Payment_ID(0); setC_Payment_ID(0);

View File

@ -33,6 +33,9 @@ import org.compiere.util.*;
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1619150 ] Usability/Consistency: reversed gl journal description * <li>BF [ 1619150 ] Usability/Consistency: reversed gl journal description
* <li>BF [ 1775358 ] GL Journal DateAcct/C_Period_ID issue * <li>BF [ 1775358 ] GL Journal DateAcct/C_Period_ID issue
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
*/ */
public class MJournal extends X_GL_Journal implements DocAction public class MJournal extends X_GL_Journal implements DocAction
{ {
@ -677,6 +680,8 @@ public class MJournal extends X_GL_Journal implements DocAction
reverse.setDateAcct(getDateAcct()); reverse.setDateAcct(getDateAcct());
// Reverse indicator // Reverse indicator
reverse.addDescription("(->" + getDocumentNo() + ")"); reverse.addDescription("(->" + getDocumentNo() + ")");
//FR [ 1948157 ]
reverse.setReversal_ID(getGL_Journal_ID());
if (!reverse.save()) if (!reverse.save())
return null; return null;
addDescription("(" + reverse.getDocumentNo() + "<-)"); addDescription("(" + reverse.getDocumentNo() + "<-)");
@ -685,6 +690,8 @@ public class MJournal extends X_GL_Journal implements DocAction
reverse.copyLinesFrom(this, null, 'C'); reverse.copyLinesFrom(this, null, 'C');
// //
setProcessed(true); setProcessed(true);
//FR [ 1948157 ]
setReversal_ID(reverse.getGL_Journal_ID());
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
return reverse; return reverse;
} // reverseCorrectionIt } // reverseCorrectionIt

View File

@ -28,6 +28,9 @@ import org.compiere.util.*;
* Journal Batch Model * Journal Batch Model
* *
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
* @version $Id: MJournalBatch.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ * @version $Id: MJournalBatch.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/ */
public class MJournalBatch extends X_GL_JournalBatch implements DocAction public class MJournalBatch extends X_GL_JournalBatch implements DocAction
@ -618,6 +621,8 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
else else
description += " ** " + getDocumentNo() + " **"; description += " ** " + getDocumentNo() + " **";
reverse.setDescription(description); reverse.setDescription(description);
//[ 1948157 ]
reverse.setReversal_ID(getGL_JournalBatch_ID());
reverse.save(); reverse.save();
// //
@ -634,6 +639,10 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
} }
journal.save(); journal.save();
} }
//[ 1948157 ]
setReversal_ID(reverse.getGL_JournalBatch_ID());
save();
// After reverseCorrect // After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
if (m_processMsg != null) if (m_processMsg != null)

View File

@ -25,6 +25,8 @@ import org.compiere.util.*;
* Warehouse Locator Object * Warehouse Locator Object
* *
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com
* @see [ 1966333 ] New Method to get the Default Locator based in Warehouse http://sourceforge.net/tracker/index.php?func=detail&aid=1966333&group_id=176962&atid=879335
* @version $Id: MLocator.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $ * @version $Id: MLocator.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
*/ */
public class MLocator extends X_M_Locator public class MLocator extends X_M_Locator
@ -40,7 +42,7 @@ public class MLocator extends X_M_Locator
String trxName = null; String trxName = null;
MLocator retValue = null; MLocator retValue = null;
String sql = "SELECT * FROM M_Locator l " String sql = "SELECT * FROM M_Locator l "
+ "WHERE IsDefault='Y'" + "WHERE IsActive = 'Y' AND IsDefault='Y'"
+ " AND EXISTS (SELECT * FROM M_Locator lx " + " AND EXISTS (SELECT * FROM M_Locator lx "
+ "WHERE l.M_Warehouse_ID=lx.M_Warehouse_ID AND lx.M_Locator_ID=?) " + "WHERE l.M_Warehouse_ID=lx.M_Warehouse_ID AND lx.M_Locator_ID=?) "
+ "ORDER BY Created"; + "ORDER BY Created";
@ -67,6 +69,43 @@ public class MLocator extends X_M_Locator
return retValue; return retValue;
} // getDefault } // getDefault
/**
* FR [ 1966333 ]
* Get oldest Default Locator of warehouse with locator
* @param ctx context
* @param M_Locator_ID locator
* @return locator or null
*/
public static MLocator getDefault (MWarehouse warehouse)
{
String trxName = null;
MLocator retValue = null;
String sql = "SELECT * FROM M_Locator l "
+ "WHERE IsActive = 'Y' AND IsDefault='Y' AND l.M_Warehouse_ID=? "
+ "ORDER BY PriorityNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, warehouse.getM_Warehouse_ID());
rs = pstmt.executeQuery ();
while (rs.next ())
retValue = new MLocator (warehouse.getCtx(), rs, trxName);
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return retValue;
} // getDefault
/** /**
* Get the Locator with the combination or create new one * Get the Locator with the combination or create new one
@ -82,7 +121,7 @@ public class MLocator extends X_M_Locator
String X, String Y, String Z) String X, String Y, String Z)
{ {
MLocator retValue = null; MLocator retValue = null;
String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=? AND X=? AND Y=? AND Z=?"; String sql = "SELECT * FROM M_Locator WHERE IsActive = 'Y' AND M_Warehouse_ID=? AND X=? AND Y=? AND Z=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try

View File

@ -19,12 +19,15 @@ package org.compiere.model;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
* Menu Model * Menu Model
* *
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com
* @see FR [ 1966326 ] Is necessary create method to get ID menu use menu Name http://sourceforge.net/tracker/index.php?func=detail&aid=1966326&group_id=176962&atid=879335
* @version $Id: MMenu.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $ * @version $Id: MMenu.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
*/ */
public class MMenu extends X_AD_Menu public class MMenu extends X_AD_Menu
@ -166,4 +169,35 @@ public class MMenu extends X_AD_Menu
return success; return success;
} // afterDelete } // afterDelete
/**
* FR [ 1966326 ]
* get Menu ID
* @param String Menu Name
* @return int retValue
*/
public static int getMenu_ID(String menuName) {
int retValue = 0;
String SQL = "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = ?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, menuName);
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, SQL, e);
retValue = -1;
}
finally
{
DB.close(rs, pstmt);
}
return retValue;
}
} // MMenu } // MMenu

View File

@ -24,10 +24,14 @@ import java.util.logging.*;
import org.compiere.process.*; import org.compiere.process.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.eevolution.model.*;
/** /**
* Inventory Movement Model * Inventory Movement Model
* *
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
* @version $Id: MMovement.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ * @version $Id: MMovement.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/ */
public class MMovement extends X_M_Movement implements DocAction public class MMovement extends X_M_Movement implements DocAction
@ -321,7 +325,7 @@ public class MMovement extends X_M_Movement implements DocAction
// Add up Amounts // Add up Amounts
checkMaterialPolicy(); //checkMaterialPolicy();
// Confirmation // Confirmation
if (dt.isInTransit()) if (dt.isInTransit())
@ -414,6 +418,16 @@ public class MMovement extends X_M_Movement implements DocAction
{ {
MMovementLine line = lines[i]; MMovementLine line = lines[i];
MTransaction trxFrom = null; MTransaction trxFrom = null;
//Stock Movement - Counterpart MOrder.reserveStock
MProduct product = line.getProduct();
if (product != null
&& product.isStocked() )
{
//Ignore the Material Policy when is Reverse Correction
if(!isReversal())
checkMaterialPolicy(line);
if (line.getM_AttributeSetInstance_ID() == 0) if (line.getM_AttributeSetInstance_ID() == 0)
{ {
MMovementLineMA mas[] = MMovementLineMA.get(getCtx(), MMovementLineMA mas[] = MMovementLineMA.get(getCtx(),
@ -422,19 +436,44 @@ public class MMovement extends X_M_Movement implements DocAction
{ {
MMovementLineMA ma = mas[j]; MMovementLineMA ma = mas[j];
// //
MStorage storageFrom = MStorage.get(getCtx(), line.getM_Locator_ID(), /*MStorage storageFrom = MStorage.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName()); line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
if (storageFrom == null) if (storageFrom == null)
storageFrom = MStorage.getCreate(getCtx(), line.getM_Locator_ID(), storageFrom = MStorage.getCreate(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName()); line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
// //*/
MStorage storageTo = MStorage.get(getCtx(), line.getM_LocatorTo_ID(), MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName());
//Update Storage
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), 0,
ma.getMovementQty().negate(), Env.ZERO , Env.ZERO , get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
/*MStorage storageTo = MStorage.get(getCtx(), line.getM_LocatorTo_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName()); line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
if (storageTo == null) if (storageTo == null)
storageTo = MStorage.getCreate(getCtx(), line.getM_LocatorTo_ID(), storageTo = MStorage.getCreate(getCtx(), line.getM_LocatorTo_ID(),
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName()); line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
// //*/
storageFrom.setQtyOnHand(storageFrom.getQtyOnHand().subtract(ma.getMovementQty()));
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
//Update Storage
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
line.getM_LocatorTo_ID(),
line.getM_Product_ID(),
ma.getM_AttributeSetInstance_ID(), 0,
ma.getMovementQty(), Env.ZERO , Env.ZERO , get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
/*storageFrom.setQtyOnHand(storageFrom.getQtyOnHand().subtract(ma.getMovementQty()));
if (!storageFrom.save(get_TrxName())) if (!storageFrom.save(get_TrxName()))
{ {
m_processMsg = "Storage From not updated (MA)"; m_processMsg = "Storage From not updated (MA)";
@ -446,7 +485,7 @@ public class MMovement extends X_M_Movement implements DocAction
{ {
m_processMsg = "Storage To not updated (MA)"; m_processMsg = "Storage To not updated (MA)";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }*/
// //
trxFrom = new MTransaction (getCtx(), line.getAD_Org_ID(), trxFrom = new MTransaction (getCtx(), line.getAD_Org_ID(),
@ -475,7 +514,7 @@ public class MMovement extends X_M_Movement implements DocAction
// Fallback - We have ASI // Fallback - We have ASI
if (trxFrom == null) if (trxFrom == null)
{ {
MStorage storageFrom = MStorage.get(getCtx(), line.getM_Locator_ID(), /*MStorage storageFrom = MStorage.get(getCtx(), line.getM_Locator_ID(),
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName()); line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName());
if (storageFrom == null) if (storageFrom == null)
storageFrom = MStorage.getCreate(getCtx(), line.getM_Locator_ID(), storageFrom = MStorage.getCreate(getCtx(), line.getM_Locator_ID(),
@ -499,6 +538,30 @@ public class MMovement extends X_M_Movement implements DocAction
{ {
m_processMsg = "Storage To not updated"; m_processMsg = "Storage To not updated";
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
}*/
MLocator locator = new MLocator (getCtx(), line.getM_Locator_ID(), get_TrxName());
//Update Storage
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
line.getM_Locator_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(), 0,
line.getMovementQty().negate(), Env.ZERO , Env.ZERO , get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
}
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
//Update Storage
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
line.getM_LocatorTo_ID(),
line.getM_Product_ID(),
line.getM_AttributeSetInstance_ID(), 0,
line.getMovementQty(), Env.ZERO , Env.ZERO , get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
return DocAction.STATUS_Invalid;
} }
// //
@ -524,6 +587,7 @@ public class MMovement extends X_M_Movement implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
} // Fallback } // Fallback
} // product stock
} // for all lines } // for all lines
// User Validation // User Validation
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
@ -561,18 +625,19 @@ public class MMovement extends X_M_Movement implements DocAction
* Check Material Policy * Check Material Policy
* Sets line ASI * Sets line ASI
*/ */
private void checkMaterialPolicy() private void checkMaterialPolicy(MMovementLine line)
{ {
int no = MMovementLineMA.deleteMovementMA(getM_Movement_ID(), get_TrxName()); int no = MMovementLineMA.deleteMovementMA(getM_Movement_ID(), get_TrxName());
if (no > 0) if (no > 0)
log.config("Delete old #" + no); log.config("Delete old #" + no);
MMovementLine[] lines = getLines(false); //MMovementLine[] lines = getLines(false);
// Check Lines // Check Lines
for (int i = 0; i < lines.length; i++) //for (int i = 0; i < lines.length; i++)
{ //{
MMovementLine line = lines[i]; // MMovementLine line = lines[i];
boolean needSave = false; boolean needSave = false;
BigDecimal qtyASI = Env.ZERO ;
// Attribute Set Instance // Attribute Set Instance
if (line.getM_AttributeSetInstance_ID() == 0) if (line.getM_AttributeSetInstance_ID() == 0)
@ -583,7 +648,8 @@ public class MMovement extends X_M_Movement implements DocAction
line.getM_Product_ID(), line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_Locator_ID(),
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName()); MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
BigDecimal qtyToDeliver = line.getMovementQty(); BigDecimal qtyToDeliver = line.getMovementQty();
for (int ii = 0; ii < storages.length; ii++)
/*for (int ii = 0; ii < storages.length; ii++)
{ {
MStorage storage = storages[ii]; MStorage storage = storages[ii];
if (ii == 0) if (ii == 0)
@ -635,12 +701,58 @@ public class MMovement extends X_M_Movement implements DocAction
if (!ma.save()) if (!ma.save())
; ;
log.fine("##: " + ma); log.fine("##: " + ma);
}*/
for (MStorage storage: storages)
{
//consume ASI Zero
if (storage.getM_AttributeSetInstance_ID() == 0)
{
qtyASI = qtyASI.add(storage.getQtyOnHand());
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
continue;
}
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
{
MMovementLineMA ma = new MMovementLineMA (line,
storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = Env.ZERO;
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
//return;
}
else
{
MMovementLineMA ma = new MMovementLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
if (!ma.save())
{
throw new IllegalStateException("Error try create ASI Reservation");
}
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
}
}
// No AttributeSetInstance found for remainder
if (qtyToDeliver.signum() != 0 || qtyASI.signum() != 0)
{
MMovementLineMA ma = new MMovementLineMA (line, 0 , qtyToDeliver.add(qtyASI));
if (!ma.save())
;
log.fine("##: " + ma);
} }
} // attributeSetInstance } // attributeSetInstance
if (needSave && !line.save()) if (needSave && !line.save())
log.severe("NOT saved " + line); log.severe("NOT saved " + line);
} // for all lines //} // for all lines
} // checkMaterialPolicy } // checkMaterialPolicy
@ -750,12 +862,14 @@ public class MMovement extends X_M_Movement implements DocAction
reversal.setPosted(false); reversal.setPosted(false);
reversal.setProcessed(false); reversal.setProcessed(false);
reversal.addDescription("{->" + getDocumentNo() + ")"); reversal.addDescription("{->" + getDocumentNo() + ")");
//FR [ 1948157 ]
reversal.setReversal_ID(getM_Movement_ID());
if (!reversal.save()) if (!reversal.save())
{ {
m_processMsg = "Could not create Movement Reversal"; m_processMsg = "Could not create Movement Reversal";
return false; return false;
} }
reversal.setReversal(true);
// Reverse Line Qty // Reverse Line Qty
MMovementLine[] oLines = getLines(true); MMovementLine[] oLines = getLines(true);
for (int i = 0; i < oLines.length; i++) for (int i = 0; i < oLines.length; i++)
@ -795,6 +909,8 @@ public class MMovement extends X_M_Movement implements DocAction
// Update Reversed (this) // Update Reversed (this)
addDescription("(" + reversal.getDocumentNo() + "<-)"); addDescription("(" + reversal.getDocumentNo() + "<-)");
//FR [ 1948157 ]
setReversal_ID(reversal.getM_Movement_ID());
setProcessed(true); setProcessed(true);
setDocStatus(DOCSTATUS_Reversed); // may come from void setDocStatus(DOCSTATUS_Reversed); // may come from void
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
@ -890,5 +1006,79 @@ public class MMovement extends X_M_Movement implements DocAction
return 0; return 0;
} // getC_Currency_ID } // getC_Currency_ID
/**
* Order Constructor - create header only
* @param order order
* @param movementDate optional movement date (default today)
* @param C_DocType_ID document type or 0
*/
public MMovement (MDDOrder order, int C_DocType_ID, Timestamp movementDate)
{
this (order.getCtx(), 0, order.get_TrxName());
setClientOrg(order);
setC_BPartner_ID (order.getC_BPartner_ID());
setC_BPartner_Location_ID (order.getC_BPartner_Location_ID()); // shipment address
setAD_User_ID(order.getAD_User_ID());
//
//setM_Warehouse_ID (order.getM_Warehouse_ID());
//setIsSOTrx (order.isSOTrx());
//setMovementType (order.isSOTrx() ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReceipts);
if (C_DocType_ID == 0)
C_DocType_ID = DB.getSQLValue(null,
"SELECT C_DocType_ID FROM C_DocType WHERE C_DocType_ID=?",
order.getC_DocType_ID());
setC_DocType_ID (C_DocType_ID);
// Default - Today
if (movementDate != null)
setMovementDate (movementDate);
//setDateAcct (getMovementDate());
// Copy from Order
setDD_Order_ID(order.getC_Order_ID());
setDeliveryRule (order.getDeliveryRule());
setDeliveryViaRule (order.getDeliveryViaRule());
setM_Shipper_ID(order.getM_Shipper_ID());
setFreightCostRule (order.getFreightCostRule());
setFreightAmt(order.getFreightAmt());
setSalesRep_ID(order.getSalesRep_ID());
//
setC_Activity_ID(order.getC_Activity_ID());
setC_Campaign_ID(order.getC_Campaign_ID());
setC_Charge_ID(order.getC_Charge_ID());
setChargeAmt(order.getChargeAmt());
//
setC_Project_ID(order.getC_Project_ID());
//setDateOrdered(order.getDateOrdered());
setDescription(order.getDescription());
//setPOReference(order.getPOReference());
setSalesRep_ID(order.getSalesRep_ID());
setAD_OrgTrx_ID(order.getAD_OrgTrx_ID());
setUser1_ID(order.getUser1_ID());
setUser2_ID(order.getUser2_ID());
setPriorityRule(order.getPriorityRule());
} // MMovement
/** Reversal Flag */
private boolean m_reversal = false;
/**
* Set Reversal
* @param reversal reversal
*/
private void setReversal(boolean reversal)
{
m_reversal = reversal;
} // setReversal
/**
* Is Reversal
* @return reversal
*/
private boolean isReversal()
{
return m_reversal;
} // isReversal
} // MMovement } // MMovement

View File

@ -19,7 +19,9 @@ package org.compiere.model;
import java.math.*; import java.math.*;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.Level;
import org.compiere.util.*; import org.compiere.util.*;
import org.eevolution.model.*;
/** /**
* Inventory Move Line Model * Inventory Move Line Model
@ -53,6 +55,8 @@ public class MMovementLine extends X_M_MovementLine
setProcessed (false); setProcessed (false);
} }
} // MMovementLine } // MMovementLine
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MMovementLine.class);
/** /**
* Load Constructor * Load Constructor
@ -200,6 +204,119 @@ public class MMovementLine extends X_M_MovementLine
return true; return true;
} // beforeSave } // beforeSave
/**
* Set Distribution Order Line.
* Does not set Quantity!
* @param oLine order line
* @param M_Locator_ID locator
* @param Qty used only to find suitable locator
*/
public void setOrderLine (MDDOrderLine oLine, int M_Locator_ID, BigDecimal Qty)
{
setDD_OrderLine_ID(oLine.getDD_OrderLine_ID());
setLine(oLine.getLine());
//setC_UOM_ID(oLine.getC_UOM_ID());
MProduct product = oLine.getProduct();
if (product == null)
{
set_ValueNoCheck("M_Product_ID", null);
set_ValueNoCheck("M_AttributeSetInstance_ID", null);
set_ValueNoCheck("M_Locator_ID", null);
}
else
{
setM_Product_ID(oLine.getM_Product_ID());
setM_AttributeSetInstance_ID(oLine.getM_AttributeSetInstance_ID());
//
if (product.isItem())
{
setM_Locator_ID(M_Locator_ID);
}
else
set_ValueNoCheck("M_Locator_ID", null);
}
//setC_Charge_ID(oLine.getC_Charge_ID());
setDescription(oLine.getDescription());
//setIsDescription(oLine.isDescription());
//
//setC_Project_ID(oLine.getC_Project_ID());
//setC_ProjectPhase_ID(oLine.getC_ProjectPhase_ID());
//setC_ProjectTask_ID(oLine.getC_ProjectTask_ID());
//setC_Activity_ID(oLine.getC_Activity_ID());
//setC_Campaign_ID(oLine.getC_Campaign_ID());
//setAD_OrgTrx_ID(oLine.getAD_OrgTrx_ID());
//setUser1_ID(oLine.getUser1_ID());
//setUser2_ID(oLine.getUser2_ID());
} // setOrderLine
/**
* Set M_Locator_ID
* @param M_Locator_ID id
*/
public void setM_Locator_ID (int M_Locator_ID)
{
if (M_Locator_ID < 0)
throw new IllegalArgumentException ("M_Locator_ID is mandatory.");
// set to 0 explicitly to reset
set_Value ("M_Locator_ID", new Integer(M_Locator_ID));
} // setM_Locator_ID
/**
* Set M_Locator_ID
* @param M_Locator_ID id
*/
public void setM_LocatorTo_ID (int M_Locator_ID)
{
if (M_Locator_ID < 0)
throw new IllegalArgumentException ("M_LocatorTo_ID is mandatory.");
// set to 0 explicitly to reset
set_Value ("M_Locator_ID", new Integer(M_Locator_ID));
} // setM_Locator_ID
/**
* Get Movement lines Of Distribution Order Line
* @param ctx context
* @param DD_OrderLine_ID line
* @param where optional addition where clause
* @param trxName transaction
* @return array of receipt lines
*/
public static MMovementLine[] getOfOrderLine (Properties ctx,
int DD_OrderLine_ID, String where, String trxName)
{
ArrayList<MMovementLine> list = new ArrayList<MMovementLine>();
String sql = "SELECT * FROM M_MovementLine WHERE DD_OrderLine_ID=?";
if (where != null && where.length() > 0)
sql += " AND " + where;
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, DD_OrderLine_ID);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MMovementLine(ctx, rs, trxName));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MMovementLine[] retValue = new MMovementLine[list.size ()];
list.toArray (retValue);
return retValue;
} // getOfOrderLine
} // MMovementLine } // MMovementLine

View File

@ -24,6 +24,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Pattern;
import org.compiere.print.ReportEngine; import org.compiere.print.ReportEngine;
import org.compiere.process.DocAction; import org.compiere.process.DocAction;
@ -31,6 +32,9 @@ import org.compiere.process.DocumentEngine;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.eevolution.model.MPPProductBOMLine;
import org.eevolution.model.MPPProductBOM;
/** /**
* Order Model. * Order Model.
@ -1355,23 +1359,51 @@ public class MOrder extends X_C_Order implements DocAction
log.fine(product.getName()); log.fine(product.getName());
// New Lines // New Lines
int lineNo = line.getLine (); int lineNo = line.getLine ();
MProductBOM[] boms = MProductBOM.getBOMLines (product); //find default BOM with valid dates and to this product
for (int j = 0; j < boms.length; j++) MPPProductBOM bom = MPPProductBOM.get(product, getAD_Org_ID(),getDatePromised(), get_TrxName());
if(bom != null)
{ {
MProductBOM bom = boms[j]; MPPProductBOMLine[] bomlines = bom.getLines(getDatePromised());
for (int j = 0; j < bomlines.length; j++)
{
MPPProductBOMLine bomline = bomlines[j];
MOrderLine newLine = new MOrderLine (this); MOrderLine newLine = new MOrderLine (this);
newLine.setLine (++lineNo); newLine.setLine (++lineNo);
newLine.setM_Product_ID (bom.getProduct () newLine.setM_Product_ID (bomline.getM_Product_ID ());
.getM_Product_ID ()); newLine.setC_UOM_ID (bomline.getC_UOM_ID ());
newLine.setC_UOM_ID (bom.getProduct ().getC_UOM_ID ());
newLine.setQty (line.getQtyOrdered ().multiply ( newLine.setQty (line.getQtyOrdered ().multiply (
bom.getBOMQty ())); bomline.getQtyBOM()));
if (bomline.getDescription () != null)
newLine.setDescription (bomline.getDescription ());
//
newLine.setPrice ();
newLine.save (get_TrxName());
}
}
/*MProductBOM[] boms = MProductBOM.getBOMLines (product);
for (int j = 0; j < boms.length; j++)
{
//MProductBOM bom = boms[j];
MPPProductBOMLine bom = boms[j];
MOrderLine newLine = new MOrderLine (this);
newLine.setLine (++lineNo);
//newLine.setM_Product_ID (bom.getProduct ()
// .getM_Product_ID ());
newLine.setM_Product_ID (bom.getM_Product_ID ());
//newLine.setC_UOM_ID (bom.getProduct ().getC_UOM_ID ());
newLine.setC_UOM_ID (bom.getC_UOM_ID ());
//newLine.setQty (line.getQtyOrdered ().multiply (
// bom.getBOMQty ()));
newLine.setQty (line.getQtyOrdered ().multiply (
bom.getQtyBOM()));
if (bom.getDescription () != null) if (bom.getDescription () != null)
newLine.setDescription (bom.getDescription ()); newLine.setDescription (bom.getDescription ());
// //
newLine.setPrice (); newLine.setPrice ();
newLine.save (get_TrxName()); newLine.save (get_TrxName());
} }*/
// Convert into Comment Line // Convert into Comment Line
line.setM_Product_ID (0); line.setM_Product_ID (0);
line.setM_AttributeSetInstance_ID (0); line.setM_AttributeSetInstance_ID (0);
@ -2178,6 +2210,58 @@ public class MOrder extends X_C_Order implements DocAction
return true; return true;
} // closeIt } // closeIt
/**
* @author: phib
* re-open a closed order
* (reverse steps of close())
*/
public String reopenIt() {
log.info(toString());
if (!MOrder.DOCSTATUS_Closed.equals(getDocStatus()))
{
return "Not closed - can't reopen";
}
//
MOrderLine[] lines = getLines(true, "M_Product_ID");
for (int i = 0; i < lines.length; i++)
{
MOrderLine line = lines[i];
if (Env.ZERO.compareTo(line.getQtyLostSales()) != 0)
{
line.setQtyOrdered(line.getQtyLostSales().add(line.getQtyDelivered()));
line.setQtyLostSales(Env.ZERO);
// QtyEntered unchanged
// Strip Close() tags from description
String desc = line.getDescription();
if (desc == null)
desc = "";
Pattern pattern = Pattern.compile("( \\| )?Close \\(.*\\)");
String[] parts = pattern.split(desc);
desc = "";
for (String s : parts) {
desc = desc.concat(s);
}
line.setDescription(desc);
if (!line.save(get_TrxName()))
return "Couldn't save orderline";
}
}
// Clear Reservations
if (!reserveStock(null, lines))
{
m_processMsg = "Cannot unreserve Stock (close)";
return "Failed to update reservations";
}
setDocStatus(MOrder.DOCSTATUS_Completed);
setDocAction(DOCACTION_Close);
if (!this.save(get_TrxName()))
return "Couldn't save reopened order";
else
return "";
} // reopenIt
/** /**
* Reverse Correction - same void * Reverse Correction - same void
* @return true if success * @return true if success

View File

@ -52,7 +52,11 @@ import org.compiere.util.*;
* When Payment is posed, the Allocation is made * When Payment is posed, the Allocation is made
* </pre> * </pre>
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com, e-Evolution
* <li>FR [ 1948157 ] Is necessary the reference for document reverse
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
* @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $ * @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
* @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
*/ */
public final class MPayment extends X_C_Payment public final class MPayment extends X_C_Payment
implements DocAction, ProcessCall implements DocAction, ProcessCall
@ -2167,6 +2171,8 @@ public final class MPayment extends X_C_Payment
reversal.setPosted(false); reversal.setPosted(false);
reversal.setDescription(getDescription()); reversal.setDescription(getDescription());
reversal.addDescription("{->" + getDocumentNo() + ")"); reversal.addDescription("{->" + getDocumentNo() + ")");
//FR [ 1948157 ]
reversal.setReversal_ID(getC_Payment_ID());
reversal.save(get_TrxName()); reversal.save(get_TrxName());
// Post Reversal // Post Reversal
if (!reversal.processIt(DocAction.ACTION_Complete)) if (!reversal.processIt(DocAction.ACTION_Complete))
@ -2188,6 +2194,8 @@ public final class MPayment extends X_C_Payment
setDocStatus(DOCSTATUS_Reversed); setDocStatus(DOCSTATUS_Reversed);
setDocAction(DOCACTION_None); setDocAction(DOCACTION_None);
setProcessed(true); setProcessed(true);
//FR [ 1948157 ]
setReversal_ID(reversal.getC_Payment_ID());
// Create automatic Allocation // Create automatic Allocation
MAllocationHdr alloc = new MAllocationHdr (getCtx(), false, MAllocationHdr alloc = new MAllocationHdr (getCtx(), false,

View File

@ -95,8 +95,10 @@ public class MStorage extends X_M_Storage
ArrayList<MStorage> list = new ArrayList<MStorage>(); ArrayList<MStorage> list = new ArrayList<MStorage>();
String sql = "SELECT * FROM M_Storage " String sql = "SELECT * FROM M_Storage "
+ "WHERE M_Product_ID=? AND M_Locator_ID=?" + "WHERE M_Product_ID=? AND M_Locator_ID=?"
+ " AND M_AttributeSetInstance_ID > 0" // Remove for management rightly FIFO/LIFO now you can consume a layer with ASI ID = zero and Qty onhand in negative
+ " AND QtyOnHand > 0 " // + " AND M_AttributeSetInstance_ID > 0"
// + " AND QtyOnHand > 0 "
+ " AND QtyOnHand <> 0 "
+ "ORDER BY M_AttributeSetInstance_ID"; + "ORDER BY M_AttributeSetInstance_ID";
if (!FiFo) if (!FiFo)
sql += " DESC"; sql += " DESC";

View File

@ -25,6 +25,8 @@ import org.compiere.util.*;
* Warehouse Model * Warehouse Model
* *
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com
* @see FR [ 1966337 ] New Method to get the Transit Warehouse based in ID Org http://sourceforge.net/tracker/index.php?func=detail&aid=1966337&group_id=176962&atid=879335
* @version $Id: MWarehouse.java,v 1.3 2006/07/30 00:58:05 jjanke Exp $ * @version $Id: MWarehouse.java,v 1.3 2006/07/30 00:58:05 jjanke Exp $
*/ */
public class MWarehouse extends X_M_Warehouse public class MWarehouse extends X_M_Warehouse
@ -56,7 +58,7 @@ public class MWarehouse extends X_M_Warehouse
public static MWarehouse[] getForOrg (Properties ctx, int AD_Org_ID) public static MWarehouse[] getForOrg (Properties ctx, int AD_Org_ID)
{ {
ArrayList<MWarehouse> list = new ArrayList<MWarehouse>(); ArrayList<MWarehouse> list = new ArrayList<MWarehouse>();
String sql = "SELECT * FROM M_Warehouse WHERE AD_Org_ID=? ORDER BY Created"; String sql = "SELECT * FROM M_Warehouse WHERE IsActive = 'Y' AND AD_Org_ID=? ORDER BY Created";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try
{ {
@ -88,6 +90,47 @@ public class MWarehouse extends X_M_Warehouse
return retValue; return retValue;
} // get } // get
/**
* FR [ 1966337 ]
* Get Warehouses Transit for Org
* @param ctx context
* @param AD_Org_ID id
* @return warehouse
*/
public static MWarehouse[] getInTransitForOrg (Properties ctx, int AD_Org_ID)
{
ArrayList<MWarehouse> list = new ArrayList<MWarehouse>();
String sql = "SELECT * FROM M_Warehouse WHERE IsActive = 'Y' AND IsInTransit = 'Y' AND AD_Org_ID=? ORDER BY Created";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_Org_ID);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MWarehouse (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MWarehouse[] retValue = new MWarehouse[list.size ()];
list.toArray (retValue);
return retValue;
} // get
/** Cache */ /** Cache */
private static CCache<Integer,MWarehouse> s_cache = new CCache<Integer,MWarehouse>("M_Warehouse", 5); private static CCache<Integer,MWarehouse> s_cache = new CCache<Integer,MWarehouse>("M_Warehouse", 5);
@ -150,7 +193,7 @@ public class MWarehouse extends X_M_Warehouse
if (!reload && m_locators != null) if (!reload && m_locators != null)
return m_locators; return m_locators;
// //
String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=? ORDER BY X,Y,Z"; String sql = "SELECT * FROM M_Locator WHERE IsActive = 'Y' AND M_Warehouse_ID=? ORDER BY X,Y,Z";
ArrayList<MLocator> list = new ArrayList<MLocator>(); ArrayList<MLocator> list = new ArrayList<MLocator>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
try try

View File

@ -32,16 +32,19 @@ public interface ModelValidator
public static final int TYPE_NEW = 1; public static final int TYPE_NEW = 1;
public static final int CHANGETYPE_NEW = 1; // Compatibility with Compiere 260c public static final int CHANGETYPE_NEW = 1; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_NEW = 4; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_NEW = 4; // teo_sarca [ 1675490 ]
public static final int TYPE_AFTER_NEW_REPLICATION = 7; // @Trifon
/** Model Change Type Change */ /** Model Change Type Change */
public static final int TYPE_BEFORE_CHANGE = 2; // teo_sarca [ 1675490 ] public static final int TYPE_BEFORE_CHANGE = 2; // teo_sarca [ 1675490 ]
public static final int TYPE_CHANGE = 2; public static final int TYPE_CHANGE = 2;
public static final int CHANGETYPE_CHANGE = 2; // Compatibility with Compiere 260c public static final int CHANGETYPE_CHANGE = 2; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_CHANGE = 5; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_CHANGE = 5; // teo_sarca [ 1675490 ]
public static final int TYPE_AFTER_CHANGE_REPLICATION = 8; // @Trifon
/** Model Change Type Delete */ /** Model Change Type Delete */
public static final int TYPE_BEFORE_DELETE = 3; // teo_sarca [ 1675490 ] public static final int TYPE_BEFORE_DELETE = 3; // teo_sarca [ 1675490 ]
public static final int TYPE_DELETE = 3; public static final int TYPE_DELETE = 3;
public static final int CHANGETYPE_DELETE = 3; // Compatibility with Compiere 260c public static final int CHANGETYPE_DELETE = 3; // Compatibility with Compiere 260c
public static final int TYPE_AFTER_DELETE = 6; // teo_sarca [ 1675490 ] public static final int TYPE_AFTER_DELETE = 6; // teo_sarca [ 1675490 ]
public static final int TYPE_BEFORE_DELETE_REPLICATION = 9; // @Trifon
// Correlation between constant events and list of event script model validators // Correlation between constant events and list of event script model validators
public static String[] tableEventValidators = new String[] { public static String[] tableEventValidators = new String[] {
@ -51,7 +54,10 @@ public interface ModelValidator
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDelete, // TYPE_BEFORE_DELETE = 3 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDelete, // TYPE_BEFORE_DELETE = 3
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNew, // TYPE_AFTER_NEW = 4 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNew, // TYPE_AFTER_NEW = 4
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChange, // TYPE_AFTER_CHANGE = 5 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChange, // TYPE_AFTER_CHANGE = 5
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterDelete // TYPE_AFTER_DELETE = 6 X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterDelete, // TYPE_AFTER_DELETE = 6
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterNewReplication, // TYPE_AFTER_NEW_REPLICATION = 7
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableAfterChangeReplication, // TYPE_AFTER_CHANGE_REPLICATION = 8
X_AD_Table_ScriptValidator.EVENTMODELVALIDATOR_TableBeforeDeleteReplication // TYPE_BEFORE_DELETE_REPLICATION = 9
}; };
/** Called before document is prepared */ /** Called before document is prepared */

View File

@ -208,6 +208,8 @@ public abstract class PO
/** Accounting Columns */ /** Accounting Columns */
private ArrayList <String> s_acctColumns = null; private ArrayList <String> s_acctColumns = null;
/** TODO - Trifon */
private boolean m_isReplication = false;
/** Access Level S__ 100 4 System info */ /** Access Level S__ 100 4 System info */
public static final int ACCESSLEVEL_SYSTEM = 4; public static final int ACCESSLEVEL_SYSTEM = 4;
@ -1977,7 +1979,12 @@ public abstract class PO
// Call ModelValidators TYPE_AFTER_NEW/TYPE_AFTER_CHANGE - teo_sarca [ 1675490 ] // Call ModelValidators TYPE_AFTER_NEW/TYPE_AFTER_CHANGE - teo_sarca [ 1675490 ]
if (success) { if (success) {
String errorMsg = ModelValidationEngine.get().fireModelChange String errorMsg = ModelValidationEngine.get().fireModelChange
(this, newRecord ? ModelValidator.TYPE_AFTER_NEW : ModelValidator.TYPE_AFTER_CHANGE); (this, newRecord ?
(isReplication() ? ModelValidator.TYPE_AFTER_NEW_REPLICATION : ModelValidator.TYPE_AFTER_NEW)
:
(isReplication() ? ModelValidator.TYPE_AFTER_CHANGE_REPLICATION : ModelValidator.TYPE_AFTER_CHANGE)
);
setReplication(false);
if (errorMsg != null) { if (errorMsg != null) {
log.saveError("Error", errorMsg); log.saveError("Error", errorMsg);
success = false; success = false;
@ -2031,6 +2038,12 @@ public abstract class PO
return save(); return save();
} // save } // save
public boolean saveReplica (boolean isFromReplication)
{
setReplication(isFromReplication);
return save();
}
/** /**
* Is there a Change to be saved? * Is there a Change to be saved?
* @return true if record changed * @return true if record changed
@ -2644,7 +2657,8 @@ public abstract class PO
} }
// Call ModelValidators TYPE_DELETE // Call ModelValidators TYPE_DELETE
errorMsg = ModelValidationEngine.get().fireModelChange errorMsg = ModelValidationEngine.get().fireModelChange
(this, ModelValidator.TYPE_DELETE); (this, isReplication() ? ModelValidator.TYPE_BEFORE_DELETE_REPLICATION : ModelValidator.TYPE_DELETE);
setReplication(false); // @Trifon
if (errorMsg != null) if (errorMsg != null)
{ {
log.saveError("Error", errorMsg); log.saveError("Error", errorMsg);
@ -3623,6 +3637,16 @@ public abstract class PO
m_doc = doc; m_doc = doc;
} }
public void setReplication(boolean isFromReplication)
{
m_isReplication = isFromReplication;
}
public boolean isReplication()
{
return m_isReplication;
}
/** /**
* Set the accounting document associated to the PO - for use in POST ModelValidator * Set the accounting document associated to the PO - for use in POST ModelValidator
* @return Doc Document * @return Doc Document

View File

@ -1569,11 +1569,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
Object dataElement = null; Object dataElement = null;
if (item.isPrinted()) // Text Columns if (item.isPrinted()) // Text Columns
{ {
if (item.isTypePrintFormat()) if (item.isTypeImage())
{
log.warning("Unsupported: PrintFormat in Table: " + item);
}
else if (item.isTypeImage())
{ {
if (item.isImageField()) if (item.isImageField())
{ {
@ -1631,7 +1627,11 @@ public class LayoutEngine implements Pageable, Printable, Doc
data[row][col] = element; data[row][col] = element;
} }
} }
else else if (item.isTypeText() )
{
data[row][col] = item.getPrintName(format.getLanguage());
}
else if (item.isTypeField())
{ {
Object obj = null; Object obj = null;
if (item.getAD_Column_ID() > 0) // teo_sarca, [ 1673542 ] if (item.getAD_Column_ID() > 0) // teo_sarca, [ 1673542 ]
@ -1651,6 +1651,10 @@ public class LayoutEngine implements Pageable, Printable, Doc
// System.out.println(" row=" + row + ",col=" + col + " - " + item.getAD_Column_ID() + " => " + dataElement); // System.out.println(" row=" + row + ",col=" + col + " - " + item.getAD_Column_ID() + " => " + dataElement);
data[row][col] = dataElement; data[row][col] = dataElement;
} }
else // item.isTypeBox() or isTypePrintFormat()
{
log.warning("Unsupported: " + (item.isTypeBox() ? "Box" : "PrintFormat") + " in Table: " + item);
}
col++; col++;
} // printed } // printed
} // for all columns } // for all columns

View File

@ -26,12 +26,16 @@ import org.compiere.util.*;
* Invoice Aging Report. * Invoice Aging Report.
* Based on RV_Aging. * Based on RV_Aging.
* @author Jorg Janke * @author Jorg Janke
* @author victor.perez@e-evolution.com FR 1933937 Is necessary a new Aging to Date
* @see http://sourceforge.net/tracker/index.php?func=detail&aid=1933937&group_id=176962&atid=879335
* @version $Id: Aging.java,v 1.5 2006/10/07 00:58:44 jjanke Exp $ * @version $Id: Aging.java,v 1.5 2006/10/07 00:58:44 jjanke Exp $
*/ */
public class Aging extends SvrProcess public class Aging extends SvrProcess
{ {
/** The date to calculate the days due from */ /** The date to calculate the days due from */
private Timestamp p_StatementDate = null; private Timestamp p_StatementDate = null;
//FR 1933937
private boolean p_DateAcct = false;
private boolean p_IsSOTrx = false; private boolean p_IsSOTrx = false;
private int p_C_Currency_ID = 0; private int p_C_Currency_ID = 0;
private int p_C_BP_Group_ID = 0; private int p_C_BP_Group_ID = 0;
@ -53,6 +57,8 @@ public class Aging extends SvrProcess
; ;
else if (name.equals("StatementDate")) else if (name.equals("StatementDate"))
p_StatementDate = (Timestamp)para[i].getParameter(); p_StatementDate = (Timestamp)para[i].getParameter();
else if (name.equals("DateAcct"))
p_DateAcct = "Y".equals(para[i].getParameter());
else if (name.equals("IsSOTrx")) else if (name.equals("IsSOTrx"))
p_IsSOTrx = "Y".equals(para[i].getParameter()); p_IsSOTrx = "Y".equals(para[i].getParameter());
else if (name.equals("C_Currency_ID")) else if (name.equals("C_Currency_ID"))
@ -84,28 +90,46 @@ public class Aging extends SvrProcess
+ ", C_Currency_ID=" + p_C_Currency_ID + ", C_Currency_ID=" + p_C_Currency_ID
+ ", C_BP_Group_ID=" + p_C_BP_Group_ID + ", C_BPartner_ID=" + p_C_BPartner_ID + ", C_BP_Group_ID=" + p_C_BP_Group_ID + ", C_BPartner_ID=" + p_C_BPartner_ID
+ ", IsListInvoices=" + p_IsListInvoices); + ", IsListInvoices=" + p_IsListInvoices);
// //FR 1933937
String dateacct = DB.TO_DATE(p_StatementDate);
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("SELECT bp.C_BP_Group_ID, oi.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, " sql.append("SELECT bp.C_BP_Group_ID, oi.C_BPartner_ID,oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID, "
+ "oi.C_Currency_ID, oi.IsSOTrx, " // 5..6 + "oi.C_Currency_ID, oi.IsSOTrx, " // 5..6
+ "oi.DateInvoiced, oi.NetDays,oi.DueDate,oi.DaysDue, "); // 7..10 + "oi.DateInvoiced, oi.NetDays,oi.DueDate,oi.DaysDue, "); // 7..10
if (p_C_Currency_ID == 0) if (p_C_Currency_ID == 0)
if (!p_DateAcct)//FR 1933937
sql.append("oi.GrandTotal, oi.PaidAmt, oi.OpenAmt "); // 11..13 sql.append("oi.GrandTotal, oi.PaidAmt, oi.OpenAmt "); // 11..13
else
sql.append("oi.GrandTotal, invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,"+dateacct+") AS PaidAmt, invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+") AS OpenAmt "); // 11..13
else else
{ {
String s = ",oi.C_Currency_ID," + p_C_Currency_ID + ",oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID)"; String s = ",oi.C_Currency_ID," + p_C_Currency_ID + ",oi.DateAcct,oi.C_ConversionType_ID,oi.AD_Client_ID,oi.AD_Org_ID)";
sql.append("currencyConvert(oi.GrandTotal").append(s) // 11.. sql.append("currencyConvert(oi.GrandTotal").append(s); // 11..
.append(", currencyConvert(oi.PaidAmt").append(s) if (!p_DateAcct)
sql.append(", currencyConvert(oi.PaidAmt").append(s)
.append(", currencyConvert(oi.OpenAmt").append(s); .append(", currencyConvert(oi.OpenAmt").append(s);
else
sql.append(", currencyConvert(invoicePaidToDate(oi.C_Invoice_ID, oi.C_Currency_ID, 1,"+dateacct+")").append(s)
.append(", currencyConvert(invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+")").append(s);
} }
sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID " // 14 sql.append(",oi.C_Activity_ID,oi.C_Campaign_ID,oi.C_Project_ID "); // 14
+ "FROM RV_OpenItem oi" if (!p_DateAcct)//FR 1933937
+ " INNER JOIN C_BPartner bp ON (oi.C_BPartner_ID=bp.C_BPartner_ID) " sql.append( "FROM RV_OpenItem oi");
else
sql.append( "FROM RV_OpenItemToDate oi");
sql.append(" INNER JOIN C_BPartner bp ON (oi.C_BPartner_ID=bp.C_BPartner_ID) "
+ "WHERE oi.ISSoTrx=").append(p_IsSOTrx ? "'Y'" : "'N'"); + "WHERE oi.ISSoTrx=").append(p_IsSOTrx ? "'Y'" : "'N'");
if (p_C_BPartner_ID > 0) if (p_C_BPartner_ID > 0)
sql.append(" AND oi.C_BPartner_ID=").append(p_C_BPartner_ID); sql.append(" AND oi.C_BPartner_ID=").append(p_C_BPartner_ID);
else if (p_C_BP_Group_ID > 0) else if (p_C_BP_Group_ID > 0)
sql.append(" AND bp.C_BP_Group_ID=").append(p_C_BP_Group_ID); sql.append(" AND bp.C_BP_Group_ID=").append(p_C_BP_Group_ID);
if (p_DateAcct)//FR 1933937
sql.append("AND invoiceOpenToDate(oi.C_Invoice_ID,oi.C_InvoicePaySchedule_ID,"+dateacct+") <> 0 ");
sql.append(" ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID"); sql.append(" ORDER BY oi.C_BPartner_ID, oi.C_Currency_ID, oi.C_Invoice_ID");
log.finest(sql.toString()); log.finest(sql.toString());
@ -174,6 +198,7 @@ public class Aging extends SvrProcess
aging.setC_Activity_ID(C_Activity_ID); aging.setC_Activity_ID(C_Activity_ID);
aging.setC_Campaign_ID(C_Campaign_ID); aging.setC_Campaign_ID(C_Campaign_ID);
aging.setC_Project_ID(C_Project_ID); aging.setC_Project_ID(C_Project_ID);
aging.setDateAcct(p_DateAcct);
} }
// Fill Buckets // Fill Buckets
aging.add (DueDate, DaysDue, GrandTotal, OpenAmt); aging.add (DueDate, DaysDue, GrandTotal, OpenAmt);

View File

@ -33,6 +33,7 @@ import org.compiere.interfaces.Server;
import org.compiere.interfaces.ServerHome; import org.compiere.interfaces.ServerHome;
import org.compiere.model.MAllocationHdr; import org.compiere.model.MAllocationHdr;
import org.compiere.model.MBankStatement; import org.compiere.model.MBankStatement;
import org.compiere.model.MCash;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MInOut; import org.compiere.model.MInOut;
import org.compiere.model.MInventory; import org.compiere.model.MInventory;
@ -53,6 +54,7 @@ import org.compiere.util.Ini;
* *
* @author Jorg Janke * @author Jorg Janke
* @author Karsten Thiemann FR [ 1782412 ] * @author Karsten Thiemann FR [ 1782412 ]
* @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
* @version $Id: DocumentEngine.java,v 1.2 2006/07/30 00:54:44 jjanke Exp $ * @version $Id: DocumentEngine.java,v 1.2 2006/07/30 00:54:44 jjanke Exp $
*/ */
public class DocumentEngine implements DocAction public class DocumentEngine implements DocAction
@ -1009,6 +1011,18 @@ public class DocumentEngine implements DocAction
options[index++] = DocumentEngine.ACTION_Reverse_Correct; options[index++] = DocumentEngine.ACTION_Reverse_Correct;
} }
} }
//[ 1782412 ]
/********************
* Cash
*/
else if (AD_Table_ID == MCash.Table_ID)
{
// Complete .. CO
if (docStatus.equals(DocumentEngine.STATUS_Completed))
{
options[index++] = DocumentEngine.ACTION_Void;
}
}
/******************** /********************
* Bank Statement * Bank Statement
*/ */

View File

@ -131,7 +131,8 @@ public class M_Product_BOM_Check extends SvrProcess
// Insert BOM Nodes into "All" table // Insert BOM Nodes into "All" table
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) " sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) "
+ "SELECT " + m_AD_PInstance_ID + ", 0, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS " + "SELECT " + m_AD_PInstance_ID + ", 0, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS "
+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN " //+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN "
+ "(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN "
+ "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))"); + "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
@ -141,7 +142,8 @@ public class M_Product_BOM_Check extends SvrProcess
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());
sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) " sql1 = new StringBuffer("INSERT INTO T_Selection2 (AD_PInstance_ID, Query_ID, T_Selection_ID) "
+ "SELECT " + m_AD_PInstance_ID + ", 1, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS " + "SELECT " + m_AD_PInstance_ID + ", 1, p.M_Product_ID FROM M_Product p WHERE IsBOM='Y' AND EXISTS "
+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN " //+ "(SELECT * FROM M_Product_BOM b WHERE p.M_Product_ID=b.M_ProductBOM_ID AND b.M_Product_ID IN "
+ "(SELECT * FROM PP_Product_BOM b WHERE p.M_Product_ID=b.M_Product_ID AND b.M_Product_ID IN "
+ "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))"); + "(SELECT T_Selection_ID FROM T_Selection WHERE AD_PInstance_ID="+ m_AD_PInstance_ID + "))");
no = DB.executeUpdate(sql1.toString(), get_TrxName()); no = DB.executeUpdate(sql1.toString(), get_TrxName());
if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString()); if (no == -1) raiseError("InsertingRoot:ERROR", sql1.toString());

View File

@ -13,6 +13,7 @@
* For the text or an alternative of this public license, you may reach us * * For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html * * or via info@compiere.org or http://www.compiere.org/license.html *
* @contributor Karsten Thiemann / Schaeffer AG - kthiemann@adempiere.org *
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
@ -37,6 +38,8 @@ public class OrderBatchProcess extends SvrProcess
private Timestamp p_DateOrdered_From = null; private Timestamp p_DateOrdered_From = null;
private Timestamp p_DateOrdered_To = null; private Timestamp p_DateOrdered_To = null;
private String p_DocAction = null; private String p_DocAction = null;
private String p_IsDelivered = null;
private String p_IsInvoiced = null;
/** /**
* Prepare * Prepare
@ -64,6 +67,11 @@ public class OrderBatchProcess extends SvrProcess
} }
else if (name.equals("DocAction")) else if (name.equals("DocAction"))
p_DocAction = (String)para[i].getParameter(); p_DocAction = (String)para[i].getParameter();
else if (name.equals("IsDelivered")) {
p_IsDelivered = (String)para[i].getParameter();
} else if (name.equals("IsInvoiced")) {
p_IsInvoiced = (String)para[i].getParameter();
}
else else
log.log(Level.SEVERE, "Unknown Parameter: " + name); log.log(Level.SEVERE, "Unknown Parameter: " + name);
} }
@ -79,7 +87,8 @@ public class OrderBatchProcess extends SvrProcess
log.info("C_DocTypeTarget_ID=" + p_C_DocTypeTarget_ID + ", DocStatus=" + p_DocStatus log.info("C_DocTypeTarget_ID=" + p_C_DocTypeTarget_ID + ", DocStatus=" + p_DocStatus
+ ", IsSelfService=" + p_IsSelfService + ", C_BPartner_ID=" + p_C_BPartner_ID + ", IsSelfService=" + p_IsSelfService + ", C_BPartner_ID=" + p_C_BPartner_ID
+ ", DateOrdered=" + p_DateOrdered_From + "->" + p_DateOrdered_To + ", DateOrdered=" + p_DateOrdered_From + "->" + p_DateOrdered_To
+ ", DocAction=" + p_DocAction); + ", DocAction=" + p_DocAction + ", IsDelivered=" + p_IsDelivered
+ ", IsInvoiced=" + p_IsInvoiced);
if (p_C_DocTypeTarget_ID == 0) if (p_C_DocTypeTarget_ID == 0)
throw new AdempiereUserError("@NotFound@: @C_DocTypeTarget_ID@"); throw new AdempiereUserError("@NotFound@: @C_DocTypeTarget_ID@");
@ -89,16 +98,28 @@ public class OrderBatchProcess extends SvrProcess
throw new AdempiereUserError("@NotFound@: @DocAction@"); throw new AdempiereUserError("@NotFound@: @DocAction@");
// //
StringBuffer sql = new StringBuffer("SELECT * FROM C_Order " StringBuffer sql = new StringBuffer("SELECT * FROM C_Order o "
+ "WHERE C_DocTypeTarget_ID=? AND DocStatus=?"); + " WHERE o.C_DocTypeTarget_ID=? AND o.DocStatus=? ");
if (p_IsSelfService != null && p_IsSelfService.length() == 1) if (p_IsSelfService != null && p_IsSelfService.length() == 1)
sql.append(" AND IsSelfService='").append(p_IsSelfService).append("'"); sql.append(" AND o.IsSelfService='").append(p_IsSelfService).append("'");
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
sql.append(" AND C_BPartner_ID=").append(p_C_BPartner_ID); sql.append(" AND o.C_BPartner_ID=").append(p_C_BPartner_ID);
if (p_DateOrdered_From != null) if (p_DateOrdered_From != null)
sql.append(" AND TRUNC(DateOrdered) >= ").append(DB.TO_DATE(p_DateOrdered_From, true)); sql.append(" AND TRUNC(o.DateOrdered) >= ").append(DB.TO_DATE(p_DateOrdered_From, true));
if (p_DateOrdered_To != null) if (p_DateOrdered_To != null)
sql.append(" AND TRUNC(DateOrdered) <= ").append(DB.TO_DATE(p_DateOrdered_To, true)); sql.append(" AND TRUNC(o.DateOrdered) <= ").append(DB.TO_DATE(p_DateOrdered_To, true));
if ("Y".equals(p_IsDelivered))
sql.append(" AND NOT EXISTS (SELECT l.C_OrderLine_ID FROM C_OrderLine l ")
.append(" WHERE l.C_Order_ID=o.C_Order_ID AND l.QtyOrdered>l.QtyDelivered) ");
else if ("N".equals(p_IsDelivered))
sql.append(" AND EXISTS (SELECT l.C_OrderLine_ID FROM C_OrderLine l ")
.append(" WHERE l.C_Order_ID=o.C_Order_ID AND l.QtyOrdered>l.QtyDelivered) ");
if ("Y".equals(p_IsInvoiced))
sql.append(" AND NOT EXISTS (SELECT l.C_OrderLine_ID FROM C_OrderLine l ")
.append(" WHERE l.C_Order_ID=o.C_Order_ID AND l.QtyOrdered>l.QtyInvoiced) ");
else if ("N".equals(p_IsInvoiced))
sql.append(" AND EXISTS (SELECT l.C_OrderLine_ID FROM C_OrderLine l ")
.append(" WHERE l.C_Order_ID=o.C_Order_ID AND l.QtyOrdered>l.QtyInvoiced) ");
int counter = 0; int counter = 0;
int errCounter = 0; int errCounter = 0;

View File

@ -18,6 +18,7 @@ package org.compiere.process;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.util.AdempiereSystemError;
/** /**
* Re-Open Order Process (from Closed to Completed) * Re-Open Order Process (from Closed to Completed)
@ -53,20 +54,20 @@ public class OrderOpen extends SvrProcess
* @return Message * @return Message
* @throws Exception if not successful * @throws Exception if not successful
*/ */
protected String doIt() throws Exception protected String doIt() throws AdempiereSystemError
{ {
log.info("doIt - Open C_Order_ID=" + p_C_Order_ID); log.info("doIt - Open C_Order_ID=" + p_C_Order_ID);
if (p_C_Order_ID == 0) if (p_C_Order_ID == 0)
throw new IllegalArgumentException("C_Order_ID == 0"); return "";
// //
MOrder order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName()); MOrder order = new MOrder (getCtx(), p_C_Order_ID, get_TrxName());
if (MOrder.DOCSTATUS_Closed.equals(order.getDocStatus())) String msg = order.reopenIt();
if ( msg.length() != 0 )
{ {
order.setDocStatus(MOrder.DOCSTATUS_Completed); throw new AdempiereSystemError(msg);
return order.save() ? "@OK@" : "@Error@";
} }
else
throw new IllegalStateException("Order is not closed"); return order.save() ? "@OK@" : "@Error@";
} // doIt } // doIt
} // OrderOpen } // OrderOpen

View File

@ -96,8 +96,8 @@ public class OrderPOCreate extends SvrProcess
String sql = "SELECT * FROM C_Order o " String sql = "SELECT * FROM C_Order o "
+ "WHERE o.IsSOTrx='Y'" + "WHERE o.IsSOTrx='Y'"
// No Duplicates // No Duplicates
// " AND o.Ref_Order_ID IS NULL" // " AND o.Link_Order_ID IS NULL"
+ " AND NOT EXISTS (SELECT * FROM C_OrderLine ol WHERE o.C_Order_ID=ol.C_Order_ID AND ol.Ref_OrderLine_ID IS NOT NULL)" + " AND NOT EXISTS (SELECT * FROM C_OrderLine ol WHERE o.C_Order_ID=ol.C_Order_ID AND ol.Link_OrderLine_ID IS NOT NULL)"
; ;
if (p_C_Order_ID != 0) if (p_C_Order_ID != 0)
sql += " AND o.C_Order_ID=?"; sql += " AND o.C_Order_ID=?";
@ -213,7 +213,7 @@ public class OrderPOCreate extends SvrProcess
if (soLines[i].getM_Product_ID() == M_Product_ID) if (soLines[i].getM_Product_ID() == M_Product_ID)
{ {
MOrderLine poLine = new MOrderLine (po); MOrderLine poLine = new MOrderLine (po);
poLine.setRef_OrderLine_ID(soLines[i].getC_OrderLine_ID()); poLine.setLink_OrderLine_ID(soLines[i].getC_OrderLine_ID());
poLine.setM_Product_ID(soLines[i].getM_Product_ID()); poLine.setM_Product_ID(soLines[i].getM_Product_ID());
poLine.setM_AttributeSetInstance_ID(soLines[i].getM_AttributeSetInstance_ID()); poLine.setM_AttributeSetInstance_ID(soLines[i].getM_AttributeSetInstance_ID());
poLine.setC_UOM_ID(soLines[i].getC_UOM_ID()); poLine.setC_UOM_ID(soLines[i].getC_UOM_ID());
@ -223,6 +223,9 @@ public class OrderPOCreate extends SvrProcess
poLine.setDatePromised(soLines[i].getDatePromised()); poLine.setDatePromised(soLines[i].getDatePromised());
poLine.setPrice(); poLine.setPrice();
poLine.save(); poLine.save();
soLines[i].setLink_OrderLine_ID(poLine.getC_OrderLine_ID());
soLines[i].save();
} }
} }
} }
@ -239,7 +242,7 @@ public class OrderPOCreate extends SvrProcess
// Set Reference to PO // Set Reference to PO
if (counter == 1 && po != null) if (counter == 1 && po != null)
{ {
so.setRef_Order_ID(po.getC_Order_ID()); so.setLink_Order_ID(po.getC_Order_ID());
so.save(); so.save();
} }
return counter; return counter;
@ -254,7 +257,7 @@ public class OrderPOCreate extends SvrProcess
{ {
MOrder po = new MOrder (getCtx(), 0, get_TrxName()); MOrder po = new MOrder (getCtx(), 0, get_TrxName());
po.setClientOrg(so.getAD_Client_ID(), so.getAD_Org_ID()); po.setClientOrg(so.getAD_Client_ID(), so.getAD_Org_ID());
po.setRef_Order_ID(so.getC_Order_ID()); po.setLink_Order_ID(so.getC_Order_ID());
po.setIsSOTrx(false); po.setIsSOTrx(false);
po.setC_DocTypeTarget_ID(); po.setC_DocTypeTarget_ID();
// //

View File

@ -22,6 +22,7 @@ import java.util.*;
import java.math.*; import java.math.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.eevolution.model.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.util.*; import org.compiere.util.*;
@ -105,6 +106,8 @@ public class ReplenishReport extends SvrProcess
createRequisition(); createRequisition();
else if (p_ReplenishmentCreate.equals("MMM")) else if (p_ReplenishmentCreate.equals("MMM"))
createMovements(); createMovements();
else if (p_ReplenishmentCreate.equals("DOO"))
createDO();
return m_info; return m_info;
} // doIt } // doIt
@ -546,7 +549,154 @@ public class ReplenishReport extends SvrProcess
m_info = "#" + noMoves + info; m_info = "#" + noMoves + info;
log.info(m_info); log.info(m_info);
} }
} // createRequisition } // Create Inventory Movements
/**
* Create Distribution Order
*/
private void createDO() throws Exception
{
int noMoves = 0;
String info = "";
//
MClient client = null;
MDDOrder order = null;
int M_Warehouse_ID = 0;
int M_WarehouseSource_ID = 0;
MWarehouse whSource = null;
MWarehouse wh = null;
X_T_Replenish[] replenishs = getReplenishDO("M_WarehouseSource_ID IS NOT NULL");
for (X_T_Replenish replenish:replenishs)
{
if (whSource == null || whSource.getM_WarehouseSource_ID() != replenish.getM_WarehouseSource_ID())
whSource = MWarehouse.get(getCtx(), replenish.getM_WarehouseSource_ID());
if (wh == null || wh.getM_Warehouse_ID() != replenish.getM_Warehouse_ID())
wh = MWarehouse.get(getCtx(), replenish.getM_Warehouse_ID());
if (client == null || client.getAD_Client_ID() != whSource.getAD_Client_ID())
client = MClient.get(getCtx(), whSource.getAD_Client_ID());
//
if (order == null
|| M_WarehouseSource_ID != replenish.getM_WarehouseSource_ID()
|| M_Warehouse_ID != replenish.getM_Warehouse_ID())
{
M_WarehouseSource_ID = replenish.getM_WarehouseSource_ID();
M_Warehouse_ID = replenish.getM_Warehouse_ID();
order = new MDDOrder (getCtx(), 0, get_TrxName());
order.setC_DocType_ID(p_C_DocType_ID);
order.setDescription(Msg.getMsg(getCtx(), "Replenishment")
+ ": " + whSource.getName() + "->" + wh.getName());
// Set Org
order.setAD_Org_ID(whSource.getAD_Org_ID());
// Set Org Trx
MOrg orgTrx = MOrg.get(getCtx(), wh.getAD_Org_ID());
order.setAD_OrgTrx_ID(orgTrx.getAD_Org_ID());
int C_BPartner_ID = orgTrx.getLinkedC_BPartner_ID(get_TrxName());
if (C_BPartner_ID==0)
throw new AdempiereUserError(Msg.translate(getCtx(), "C_BPartner_ID")+ " @FillMandatory@ ");
MBPartner bp = new MBPartner(getCtx(),C_BPartner_ID,get_TrxName());
// Set BPartner Link to Org
order.setBPartner(bp);
order.setDateOrdered(new Timestamp(System.currentTimeMillis()));
//order.setDatePromised(DatePromised);
order.setDeliveryRule(MDDOrder.DELIVERYRULE_Availability);
order.setDeliveryViaRule(MDDOrder.DELIVERYVIARULE_Delivery);
order.setPriorityRule(MDDOrder.PRIORITYRULE_Medium);
order.setIsInDispute(false);
order.setIsApproved(false);
order.setIsDropShip(false);
order.setIsDelivered(false);
order.setIsInTransit(false);
order.setIsPrinted(false);
order.setIsSelected(false);
order.setIsSOTrx(false);
// Warehouse in Transit
MWarehouse[] whsInTransit = MWarehouse.getForOrg(getCtx(), whSource.getAD_Org_ID());
for (MWarehouse whInTransit:whsInTransit)
{
if(whInTransit.isInTransit())
order.setM_Warehouse_ID(whInTransit.getM_Warehouse_ID());
}
if (order.getM_Warehouse_ID()==0)
throw new AdempiereUserError("Warehouse inTransit is @FillMandatory@ ");
if (!order.save())
return;
log.fine(order.toString());
noMoves++;
info += " - " + order.getDocumentNo();
}
// To
int M_LocatorTo_ID = wh.getDefaultLocator().getM_Locator_ID();
int M_Locator_ID = whSource.getDefaultLocator().getM_Locator_ID();
if(M_LocatorTo_ID == 0 || M_Locator_ID==0)
throw new AdempiereUserError(Msg.translate(getCtx(), "M_Locator_ID")+" @FillMandatory@ ");
// From: Look-up Storage
/*MProduct product = MProduct.get(getCtx(), replenish.getM_Product_ID());
MProductCategory pc = MProductCategory.get(getCtx(), product.getM_Product_Category_ID());
String MMPolicy = pc.getMMPolicy();
if (MMPolicy == null || MMPolicy.length() == 0)
MMPolicy = client.getMMPolicy();
//
MStorage[] storages = MStorage.getWarehouse(getCtx(),
whSource.getM_Warehouse_ID(), replenish.getM_Product_ID(), 0, 0,
true, null,
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
BigDecimal target = replenish.getQtyToOrder();
for (int j = 0; j < storages.length; j++)
{
MStorage storage = storages[j];
if (storage.getQtyOnHand().signum() <= 0)
continue;
BigDecimal moveQty = target;
if (storage.getQtyOnHand().compareTo(moveQty) < 0)
moveQty = storage.getQtyOnHand();
//
MDDOrderLine line = new MDDOrderLine(order);
line.setM_Product_ID(replenish.getM_Product_ID());
line.setQtyEntered(moveQty);
if (replenish.getQtyToOrder().compareTo(moveQty) != 0)
line.setDescription("Total: " + replenish.getQtyToOrder());
line.setM_Locator_ID(storage.getM_Locator_ID()); // from
line.setM_AttributeSetInstance_ID(storage.getM_AttributeSetInstance_ID());
line.setM_LocatorTo_ID(M_LocatorTo_ID); // to
line.setM_AttributeSetInstanceTo_ID(storage.getM_AttributeSetInstance_ID());
line.setIsInvoiced(false);
line.save();
//
target = target.subtract(moveQty);
if (target.signum() == 0)
break;
}*/
MDDOrderLine line = new MDDOrderLine(order);
line.setM_Product_ID(replenish.getM_Product_ID());
line.setQty(replenish.getQtyToOrder());
if (replenish.getQtyToOrder().compareTo(replenish.getQtyToOrder()) != 0)
line.setDescription("Total: " + replenish.getQtyToOrder());
line.setM_Locator_ID(M_Locator_ID); // from
line.setM_AttributeSetInstance_ID(0);
line.setM_LocatorTo_ID(M_LocatorTo_ID); // to
line.setM_AttributeSetInstanceTo_ID(0);
line.setIsInvoiced(false);
line.save();
}
if (replenishs.length == 0)
{
m_info = "No Source Warehouse";
log.warning(m_info);
}
else
{
m_info = "#" + noMoves + info;
log.info(m_info);
}
} // create Distribution Order
/** /**
* Get Replenish Records * Get Replenish Records
@ -591,4 +741,47 @@ public class ReplenishReport extends SvrProcess
return retValue; return retValue;
} // getReplenish } // getReplenish
/**
* Get Replenish Records
* @return replenish
*/
private X_T_Replenish[] getReplenishDO (String where)
{
String sql = "SELECT * FROM T_Replenish "
+ "WHERE AD_PInstance_ID=? ";
if (where != null && where.length() > 0)
sql += " AND " + where;
sql += " ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID";
ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>();
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new X_T_Replenish (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
X_T_Replenish[] retValue = new X_T_Replenish[list.size ()];
list.toArray (retValue);
return retValue;
} // getReplenish
} // Replenish } // Replenish

View File

@ -24,6 +24,8 @@ import java.sql.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
import javax.swing.*; import javax.swing.*;
import org.compiere.apps.form.FormFrame;
import org.compiere.db.*; import org.compiere.db.*;
import org.compiere.grid.ed.Calculator; import org.compiere.grid.ed.Calculator;
import org.compiere.interfaces.*; import org.compiere.interfaces.*;
@ -37,7 +39,10 @@ import org.compiere.util.*;
* @author Jorg Janke * @author Jorg Janke
* @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
* *
* Colin Rooney (croo) & kstan_79 RFE#1670185 * @author Colin Rooney (croo) & kstan_79 RFE#1670185
* @author victor.perez@e-evolution.com
* @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335
*
*/ */
public final class AEnv public final class AEnv
{ {
@ -365,6 +370,23 @@ public final class AEnv
{ {
new org.compiere.apps.search.InfoSchedule (Env.getFrame(c), null, false); new org.compiere.apps.search.InfoSchedule (Env.getFrame(c), null, false);
} }
//FR [ 1966328 ]
else if (actionCommand.equals("InfoMRP") && AEnv.canAccessInfo("MRP"))
{
CFrame frame = (CFrame) Env.getFrame(c);
int m_menu_id = MMenu.getMenu_ID("MRP Info");
AMenu menu = AEnv.getAMenu(frame);
AMenuStartItem form = new AMenuStartItem (m_menu_id, true, Msg.translate(Env.getCtx(), "MRP Info"), menu); // async load
form.start();
}
else if (actionCommand.equals("InfoCRP") && AEnv.canAccessInfo("CRP"))
{
CFrame frame = (CFrame) Env.getFrame(c);
int m_menu_id = MMenu.getMenu_ID("CRP Info");
AMenu menu = AEnv.getAMenu(frame);
AMenuStartItem form = new AMenuStartItem (m_menu_id, true, Msg.translate(Env.getCtx(), "CRP Info"), menu); // async load
form.start();
}
else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER"))
{ {
org.compiere.apps.search.Info.showOrder (Env.getFrame(c), WindowNo, ""); org.compiere.apps.search.Info.showOrder (Env.getFrame(c), WindowNo, "");
@ -390,6 +412,7 @@ public final class AEnv
org.compiere.apps.search.Info.showAssignment (Env.getFrame(c), WindowNo, ""); org.compiere.apps.search.Info.showAssignment (Env.getFrame(c), WindowNo, "");
} }
// Go Menu ------------------------ // Go Menu ------------------------
else if (actionCommand.equals("WorkFlow")) else if (actionCommand.equals("WorkFlow"))
{ {
@ -609,6 +632,21 @@ public final class AEnv
((AMenu)top).getWindowManager().add(frame); ((AMenu)top).getWindowManager().add(frame);
} }
} }
/**
* FR [ 1966328 ]
* get AMenu
* @param frame
*/
public static AMenu getAMenu(CFrame frame)
{
JFrame top = Env.getWindow(0);
if (top instanceof AMenu)
{
return (AMenu)top;
}
return null;
}
/** /**
* Exit System * Exit System
* @param status System exit status (usually 0 for no error) * @param status System exit status (usually 0 for no error)

View File

@ -79,7 +79,10 @@ import org.compiere.util.Splash;
* @author Jorg Janke * @author Jorg Janke
* @version $Id: AMenu.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ * @version $Id: AMenu.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
* *
* Colin Rooney (croo) RFE#1670185 restrict access to info queries * @author Colin Rooney (croo) RFE#1670185 restrict access to info queries
* @author victor.perez@e-evolution.com
* @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335
*
*/ */
public final class AMenu extends CFrame public final class AMenu extends CFrame
implements ActionListener, PropertyChangeListener, ChangeListener implements ActionListener, PropertyChangeListener, ChangeListener
@ -418,6 +421,15 @@ public final class AMenu extends CFrame
{ {
AEnv.addMenuItem("InfoSchedule", null, null, mView, this); AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
} }
//FR [ 1966328 ]
if (MRole.getDefault().isAllow_Info_MRP())
{
AEnv.addMenuItem("InfoMRP", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_CRP())
{
AEnv.addMenuItem("InfoCRP", "Info", null, mView, this);
}
mView.addSeparator(); mView.addSeparator();
if (MRole.getDefault().isAllow_Info_Order()) if (MRole.getDefault().isAllow_Info_Order())
{ {

View File

@ -54,6 +54,9 @@ import org.compiere.util.*;
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1824621 ] History button can't be canceled * <li>BF [ 1824621 ] History button can't be canceled
* <li>BF [ 1941271 ] VTreePanel is modifying even if is save wasn't successfull * <li>BF [ 1941271 ] VTreePanel is modifying even if is save wasn't successfull
* @author victor.perez@e-evolution.com
* @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335
*
*/ */
public final class APanel extends CPanel public final class APanel extends CPanel
implements DataStatusListener, ChangeListener, ActionListener, ASyncProcess implements DataStatusListener, ChangeListener, ActionListener, ASyncProcess
@ -282,6 +285,15 @@ public final class APanel extends CPanel
{ {
AEnv.addMenuItem("InfoSchedule", null, null, mView, this); AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
} }
//FR [ 1966328 ]
if (MRole.getDefault().isAllow_Info_MRP())
{
AEnv.addMenuItem("InfoMRP", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_CRP())
{
AEnv.addMenuItem("InfoCRP", "Info", null, mView, this);
}
mView.addSeparator(); mView.addSeparator();
if (MRole.getDefault().isAllow_Info_Order()) if (MRole.getDefault().isAllow_Info_Order())
{ {
@ -312,6 +324,8 @@ public final class APanel extends CPanel
AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); AEnv.addMenuItem("InfoAsset", "Info", null, mView, this);
} }
mView.addSeparator(); mView.addSeparator();
aAttachment = addAction("Attachment", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), true); // toggle aAttachment = addAction("Attachment", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), true); // toggle
aChat = addAction("Chat", mView, null, true); // toggle aChat = addAction("Chat", mView, null, true); // toggle

View File

@ -105,6 +105,10 @@ public final class AStart extends JApplet
return null; return null;
} }
public void setStandAlone(boolean ok)
{
isStandalone=ok;
}
/** /**
* Main method * Main method
*/ */

View File

@ -434,5 +434,12 @@ public class FormFrame extends CFrame
{ {
return p_AD_Form_ID; return p_AD_Form_ID;
} // getAD_Window_ID } // getAD_Window_ID
/**
* @return Returns the manuBar
*/
public JMenuBar getMenu()
{
return menuBar;
}
} // FormFrame } // FormFrame

View File

@ -135,6 +135,9 @@ public class VAllocation extends CPanel
private JLabel dateLabel = new JLabel(); private JLabel dateLabel = new JLabel();
private VDate dateField = new VDate(); private VDate dateField = new VDate();
private JCheckBox autoWriteOff = new JCheckBox(); private JCheckBox autoWriteOff = new JCheckBox();
private int m_AD_Org_ID = 0;
private JLabel organizationLabel = new JLabel();
private VLookup organizationPick = null;
private ArrayList<Integer> m_bpartnerCheck = new ArrayList<Integer>(); private ArrayList<Integer> m_bpartnerCheck = new ArrayList<Integer>();
@ -148,6 +151,7 @@ public class VAllocation extends CPanel
// //
mainPanel.setLayout(mainLayout); mainPanel.setLayout(mainLayout);
dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date")); dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date"));
dateLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "AllocDate", false));
autoWriteOff.setSelected(false); autoWriteOff.setSelected(false);
autoWriteOff.setText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", true)); autoWriteOff.setText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", true));
autoWriteOff.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", false)); autoWriteOff.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", false));
@ -182,6 +186,14 @@ public class VAllocation extends CPanel
invoiceScrollPane.setPreferredSize(new Dimension(200, 200)); invoiceScrollPane.setPreferredSize(new Dimension(200, 200));
paymentScrollPane.setPreferredSize(new Dimension(200, 200)); paymentScrollPane.setPreferredSize(new Dimension(200, 200));
mainPanel.add(parameterPanel, BorderLayout.NORTH); mainPanel.add(parameterPanel, BorderLayout.NORTH);
//org filter
organizationLabel.setText(Msg.translate(Env.getCtx(), "AD_Org_ID"));
parameterPanel.add(organizationLabel, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));
parameterPanel.add(organizationPick, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));
parameterPanel.add(bpartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 parameterPanel.add(bpartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
parameterPanel.add(bpartnerSearch, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 parameterPanel.add(bpartnerSearch, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
@ -251,6 +263,15 @@ public class VAllocation extends CPanel
currencyPick.setValue(new Integer(m_C_Currency_ID)); currencyPick.setValue(new Integer(m_C_Currency_ID));
currencyPick.addVetoableChangeListener(this); currencyPick.addVetoableChangeListener(this);
// Organization filter selection
AD_Column_ID = 839; //C_Period.AD_Org_ID (needed to allow org 0)
MLookup lookupOrg = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir);
organizationPick = new VLookup("AD_Org_ID", true, false, true, lookupOrg);
organizationPick.setValue(Env.getAD_Org_ID(Env.getCtx()));
organizationPick.addVetoableChangeListener(this);
m_AD_Org_ID = Env.getAD_Org_ID(Env.getCtx());
// BPartner // BPartner
AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
MLookup lookupBP = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); MLookup lookupBP = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
@ -301,26 +322,34 @@ public class VAllocation extends CPanel
Vector<Vector<Object>> data = new Vector<Vector<Object>>(); Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuffer sql = new StringBuffer("SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," // 1..3 StringBuffer sql = new StringBuffer("SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," // 1..3
+ "c.ISO_Code,p.PayAmt," // 4..5 + "c.ISO_Code,p.PayAmt," // 4..5
+ "currencyConvert(p.PayAmt,p.C_Currency_ID,?,p.DateTrx,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"// 6 #1 + "currencyConvert(p.PayAmt,p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"// 6 #1, #2
+ "currencyConvert(paymentAvailable(C_Payment_ID),p.C_Currency_ID,?,p.DateTrx,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," // 7 #2 + "currencyConvert(paymentAvailable(C_Payment_ID),p.C_Currency_ID,?,?,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," // 7 #3, #4
+ "p.MultiplierAP " + "p.MultiplierAP "
+ "FROM C_Payment_v p" // Corrected for AP/AR + "FROM C_Payment_v p" // Corrected for AP/AR
+ " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) " + " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) "
+ "WHERE p.IsAllocated='N' AND p.Processed='Y'" + "WHERE p.IsAllocated='N' AND p.Processed='Y'"
+ " AND p.C_Charge_ID IS NULL" // Prepayments OK + " AND p.C_Charge_ID IS NULL" // Prepayments OK
+ " AND p.C_BPartner_ID=?"); // #3 + " AND p.C_BPartner_ID=?"); // #5
if (!multiCurrency.isSelected()) if (!multiCurrency.isSelected())
sql.append(" AND p.C_Currency_ID=?"); // #4 sql.append(" AND p.C_Currency_ID=?"); // #6
if (m_AD_Org_ID != 0 )
sql.append(" AND p.AD_Org_ID=" + m_AD_Org_ID);
sql.append(" ORDER BY p.DateTrx,p.DocumentNo"); sql.append(" ORDER BY p.DateTrx,p.DocumentNo");
// role security
sql = new StringBuffer( MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "p", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO ) );
log.fine("PaySQL=" + sql.toString()); log.fine("PaySQL=" + sql.toString());
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_C_Currency_ID); pstmt.setInt(1, m_C_Currency_ID);
pstmt.setInt(2, m_C_Currency_ID); pstmt.setTimestamp(2, (Timestamp)dateField.getValue());
pstmt.setInt(3, m_C_BPartner_ID); pstmt.setInt(3, m_C_Currency_ID);
pstmt.setTimestamp(4, (Timestamp)dateField.getValue());
pstmt.setInt(5, m_C_BPartner_ID);
if (!multiCurrency.isSelected()) if (!multiCurrency.isSelected())
pstmt.setInt(4, m_C_Currency_ID); pstmt.setInt(6, m_C_Currency_ID);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -414,29 +443,37 @@ public class VAllocation extends CPanel
data = new Vector<Vector<Object>>(); data = new Vector<Vector<Object>>();
sql = new StringBuffer("SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID," // 1..3 sql = new StringBuffer("SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID," // 1..3
+ "c.ISO_Code,i.GrandTotal*i.MultiplierAP, " // 4..5 Orig Currency + "c.ISO_Code,i.GrandTotal*i.MultiplierAP, " // 4..5 Orig Currency
+ "currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID), " // 6 #1 Converted + "currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID), " // 6 #1 Converted, #2 Date
+ "currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP, " // 7 #2 Converted Open + "currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP, " // 7 #3, #4 Converted Open
+ "currencyConvert(invoiceDiscount" // 8 AllowedDiscount + "currencyConvert(invoiceDiscount" // 8 AllowedDiscount
+ "(i.C_Invoice_ID,?,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP," // #3, #4 + "(i.C_Invoice_ID,?,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP," // #5, #6
+ "i.MultiplierAP " + "i.MultiplierAP "
+ "FROM C_Invoice_v i" // corrected for CM/Split + "FROM C_Invoice_v i" // corrected for CM/Split
+ " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) " + " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) "
+ "WHERE i.IsPaid='N' AND i.Processed='Y'" + "WHERE i.IsPaid='N' AND i.Processed='Y'"
+ " AND i.C_BPartner_ID=?"); // #5 + " AND i.C_BPartner_ID=?"); // #7
if (!multiCurrency.isSelected()) if (!multiCurrency.isSelected())
sql.append(" AND i.C_Currency_ID=?"); // #6 sql.append(" AND i.C_Currency_ID=?"); // #8
if (m_AD_Org_ID != 0 )
sql.append(" AND i.AD_Org_ID=" + m_AD_Org_ID);
sql.append(" ORDER BY i.DateInvoiced, i.DocumentNo"); sql.append(" ORDER BY i.DateInvoiced, i.DocumentNo");
log.fine("InvSQL=" + sql.toString()); log.fine("InvSQL=" + sql.toString());
// role security
sql = new StringBuffer( MRole.getDefault(Env.getCtx(), false).addAccessSQL( sql.toString(), "i", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO ) );
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_C_Currency_ID); pstmt.setInt(1, m_C_Currency_ID);
pstmt.setInt(2, m_C_Currency_ID); pstmt.setTimestamp(2, (Timestamp)dateField.getValue());
pstmt.setTimestamp(3, (Timestamp)dateField.getValue()); pstmt.setInt(3, m_C_Currency_ID);
pstmt.setInt(4, m_C_Currency_ID); pstmt.setTimestamp(4, (Timestamp)dateField.getValue());
pstmt.setInt(5, m_C_BPartner_ID); pstmt.setTimestamp(5, (Timestamp)dateField.getValue());
if (!multiCurrency.isSelected())
pstmt.setInt(6, m_C_Currency_ID); pstmt.setInt(6, m_C_Currency_ID);
pstmt.setInt(7, m_C_BPartner_ID);
if (!multiCurrency.isSelected())
pstmt.setInt(8, m_C_Currency_ID);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -865,6 +902,7 @@ public class VAllocation extends CPanel
if (((Boolean)payment.getValueAt(i, 0)).booleanValue()) if (((Boolean)payment.getValueAt(i, 0)).booleanValue())
{ {
Timestamp ts = (Timestamp)payment.getValueAt(i, 1); Timestamp ts = (Timestamp)payment.getValueAt(i, 1);
if ( !multiCurrency.isSelected() ) // the converted amounts are only valid for the selected date
allocDate = TimeUtil.max(allocDate, ts); allocDate = TimeUtil.max(allocDate, ts);
BigDecimal bd = (BigDecimal)payment.getValueAt(i, i_payment); BigDecimal bd = (BigDecimal)payment.getValueAt(i, i_payment);
totalPay = totalPay.add(bd); // Applied Pay totalPay = totalPay.add(bd); // Applied Pay
@ -886,6 +924,7 @@ public class VAllocation extends CPanel
if (((Boolean)invoice.getValueAt(i, 0)).booleanValue()) if (((Boolean)invoice.getValueAt(i, 0)).booleanValue())
{ {
Timestamp ts = (Timestamp)invoice.getValueAt(i, 1); Timestamp ts = (Timestamp)invoice.getValueAt(i, 1);
if ( !multiCurrency.isSelected() ) // converted amounts only valid for selected date
allocDate = TimeUtil.max(allocDate, ts); allocDate = TimeUtil.max(allocDate, ts);
BigDecimal bd = (BigDecimal)invoice.getValueAt(i, i_applied); BigDecimal bd = (BigDecimal)invoice.getValueAt(i, i_applied);
totalInv = totalInv.add(bd); // Applied Inv totalInv = totalInv.add(bd); // Applied Inv
@ -924,6 +963,18 @@ public class VAllocation extends CPanel
String name = e.getPropertyName(); String name = e.getPropertyName();
Object value = e.getNewValue(); Object value = e.getNewValue();
log.config(name + "=" + value); log.config(name + "=" + value);
// Organization
if (name.equals("AD_Org_ID"))
{
if (value == null)
m_AD_Org_ID = 0;
else
m_AD_Org_ID = ((Integer) value).intValue();
loadBPartner();
}
if (value == null) if (value == null)
return; return;

View File

@ -762,6 +762,7 @@ public class GridController extends CPanel
int rowTable = vTable.getSelectedRow(); int rowTable = vTable.getSelectedRow();
int rowCurrent = m_mTab.getCurrentRow(); int rowCurrent = m_mTab.getCurrentRow();
log.config("(" + m_mTab.toString() + ") Row in Table=" + rowTable + ", in Model=" + rowCurrent); log.config("(" + m_mTab.toString() + ") Row in Table=" + rowTable + ", in Model=" + rowCurrent);
/* BT [ 1972495 ] Multirow Automatic New Record loses context
// FR [ 1757088 ] // FR [ 1757088 ]
if(rowCurrent + 1 == vTable.getRowCount() && !isSingleRow() && Env.isAutoNew(Env.getCtx()) && m_mTab.getRecord_ID() != -1) if(rowCurrent + 1 == vTable.getRowCount() && !isSingleRow() && Env.isAutoNew(Env.getCtx()) && m_mTab.getRecord_ID() != -1)
{ {
@ -771,7 +772,7 @@ public class GridController extends CPanel
dynamicDisplay(0); dynamicDisplay(0);
vTable.getSelectionModel().addListSelectionListener(this); vTable.getSelectionModel().addListSelectionListener(this);
return; return;
} } */
if (rowTable == -1) // nothing selected if (rowTable == -1) // nothing selected
{ {
if (rowCurrent >= 0) if (rowCurrent >= 0)

View File

@ -26,7 +26,7 @@ import org.compiere.model.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.adempiere.interfaces.*; import com.akunagroup.uk.postcode.*;
import org.adempiere.model.*; import org.adempiere.model.*;
/** /**
@ -37,6 +37,8 @@ import org.adempiere.model.*;
* *
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements * <li>BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements
* @author Michael Judd, Akuna Ltd (UK)
* <li>FR [ 1741222 ] - Webservice connector for address lookups
*/ */
public class VLocationDialog extends CDialog public class VLocationDialog extends CDialog
implements ActionListener implements ActionListener
@ -121,7 +123,7 @@ public class VLocationDialog extends CDialog
private CLabel lRegion = new CLabel(Msg.getMsg(Env.getCtx(), "Region")); private CLabel lRegion = new CLabel(Msg.getMsg(Env.getCtx(), "Region"));
private CLabel lPostal = new CLabel(Msg.getMsg(Env.getCtx(), "Postal")); private CLabel lPostal = new CLabel(Msg.getMsg(Env.getCtx(), "Postal"));
private CLabel lPostalAdd = new CLabel(Msg.getMsg(Env.getCtx(), "PostalAdd")); private CLabel lPostalAdd = new CLabel(Msg.getMsg(Env.getCtx(), "PostalAdd"));
private CLabel lOnline = new CLabel(""); // dummy to use addLine without error.... private CLabel lOnline = new CLabel("");
private CTextField fAddress1 = new CTextField(20); // length=60 private CTextField fAddress1 = new CTextField(20); // length=60
private CTextField fAddress2 = new CTextField(20); // length=60 private CTextField fAddress2 = new CTextField(20); // length=60
private CTextField fAddress3 = new CTextField(20); // length=60 private CTextField fAddress3 = new CTextField(20); // length=60
@ -214,6 +216,7 @@ public class VLocationDialog extends CDialog
addLine(line++, lOnline, fOnline); addLine(line++, lOnline, fOnline);
fOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
// Country Last // Country Last
addLine(line++, lCountry, fCountry); addLine(line++, lCountry, fCountry);
@ -228,7 +231,6 @@ public class VLocationDialog extends CDialog
fCity.setText(m_location.getCity()); fCity.setText(m_location.getCity());
fPostal.setText(m_location.getPostal()); fPostal.setText(m_location.getPostal());
fPostalAdd.setText(m_location.getPostal_Add()); fPostalAdd.setText(m_location.getPostal_Add());
fOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
if (m_location.getCountry().isHasRegion()) if (m_location.getCountry().isHasRegion())
{ {
lRegion.setText(m_location.getCountry().getRegionName()); lRegion.setText(m_location.getCountry().getRegionName());
@ -395,9 +397,9 @@ public class VLocationDialog extends CDialog
private String lookupPostcode(MCountry country, String postcode) private String lookupPostcode(MCountry country, String postcode)
{ {
// Initialise the lookup class. // Initialise the lookup class.
PostcodeLookupInterface pcLookup = null; AddressLookupInterface pcLookup = null;
try { try {
PostcodeLookupInterface pcLookupTmp = (PostcodeLookupInterface) Class AddressLookupInterface pcLookupTmp = (AddressLookupInterface) Class
.forName(country.getLookupClassName()).newInstance(); .forName(country.getLookupClassName()).newInstance();
pcLookup = pcLookupTmp.newInstance(); pcLookup = pcLookupTmp.newInstance();
} catch (Exception e) { } catch (Exception e) {
@ -415,7 +417,7 @@ public class VLocationDialog extends CDialog
pcLookup.setPassword(country.getLookupPassword()); pcLookup.setPassword(country.getLookupPassword());
if (pcLookup.lookupPostcode(postcode)==1){ if (pcLookup.lookupPostcode(postcode)==1){
// Success // Success
fillLocation(pcLookup.getPostCodeData(), country); fillLocation(pcLookup.getAddressData(), country);
fAddress1.requestFocusInWindow(); fAddress1.requestFocusInWindow();
} else } else
return "Postcode Lookup Error"; return "Postcode Lookup Error";
@ -476,6 +478,9 @@ public class VLocationDialog extends CDialog
// Overwrite the values in location field. // Overwrite the values in location field.
fAddress1.setText(values.getStreet1()); fAddress1.setText(values.getStreet1());
fAddress2.setText(values.getStreet2());
fAddress3.setText(values.getStreet3());
fAddress4.setText(values.getStreet4());
fCity.setText(values.getCity()); fCity.setText(values.getCity());
fPostal.setText(values.getPostcode()); fPostal.setText(values.getPostcode());
@ -495,7 +500,7 @@ public class VLocationDialog extends CDialog
if (regions[i].getName().equals(values.getRegion()) ) if (regions[i].getName().equals(values.getRegion()) )
{ {
// found county // found Region
fRegion.setSelectedItem(regions[i]); fRegion.setSelectedItem(regions[i]);
log.fine("Found region: " + regions[i].getName()); log.fine("Found region: " + regions[i].getName());
found = true; found = true;
@ -508,6 +513,11 @@ public class VLocationDialog extends CDialog
if (region.save()) if (region.save())
{ {
log.fine("Added new region from web service: " + values.getRegion()); log.fine("Added new region from web service: " + values.getRegion());
// clears cache
Env.reset(false);
//reload regions to combo box
fRegion = new CComboBox(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID()));
// select region
fRegion.setSelectedItem(values); fRegion.setSelectedItem(values);
} else } else
log.severe("Error saving new region: " + region.getName()); log.severe("Error saving new region: " + region.getName());

View File

@ -29,6 +29,8 @@ import org.compiere.model.*;
import org.compiere.swing.*; import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.eevolution.model.*;
/** /**
* Lookup Visual Field. * Lookup Visual Field.
* <p> * <p>
@ -766,7 +768,8 @@ public class VLookup extends JComponent
int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_PriceList_ID");
int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), m_mField.getAD_Column_ID(), null); int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), m_mField.getAD_Column_ID(), null);
multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID);
multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID) || (MPPProductBOMLine.Table_ID == AD_Table_ID) || (MProductPrice.Table_ID == AD_Table_ID);
// Show Info // Show Info
InfoProduct ip = new InfoProduct (frame, true, m_lookup.getWindowNo(), InfoProduct ip = new InfoProduct (frame, true, m_lookup.getWindowNo(),

View File

@ -47,6 +47,9 @@ import org.adempiere.pdf.*;
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>FR [ 1762466 ] Add "Window" menu to report viewer. * <li>FR [ 1762466 ] Add "Window" menu to report viewer.
* <li>FR [ 1894640 ] Report Engine: Excel Export support * <li>FR [ 1894640 ] Report Engine: Excel Export support
* @author victor.perez@e-evolution.com
* @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335
*
*/ */
public class Viewer extends CFrame public class Viewer extends CFrame
implements ActionListener, ChangeListener, WindowStateListener implements ActionListener, ChangeListener, WindowStateListener
@ -412,6 +415,15 @@ public class Viewer extends CFrame
{ {
AEnv.addMenuItem("InfoSchedule", null, null, mView, this); AEnv.addMenuItem("InfoSchedule", null, null, mView, this);
} }
//FR [ 1966328 ]
if (MRole.getDefault().isAllow_Info_MRP())
{
AEnv.addMenuItem("InfoMRP", "Info", null, mView, this);
}
if (MRole.getDefault().isAllow_Info_CRP())
{
AEnv.addMenuItem("InfoCRP", "Info", null, mView, this);
}
mView.addSeparator(); mView.addSeparator();
if (MRole.getDefault().isAllow_Info_Order()) if (MRole.getDefault().isAllow_Info_Order())
{ {
@ -441,6 +453,8 @@ public class Viewer extends CFrame
{ {
AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); AEnv.addMenuItem("InfoAsset", "Info", null, mView, this);
} }
// Go // Go
JMenu mGo = AEnv.getMenu("Go"); JMenu mGo = AEnv.getMenu("Go");
menuBar.add(mGo); menuBar.add(mGo);

View File

@ -49,9 +49,11 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.
'en_US' AS AD_Language, 'en_US' AS AD_Language,
il.C_Invoice_ID, il.C_InvoiceLine_ID, il.C_Invoice_ID, il.C_InvoiceLine_ID,
il.C_Tax_ID, il.TaxAmt, il.LineTotalAmt, t.TaxIndicator, il.C_Tax_ID, il.TaxAmt, il.LineTotalAmt, t.TaxIndicator,
il.Line+(b.Line/100) AS Line, p.M_Product_ID, il.Line+(bl.Line/100) AS Line, p.M_Product_ID,
il.QtyInvoiced*b.BOMQty AS QtyInvoiced, --il.QtyInvoiced*b.BOMQty AS QtyInvoiced,
il.QtyEntered*b.BOMQty AS QtyEntered, CASE WHEN bl.IsQtyPercentage = 'N' THEN il.QtyInvoiced*bl.QtyBOM ELSE il.QtyInvoiced*(bl.QtyBatch / 100) END AS QtyInvoiced,
--il.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN il.QtyEntered*bl.QtyBOM ELSE il.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol, uom.UOMSymbol,
p.Name, -- main p.Name, -- main
b.Description, b.Description,
@ -60,13 +62,22 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.
il.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate, il.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description as ProductDescription, p.ImageURL, p.Description as ProductDescription, p.ImageURL,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID) INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID) LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
UNION -- comment lines UNION -- comment lines
SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy, SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy,

View File

@ -49,9 +49,11 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.
uom.AD_Language, uom.AD_Language,
il.C_Invoice_ID, il.C_InvoiceLine_ID, il.C_Invoice_ID, il.C_InvoiceLine_ID,
il.C_Tax_ID, il.TaxAmt, il.LineTotalAmt, t.TaxIndicator, il.C_Tax_ID, il.TaxAmt, il.LineTotalAmt, t.TaxIndicator,
il.Line+(b.Line/100) AS Line, p.M_Product_ID, il.Line+(bl.Line/100) AS Line, p.M_Product_ID,
il.QtyInvoiced*b.BOMQty AS QtyInvoiced, --il.QtyInvoiced*b.BOMQty AS QtyInvoiced,
il.QtyEntered*b.BOMQty AS QtyEntered, CASE WHEN bl.IsQtyPercentage = 'N' THEN il.QtyInvoiced*bl.QtyBOM ELSE il.QtyInvoiced*(bl.QtyBatch / 100) END AS QtyInvoiced,
--il.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN il.QtyEntered*bl.QtyBOM ELSE il.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol, uom.UOMSymbol,
COALESCE(pt.Name,p.Name) AS Name, -- main COALESCE(pt.Name,p.Name) AS Name, -- main
b.Description, b.Description,
@ -60,7 +62,7 @@ SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.
il.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate, il.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description as ProductDescription, p.ImageURL, pt.Description as ProductDescription, p.ImageURL,
il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID il.C_Campaign_ID, il.C_Project_ID, il.C_Activity_ID, il.C_ProjectPhase_ID, il.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID) INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
@ -68,6 +70,16 @@ FROM M_Product_BOM b -- BOM lines
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (b.M_ProductBOM_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language) INNER JOIN M_Product_Trl pt ON (b.M_ProductBOM_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID) LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN C_InvoiceLine il ON (b.M_Product_ID=il.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=il.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (bl.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN C_Tax t ON (il.C_Tax_ID=t.C_Tax_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) LEFT OUTER JOIN M_AttributeSetInstance asi ON (il.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
UNION -- comment line UNION -- comment line
SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy, SELECT il.AD_Client_ID, il.AD_Org_ID, il.IsActive, il.Created, il.CreatedBy, il.Updated, il.UpdatedBy,

View File

@ -2,7 +2,7 @@ CREATE OR REPLACE VIEW C_ORDER_LINETAX_V
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, (AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_ORDER_ID, C_ORDERLINE_ID, UPDATED, UPDATEDBY, AD_LANGUAGE, C_ORDER_ID, C_ORDERLINE_ID,
C_TAX_ID, TAXINDICATOR, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, BPNAME, C_TAX_ID, TAXINDICATOR, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, BPNAME,
C_LOCATION_ID, LINE, M_PRODUCT_ID, QTYORDERED, QTYENTERED, C_LOCATION_ID, LINE, M_PRODUCT_ID,VendorProductNo, QTYORDERED, QTYENTERED,
UOMSYMBOL, NAME, DESCRIPTION, DOCUMENTNOTE, UPC, UOMSYMBOL, NAME, DESCRIPTION, DOCUMENTNOTE, UPC,
SKU, PRODUCTVALUE, RESOURCEDESCRIPTION, PRICELIST, PRICEENTEREDLIST, SKU, PRODUCTVALUE, RESOURCEDESCRIPTION, PRICELIST, PRICEENTEREDLIST,
DISCOUNT, PRICEACTUAL, PRICEENTERED, LINENETAMT, PRODUCTDESCRIPTION, DISCOUNT, PRICEACTUAL, PRICEENTERED, LINENETAMT, PRODUCTDESCRIPTION,
@ -13,7 +13,7 @@ SELECT ol.AD_Client_ID, ol.AD_Org_ID, ol.IsActive, ol.Created, ol.CreatedBy, ol.
'en_US' AS AD_Language, 'en_US' AS AD_Language,
ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, t.TaxIndicator, ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, t.TaxIndicator,
ol.C_BPartner_ID, ol.C_BPartner_Location_ID, bp.Name AS BPName, bpl.C_Location_ID, ol.C_BPartner_ID, ol.C_BPartner_Location_ID, bp.Name AS BPName, bpl.C_Location_ID,
ol.Line, p.M_Product_ID, ol.Line, p.M_Product_ID, po.VendorProductNo,
CASE WHEN ol.QtyOrdered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered END AS QtyOrdered, CASE WHEN ol.QtyOrdered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered END AS QtyOrdered,
CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyEntered END AS QtyEntered, CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyEntered END AS QtyEntered,
CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol, CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
@ -37,6 +37,7 @@ FROM C_OrderLine ol
INNER JOIN C_UOM uom ON (ol.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM uom ON (ol.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN C_Order i ON (ol.C_Order_ID=i.C_Order_ID) INNER JOIN C_Order i ON (ol.C_Order_ID=i.C_Order_ID)
LEFT OUTER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID) LEFT OUTER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_Product_PO po ON (p.M_Product_ID=po.M_Product_ID)
LEFT OUTER JOIN S_ResourceAssignment ra ON (ol.S_ResourceAssignment_ID=ra.S_ResourceAssignment_ID) LEFT OUTER JOIN S_ResourceAssignment ra ON (ol.S_ResourceAssignment_ID=ra.S_ResourceAssignment_ID)
LEFT OUTER JOIN C_Charge c ON (ol.C_Charge_ID=c.C_Charge_ID) LEFT OUTER JOIN C_Charge c ON (ol.C_Charge_ID=c.C_Charge_ID)
LEFT OUTER JOIN C_BPartner_Product pp ON (ol.M_Product_ID=pp.M_Product_ID AND i.C_BPartner_ID=pp.C_BPartner_ID) LEFT OUTER JOIN C_BPartner_Product pp ON (ol.M_Product_ID=pp.M_Product_ID AND i.C_BPartner_ID=pp.C_BPartner_ID)
@ -48,18 +49,30 @@ SELECT ol.AD_Client_ID, ol.AD_Org_ID, ol.IsActive, ol.Created, ol.CreatedBy, ol.
'en_US' AS AD_Language, 'en_US' AS AD_Language,
ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, null, ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, null,
null, null, null, null, null, null, null, null,
ol.Line+(b.Line/100) AS Line, p.M_Product_ID, ol.Line+(bl.Line/100) AS Line, p.M_Product_ID,po.VendorProductNo,
ol.QtyOrdered*b.BOMQty AS QtyInvoiced, ol.QtyEntered*b.BOMQty AS QtyEntered, uom.UOMSymbol, --ol.QtyOrdered*bl.BOMQty AS QtyInvoiced
CASE WHEN bl.IsQtyPercentage = 'N' THEN ol.QtyOrdered*bl.QtyBOM ELSE ol.QtyOrdered*(bl.QtyBatch / 100) END AS QtyInvoiced,
--ol.QtyEntered*bl.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN ol.QtyEntered*bl.QtyBOM ELSE ol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
p.Name, -- main p.Name, -- main
b.Description, bl.Description,
p.DocumentNote, p.UPC, p.SKU, p.Value AS ProductValue, p.DocumentNote, p.UPC, p.SKU, p.Value AS ProductValue,
null, null, null, null, null, null, null, p.Description as ProductDescription, p.ImageURL, null, null, null, null, null, null, null, p.Description as ProductDescription, p.ImageURL,
ol.C_Campaign_ID, ol.C_Project_ID, ol.C_Activity_ID, ol.C_ProjectPhase_ID, ol.C_ProjectTask_ID ol.C_Campaign_ID, ol.C_Project_ID, ol.C_Activity_ID, ol.C_ProjectPhase_ID, ol.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID) INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)*/
FROM PP_Product_BOM b
INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (p.M_Product_ID=bl.M_Product_ID) -- BOM line product
LEFT OUTER JOIN M_Product_PO po ON (p.M_Product_ID=po.M_Product_ID)
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
UNION UNION
SELECT AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy, SELECT AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,
@ -67,7 +80,7 @@ SELECT AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy
null, null,
null, null, null, null, null, null,
null, null, null, null, null, null, null, null,
null, null, null, null,null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null,null,null,null,null null,null,null,null,null
@ -76,7 +89,7 @@ UNION
SELECT ot.AD_Client_ID, ot.AD_Org_ID, ot.IsActive, ot.Created, ot.CreatedBy, ot.Updated, ot.UpdatedBy, SELECT ot.AD_Client_ID, ot.AD_Org_ID, ot.IsActive, ot.Created, ot.CreatedBy, ot.Updated, ot.UpdatedBy,
'en_US', ot.C_Order_ID, null, ot.C_Tax_ID, t.TaxIndicator, 'en_US', ot.C_Order_ID, null, ot.C_Tax_ID, t.TaxIndicator,
null, null, null, null, null, null, null, null,
null, null, null, null,null,
null, null, null, null, null, null,
t.Name, t.Name,
null, null, null, null, null, null, null, null, null, null, null, null,

View File

@ -2,7 +2,7 @@ CREATE OR REPLACE VIEW C_ORDER_LINETAX_VT
(AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, (AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY,
UPDATED, UPDATEDBY, AD_LANGUAGE, C_ORDER_ID, C_ORDERLINE_ID, UPDATED, UPDATEDBY, AD_LANGUAGE, C_ORDER_ID, C_ORDERLINE_ID,
C_TAX_ID, TAXINDICATOR, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, BPNAME, C_TAX_ID, TAXINDICATOR, C_BPARTNER_ID, C_BPARTNER_LOCATION_ID, BPNAME,
C_LOCATION_ID, LINE, M_PRODUCT_ID, QTYORDERED, QTYENTERED, C_LOCATION_ID, LINE, M_PRODUCT_ID,VendorProductNo, QTYORDERED, QTYENTERED,
UOMSYMBOL, NAME, DESCRIPTION, DOCUMENTNOTE, UPC, UOMSYMBOL, NAME, DESCRIPTION, DOCUMENTNOTE, UPC,
SKU, PRODUCTVALUE, RESOURCEDESCRIPTION, PRICELIST, PRICEENTEREDLIST, SKU, PRODUCTVALUE, RESOURCEDESCRIPTION, PRICELIST, PRICEENTEREDLIST,
DISCOUNT, PRICEACTUAL, PRICEENTERED, LINENETAMT, PRODUCTDESCRIPTION, DISCOUNT, PRICEACTUAL, PRICEENTERED, LINENETAMT, PRODUCTDESCRIPTION,
@ -13,7 +13,7 @@ SELECT ol.AD_Client_ID, ol.AD_Org_ID, ol.IsActive, ol.Created, ol.CreatedBy, ol.
uom.AD_Language, uom.AD_Language,
ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, t.TaxIndicator, ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, t.TaxIndicator,
ol.C_BPartner_ID, ol.C_BPartner_Location_ID, bp.Name AS BPName, bpl.C_Location_ID, ol.C_BPartner_ID, ol.C_BPartner_Location_ID, bp.Name AS BPName, bpl.C_Location_ID,
ol.Line, p.M_Product_ID, ol.Line, p.M_Product_ID,po.VendorProductNo,
CASE WHEN ol.QtyOrdered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered END AS QtyOrdered, CASE WHEN ol.QtyOrdered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyOrdered END AS QtyOrdered,
CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyEntered END AS QtyEntered, CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN ol.QtyEntered END AS QtyEntered,
CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol, CASE WHEN ol.QtyEntered<>0 OR ol.M_Product_ID IS NOT NULL THEN uom.UOMSymbol END AS UOMSymbol,
@ -37,6 +37,7 @@ FROM C_OrderLine ol
INNER JOIN C_UOM_Trl uom ON (ol.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM_Trl uom ON (ol.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN C_Order i ON (ol.C_Order_ID=i.C_Order_ID) INNER JOIN C_Order i ON (ol.C_Order_ID=i.C_Order_ID)
LEFT OUTER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID) LEFT OUTER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID)
LEFT OUTER JOIN M_Product_PO po ON (p.M_Product_ID=po.M_Product_ID)
LEFT OUTER JOIN M_Product_Trl pt ON (ol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language) LEFT OUTER JOIN M_Product_Trl pt ON (ol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN S_ResourceAssignment ra ON (ol.S_ResourceAssignment_ID=ra.S_ResourceAssignment_ID) LEFT OUTER JOIN S_ResourceAssignment ra ON (ol.S_ResourceAssignment_ID=ra.S_ResourceAssignment_ID)
LEFT OUTER JOIN C_Charge c ON (ol.C_Charge_ID=c.C_Charge_ID) LEFT OUTER JOIN C_Charge c ON (ol.C_Charge_ID=c.C_Charge_ID)
@ -49,27 +50,40 @@ SELECT ol.AD_Client_ID, ol.AD_Org_ID, ol.IsActive, ol.Created, ol.CreatedBy, ol.
uom.AD_Language, uom.AD_Language,
ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, null, ol.C_Order_ID, ol.C_OrderLine_ID, ol.C_Tax_ID, null,
null, null, null, null, null, null, null, null,
ol.Line+(b.Line/100) AS Line, p.M_Product_ID, ol.Line+(bl.Line/100) AS Line, p.M_Product_ID,po.VendorProductNo,
ol.QtyOrdered*b.BOMQty AS QtyInvoiced, ol.QtyEntered*b.BOMQty AS QtyEntered, uom.UOMSymbol, --ol.QtyOrdered*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN ol.QtyOrdered*bl.QtyBOM ELSE ol.QtyOrdered*(bl.QtyBatch / 100) END AS QtyInvoiced,
--ol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN ol.QtyEntered*bl.QtyBOM ELSE ol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
COALESCE(pt.Name, p.Name) AS Name, -- main COALESCE(pt.Name, p.Name) AS Name, -- main
b.Description, b.Description,
COALESCE(pt.DocumentNote, p.DocumentNote) AS DocumentNote, p.UPC, p.SKU, p.Value AS ProductValue, COALESCE(pt.DocumentNote, p.DocumentNote) AS DocumentNote, p.UPC, p.SKU, p.Value AS ProductValue,
null, null, null, null, null, null, null, pt.Description AS ProductDescription, p.ImageURL, null, null, null, null, null, null, null, pt.Description AS ProductDescription, p.ImageURL,
ol.C_Campaign_ID, ol.C_Project_ID, ol.C_Activity_ID, ol.C_ProjectPhase_ID, ol.C_ProjectTask_ID ol.C_Campaign_ID, ol.C_Project_ID, ol.C_Activity_ID, ol.C_ProjectPhase_ID, ol.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID) INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product INNER JOIN M_Product p ON (b.M_ProductBOM_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (b.M_ProductBOM_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language) INNER JOIN M_Product_Trl pt ON (b.M_ProductBOM_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)*/
FROM PP_Product_BOM b
INNER JOIN C_OrderLine ol ON (b.M_Product_ID=ol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=ol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsInvoicePrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (p.M_Product_ID=bl.M_Product_ID) -- BOM line product
LEFT OUTER JOIN M_Product_PO po ON (p.M_Product_ID=po.M_Product_ID)
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (pt.M_Product_ID=bl.M_Product_ID AND uom.AD_Language=pt.AD_Language)
UNION UNION
SELECT o.AD_Client_ID, o.AD_Org_ID, o.IsActive, o.Created, o.CreatedBy, o.Updated, o.UpdatedBy, SELECT o.AD_Client_ID, o.AD_Org_ID, o.IsActive, o.Created, o.CreatedBy, o.Updated, o.UpdatedBy,
l.AD_Language, o.C_Order_ID, null, null, null, l.AD_Language, o.C_Order_ID, null, null, null,
null, null,
null, null, null, null, null, null,
null, null, null, null, null, null, null, null,
null, null, null, null,null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null,null,null,null,null null,null,null,null,null
@ -79,7 +93,7 @@ UNION
SELECT ot.AD_Client_ID, ot.AD_Org_ID, ot.IsActive, ot.Created, ot.CreatedBy, ot.Updated, ot.UpdatedBy, SELECT ot.AD_Client_ID, ot.AD_Org_ID, ot.IsActive, ot.Created, ot.CreatedBy, ot.Updated, ot.UpdatedBy,
t.AD_Language, ot.C_Order_ID, null, ot.C_Tax_ID, t.TaxIndicator, t.AD_Language, ot.C_Order_ID, null, ot.C_Tax_ID, t.TaxIndicator,
null, null, null, null, null, null, null, null,
null, null, null, null,null,
null, null, null, null, null, null,
t.Name, t.Name,
null, null, null, null, null, null, null, null, null, null, null, null,

View File

@ -37,8 +37,12 @@ UNION -- BOM lines
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy, SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
'en_US' AS AD_Language, 'en_US' AS AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID, iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(b.Line/100) AS Line, p.M_Product_ID, iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
iol.MovementQty*b.BOMQty AS QtyInvoiced, iol.QtyEntered*b.BOMQty AS QtyEntered, uom.UOMSymbol, --iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
null, null, null, null, null, null,
p.Name, -- main line p.Name, -- main line
b.Description, -- second line b.Description, -- second line
@ -48,7 +52,7 @@ SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate, iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
p.Description AS ProductDescription, p.ImageURL, p.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID) INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
@ -56,6 +60,16 @@ FROM M_Product_BOM b -- BOM lines
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID); LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);
*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM uom ON (p.C_UOM_ID=uom.C_UOM_ID)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);

View File

@ -38,8 +38,12 @@ UNION
SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy, SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy, iol.Updated, iol.UpdatedBy,
uom.AD_Language, uom.AD_Language,
iol.M_InOut_ID, iol.M_InOutLine_ID, iol.M_InOut_ID, iol.M_InOutLine_ID,
iol.Line+(b.Line/100) AS Line, p.M_Product_ID, iol.Line+(bl.Line/100) AS Line, p.M_Product_ID,
iol.MovementQty*b.BOMQty AS QtyInvoiced, iol.QtyEntered*b.BOMQty AS QtyEntered, uom.UOMSymbol, --iol.MovementQty*b.BOMQty AS QtyInvoiced,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.MovementQty*bl.QtyBOM ELSE iol.MovementQty*(bl.QtyBatch / 100) END AS QtyInvoiced,
--iol.QtyEntered*b.BOMQty AS QtyEntered,
CASE WHEN bl.IsQtyPercentage = 'N' THEN iol.QtyEntered*bl.QtyBOM ELSE iol.QtyEntered*(bl.QtyBatch / 100) END AS QtyEntered,
uom.UOMSymbol,
null, null, null, null, null, null,
COALESCE (pt.Name, p.Name) AS Name, -- main line COALESCE (pt.Name, p.Name) AS Name, -- main line
b.Description, -- second line b.Description, -- second line
@ -49,7 +53,7 @@ SELECT iol.AD_Client_ID, iol.AD_Org_ID, iol.IsActive, iol.Created, iol.CreatedBy
iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate, iol.M_AttributeSetInstance_ID, asi.M_AttributeSet_ID, asi.SerNo, asi.Lot, asi.M_Lot_ID,asi.GuaranteeDate,
pt.Description AS ProductDescription, p.ImageURL, pt.Description AS ProductDescription, p.ImageURL,
iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID iol.C_Campaign_ID, iol.C_Project_ID, iol.C_Activity_ID, iol.C_ProjectPhase_ID, iol.C_ProjectTask_ID
FROM M_Product_BOM b -- BOM lines /*FROM M_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID) INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y') AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
@ -57,6 +61,16 @@ FROM M_Product_BOM b -- BOM lines
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID) INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language) INNER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);*/
FROM PP_Product_BOM b -- BOM lines
INNER JOIN M_InOutLine iol ON (b.M_Product_ID=iol.M_Product_ID)
INNER JOIN M_Product bp ON (bp.M_Product_ID=iol.M_Product_ID -- BOM Product
AND bp.IsBOM='Y' AND bp.IsVerified='Y' AND bp.IsPickListPrintDetails='Y')
INNER JOIN PP_Product_BOMLine bl ON (bl.PP_Product_BOM_ID=b.PP_Product_BOM_ID)
INNER JOIN M_Product p ON (bl.M_Product_ID=p.M_Product_ID) -- BOM line product
INNER JOIN C_UOM_Trl uom ON (p.C_UOM_ID=uom.C_UOM_ID)
INNER JOIN M_Product_Trl pt ON (iol.M_Product_ID=pt.M_Product_ID AND uom.AD_Language=pt.AD_Language)
LEFT OUTER JOIN M_AttributeSetInstance asi ON (iol.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)
LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID); LEFT OUTER JOIN M_Locator l ON (iol.M_Locator_ID=l.M_Locator_ID);

View File

@ -6,10 +6,11 @@ AS
SELECT t.AD_Client_ID,t.AD_Org_ID, t.MovementDate, t.MovementQty, SELECT t.AD_Client_ID,t.AD_Org_ID, t.MovementDate, t.MovementQty,
t.M_Product_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID, t.M_Product_ID, t.M_Locator_ID, t.M_AttributeSetInstance_ID,
p.M_Product_Category_ID, p.Value, p.M_Product_Category_ID, p.Value,
po.C_BPartner_ID, po.PricePO, po.PriceLastPO, po.PriceList --po.C_BPartner_ID, po.PricePO, po.PriceLastPO, po.PriceList
FROM M_Transaction t FROM M_Transaction t
INNER JOIN M_Product p ON (t.M_Product_ID=p.M_Product_ID) INNER JOIN M_Product p ON (t.M_Product_ID=p.M_Product_ID)
INNER JOIN M_Product_PO po ON (t.M_Product_ID=po.M_Product_ID) --INNER JOIN M_Product_PO po ON (t.M_Product_ID=po.M_Product_ID)
LEFT JOIN M_CostDetail cd (M_)
WHERE po.IsCurrentVendor='Y'; WHERE po.IsCurrentVendor='Y';

View File

@ -2,7 +2,8 @@ CREATE OR REPLACE VIEW RV_OPENITEM
(AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID, (AD_ORG_ID, AD_CLIENT_ID, DOCUMENTNO, C_INVOICE_ID, C_ORDER_ID,
C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS, C_BPARTNER_ID, ISSOTRX, DATEINVOICED, DATEACCT, NETDAYS,
DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL, DUEDATE, DAYSDUE, DISCOUNTDATE, DISCOUNTAMT, GRANDTOTAL,
PAIDAMT, OPENAMT, C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID, PAIDAMT, OPENAMT,
C_CURRENCY_ID, C_CONVERSIONTYPE_ID, C_PAYMENTTERM_ID,
ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID, ISPAYSCHEDULEVALID, C_INVOICEPAYSCHEDULE_ID, INVOICECOLLECTIONTYPE, C_CAMPAIGN_ID, C_PROJECT_ID,
C_ACTIVITY_ID) C_ACTIVITY_ID)
AS AS
@ -24,8 +25,8 @@ SELECT i.AD_Org_ID, i.AD_Client_ID,
FROM RV_C_Invoice i FROM RV_C_Invoice i
INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID) INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)
WHERE -- i.IsPaid='N' WHERE -- i.IsPaid='N'
invoiceOpen(i.C_Invoice_ID,0) <> 0 invoiceOpen(i.C_Invoice_ID,0) <> 0 AND
AND i.IsPayScheduleValid<>'Y' i.IsPayScheduleValid<>'Y'
AND i.DocStatus<>'DR' AND i.DocStatus<>'DR'
UNION UNION
SELECT i.AD_Org_ID, i.AD_Client_ID, SELECT i.AD_Org_ID, i.AD_Client_ID,
@ -46,8 +47,8 @@ SELECT i.AD_Org_ID, i.AD_Client_ID,
FROM RV_C_Invoice i FROM RV_C_Invoice i
INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID) INNER JOIN C_InvoicePaySchedule ips ON (i.C_Invoice_ID=ips.C_Invoice_ID)
WHERE -- i.IsPaid='N' WHERE -- i.IsPaid='N'
invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 invoiceOpen(i.C_Invoice_ID,ips.C_InvoicePaySchedule_ID) <> 0 AND
AND i.IsPayScheduleValid='Y' i.IsPayScheduleValid='Y'
AND i.DocStatus<>'DR' AND i.DocStatus<>'DR'
AND ips.IsValid='Y'; AND ips.IsValid='Y';

View File

@ -23,6 +23,7 @@ import org.compiere.ldap.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.compiere.wf.*; import org.compiere.wf.*;
import org.eevolution.model.*;
/** /**
* Adempiere Server Base * Adempiere Server Base
@ -51,6 +52,8 @@ public abstract class AdempiereServer extends Thread
return new Scheduler ((MScheduler)model); return new Scheduler ((MScheduler)model);
if (model instanceof MLdapProcessor) if (model instanceof MLdapProcessor)
return new LdapProcessor((MLdapProcessor)model); return new LdapProcessor((MLdapProcessor)model);
if (model instanceof MIMPProcessor) // @Trifon
return new ReplicationProcessor((MIMPProcessor)model);
// //
throw new IllegalArgumentException("Unknown Processor"); throw new IllegalArgumentException("Unknown Processor");
} // create } // create

View File

@ -23,6 +23,7 @@ import org.compiere.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.util.*; import org.compiere.util.*;
import org.compiere.wf.*; import org.compiere.wf.*;
import org.eevolution.model.*;
/** /**
* Adempiere Server Manager * Adempiere Server Manager
@ -156,6 +157,16 @@ public class AdempiereServerMgr
server.setPriority(Thread.NORM_PRIORITY-1); server.setPriority(Thread.NORM_PRIORITY-1);
m_servers.add(server); m_servers.add(server);
} }
// ImportProcessor - @Trifon
MIMPProcessor[] importModels = MIMPProcessor.getActive(m_ctx);
for (int i = 0; i < importModels.length; i++)
{
MIMPProcessor lp = importModels[i];
AdempiereServer server = AdempiereServer.create(lp);
server.start();
server.setPriority(Thread.NORM_PRIORITY-1);
m_servers.add(server);
}
log.fine("#" + noServers); log.fine("#" + noServers);
return startAll(); return startAll();

View File

@ -69,6 +69,32 @@ CREATE OR REPLACE FUNCTION bomQtyReserved (M_Product_ID NUMBER, M_Warehouse_ID N
NAME 'org.compiere.sqlj.Product.bomQtyReserved(int,int,int) return java.math.BigDecimal'; NAME 'org.compiere.sqlj.Product.bomQtyReserved(int,int,int) return java.math.BigDecimal';
/ /
CREATE OR REPLACE FUNCTION bomQtyAvailableASI (M_Product_ID NUMBER, M_AttributeSetInstance_ID NUMBER, M_Warehouse_ID NUMBER,
M_Locator_ID NUMBER)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Product.bomQtyAvailableASI(int,int,int,int) return java.math.BigDecimal';
/
CREATE OR REPLACE FUNCTION bomQtyOnHandASI (M_Product_ID NUMBER,M_AttributeSetInstance_ID NUMBER, M_Warehouse_ID NUMBER,
M_Locator_ID NUMBER)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Product.bomQtyOnHandASI(int,int,int,int) return java.math.BigDecimal';
/
CREATE OR REPLACE FUNCTION bomQtyOrderedASI (M_Product_ID NUMBER, M_AttributeSetInstance_ID NUMBER, M_Warehouse_ID NUMBER,
M_Locator_ID NUMBER)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Product.bomQtyOrderedASI(int,int,int,int) return java.math.BigDecimal';
/
CREATE OR REPLACE FUNCTION bomQtyReservedASI (M_Product_ID NUMBER, M_AttributeSetInstance_ID NUMBER, M_Warehouse_ID NUMBER,
M_Locator_ID NUMBER)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Product.bomQtyReserved(int,int,int,int) return java.math.BigDecimal';
/
/** Currency **/ /** Currency **/
CREATE OR REPLACE FUNCTION currencyBase (Amount NUMBER, C_CurrencyFrom_ID NUMBER, CREATE OR REPLACE FUNCTION currencyBase (Amount NUMBER, C_CurrencyFrom_ID NUMBER,
ConversionDate DATE, AD_Client_ID NUMBER, AD_Org_ID NUMBER) ConversionDate DATE, AD_Client_ID NUMBER, AD_Org_ID NUMBER)
@ -108,12 +134,26 @@ CREATE OR REPLACE FUNCTION invoiceOpen (p_C_Invoice_ID NUMBER, p_C_InvoicePaySch
AS LANGUAGE JAVA AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Invoice.open(int,int) return java.math.BigDecimal'; NAME 'org.compiere.sqlj.Invoice.open(int,int) return java.math.BigDecimal';
/ /
CREATE OR REPLACE FUNCTION invoicePaid (p_C_Invoice_ID NUMBER, p_C_Currency_ID NUMBER, CREATE OR REPLACE FUNCTION invoicePaid (p_C_Invoice_ID NUMBER, p_C_Currency_ID NUMBER,
p_MultiplierAP NUMBER) p_MultiplierAP NUMBER)
RETURN NUMBER RETURN NUMBER
AS LANGUAGE JAVA AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Invoice.paid(int,int,int) return java.math.BigDecimal'; NAME 'org.compiere.sqlj.Invoice.paid(int,int,int) return java.math.BigDecimal';
/ /
CREATE OR REPLACE FUNCTION invoiceOpenToDate (p_C_Invoice_ID NUMBER, p_C_InvoicePaySchedule_ID NUMBER,p_AcctDate DATE)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Invoice.openToDate(int,int,java.sql.Timestamp) return java.math.BigDecimal';
/
CREATE OR REPLACE FUNCTION invoicePaidToDate (p_C_Invoice_ID NUMBER, p_C_Currency_ID NUMBER, p_MultiplierAP NUMBER,p_AcctDate DATE)
RETURN NUMBER
AS LANGUAGE JAVA
NAME 'org.compiere.sqlj.Invoice.paid(int,int,int,java.sql.Timestamp) return java.math.BigDecimal';
/
CREATE OR REPLACE FUNCTION invoiceDiscount (p_C_Invoice_ID NUMBER, p_PayDate Date, CREATE OR REPLACE FUNCTION invoiceDiscount (p_C_Invoice_ID NUMBER, p_PayDate Date,
p_C_InvoicePaySchedule_ID NUMBER) p_C_InvoicePaySchedule_ID NUMBER)
RETURN NUMBER RETURN NUMBER

View File

@ -3,14 +3,14 @@
@Rem Check java home @Rem Check java home
@IF NOT EXIST "%JAVA_HOME%\bin" ECHO "** JAVA_HOME NOT found" @IF NOT EXIST "%JAVA_HOME%\bin" ECHO "** JAVA_HOME NOT found"
@SET PATH=%JAVA_HOME%\bin;%PATH% @SET PATH="%JAVA_HOME%\bin";%PATH%
@Rem Check jdk @Rem Check jdk
@IF NOT EXIST "%JAVA_HOME%\lib\tools.jar" ECHO "** Need Full Java SDK **" @IF NOT EXIST "%JAVA_HOME%\lib\tools.jar" ECHO "** Need Full Java SDK **"
@Rem Set ant classpath @Rem Set ant classpath
@SET ANT_CLASSPATH=%CLASSPATH%;..\tools\lib\ant.jar;..\tools\lib\ant-launcher.jar;..\tools\lib\ant-swing.jar;..\tools\lib\ant-commons-net.jar;..\tools\lib\commons-net-1.4.0.jar @SET ANT_CLASSPATH=%CLASSPATH%;..\tools\lib\ant.jar;..\tools\lib\ant-launcher.jar;..\tools\lib\ant-swing.jar;..\tools\lib\ant-commons-net.jar;..\tools\lib\commons-net-1.4.0.jar
@SET ANT_CLASSPATH=%ANT_CLASSPATH%;"%JAVA_HOME%\lib\tools.jar" @SET ANT_CLASSPATH="%ANT_CLASSPATH%";"%JAVA_HOME%\lib\tools.jar"
@SET ANT_OPTS=-Xms128m -Xmx512m @SET ANT_OPTS=-Xms128m -Xmx512m