diff --git a/base/src/org/compiere/model/CalloutInOut.java b/base/src/org/compiere/model/CalloutInOut.java
index d6045014ca..dbebf2ab2a 100644
--- a/base/src/org/compiere/model/CalloutInOut.java
+++ b/base/src/org/compiere/model/CalloutInOut.java
@@ -29,8 +29,8 @@ import org.compiere.util.Env;
/**
- * Shipment/Receipt Callouts
- *
+ * Shipment/Receipt Callouts
+ *
* @author Jorg Janke
* @version $Id: CalloutInOut.java,v 1.7 2006/07/30 00:51:05 jjanke Exp $
* @author victor.perez@e-evolution.com www.e-evolution.com [ 1867464 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1867464&group_id=176962&atid=879332
@@ -54,7 +54,7 @@ public class CalloutInOut extends CalloutEngine
// No Callout Active to fire dependent values
if (isCalloutActive()) // prevent recursive
return "";
-
+
// Get Details
MOrder order = new MOrder (ctx, C_Order_ID.intValue(), null);
if (order.get_ID() != 0)
@@ -77,15 +77,15 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("FreightAmt", order.getFreightAmt());
mTab.setValue("C_BPartner_ID", new Integer(order.getC_BPartner_ID()));
-
+
//[ 1867464 ]
mTab.setValue("C_BPartner_Location_ID", new Integer(order.getC_BPartner_Location_ID()));
mTab.setValue("AD_User_ID", new Integer(order.getAD_User_ID()));
}
return "";
} // order
-
-
+
+
/**
* InOut - DocType.
* - sets MovementType
@@ -107,7 +107,7 @@ public class CalloutInOut extends CalloutEngine
+ "s.AD_Sequence_ID, s.StartNewYear, s.DateColumn, d.IsSOTrx " //4..7
+ "FROM C_DocType d "
+ "LEFT OUTER JOIN AD_Sequence s ON (d.DocNoSequence_ID=s.AD_Sequence_ID) "
- + "WHERE C_DocType_ID=?"; // 1
+ + "WHERE C_DocType_ID=?"; // 1
PreparedStatement pstmt = null;
ResultSet rs = null;
try
@@ -123,26 +123,28 @@ public class CalloutInOut extends CalloutEngine
// BF [2708789] Read IsSOTrx from C_DocType
String trxFlag = rs.getString(7);
if (DocBaseType.equals("MMS")) // Material Shipments
- /**solve 1648131 bug vpj-cd e-evolution */
+ /**solve 1648131 bug vpj-cd e-evolution */
{
boolean IsSOTrx = "Y".equals(trxFlag);
if (IsSOTrx)
mTab.setValue("MovementType", "C-"); // Customer Shipments
- else
+ else
mTab.setValue("MovementType", "V-"); // Vendor Return
-
+
}
- /**END vpj-cd e-evolution */
+ /**END vpj-cd e-evolution */
else if (DocBaseType.equals("MMR")) // Material Receipts
- /**solve 1648131 bug vpj-cd e-evolution */
+ /**solve 1648131 bug vpj-cd e-evolution */
{
boolean IsSOTrx = "Y".equals(trxFlag);
if (IsSOTrx)
- mTab.setValue("MovementType", "C+"); // Customer Return
- else
+ mTab.setValue("MovementType", "C+"); // Customer Return
+ else
mTab.setValue("MovementType", "V+"); // Vendor Receipts
}
- /**END vpj-cd e-evolution */
+ if (!(trxFlag.equals(mTab.getValue("IsSOTrx"))))
+ mTab.setValue("IsSOTrx", trxFlag);
+ /**END vpj-cd e-evolution */
// DocumentNo
if (rs.getString("IsDocNoControlled").equals("Y"))
@@ -151,9 +153,9 @@ public class CalloutInOut extends CalloutEngine
{
String dateColumn = rs.getString(6);
int AD_Sequence_ID = rs.getInt(4);
- mTab.setValue("DocumentNo",
- "<"
- + MSequence.getPreliminaryNoByYear(mTab, AD_Sequence_ID, dateColumn, null)
+ mTab.setValue("DocumentNo",
+ "<"
+ + MSequence.getPreliminaryNoByYear(mTab, AD_Sequence_ID, dateColumn, null)
+ ">");
}
else
@@ -214,7 +216,7 @@ public class CalloutInOut extends CalloutEngine
//[ 1867464 ]
boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
if (!IsSOTrx)
- {
+ {
// Location
Integer ii = new Integer(rs.getInt("C_BPartner_Location_ID"));
if (rs.wasNull())
@@ -250,7 +252,7 @@ public class CalloutInOut extends CalloutEngine
{
DB.close(rs, pstmt);
}
-
+
return "";
} // bpartner
@@ -315,7 +317,7 @@ public class CalloutInOut extends CalloutEngine
return "";
} // warehouse
-
+
/**************************************************************************
* OrderLine Callout
* @param ctx context
@@ -330,7 +332,7 @@ public class CalloutInOut extends CalloutEngine
Integer C_OrderLine_ID = (Integer)value;
if (C_OrderLine_ID == null || C_OrderLine_ID.intValue() == 0)
return "";
-
+
// Get Details
MOrderLine ol = new MOrderLine (ctx, C_OrderLine_ID.intValue(), null);
if (ol.get_ID() != 0)
@@ -375,13 +377,13 @@ public class CalloutInOut extends CalloutEngine
Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return "";
-
+
// Set Attribute & Locator
int M_Locator_ID = 0;
if (Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_Product_ID") == M_Product_ID.intValue()
&& Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID") != 0)
{
- mTab.setValue("M_AttributeSetInstance_ID",
+ mTab.setValue("M_AttributeSetInstance_ID",
new Integer(Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID")));
M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, Env.TAB_INFO, "M_Locator_ID");
if (M_Locator_ID != 0)
@@ -436,7 +438,7 @@ public class CalloutInOut extends CalloutEngine
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
// log.log(Level.WARNING,"qty - init - M_Product_ID=" + M_Product_ID);
BigDecimal MovementQty, QtyEntered;
-
+
// No Product
if (M_Product_ID == 0)
{
@@ -451,19 +453,19 @@ public class CalloutInOut extends CalloutEngine
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0)
{
- log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
- + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
+ log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
+ + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
QtyEntered = QtyEntered1;
mTab.setValue("QtyEntered", QtyEntered);
}
- MovementQty = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
+ MovementQty = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (MovementQty == null)
MovementQty = QtyEntered;
boolean conversion = QtyEntered.compareTo(MovementQty) != 0;
- log.fine("UOM=" + C_UOM_To_ID
+ log.fine("UOM=" + C_UOM_To_ID
+ ", QtyEntered=" + QtyEntered
- + " -> " + conversion
+ + " -> " + conversion
+ " MovementQty=" + MovementQty);
Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N");
mTab.setValue("MovementQty", MovementQty);
@@ -482,19 +484,19 @@ public class CalloutInOut extends CalloutEngine
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0)
{
- log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
- + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
+ log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
+ + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
QtyEntered = QtyEntered1;
mTab.setValue("QtyEntered", QtyEntered);
}
- MovementQty = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
+ MovementQty = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (MovementQty == null)
MovementQty = QtyEntered;
boolean conversion = QtyEntered.compareTo(MovementQty) != 0;
- log.fine("UOM=" + C_UOM_To_ID
+ log.fine("UOM=" + C_UOM_To_ID
+ ", QtyEntered=" + QtyEntered
- + " -> " + conversion
+ + " -> " + conversion
+ " MovementQty=" + MovementQty);
Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N");
mTab.setValue("MovementQty", MovementQty);
@@ -504,23 +506,23 @@ public class CalloutInOut extends CalloutEngine
{
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, "C_UOM_ID");
MovementQty = (BigDecimal)value;
- int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision();
+ int precision = MProduct.get(ctx, M_Product_ID).getUOMPrecision();
BigDecimal MovementQty1 = MovementQty.setScale(precision, BigDecimal.ROUND_HALF_UP);
if (MovementQty.compareTo(MovementQty1) != 0)
{
- log.fine("Corrected MovementQty "
- + MovementQty + "->" + MovementQty1);
+ log.fine("Corrected MovementQty "
+ + MovementQty + "->" + MovementQty1);
MovementQty = MovementQty1;
mTab.setValue("MovementQty", MovementQty);
}
- QtyEntered = MUOMConversion.convertProductTo (ctx, M_Product_ID,
+ QtyEntered = MUOMConversion.convertProductTo (ctx, M_Product_ID,
C_UOM_To_ID, MovementQty);
if (QtyEntered == null)
QtyEntered = MovementQty;
boolean conversion = MovementQty.compareTo(QtyEntered) != 0;
- log.fine("UOM=" + C_UOM_To_ID
+ log.fine("UOM=" + C_UOM_To_ID
+ ", MovementQty=" + MovementQty
- + " -> " + conversion
+ + " -> " + conversion
+ " QtyEntered=" + QtyEntered);
Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N");
mTab.setValue("QtyEntered", QtyEntered);
@@ -551,7 +553,7 @@ public class CalloutInOut extends CalloutEngine
int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID");
log.fine("M_Product_ID=" + M_Product_ID
+ ", M_ASI_ID=" + M_ASI_ID
- + " - M_Warehouse_ID=" + M_Warehouse_ID
+ + " - M_Warehouse_ID=" + M_Warehouse_ID
+ ", M_Locator_ID=" + M_Locator_ID);
// Check Selection
int M_AttributeSetInstance_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID");
diff --git a/base/src/org/compiere/model/I_M_RMA.java b/base/src/org/compiere/model/I_M_RMA.java
index 420a3adcac..95181c42f0 100644
--- a/base/src/org/compiere/model/I_M_RMA.java
+++ b/base/src/org/compiere/model/I_M_RMA.java
@@ -279,19 +279,6 @@ public interface I_M_RMA
*/
public boolean isSOTrx();
- /** Column name M_RMA_ID */
- public static final String COLUMNNAME_M_RMA_ID = "M_RMA_ID";
-
- /** Set RMA.
- * Return Material Authorization
- */
- public void setM_RMA_ID (int M_RMA_ID);
-
- /** Get RMA.
- * Return Material Authorization
- */
- public int getM_RMA_ID();
-
/** Column name M_RMAType_ID */
public static final String COLUMNNAME_M_RMAType_ID = "M_RMAType_ID";
@@ -307,6 +294,19 @@ public interface I_M_RMA
public I_M_RMAType getM_RMAType() throws RuntimeException;
+ /** Column name M_RMA_ID */
+ public static final String COLUMNNAME_M_RMA_ID = "M_RMA_ID";
+
+ /** Set RMA.
+ * Return Material Authorization
+ */
+ public void setM_RMA_ID (int M_RMA_ID);
+
+ /** Get RMA.
+ * Return Material Authorization
+ */
+ public int getM_RMA_ID();
+
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";
@@ -342,6 +342,15 @@ public interface I_M_RMA
/** Get Process Now */
public boolean isProcessing();
+ /** Column name Ref_RMA_ID */
+ public static final String COLUMNNAME_Ref_RMA_ID = "Ref_RMA_ID";
+
+ /** Set Referenced RMA */
+ public void setRef_RMA_ID (int Ref_RMA_ID);
+
+ /** Get Referenced RMA */
+ public int getRef_RMA_ID();
+
/** Column name SalesRep_ID */
public static final String COLUMNNAME_SalesRep_ID = "SalesRep_ID";
diff --git a/base/src/org/compiere/model/I_M_RMALine.java b/base/src/org/compiere/model/I_M_RMALine.java
index b8cbb0c540..7e381c0c0e 100644
--- a/base/src/org/compiere/model/I_M_RMALine.java
+++ b/base/src/org/compiere/model/I_M_RMALine.java
@@ -173,6 +173,19 @@ public interface I_M_RMALine
public I_M_InOutLine getM_InOutLine() throws RuntimeException;
+ /** Column name M_RMALine_ID */
+ public static final String COLUMNNAME_M_RMALine_ID = "M_RMALine_ID";
+
+ /** Set RMA Line.
+ * Return Material Authorization Line
+ */
+ public void setM_RMALine_ID (int M_RMALine_ID);
+
+ /** Get RMA Line.
+ * Return Material Authorization Line
+ */
+ public int getM_RMALine_ID();
+
/** Column name M_RMA_ID */
public static final String COLUMNNAME_M_RMA_ID = "M_RMA_ID";
@@ -188,19 +201,6 @@ public interface I_M_RMALine
public I_M_RMA getM_RMA() throws RuntimeException;
- /** Column name M_RMALine_ID */
- public static final String COLUMNNAME_M_RMALine_ID = "M_RMALine_ID";
-
- /** Set RMA Line.
- * Return Material Authorization Line
- */
- public void setM_RMALine_ID (int M_RMALine_ID);
-
- /** Get RMA Line.
- * Return Material Authorization Line
- */
- public int getM_RMALine_ID();
-
/** Column name Processed */
public static final String COLUMNNAME_Processed = "Processed";
@@ -240,6 +240,28 @@ public interface I_M_RMALine
*/
public BigDecimal getQtyDelivered();
+ /** Column name QtyInvoiced */
+ public static final String COLUMNNAME_QtyInvoiced = "QtyInvoiced";
+
+ /** Set Quantity Invoiced.
+ * Invoiced Quantity
+ */
+ public void setQtyInvoiced (BigDecimal QtyInvoiced);
+
+ /** Get Quantity Invoiced.
+ * Invoiced Quantity
+ */
+ public BigDecimal getQtyInvoiced();
+
+ /** Column name Ref_RMALine_ID */
+ public static final String COLUMNNAME_Ref_RMALine_ID = "Ref_RMALine_ID";
+
+ /** Set Referenced RMA Line */
+ public void setRef_RMALine_ID (int Ref_RMALine_ID);
+
+ /** Get Referenced RMA Line */
+ public int getRef_RMALine_ID();
+
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java
index de6d314acf..62a21ab5f3 100644
--- a/base/src/org/compiere/model/MInOut.java
+++ b/base/src/org/compiere/model/MInOut.java
@@ -39,14 +39,14 @@ import org.compiere.util.Msg;
*
* @author Jorg Janke
* @version $Id: MInOut.java,v 1.4 2006/07/30 00:51:03 jjanke Exp $
- *
+ *
* Modifications: Added the RMA functionality (Ashley Ramdass)
* @author Karsten Thiemann, Schaeffer AG
*
Bug [ 1759431 ] Problems with VCreateFrom
* @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
* FR [ 1948157 ] Is necessary the reference for document reverse
- * FR [ 2520591 ] Support multiples calendar for Org
- * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @author Armen Rizal, Goodwill Consulting
* BF [ 1745154 ] Cost in Reversing Material Related Docs
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
@@ -54,7 +54,7 @@ import org.compiere.util.Msg;
public class MInOut extends X_M_InOut implements DocAction
{
/**
- *
+ *
*/
private static final long serialVersionUID = -1222763355238200128L;
@@ -67,11 +67,11 @@ public class MInOut extends X_M_InOut implements DocAction
* @param allAttributeInstances if true, all attribute set instances
* @param minGuaranteeDate optional minimum guarantee date if all attribute instances
* @param complete complete document (Process if false, Complete if true)
- * @param trxName transaction
+ * @param trxName transaction
* @return Shipment or null
*/
public static MInOut createFrom (MOrder order, Timestamp movementDate,
- boolean forceDelivery, boolean allAttributeInstances, Timestamp minGuaranteeDate,
+ boolean forceDelivery, boolean allAttributeInstances, Timestamp minGuaranteeDate,
boolean complete, String trxName)
{
if (order == null)
@@ -100,13 +100,13 @@ public class MInOut extends X_M_InOut implements DocAction
if (product != null && product.get_ID() != 0 && product.isStocked())
{
String MMPolicy = product.getMMPolicy();
- storages = MStorage.getWarehouse (order.getCtx(), order.getM_Warehouse_ID(),
- oLines[i].getM_Product_ID(), oLines[i].getM_AttributeSetInstance_ID(),
+ storages = MStorage.getWarehouse (order.getCtx(), order.getM_Warehouse_ID(),
+ oLines[i].getM_Product_ID(), oLines[i].getM_AttributeSetInstance_ID(),
minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, 0, trxName);
} else {
continue;
}
-
+
if (!forceDelivery)
{
BigDecimal maxQty = Env.ZERO;
@@ -122,7 +122,7 @@ public class MInOut extends X_M_InOut implements DocAction
if (maxQty.compareTo(qty) < 0)
continue;
}
- }
+ }
// Create Line
if (retValue.get_ID() == 0) // not saved yet
retValue.save(trxName);
@@ -151,13 +151,13 @@ public class MInOut extends X_M_InOut implements DocAction
}
} // for all order lines
- // No Lines saved
+ // No Lines saved
if (retValue.get_ID() == 0)
return null;
-
+
return retValue;
} // createFrom
-
+
/**
* Create new Shipment by copying
* @param from shipment
@@ -169,7 +169,7 @@ public class MInOut extends X_M_InOut implements DocAction
* @param setOrder set the order link
* @return Shipment
*/
- public static MInOut copyFrom (MInOut from, Timestamp dateDoc,
+ public static MInOut copyFrom (MInOut from, Timestamp dateDoc,
int C_DocType_ID, boolean isSOTrx, boolean counter, String trxName, boolean setOrder)
{
MInOut to = new MInOut (from.getCtx(), 0, null);
@@ -184,7 +184,16 @@ public class MInOut extends X_M_InOut implements DocAction
to.setC_DocType_ID (C_DocType_ID);
to.setIsSOTrx(isSOTrx);
if (counter)
- to.setMovementType (isSOTrx ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReceipts);
+ {
+ MDocType docType = new MDocType(from.getCtx(), C_DocType_ID, trxName);
+ if (docType.getDocBaseType().equals("MMS")) {
+ to.setMovementType (isSOTrx ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReturns);
+ }
+ else if (docType.getDocBaseType().equals("MMR")) {
+ to.setMovementType (isSOTrx ? MOVEMENTTYPE_CustomerReturns : MOVEMENTTYPE_VendorReceipts);
+ }
+ }
+
//
to.setDateOrdered (dateDoc);
to.setDateAcct (dateDoc);
@@ -225,6 +234,13 @@ public class MInOut extends X_M_InOut implements DocAction
if (peer.getRef_Invoice_ID() != 0)
to.setC_Invoice_ID(peer.getRef_Invoice_ID());
}
+ //find RMA link
+ if (from.getM_RMA_ID() != 0)
+ {
+ MRMA peer = new MRMA (from.getCtx(), from.getM_RMA_ID(), from.get_TrxName());
+ if (peer.getRef_RMA_ID() > 0)
+ to.setM_RMA_ID(peer.getRef_RMA_ID());
+ }
}
else
{
@@ -243,11 +259,11 @@ public class MInOut extends X_M_InOut implements DocAction
if (to.copyLinesFrom(from, counter, setOrder) == 0)
throw new IllegalStateException("Could not create Shipment Lines");
-
+
return to;
} // copyFrom
-
-
+
+
/**************************************************************************
* Standard Constructor
* @param ctx context
@@ -291,7 +307,7 @@ public class MInOut extends X_M_InOut implements DocAction
* Load Constructor
* @param ctx context
* @param rs result set record
- * @param trxName transaction
+ * @param trxName transaction
*/
public MInOut (Properties ctx, ResultSet rs, String trxName)
{
@@ -317,15 +333,15 @@ public class MInOut extends X_M_InOut implements DocAction
setMovementType (order.isSOTrx() ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReceipts);
if (C_DocTypeShipment_ID == 0)
C_DocTypeShipment_ID = DB.getSQLValue(null,
- "SELECT C_DocTypeShipment_ID FROM C_DocType WHERE C_DocType_ID=?",
+ "SELECT C_DocTypeShipment_ID FROM C_DocType WHERE C_DocType_ID=?",
order.getC_DocType_ID());
setC_DocType_ID (C_DocTypeShipment_ID);
-
+
// Default - Today
if (movementDate != null)
setMovementDate (movementDate);
setDateAcct (getMovementDate());
-
+
// Copy from Order
setC_Order_ID(order.getC_Order_ID());
setDeliveryRule (order.getDeliveryRule());
@@ -343,7 +359,7 @@ public class MInOut extends X_M_InOut implements DocAction
setC_Project_ID(order.getC_Project_ID());
setDateOrdered(order.getDateOrdered());
setDescription(order.getDescription());
- setPOReference(order.getPOReference());
+ setPOReference(order.getPOReference());
setSalesRep_ID(order.getSalesRep_ID());
setAD_OrgTrx_ID(order.getAD_OrgTrx_ID());
setUser1_ID(order.getUser1_ID());
@@ -379,18 +395,18 @@ public class MInOut extends X_M_InOut implements DocAction
order = new MOrder (invoice.getCtx(), invoice.getC_Order_ID(), invoice.get_TrxName());
if (C_DocTypeShipment_ID == 0 && order != null)
C_DocTypeShipment_ID = DB.getSQLValue(null,
- "SELECT C_DocTypeShipment_ID FROM C_DocType WHERE C_DocType_ID=?",
+ "SELECT C_DocTypeShipment_ID FROM C_DocType WHERE C_DocType_ID=?",
order.getC_DocType_ID());
if (C_DocTypeShipment_ID != 0)
setC_DocType_ID (C_DocTypeShipment_ID);
else
setC_DocType_ID();
-
+
// Default - Today
if (movementDate != null)
setMovementDate (movementDate);
setDateAcct (getMovementDate());
-
+
// Copy from Invoice
setC_Order_ID(invoice.getC_Order_ID());
setSalesRep_ID(invoice.getSalesRep_ID());
@@ -415,7 +431,7 @@ public class MInOut extends X_M_InOut implements DocAction
setM_Shipper_ID(order.getM_Shipper_ID());
setFreightCostRule (order.getFreightCostRule());
setFreightAmt(order.getFreightAmt());
-
+
// Drop Shipment
setIsDropShip(order.isDropShip());
setDropShip_BPartner_ID(order.getDropShip_BPartner_ID());
@@ -423,10 +439,10 @@ public class MInOut extends X_M_InOut implements DocAction
setDropShip_User_ID(order.getDropShip_User_ID());
}
} // MInOut
-
+
/**
* Copy Constructor - create header only
- * @param original original
+ * @param original original
* @param movementDate optional movement date (default today)
* @param C_DocTypeShipment_ID document type or 0
*/
@@ -445,12 +461,12 @@ public class MInOut extends X_M_InOut implements DocAction
setC_DocType_ID(original.getC_DocType_ID());
else
setC_DocType_ID (C_DocTypeShipment_ID);
-
+
// Default - Today
if (movementDate != null)
setMovementDate (movementDate);
setDateAcct (getMovementDate());
-
+
// Copy from Order
setC_Order_ID(original.getC_Order_ID());
setDeliveryRule (original.getDeliveryRule());
@@ -468,21 +484,21 @@ public class MInOut extends X_M_InOut implements DocAction
setC_Project_ID(original.getC_Project_ID());
setDateOrdered(original.getDateOrdered());
setDescription(original.getDescription());
- setPOReference(original.getPOReference());
+ setPOReference(original.getPOReference());
setSalesRep_ID(original.getSalesRep_ID());
setAD_OrgTrx_ID(original.getAD_OrgTrx_ID());
setUser1_ID(original.getUser1_ID());
setUser2_ID(original.getUser2_ID());
-
+
// DropShipment
setIsDropShip(original.isDropShip());
setDropShip_BPartner_ID(original.getDropShip_BPartner_ID());
setDropShip_Location_ID(original.getDropShip_Location_ID());
setDropShip_User_ID(original.getDropShip_User_ID());
-
+
} // MInOut
-
+
/** Lines */
private MInOutLine[] m_lines = null;
/** Confirmations */
@@ -490,7 +506,7 @@ public class MInOut extends X_M_InOut implements DocAction
/** BPartner */
private MBPartner m_partner = null;
-
+
/**
* Get Document Status
* @return Document Status Clear Text
@@ -619,7 +635,7 @@ public class MInOut extends X_M_InOut implements DocAction
return getLines(false);
} // getLines
-
+
/**
* Get Confirmations
* @param requery requery
@@ -658,13 +674,13 @@ public class MInOut extends X_M_InOut implements DocAction
{
pstmt = null;
}
-
+
m_confirms = new MInOutConfirm[list.size ()];
list.toArray (m_confirms);
return m_confirms;
} // getConfirmations
-
-
+
+
/**
* Copy Lines From other Shipment
* @param otherShipment shipment
@@ -721,6 +737,13 @@ public class MInOut extends X_M_InOut implements DocAction
if (peer.getRef_OrderLine_ID() != 0)
line.setC_OrderLine_ID(peer.getRef_OrderLine_ID());
}
+ //RMALine link
+ if (fromLine.getM_RMALine_ID() != 0)
+ {
+ MRMALine peer = new MRMALine (getCtx(), fromLine.getM_RMALine_ID(), get_TrxName());
+ if (peer.getRef_RMALine_ID() > 0)
+ line.setM_RMALine_ID(peer.getRef_RMALine_ID());
+ }
}
//
line.setProcessed(false);
@@ -740,7 +763,7 @@ public class MInOut extends X_M_InOut implements DocAction
/** Reversal Flag */
private boolean m_reversal = false;
-
+
/**
* Set Reversal
* @param reversal reversal
@@ -757,7 +780,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
return m_reversal;
} // isReversal
-
+
/**
* Set Processed.
* Propergate to Lines/Taxes
@@ -783,10 +806,10 @@ public class MInOut extends X_M_InOut implements DocAction
public MBPartner getBPartner()
{
if (m_partner == null)
- m_partner = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
+ m_partner = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
return m_partner;
} // getPartner
-
+
/**
* Set Document Type
* @param DocBaseType doc type MDocType.DOCBASETYPE_
@@ -795,12 +818,12 @@ public class MInOut extends X_M_InOut implements DocAction
{
String sql = "SELECT C_DocType_ID FROM C_DocType "
+ "WHERE AD_Client_ID=? AND DocBaseType=?"
- + " AND IsActive='Y'"
+ + " AND IsActive='Y'"
+ " AND IsSOTrx='" + (isSOTrx() ? "Y" : "N") + "' "
+ "ORDER BY IsDefault DESC";
int C_DocType_ID = DB.getSQLValue(null, sql, getAD_Client_ID(), DocBaseType);
if (C_DocType_ID <= 0)
- log.log(Level.SEVERE, "Not found for AC_Client_ID="
+ log.log(Level.SEVERE, "Not found for AC_Client_ID="
+ getAD_Client_ID() + " - " + DocBaseType);
else
{
@@ -822,7 +845,7 @@ public class MInOut extends X_M_InOut implements DocAction
else
setC_DocType_ID(MDocType.DOCBASETYPE_MaterialReceipt);
} // setC_DocType_ID
-
+
/**
* Set Business Partner Defaults & Details
* @param bp business partner
@@ -870,7 +893,7 @@ public class MInOut extends X_M_InOut implements DocAction
log.fine("No need");
return;
}
-
+
// Create Both .. after each other
if (pick && ship)
{
@@ -912,8 +935,8 @@ public class MInOut extends X_M_InOut implements DocAction
else if (ship)
MInOutConfirm.create (this, MInOutConfirm.CONFIRMTYPE_ShipReceiptConfirm, true);
} // createConfirmation
-
-
+
+
/**
* Set Warehouse and check/set Organization
* @param M_Warehouse_ID id
@@ -930,13 +953,13 @@ public class MInOut extends X_M_InOut implements DocAction
MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID());
if (wh.getAD_Org_ID() != getAD_Org_ID())
{
- log.warning("M_Warehouse_ID=" + M_Warehouse_ID
+ log.warning("M_Warehouse_ID=" + M_Warehouse_ID
+ ", Overwritten AD_Org_ID=" + getAD_Org_ID() + "->" + wh.getAD_Org_ID());
setAD_Org_ID(wh.getAD_Org_ID());
}
} // setM_Warehouse_ID
-
-
+
+
/**
* Before Save
* @param newRecord new
@@ -954,21 +977,21 @@ public class MInOut extends X_M_InOut implements DocAction
return false;
}
}
-
+
// Shipment/Receipt can have either Order/RMA (For Movement type)
if (getC_Order_ID() != 0 && getM_RMA_ID() != 0)
{
log.saveError("OrderOrRMA", "");
return false;
}
-
+
// Shipment - Needs Order/RMA
if (!getMovementType().contentEquals(MInOut.MOVEMENTTYPE_CustomerReturns) && isSOTrx() && getC_Order_ID() == 0 && getM_RMA_ID() == 0)
{
log.saveError("FillMandatory", Msg.translate(getCtx(), "C_Order_ID"));
return false;
}
-
+
if (isSOTrx() && getM_RMA_ID() != 0)
{
// Set Document and Movement type for this Receipt
@@ -976,10 +999,10 @@ public class MInOut extends X_M_InOut implements DocAction
MDocType docType = MDocType.get(getCtx(), rma.getC_DocType_ID());
setC_DocType_ID(docType.getC_DocTypeShipment_ID());
}
-
+
return true;
} // beforeSave
-
+
/**
* After Save
* @param newRecord new
@@ -990,7 +1013,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
if (!success || newRecord)
return success;
-
+
if (is_ValueChanged("AD_Org_ID"))
{
String sql = "UPDATE M_InOutLine ol"
@@ -1000,11 +1023,11 @@ public class MInOut extends X_M_InOut implements DocAction
+ "WHERE M_InOut_ID=" + getC_Order_ID();
int no = DB.executeUpdate(sql, get_TrxName());
log.fine("Lines -> #" + no);
- }
+ }
return true;
} // afterSave
-
+
/**************************************************************************
* Process document
* @param processAction document action
@@ -1016,7 +1039,7 @@ public class MInOut extends X_M_InOut implements DocAction
DocumentEngine engine = new DocumentEngine (this, getDocStatus());
return engine.processIt (processAction, getDocAction());
} // process
-
+
/** Process Message */
private String m_processMsg = null;
/** Just Prepared Flag */
@@ -1024,7 +1047,7 @@ public class MInOut extends X_M_InOut implements DocAction
/**
* Unlock Document.
- * @return true if success
+ * @return true if success
*/
public boolean unlockIt()
{
@@ -1032,10 +1055,10 @@ public class MInOut extends X_M_InOut implements DocAction
setProcessing(false);
return true;
} // unlockIt
-
+
/**
* Invalidate Document
- * @return true if success
+ * @return true if success
*/
public boolean invalidateIt()
{
@@ -1043,10 +1066,10 @@ public class MInOut extends X_M_InOut implements DocAction
setDocAction(DOCACTION_Prepare);
return true;
} // invalidateIt
-
+
/**
* Prepare Document
- * @return new status (In Progress or Invalid)
+ * @return new status (In Progress or Invalid)
*/
public String prepareIt()
{
@@ -1069,21 +1092,21 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = "@PeriodClosed@";
return DocAction.STATUS_Invalid;
}
-
+
// Credit Check
if (isSOTrx() && !isReversal())
{
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
{
- m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
+ m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
+ bp.getTotalOpenBalance()
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
return DocAction.STATUS_Invalid;
}
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
{
- m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
+ m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
+ bp.getTotalOpenBalance()
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
return DocAction.STATUS_Invalid;
@@ -1091,13 +1114,13 @@ public class MInOut extends X_M_InOut implements DocAction
BigDecimal notInvoicedAmt = MBPartner.getNotInvoicedAmt(getC_BPartner_ID());
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(notInvoicedAmt)))
{
- m_processMsg = "@BPartnerOverSCreditHold@ - @TotalOpenBalance@="
+ m_processMsg = "@BPartnerOverSCreditHold@ - @TotalOpenBalance@="
+ bp.getTotalOpenBalance() + ", @NotInvoicedAmt@=" + notInvoicedAmt
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
return DocAction.STATUS_Invalid;
}
}
-
+
// Lines
MInOutLine[] lines = getLines(true);
if (lines == null || lines.length == 0)
@@ -1111,7 +1134,7 @@ public class MInOut extends X_M_InOut implements DocAction
// Mandatory Attributes
for (int i = 0; i < lines.length; i++)
{
- MInOutLine line = lines[i];
+ MInOutLine line = lines[i];
MProduct product = line.getProduct();
if (product != null)
{
@@ -1139,16 +1162,16 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
-
+
m_justPrepared = true;
if (!DOCACTION_Complete.equals(getDocAction()))
setDocAction(DOCACTION_Complete);
return DocAction.STATUS_InProgress;
} // prepareIt
-
+
/**
* Approve Document
- * @return true if success
+ * @return true if success
*/
public boolean approveIt()
{
@@ -1156,10 +1179,10 @@ public class MInOut extends X_M_InOut implements DocAction
setIsApproved(true);
return true;
} // approveIt
-
+
/**
* Reject Approval
- * @return true if success
+ * @return true if success
*/
public boolean rejectIt()
{
@@ -1167,7 +1190,7 @@ public class MInOut extends X_M_InOut implements DocAction
setIsApproved(false);
return true;
} // rejectIt
-
+
/**
* Complete Document
* @return new status (Complete, In Progress, Invalid, Waiting ..)
@@ -1181,11 +1204,11 @@ public class MInOut extends X_M_InOut implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
-
+
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
-
+
// Outstanding (not processed) Incoming Confirmations ?
MInOutConfirm[] confirmations = getConfirmations(true);
for (int i = 0; i < confirmations.length; i++)
@@ -1196,19 +1219,19 @@ public class MInOut extends X_M_InOut implements DocAction
if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.equals(confirm.getConfirmType()))
continue;
//
- m_processMsg = "Open @M_InOutConfirm_ID@: " +
+ m_processMsg = "Open @M_InOutConfirm_ID@: " +
confirm.getConfirmTypeName() + " - " + confirm.getDocumentNo();
return DocAction.STATUS_InProgress;
}
}
-
-
+
+
// Implicit Approval
if (!isApproved())
approveIt();
log.info(toString());
StringBuffer info = new StringBuffer();
-
+
// For all lines
MInOutLine[] lines = getLines(false);
for (int lineIndex = 0; lineIndex < lines.length; lineIndex++)
@@ -1223,33 +1246,33 @@ public class MInOut extends X_M_InOut implements DocAction
Qty = Qty.negate();
BigDecimal QtySO = Env.ZERO;
BigDecimal QtyPO = Env.ZERO;
-
+
// Update Order Line
MOrderLine oLine = null;
if (sLine.getC_OrderLine_ID() != 0)
{
oLine = new MOrderLine (getCtx(), sLine.getC_OrderLine_ID(), get_TrxName());
- log.fine("OrderLine - Reserved=" + oLine.getQtyReserved()
+ log.fine("OrderLine - Reserved=" + oLine.getQtyReserved()
+ ", Delivered=" + oLine.getQtyDelivered());
if (isSOTrx())
QtySO = sLine.getMovementQty();
else
QtyPO = sLine.getMovementQty();
}
-
-
+
+
// Load RMA Line
MRMALine rmaLine = null;
-
+
if (sLine.getM_RMALine_ID() != 0)
{
rmaLine = new MRMALine(getCtx(), sLine.getM_RMALine_ID(), get_TrxName());
}
-
+
log.info("Line=" + sLine.getLine() + " - Qty=" + sLine.getMovementQty());
// Stock Movement - Counterpart MOrder.reserveStock
- if (product != null
+ if (product != null
&& product.isStocked() )
{
//Ignore the Material Policy when is Reverse Correction
@@ -1257,9 +1280,9 @@ public class MInOut extends X_M_InOut implements DocAction
{
checkMaterialPolicy(sLine);
}
-
+
log.fine("Material Transaction");
- MTransaction mtrx = null;
+ MTransaction mtrx = null;
//same warehouse in order and receipt?
boolean sameWarehouse = true;
// Reservation ASI - assume none
@@ -1288,13 +1311,13 @@ public class MInOut extends X_M_InOut implements DocAction
else
orderedDiff = ma.getMovementQty().negate();
}
-
-
+
+
// Update Storage - see also VMatch.createMatchRecord
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Locator_ID(),
- sLine.getM_Product_ID(),
- ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ sLine.getM_Product_ID(),
+ ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
QtyMA,
sameWarehouse ? reservedDiff : Env.ZERO,
sameWarehouse ? orderedDiff : Env.ZERO,
@@ -1308,8 +1331,8 @@ public class MInOut extends X_M_InOut implements DocAction
MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
if (!MStorage.add(getCtx(), oLine.getM_Warehouse_ID(),
wh.getDefaultLocator().getM_Locator_ID(),
- sLine.getM_Product_ID(),
- ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ sLine.getM_Product_ID(),
+ ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
Env.ZERO, reservedDiff, orderedDiff, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA) in order warehouse";
@@ -1317,9 +1340,9 @@ public class MInOut extends X_M_InOut implements DocAction
}
}
// Create Transaction
- mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
+ mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
- sLine.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
+ sLine.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
QtyMA, getMovementDate(), get_TrxName());
mtrx.setM_InOutLine_ID(sLine.getM_InOutLine_ID());
if (!mtrx.save())
@@ -1334,12 +1357,12 @@ public class MInOut extends X_M_InOut implements DocAction
{
BigDecimal reservedDiff = sameWarehouse ? QtySO.negate() : Env.ZERO;
BigDecimal orderedDiff = sameWarehouse ? QtyPO.negate(): Env.ZERO;
-
+
// Fallback: Update Storage - see also VMatch.createMatchRecord
- if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
+ if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
sLine.getM_Locator_ID(),
- sLine.getM_Product_ID(),
- sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ sLine.getM_Product_ID(),
+ sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
Qty, reservedDiff, orderedDiff, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory";
@@ -1348,10 +1371,10 @@ public class MInOut extends X_M_InOut implements DocAction
if (!sameWarehouse) {
//correct qtyOrdered in warehouse of order
MWarehouse wh = MWarehouse.get(getCtx(), oLine.getM_Warehouse_ID());
- if (!MStorage.add(getCtx(), oLine.getM_Warehouse_ID(),
+ if (!MStorage.add(getCtx(), oLine.getM_Warehouse_ID(),
wh.getDefaultLocator().getM_Locator_ID(),
- sLine.getM_Product_ID(),
- sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
+ sLine.getM_Product_ID(),
+ sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
Env.ZERO, QtySO.negate(), QtyPO.negate(), get_TrxName()))
{
m_processMsg = "Cannot correct Inventory";
@@ -1361,7 +1384,7 @@ public class MInOut extends X_M_InOut implements DocAction
// FallBack: Create Transaction
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
MovementType, sLine.getM_Locator_ID(),
- sLine.getM_Product_ID(), sLine.getM_AttributeSetInstance_ID(),
+ sLine.getM_Product_ID(), sLine.getM_AttributeSetInstance_ID(),
Qty, getMovementDate(), get_TrxName());
mtrx.setM_InOutLine_ID(sLine.getM_InOutLine_ID());
if (!mtrx.save())
@@ -1371,11 +1394,11 @@ public class MInOut extends X_M_InOut implements DocAction
}
}
} // stock movement
-
+
// Correct Order Line
if (product != null && oLine != null) // other in VMatch.createMatchRecord
oLine.setQtyReserved(oLine.getQtyReserved().subtract(sLine.getMovementQty()));
-
+
// Update Sales Order Line
if (oLine != null)
{
@@ -1394,7 +1417,7 @@ public class MInOut extends X_M_InOut implements DocAction
return DocAction.STATUS_Invalid;
}
else
- log.fine("OrderLine -> Reserved=" + oLine.getQtyReserved()
+ log.fine("OrderLine -> Reserved=" + oLine.getQtyReserved()
+ ", Delivered=" + oLine.getQtyReserved());
}
// Update RMA Line Qty Delivered
@@ -1416,8 +1439,8 @@ public class MInOut extends X_M_InOut implements DocAction
}
// Create Asset for SO
- if (product != null
- && isSOTrx()
+ if (product != null
+ && isSOTrx()
&& product.isCreateAsset()
&& sLine.getMovementQty().signum() > 0
&& !isReversal())
@@ -1446,7 +1469,7 @@ public class MInOut extends X_M_InOut implements DocAction
// Matching
- if (!isSOTrx()
+ if (!isSOTrx()
&& sLine.getM_Product_ID() != 0
&& !isReversal())
{
@@ -1458,7 +1481,7 @@ public class MInOut extends X_M_InOut implements DocAction
if (matchQty.compareTo(iLine.getQtyInvoiced())>0)
matchQty = iLine.getQtyInvoiced();
- MMatchInv[] matches = MMatchInv.get(getCtx(),
+ MMatchInv[] matches = MMatchInv.get(getCtx(),
sLine.getM_InOutLine_ID(), iLine.getC_InvoiceLine_ID(), get_TrxName());
if (matches == null || matches.length == 0)
{
@@ -1475,7 +1498,7 @@ public class MInOut extends X_M_InOut implements DocAction
return DocAction.STATUS_Invalid;
}
}
- }
+ }
// Link to Order
if (sLine.getC_OrderLine_ID() != 0)
@@ -1504,7 +1527,7 @@ public class MInOut extends X_M_InOut implements DocAction
// Invoice is created before Shipment
log.fine("PO(Inv) Matching");
// Ship - Invoice
- MMatchPO po = MMatchPO.create (iLine, sLine,
+ MMatchPO po = MMatchPO.create (iLine, sLine,
getMovementDate(), matchQty);
if (!po.save(get_TrxName()))
{
@@ -1513,23 +1536,23 @@ public class MInOut extends X_M_InOut implements DocAction
}
// Update PO with ASI
oLine = new MOrderLine (getCtx(), po.getC_OrderLine_ID(), get_TrxName());
- if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0
+ if ( oLine != null && oLine.getM_AttributeSetInstance_ID() == 0
&& sLine.getMovementQty().compareTo(oLine.getQtyOrdered()) == 0) // just if full match [ 1876965 ]
{
oLine.setM_AttributeSetInstance_ID(sLine.getM_AttributeSetInstance_ID());
oLine.save(get_TrxName());
- }
+ }
}
} // No Order
} // PO Matching
-
+
} // for all lines
-
+
// Counter Documents
MInOut counter = createCounterDoc();
if (counter != null)
info.append(" - @CounterDoc@: @M_InOut_ID@=").append(counter.getDocumentNo());
-
+
// Drop Shipments
MInOut dropShipment = createDropShipment();
if (dropShipment != null)
@@ -1550,7 +1573,7 @@ public class MInOut extends X_M_InOut implements DocAction
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
} // completeIt
-
+
/**
* Automatically creates a customer shipment for any
* drop shipment material receipt
@@ -1558,14 +1581,14 @@ public class MInOut extends X_M_InOut implements DocAction
* @return shipment if created else null
*/
private MInOut createDropShipment() {
-
+
if ( isSOTrx() || !isDropShip() || getC_Order_ID() == 0 )
return null;
// Document Type
int C_DocTypeTarget_ID = 0;
MDocType[] shipmentTypes = MDocType.getOfDocBaseType(getCtx(), MDocType.DOCBASETYPE_MaterialDelivery);
-
+
for (int i = 0; i < shipmentTypes.length; i++ )
{
if (shipmentTypes[i].isSOTrx() && ( C_DocTypeTarget_ID == 0 || shipmentTypes[i].isDefault() ) )
@@ -1573,14 +1596,14 @@ public class MInOut extends X_M_InOut implements DocAction
}
// Deep Copy
- MInOut dropShipment = copyFrom(this, getMovementDate(),
+ MInOut dropShipment = copyFrom(this, getMovementDate(),
C_DocTypeTarget_ID, !isSOTrx(), false, get_TrxName(), true);
-
+
int linkedOrderID = new MOrder (getCtx(), getC_Order_ID(), get_TrxName()).getLink_Order_ID();
if (linkedOrderID != 0)
{
dropShipment.setC_Order_ID(linkedOrderID);
-
+
// get invoice id from linked order
int invID = new MOrder (getCtx(), linkedOrderID, get_TrxName()).getC_Invoice_ID();
if ( invID != 0 )
@@ -1588,7 +1611,7 @@ public class MInOut extends X_M_InOut implements DocAction
}
else
return null;
-
+
dropShipment.setC_BPartner_ID(getDropShip_BPartner_ID());
dropShipment.setC_BPartner_Location_ID(getDropShip_Location_ID());
dropShipment.setAD_User_ID(getDropShip_User_ID());
@@ -1597,11 +1620,11 @@ public class MInOut extends X_M_InOut implements DocAction
dropShipment.setDropShip_Location_ID(0);
dropShipment.setDropShip_User_ID(0);
dropShipment.setMovementType(MOVEMENTTYPE_CustomerShipment);
-
+
// References (Should not be required
dropShipment.setSalesRep_ID(getSalesRep_ID());
dropShipment.save(get_TrxName());
-
+
// Update line order references to linked sales order lines
MInOutLine[] lines = dropShipment.getLines(true);
for (int i = 0; i < lines.length; i++)
@@ -1613,9 +1636,9 @@ public class MInOut extends X_M_InOut implements DocAction
dropLine.save();
}
}
-
+
log.fine(dropShipment.toString());
-
+
dropShipment.setDocAction(DocAction.ACTION_Complete);
dropShipment.processIt(DocAction.ACTION_Complete);
dropShipment.save();
@@ -1678,9 +1701,9 @@ public class MInOut extends X_M_InOut implements DocAction
//auto balance negative on hand
MStorage[] storages = MStorage.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), 0,
null, MClient.MMPOLICY_FiFo.equals(product.getMMPolicy()), false, line.getM_Locator_ID(), get_TrxName());
- for (MStorage storage : storages)
+ for (MStorage storage : storages)
{
- if (storage.getQtyOnHand().signum() < 0)
+ if (storage.getQtyOnHand().signum() < 0)
{
asi = new MAttributeSetInstance(getCtx(), storage.getM_AttributeSetInstance_ID(), get_TrxName());
break;
@@ -1700,33 +1723,33 @@ public class MInOut extends X_M_InOut implements DocAction
{
String MMPolicy = product.getMMPolicy();
Timestamp minGuaranteeDate = getMovementDate();
- MStorage[] storages = MStorage.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
+ MStorage[] storages = MStorage.getWarehouse(getCtx(), getM_Warehouse_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
minGuaranteeDate, MClient.MMPOLICY_FiFo.equals(MMPolicy), true, line.getM_Locator_ID(), get_TrxName());
BigDecimal qtyToDeliver = line.getMovementQty();
for (MStorage storage: storages)
- {
+ {
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
{
- MInOutLineMA ma = new MInOutLineMA (line,
+ MInOutLineMA ma = new MInOutLineMA (line,
storage.getM_AttributeSetInstance_ID(),
qtyToDeliver);
- ma.saveEx();
+ ma.saveEx();
qtyToDeliver = Env.ZERO;
}
else
- {
- MInOutLineMA ma = new MInOutLineMA (line,
+ {
+ MInOutLineMA ma = new MInOutLineMA (line,
storage.getM_AttributeSetInstance_ID(),
storage.getQtyOnHand());
- ma.saveEx();
+ ma.saveEx();
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
- log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
+ log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
}
-
+
if (qtyToDeliver.signum() == 0)
break;
}
-
+
if (qtyToDeliver.signum() != 0)
{
//deliver using new asi
@@ -1745,7 +1768,7 @@ public class MInOut extends X_M_InOut implements DocAction
}
} // checkMaterialPolicy
-
+
/**************************************************************************
* Create Counter Document
* @return InOut
@@ -1755,18 +1778,18 @@ public class MInOut extends X_M_InOut implements DocAction
// Is this a counter doc ?
if (getRef_InOut_ID() != 0)
return null;
-
+
// Org Must be linked to BPartner
MOrg org = MOrg.get(getCtx(), getAD_Org_ID());
- int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
+ int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
if (counterC_BPartner_ID == 0)
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
- int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
+ int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
if (counterAD_Org_ID == 0)
return null;
-
+
MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null);
MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID);
log.info("Counter BP=" + counterBP.getName());
@@ -1790,15 +1813,15 @@ public class MInOut extends X_M_InOut implements DocAction
}
// Deep Copy
- MInOut counter = copyFrom(this, getMovementDate(),
+ MInOut counter = copyFrom(this, getMovementDate(),
C_DocTypeTarget_ID, !isSOTrx(), true, get_TrxName(), true);
-
+
//
counter.setAD_Org_ID(counterAD_Org_ID);
counter.setM_Warehouse_ID(counterOrgInfo.getM_Warehouse_ID());
//
counter.setBPartner(counterBP);
-
+
if ( isDropShip() )
{
counter.setIsDropShip(true );
@@ -1806,11 +1829,11 @@ public class MInOut extends X_M_InOut implements DocAction
counter.setDropShip_Location_ID(getDropShip_Location_ID());
counter.setDropShip_User_ID(getDropShip_User_ID());
}
-
+
// Refernces (Should not be required
counter.setSalesRep_ID(getSalesRep_ID());
counter.save(get_TrxName());
-
+
String MovementType = counter.getMovementType();
boolean inTrx = MovementType.charAt(1) == '+'; // V+ Vendor Receipt
@@ -1826,9 +1849,9 @@ public class MInOut extends X_M_InOut implements DocAction
//
counterLine.save(get_TrxName());
}
-
+
log.fine(counter.toString());
-
+
// Document Action
if (counterDT != null)
{
@@ -1841,10 +1864,10 @@ public class MInOut extends X_M_InOut implements DocAction
}
return counter;
} // createCounterDoc
-
+
/**
* Void Document.
- * @return true if success
+ * @return true if success
*/
public boolean voidIt()
{
@@ -1853,7 +1876,7 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID);
if (m_processMsg != null)
return false;
-
+
if (DOCSTATUS_Closed.equals(getDocStatus())
|| DOCSTATUS_Reversed.equals(getDocStatus())
|| DOCSTATUS_Voided.equals(getDocStatus()))
@@ -1892,15 +1915,15 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID);
if (m_processMsg != null)
return false;
-
+
setProcessed(true);
setDocAction(DOCACTION_None);
return true;
} // voidIt
-
+
/**
* Close Document.
- * @return true if success
+ * @return true if success
*/
public boolean closeIt()
{
@@ -1909,20 +1932,20 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE);
if (m_processMsg != null)
return false;
-
+
// After Close
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE);
if (m_processMsg != null)
- return false;
+ return false;
setProcessed(true);
setDocAction(DOCACTION_None);
return true;
} // closeIt
-
+
/**
* Reverse Correction - same date
- * @return true if success
+ * @return true if success
*/
public boolean reverseCorrectIt()
{
@@ -1931,14 +1954,14 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT);
if (m_processMsg != null)
return false;
-
+
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
return false;
}
-
+
// Reverse/Delete Matching
if (!isSOTrx())
{
@@ -1954,13 +1977,13 @@ public class MInOut extends X_M_InOut implements DocAction
{
mPO[i].setM_InOutLine_ID(0);
mPO[i].save();
-
+
}
}
}
// Deep Copy
- MInOut reversal = copyFrom (this, getMovementDate(),
+ MInOut reversal = copyFrom (this, getMovementDate(),
getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true);
if (reversal == null)
{
@@ -1968,7 +1991,7 @@ public class MInOut extends X_M_InOut implements DocAction
return false;
}
reversal.setReversal(true);
-
+
// Reverse Line Qty
MInOutLine[] sLines = getLines(false);
MInOutLine[] rLines = reversal.getLines(false);
@@ -1992,7 +2015,7 @@ public class MInOut extends X_M_InOut implements DocAction
sLines[i].getM_InOutLine_ID(), get_TrxName());
for (int j = 0; j < mas.length; j++)
{
- MInOutLineMA ma = new MInOutLineMA (rLine,
+ MInOutLineMA ma = new MInOutLineMA (rLine,
mas[j].getM_AttributeSetInstance_ID(),
mas[j].getMovementQty().negate());
if (!ma.save())
@@ -2020,7 +2043,7 @@ public class MInOut extends X_M_InOut implements DocAction
return false;
}
reversal.closeIt();
- //FR1948157
+ //FR1948157
reversal.setReversal_ID(getM_InOut_ID());
reversal.setProcessing (false);
reversal.setDocStatus(DOCSTATUS_Reversed);
@@ -2032,17 +2055,17 @@ public class MInOut extends X_M_InOut implements DocAction
// After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
if (m_processMsg != null)
- return false;
+ return false;
m_processMsg = reversal.getDocumentNo();
- //FR1948157
+ //FR1948157
this.setReversal_ID(reversal.getM_InOut_ID());
setProcessed(true);
setDocStatus(DOCSTATUS_Reversed); // may come from void
setDocAction(DOCACTION_None);
return true;
} // reverseCorrectionIt
-
+
/**
* Reverse Accrual - none
* @return false
@@ -2054,18 +2077,18 @@ public class MInOut extends X_M_InOut implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
// After reverseAccrual
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
return false;
} // reverseAccrualIt
-
- /**
+
+ /**
* Re-activate
- * @return false
+ * @return false
*/
public boolean reActivateIt()
{
@@ -2073,17 +2096,17 @@ public class MInOut extends X_M_InOut implements DocAction
// Before reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE);
if (m_processMsg != null)
- return false;
-
+ return false;
+
// After reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE);
if (m_processMsg != null)
return false;
-
+
return false;
} // reActivateIt
-
-
+
+
/*************************************************************************
* Get Summary
* @return Summary of Document
@@ -2101,7 +2124,7 @@ public class MInOut extends X_M_InOut implements DocAction
sb.append(" - ").append(getDescription());
return sb.toString();
} // getSummary
-
+
/**
* Get Process Message
* @return clear text error message
@@ -2110,7 +2133,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
return m_processMsg;
} // getProcessMsg
-
+
/**
* Get Document Owner (Responsible)
* @return AD_User_ID
@@ -2137,7 +2160,7 @@ public class MInOut extends X_M_InOut implements DocAction
{
return Env.getContextAsInt(getCtx(),"$C_Currency_ID");
} // getC_Currency_ID
-
+
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
@@ -2145,9 +2168,9 @@ public class MInOut extends X_M_InOut implements DocAction
public boolean isComplete()
{
String ds = getDocStatus();
- return DOCSTATUS_Completed.equals(ds)
+ return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
-
+
} // MInOut
diff --git a/base/src/org/compiere/model/MInOutLine.java b/base/src/org/compiere/model/MInOutLine.java
index 0a2a615040..82cd2c2b4d 100644
--- a/base/src/org/compiere/model/MInOutLine.java
+++ b/base/src/org/compiere/model/MInOutLine.java
@@ -33,7 +33,7 @@ import org.compiere.util.Util;
*
* @author Jorg Janke
* @version $Id: MInOutLine.java,v 1.5 2006/07/30 00:51:03 jjanke Exp $
- *
+ *
* @author Teo Sarca, www.arhipac.ro
* BF [ 2784194 ] Check Warehouse-Locator conflict
* https://sourceforge.net/tracker/?func=detail&aid=2784194&group_id=176962&atid=879332
@@ -41,9 +41,9 @@ import org.compiere.util.Util;
public class MInOutLine extends X_M_InOutLine
{
/**
- *
+ *
*/
- private static final long serialVersionUID = -1196352601949381166L;
+ private static final long serialVersionUID = 8630611882798722864L;
/**
* Get Ship lines Of Order Line
@@ -53,7 +53,7 @@ public class MInOutLine extends X_M_InOutLine
* @param trxName transaction
* @return array of receipt lines
*/
- public static MInOutLine[] getOfOrderLine (Properties ctx,
+ public static MInOutLine[] getOfOrderLine (Properties ctx,
int C_OrderLine_ID, String where, String trxName)
{
String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : "");
@@ -63,6 +63,24 @@ public class MInOutLine extends X_M_InOutLine
return list.toArray (new MInOutLine[list.size()]);
} // getOfOrderLine
+ /**
+ * Get Ship lines Of RMA Line
+ * @param ctx context
+ * @param M_RMALine_ID line
+ * @param where optional addition where clause
+ * @param trxName transaction
+ * @return array of receipt lines
+ */
+ public static MInOutLine[] getOfRMALine (Properties ctx,
+ int M_RMALine_ID, String where, String trxName)
+ {
+ String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : "");
+ List list = new Query(ctx, Table_Name, whereClause, trxName)
+ .setParameters(new Object[]{M_RMALine_ID})
+ .list();
+ return list.toArray (new MInOutLine[list.size()]);
+ } // getOfRMALine
+
/**
* Get Ship lines Of Order Line
* @param ctx context
@@ -74,8 +92,8 @@ public class MInOutLine extends X_M_InOutLine
{
return getOfOrderLine(ctx, C_OrderLine_ID, null, trxName);
} // get
-
-
+
+
/**************************************************************************
* Standard Constructor
* @param ctx context
@@ -133,7 +151,7 @@ public class MInOutLine extends X_M_InOutLine
private int m_M_Warehouse_ID = 0;
/** Parent */
private MInOut m_parent = null;
-
+
/**
* Get Parent
* @return parent
@@ -144,7 +162,7 @@ public class MInOutLine extends X_M_InOutLine
m_parent = new MInOut (getCtx(), getM_InOut_ID(), get_TrxName());
return m_parent;
} // getParent
-
+
/**
* Set Order Line.
* Does not set Quantity!
@@ -192,7 +210,7 @@ public class MInOutLine extends X_M_InOutLine
setUser1_ID(oLine.getUser1_ID());
setUser2_ID(oLine.getUser2_ID());
} // setOrderLine
-
+
/**
* Set Invoice Line.
* Does not set Quantity!
@@ -215,7 +233,7 @@ public class MInOutLine extends X_M_InOutLine
else
{
setM_Product_ID(M_Product_ID);
- setM_AttributeSetInstance_ID(iLine.getM_AttributeSetInstance_ID());
+ setM_AttributeSetInstance_ID(iLine.getM_AttributeSetInstance_ID());
if (M_Locator_ID == 0)
setM_Locator_ID(Qty); // requires warehouse, product, asi
else
@@ -234,7 +252,7 @@ public class MInOutLine extends X_M_InOutLine
setUser1_ID(iLine.getUser1_ID());
setUser2_ID(iLine.getUser2_ID());
} // setInvoiceLine
-
+
/**
* Get Warehouse
* @return Returns the m_Warehouse_ID.
@@ -245,7 +263,7 @@ public class MInOutLine extends X_M_InOutLine
m_M_Warehouse_ID = getParent().getM_Warehouse_ID();
return m_M_Warehouse_ID;
} // getM_Warehouse_ID
-
+
/**
* Set Warehouse
* @param warehouse_ID The m_Warehouse_ID to set.
@@ -262,12 +280,12 @@ public class MInOutLine extends X_M_InOutLine
@Override
public void setM_Locator_ID (int M_Locator_ID)
{
- if (M_Locator_ID < 0)
+ if (M_Locator_ID < 0)
throw new IllegalArgumentException ("M_Locator_ID is mandatory.");
// set to 0 explicitly to reset
- set_Value (COLUMNNAME_M_Locator_ID, new Integer(M_Locator_ID));
+ set_Value (COLUMNNAME_M_Locator_ID, new Integer(M_Locator_ID));
} // setM_Locator_ID
-
+
/**
* Set (default) Locator based on qty.
* @param Qty quantity
@@ -284,10 +302,10 @@ public class MInOutLine extends X_M_InOutLine
set_ValueNoCheck(COLUMNNAME_M_Locator_ID, null);
return;
}
-
+
// Get existing Location
- int M_Locator_ID = MStorage.getM_Locator_ID (getM_Warehouse_ID(),
- getM_Product_ID(), getM_AttributeSetInstance_ID(),
+ int M_Locator_ID = MStorage.getM_Locator_ID (getM_Warehouse_ID(),
+ getM_Product_ID(), getM_AttributeSetInstance_ID(),
Qty, get_TrxName());
// Get default Location
if (M_Locator_ID == 0)
@@ -297,7 +315,7 @@ public class MInOutLine extends X_M_InOutLine
}
setM_Locator_ID(M_Locator_ID);
} // setM_Locator_ID
-
+
/**
* Set Movement/Movement Qty
* @param Qty Entered/Movement Qty
@@ -309,7 +327,7 @@ public class MInOutLine extends X_M_InOutLine
} // setQtyInvoiced
/**
- * Set Qty Entered - enforce entered UOM
+ * Set Qty Entered - enforce entered UOM
* @param QtyEntered
*/
public void setQtyEntered (BigDecimal QtyEntered)
@@ -323,7 +341,7 @@ public class MInOutLine extends X_M_InOutLine
} // setQtyEntered
/**
- * Set Movement Qty - enforce Product UOM
+ * Set Movement Qty - enforce Product UOM
* @param MovementQty
*/
public void setMovementQty (BigDecimal MovementQty)
@@ -347,7 +365,7 @@ public class MInOutLine extends X_M_InOutLine
m_product = MProduct.get (getCtx(), getM_Product_ID());
return m_product;
} // getProduct
-
+
/**
* Set Product
* @param product product
@@ -367,7 +385,7 @@ public class MInOutLine extends X_M_InOutLine
}
setM_AttributeSetInstance_ID(0);
} // setProduct
-
+
/**
* Set M_Product_ID
* @param M_Product_ID product
@@ -381,7 +399,7 @@ public class MInOutLine extends X_M_InOutLine
super.setM_Product_ID (M_Product_ID);
setM_AttributeSetInstance_ID(0);
} // setM_Product_ID
-
+
/**
* Set Product and UOM
* @param M_Product_ID product
@@ -408,7 +426,7 @@ public class MInOutLine extends X_M_InOutLine
else
setDescription(desc + " | " + description);
} // addDescription
-
+
/**
* Get C_Project_ID
* @return project
@@ -420,7 +438,7 @@ public class MInOutLine extends X_M_InOutLine
ii = getParent().getC_Project_ID();
return ii;
} // getC_Project_ID
-
+
/**
* Get C_Activity_ID
* @return Activity
@@ -432,7 +450,7 @@ public class MInOutLine extends X_M_InOutLine
ii = getParent().getC_Activity_ID();
return ii;
} // getC_Activity_ID
-
+
/**
* Get C_Campaign_ID
* @return Campaign
@@ -444,7 +462,7 @@ public class MInOutLine extends X_M_InOutLine
ii = getParent().getC_Campaign_ID();
return ii;
} // getC_Campaign_ID
-
+
/**
* Get User2_ID
* @return User2
@@ -495,13 +513,13 @@ public class MInOutLine extends X_M_InOutLine
}
// Locator is mandatory if no charge is defined - teo_sarca BF [ 2757978 ]
if(getProduct() != null && MProduct.PRODUCTTYPE_Item.equals(getProduct().getProductType()))
- {
+ {
if (getM_Locator_ID() <= 0 && getC_Charge_ID() <= 0)
{
throw new FillMandatoryException(COLUMNNAME_M_Locator_ID);
}
}
-
+
// Get Line No
if (getLine() == 0)
{
@@ -523,7 +541,7 @@ public class MInOutLine extends X_M_InOutLine
setQtyEntered(getQtyEntered());
if (newRecord || is_ValueChanged("MovementQty"))
setMovementQty(getMovementQty());
-
+
// Order/RMA Line
if (getC_OrderLine_ID() == 0 && getM_RMALine_ID() == 0)
{
@@ -533,7 +551,7 @@ public class MInOutLine extends X_M_InOutLine
return false;
}
}
-
+
// Validate Locator/Warehouse - teo_sarca, BF [ 2784194 ]
if (getM_Locator_ID() > 0)
{
@@ -546,10 +564,10 @@ public class MInOutLine extends X_M_InOutLine
getLine());
}
}
-
+
// if (getC_Charge_ID() == 0 && getM_Product_ID() == 0)
// ;
-
+
/** Qty on instance ASI
if (getM_AttributeSetInstance_ID() != 0)
{
@@ -564,7 +582,7 @@ public class MInOutLine extends X_M_InOutLine
// Max
if (isInstance)
{
- MStorage storage = MStorage.get(getCtx(), getM_Locator_ID(),
+ MStorage storage = MStorage.get(getCtx(), getM_Locator_ID(),
getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName());
if (storage != null)
{
@@ -572,16 +590,16 @@ public class MInOutLine extends X_M_InOutLine
if (getMovementQty().compareTo(qty) > 0)
{
log.warning("Qty - Stock=" + qty + ", Movement=" + getMovementQty());
- log.saveError("QtyInsufficient", "=" + qty);
+ log.saveError("QtyInsufficient", "=" + qty);
return false;
}
}
}
} /**/
-
+
return true;
} // beforeSave
-
+
/**
* Before Delete
* @return true if drafted
@@ -620,7 +638,7 @@ public class MInOutLine extends X_M_InOutLine
{
MInvoiceLine m_il = MInvoiceLine.getOfInOutLine(this);
if (m_il == null)
- {
+ {
log.severe("No Invoice Line for: " + this.toString());
return Env.ZERO;
}
@@ -654,19 +672,19 @@ public class MInOutLine extends X_M_InOutLine
log.severe("Invalid Criteria: " + CostDistribution);
return Env.ZERO;
} // getBase
-
+
public boolean sameOrderLineUOM()
{
if (getC_OrderLine_ID() <= 0)
return false;
-
+
MOrderLine oLine = new MOrderLine(getCtx(), getC_OrderLine_ID(), get_TrxName());
if (oLine.getC_UOM_ID() != getC_UOM_ID())
return false;
-
+
// inout has orderline and both has the same UOM
return true;
}
-
+
} // MInOutLine
diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java
index a2b5e616c7..240e86ab64 100644
--- a/base/src/org/compiere/model/MInvoice.java
+++ b/base/src/org/compiere/model/MInvoice.java
@@ -44,22 +44,23 @@ import org.eevolution.model.MPPProductBOMLine;
/**
* Invoice Model.
- * Please do not set DocStatus and C_DocType_ID directly.
- * They are set in the process() method.
+ * Please do not set DocStatus and C_DocType_ID directly.
+ * They are set in the process() method.
* Use DocAction and C_DocTypeTarget_ID instead.
*
* @author Jorg Janke
* @version $Id: MInvoice.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
* @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1948157&group_id=176962
- * FR [ 2520591 ] Support multiples calendar for Org
- * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
+ * FR [ 2520591 ] Support multiples calendar for Org
+ * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* Modifications: Added RMA functionality (Ashley Ramdass)
*/
public class MInvoice extends X_C_Invoice implements DocAction
{
+
/**
- *
+ *
*/
private static final long serialVersionUID = -11169828430680188L;
@@ -90,8 +91,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
* @param setOrder set Order links
* @return Invoice
*/
- public static MInvoice copyFrom (MInvoice from, Timestamp dateDoc,
- int C_DocTypeTarget_ID, boolean isSOTrx, boolean counter,
+ public static MInvoice copyFrom (MInvoice from, Timestamp dateDoc,
+ int C_DocTypeTarget_ID, boolean isSOTrx, boolean counter,
String trxName, boolean setOrder)
{
MInvoice to = new MInvoice (from.getCtx(), 0, null);
@@ -141,6 +142,14 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (peer.getRef_Order_ID() != 0)
to.setC_Order_ID(peer.getRef_Order_ID());
}
+ // Try to find RMA link
+ if (from.getM_RMA_ID() != 0)
+ {
+ MRMA peer = new MRMA (from.getCtx(), from.getM_RMA_ID(), from.get_TrxName());
+ if (peer.getRef_RMA_ID() > 0)
+ to.setM_RMA_ID(peer.getRef_RMA_ID());
+ }
+ //
}
else
to.setRef_Invoice_ID(0);
@@ -174,8 +183,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
.append(".pdf");
return sb.toString();
} // getPDFFileName
-
-
+
+
/**
* Get MInvoice from Cache
* @param ctx context
@@ -196,8 +205,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
/** Cache */
private static CCache s_cache = new CCache("C_Invoice", 20, 2); // 2 minutes
-
-
+
+
/**************************************************************************
* Invoice Constructor
* @param ctx context
@@ -263,7 +272,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
//
if (C_DocTypeTarget_ID == 0)
C_DocTypeTarget_ID = DB.getSQLValue(null,
- "SELECT C_DocTypeInvoice_ID FROM C_DocType WHERE C_DocType_ID=?",
+ "SELECT C_DocTypeInvoice_ID FROM C_DocType WHERE C_DocType_ID=?",
order.getC_DocType_ID());
setC_DocTypeTarget_ID(C_DocTypeTarget_ID);
if (invoiceDate != null)
@@ -295,7 +304,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
//
setSalesRep_ID(ship.getSalesRep_ID());
} // MInvoice
-
+
/**
* Create Invoice from Batch Line
* @param batch batch
@@ -397,7 +406,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
for (int i = 0; i < locs.length; i++)
{
- if ((locs[i].isBillTo() && isSOTrx())
+ if ((locs[i].isBillTo() && isSOTrx())
|| (locs[i].isPayFrom() && !isSOTrx()))
setC_BPartner_Location_ID(locs[i].getC_BPartner_Location_ID());
}
@@ -500,7 +509,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setAD_User_ID(order.getBill_User_ID());
//
}
- // Check if Shipment/Receipt is based on RMA
+ // Check if Shipment/Receipt is based on RMA
if (ship.getM_RMA_ID() != 0)
{
MRMA rma = new MRMA(getCtx(), ship.getM_RMA_ID(), get_TrxName());
@@ -513,7 +522,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setC_ConversionType_ID(rmaOrder.getC_ConversionType_ID());
setPaymentRule(rmaOrder.getPaymentRule());
setC_PaymentTerm_ID(rmaOrder.getC_PaymentTerm_ID());
-
+
// Retrieves the invoice DocType
MDocType dt = MDocType.get(getCtx(), rma.getC_DocType_ID());
if (dt.getC_DocTypeInvoice_ID() != 0)
@@ -522,7 +531,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
setC_BPartner_Location_ID(rmaOrder.getBill_Location_ID());
}
-
+
} // setShipment
/**
@@ -537,7 +546,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
+ "ORDER BY IsDefault DESC";
int C_DocType_ID = DB.getSQLValue(null, sql, getAD_Client_ID(), DocBaseType);
if (C_DocType_ID <= 0)
- log.log(Level.SEVERE, "Not found for AC_Client_ID="
+ log.log(Level.SEVERE, "Not found for AC_Client_ID="
+ getAD_Client_ID() + " - " + DocBaseType);
else
{
@@ -563,7 +572,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setC_DocTypeTarget_ID(MDocType.DOCBASETYPE_APInvoice);
} // setC_DocTypeTarget_ID
-
+
/**
* Get Grand Total
* @param creditMemoAdjusted adjusted for CM (negative)
@@ -579,8 +588,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
return amt.negate();
return amt;
} // getGrandTotal
-
-
+
+
/**
* Get Invoice Lines of Invoice
* @param whereClause starting with AND
@@ -619,8 +628,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return getLines(false);
} // getLines
-
-
+
+
/**
* Renumber Lines
* @param step start and step
@@ -638,7 +647,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
m_lines = null;
} // renumberLines
-
+
/**
* Copy Lines From other Invoice.
* @param otherInvoice invoice
@@ -702,7 +711,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
fromLine.setRef_InvoiceLine_ID(line.getC_InvoiceLine_ID());
fromLine.save(get_TrxName());
}
-
+
// MZ Goodwill
// copy the landed cost
line.copyLandedCostFrom(fromLine);
@@ -716,7 +725,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
/** Reversal Flag */
private boolean m_reversal = false;
-
+
/**
* Set Reversal
* @param reversal reversal
@@ -733,7 +742,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return m_reversal;
} // isReversal
-
+
/**
* Get Taxes
* @param requery requery
@@ -743,7 +752,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
if (m_taxes != null && !requery)
return m_taxes;
-
+
final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?";
List list = new Query(getCtx(), MInvoiceTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()})
@@ -751,7 +760,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_taxes = list.toArray(new MInvoiceTax[list.size()]);
return m_taxes;
} // getTaxes
-
+
/**
* Add to Description
* @param description text
@@ -771,12 +780,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
*/
public boolean isCreditMemo()
{
- MDocType dt = MDocType.get(getCtx(),
+ MDocType dt = MDocType.get(getCtx(),
getC_DocType_ID()==0 ? getC_DocTypeTarget_ID() : getC_DocType_ID());
return MDocType.DOCBASETYPE_APCreditMemo.equals(dt.getDocBaseType())
|| MDocType.DOCBASETYPE_ARCreditMemo.equals(dt.getDocBaseType());
} // isCreditMemo
-
+
/**
* Set Processed.
* Propergate to Lines/Taxes
@@ -822,20 +831,20 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
boolean valid = getGrandTotal().compareTo(total) == 0;
setIsPayScheduleValid(valid);
-
+
// Update Schedule Lines
for (int i = 0; i < schedule.length; i++)
{
if (schedule[i].isValid() != valid)
{
schedule[i].setIsValid(valid);
- schedule[i].saveEx(get_TrxName());
+ schedule[i].saveEx(get_TrxName());
}
}
return valid;
} // validatePaySchedule
-
+
/**************************************************************************
* Before Save
* @param newRecord new
@@ -945,8 +954,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
return dt.getName() + " " + getDocumentNo();
} // getDocumentInfo
-
-
+
+
/**
* After Save
* @param newRecord new
@@ -957,7 +966,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
if (!success || newRecord)
return success;
-
+
if (is_ValueChanged("AD_Org_ID"))
{
String sql = "UPDATE C_InvoiceLine ol"
@@ -967,11 +976,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
+ "WHERE C_Invoice_ID=" + getC_Invoice_ID();
int no = DB.executeUpdate(sql, get_TrxName());
log.fine("Lines -> #" + no);
- }
+ }
return true;
} // afterSave
-
-
+
+
/**
* Set Price List (and Currency) when valid
* @param M_PriceList_ID price list
@@ -986,7 +995,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
} // setM_PriceList_ID
-
+
/**
* Get Allocated Amt in Invoice Currency
* @return pos/neg amount or null
@@ -995,7 +1004,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
BigDecimal retValue = null;
String sql = "SELECT SUM(currencyConvert(al.Amount+al.DiscountAmt+al.WriteOffAmt,"
- + "ah.C_Currency_ID, i.C_Currency_ID,ah.DateTrx,COALESCE(i.C_ConversionType_ID,0), al.AD_Client_ID,al.AD_Org_ID)) "
+ + "ah.C_Currency_ID, i.C_Currency_ID,ah.DateTrx,COALESCE(i.C_ConversionType_ID,0), al.AD_Client_ID,al.AD_Org_ID)) "
+ "FROM C_AllocationLine al"
+ " INNER JOIN C_AllocationHdr ah ON (al.C_AllocationHdr_ID=ah.C_AllocationHdr_ID)"
+ " INNER JOIN C_Invoice i ON (al.C_Invoice_ID=i.C_Invoice_ID) "
@@ -1037,7 +1046,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
public boolean testAllocation()
{
boolean change = false;
-
+
if ( isProcessed() ) {
BigDecimal alloc = getAllocatedAmt(); // absolute
if (alloc == null)
@@ -1054,7 +1063,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
log.fine("Paid=" + test
+ " (" + alloc + "=" + total + ")");
}
-
+
return change;
} // testAllocation
@@ -1078,7 +1087,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
whereClause.append(" AND AD_Client_ID=?");
params.add(Env.getAD_Client_ID(ctx));
}
-
+
POResultSet rs = new Query(ctx, MInvoice.Table_Name, whereClause.toString(), trxName)
.setParameters(params)
.scroll();
@@ -1152,7 +1161,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return MRefList.getListName(getCtx(), 131, getDocStatus());
} // getDocStatusName
-
+
/**************************************************************************
* Create PDF
* @return File or null
@@ -1211,8 +1220,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return MCurrency.getStdPrecision(getCtx(), getC_Currency_ID());
} // getPrecision
-
-
+
+
/**************************************************************************
* Process document
* @param processAction document action
@@ -1224,7 +1233,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
DocumentEngine engine = new DocumentEngine (this, getDocStatus());
return engine.processIt (processAction, getDocAction());
} // process
-
+
/** Process Message */
private String m_processMsg = null;
/** Just Prepared Flag */
@@ -1232,7 +1241,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
/**
* Unlock Document.
- * @return true if success
+ * @return true if success
*/
public boolean unlockIt()
{
@@ -1240,10 +1249,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
setProcessing(false);
return true;
} // unlockIt
-
+
/**
* Invalidate Document
- * @return true if success
+ * @return true if success
*/
public boolean invalidateIt()
{
@@ -1251,10 +1260,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDocAction(DOCACTION_Prepare);
return true;
} // invalidateIt
-
+
/**
* Prepare Document
- * @return new status (In Progress or Invalid)
+ * @return new status (In Progress or Invalid)
*/
public String prepareIt()
{
@@ -1264,7 +1273,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocTypeTarget_ID(), getAD_Org_ID());
-
+
// Lines
MInvoiceLine[] lines = getLines(true);
if (lines.length == 0)
@@ -1295,22 +1304,22 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = "Error calculating Tax";
return DocAction.STATUS_Invalid;
}
-
+
createPaySchedule();
-
+
// Credit Status
if (isSOTrx() && !isReversal())
{
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
{
- m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
+ m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
+ bp.getTotalOpenBalance()
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
return DocAction.STATUS_Invalid;
}
}
-
+
// Landed Costs
if (!isSOTrx())
{
@@ -1325,7 +1334,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
}
}
-
+
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@@ -1336,7 +1345,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDocAction(DOCACTION_Complete);
return DocAction.STATUS_InProgress;
} // prepareIt
-
+
/**
* Explode non stocked BOM.
*/
@@ -1347,7 +1356,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
+ " AND p.IsBOM='Y' AND p.IsVerified='Y' AND p.IsStocked='N')";
//
String sql = "SELECT COUNT(*) FROM C_InvoiceLine "
- + "WHERE C_Invoice_ID=? " + where;
+ + "WHERE C_Invoice_ID=? " + where;
int count = DB.getSQLValueEx(get_TrxName(), sql, getC_Invoice_ID());
while (count != 0)
{
@@ -1362,11 +1371,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
log.fine(product.getName());
// New Lines
int lineNo = line.getLine ();
-
+
//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++)
{
@@ -1383,8 +1392,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
newLine.setPrice ();
newLine.saveEx (get_TrxName());
}
- }
-
+ }
+
/*MProductBOM[] boms = MProductBOM.getBOMLines (product);
for (int j = 0; j < boms.length; j++)
{
@@ -1401,7 +1410,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
newLine.setPrice ();
newLine.save (get_TrxName());
}*/
-
+
// Convert into Comment Line
line.setM_Product_ID (0);
line.setM_AttributeSetInstance_ID (0);
@@ -1425,7 +1434,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
renumberLines (10);
} // while count != 0
} // explodeBOM
-
+
/**
* Calculate Tax and Total
* @return true if calculated
@@ -1436,7 +1445,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
// Delete Taxes
DB.executeUpdateEx("DELETE C_InvoiceTax WHERE C_Invoice_ID=" + getC_Invoice_ID(), get_TrxName());
m_taxes = null;
-
+
// Lines
BigDecimal totalLines = Env.ZERO;
ArrayList taxList = new ArrayList();
@@ -1458,7 +1467,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
totalLines = totalLines.add(line.getLineNetAmt());
}
-
+
// Taxes
BigDecimal grandTotal = totalLines;
MInvoiceTax[] taxes = getTaxes(true);
@@ -1494,14 +1503,14 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (!isTaxIncluded())
grandTotal = grandTotal.add(iTax.getTaxAmt());
}
- }
+ }
//
setTotalLines(totalLines);
setGrandTotal(grandTotal);
return true;
} // calculateTaxTotal
-
+
/**
* (Re) Create Pay Schedule
* @return true if valid schedule
@@ -1514,11 +1523,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
log.fine(pt.toString());
return pt.apply(this); // calls validate pay schedule
} // createPaySchedule
-
-
+
+
/**
* Approve Document
- * @return true if success
+ * @return true if success
*/
public boolean approveIt()
{
@@ -1526,10 +1535,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
setIsApproved(true);
return true;
} // approveIt
-
+
/**
* Reject Approval
- * @return true if success
+ * @return true if success
*/
public boolean rejectIt()
{
@@ -1537,7 +1546,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setIsApproved(false);
return true;
} // rejectIt
-
+
/**
* Complete Document
* @return new status (Complete, In Progress, Invalid, Waiting ..)
@@ -1551,11 +1560,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
-
+
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
-
+
// Implicit Approval
if (!isApproved())
approveIt();
@@ -1567,13 +1576,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
// Modifications for POSterita
//
- // MCash cash = MCash.get (getCtx(), getAD_Org_ID(),
+ // MCash cash = MCash.get (getCtx(), getAD_Org_ID(),
// getDateInvoiced(), getC_Currency_ID(), get_TrxName());
-
+
MCash cash;
-
+
int posId = Env.getContextAsInt(getCtx(),Env.POS_ID);
-
+
if (posId != 0)
{
MPOS pos = new MPOS(getCtx(),posId,get_TrxName());
@@ -1582,12 +1591,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
else
{
- cash = MCash.get (getCtx(), getAD_Org_ID(),
+ cash = MCash.get (getCtx(), getAD_Org_ID(),
getDateInvoiced(), getC_Currency_ID(), get_TrxName());
}
-
+
// End Posterita Modifications
-
+
if (cash == null || cash.get_ID() == 0)
{
m_processMsg = "@NoCashBook@";
@@ -1603,7 +1612,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
info.append("@C_Cash_ID@: " + cash.getName() + " #" + cl.getLine());
setC_CashLine_ID(cl.getC_CashLine_ID());
} // CashBook
-
+
// Update Order & Match
int matchInv = 0;
int matchPO = 0;
@@ -1616,7 +1625,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
MOrderLine ol = null;
if (line.getC_OrderLine_ID() != 0)
{
- if (isSOTrx()
+ if (isSOTrx()
|| line.getM_Product_ID() == 0)
{
ol = new MOrderLine (getCtx(), line.getC_OrderLine_ID(), get_TrxName());
@@ -1629,8 +1638,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
}
// Order Invoiced Qty updated via Matching Inv-PO
- else if (!isSOTrx()
- && line.getM_Product_ID() != 0
+ else if (!isSOTrx()
+ && line.getM_Product_ID() != 0
&& !isReversal())
{
// MatchPO is created also from MInOut when Invoice exists before Shipment
@@ -1647,8 +1656,24 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
}
+ //Update QtyInvoiced RMA Line
+ if (line.getM_RMALine_ID() != 0)
+ {
+ MRMALine rmaLine = new MRMALine (getCtx(),line.getM_RMALine_ID(), get_TrxName());
+ if (rmaLine.getQtyInvoiced() != null)
+ rmaLine.setQtyInvoiced(rmaLine.getQtyInvoiced().add(line.getQtyInvoiced()));
+ else
+ rmaLine.setQtyInvoiced(line.getQtyInvoiced());
+ if (!rmaLine.save(get_TrxName()))
+ {
+ m_processMsg = "Could not update RMA Line";
+ return DocAction.STATUS_Invalid;
+ }
+ }
+ //
+
// Matching - Inv-Shipment
- if (!isSOTrx()
+ if (!isSOTrx()
&& line.getM_InOutLine_ID() != 0
&& line.getM_Product_ID() != 0
&& !isReversal())
@@ -1658,7 +1683,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (receiptLine.getMovementQty().compareTo(matchQty) < 0)
matchQty = receiptLine.getMovementQty();
-
+
MMatchInv inv = new MMatchInv(line, getDateInvoiced(), matchQty);
if (!inv.save(get_TrxName()))
{
@@ -1667,8 +1692,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
else
matchInv++;
-
- // Elaine 2008/6/20
+
+ // Elaine 2008/6/20
String err = createMatchInvCostDetail(inv, line, receiptLine);
if(err != null && err.length() > 0) return err;
//
@@ -1678,13 +1703,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
info.append(" @M_MatchInv_ID@#").append(matchInv).append(" ");
if (matchPO > 0)
info.append(" @M_MatchPO_ID@#").append(matchPO).append(" ");
-
-
+
+
// Update BP Statistics
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
// Update total revenue and balance / credit limit (reversed on AllocationLine.processIt)
- BigDecimal invAmt = MConversionRate.convertBase(getCtx(), getGrandTotal(true), // CM adjusted
+ BigDecimal invAmt = MConversionRate.convertBase(getCtx(), getGrandTotal(true), // CM adjusted
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
if (invAmt == null)
{
@@ -1713,7 +1738,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
else
newCreditAmt = newCreditAmt.add(invAmt);
//
- log.fine("GrandTotal=" + getGrandTotal(true) + "(" + invAmt
+ log.fine("GrandTotal=" + getGrandTotal(true) + "(" + invAmt
+ ") BP Life=" + bp.getActualLifeTimeValue() + "->" + newLifeAmt
+ ", Credit=" + bp.getSO_CreditUsed() + "->" + newCreditAmt
+ ", Balance=" + bp.getTotalOpenBalance(false) + " -> " + newBalance);
@@ -1723,7 +1748,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
else
{
newBalance = newBalance.subtract(invAmt);
- log.fine("GrandTotal=" + getGrandTotal(true) + "(" + invAmt
+ log.fine("GrandTotal=" + getGrandTotal(true) + "(" + invAmt
+ ") Balance=" + bp.getTotalOpenBalance(false) + " -> " + newBalance);
}
bp.setTotalOpenBalance(newBalance);
@@ -1733,7 +1758,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = "Could not update Business Partner";
return DocAction.STATUS_Invalid;
}
-
+
// User - Last Result/Contact
if (getAD_User_ID() != 0)
{
@@ -1746,7 +1771,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
}
} // user
-
+
// Update Project
if (isSOTrx() && getC_Project_ID() != 0)
{
@@ -1754,7 +1779,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
BigDecimal amt = getGrandTotal(true);
int C_CurrencyTo_ID = project.getC_Currency_ID();
if (C_CurrencyTo_ID != getC_Currency_ID())
- amt = MConversionRate.convert(getCtx(), amt, getC_Currency_ID(), C_CurrencyTo_ID,
+ amt = MConversionRate.convert(getCtx(), amt, getC_Currency_ID(), C_CurrencyTo_ID,
getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID());
if (amt == null)
{
@@ -1768,7 +1793,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
else
newAmt = newAmt.add(amt);
log.fine("GrandTotal=" + getGrandTotal(true) + "(" + amt
- + ") Project " + project.getName()
+ + ") Project " + project.getName()
+ " - Invoiced=" + project.getInvoicedAmt() + "->" + newAmt);
project.setInvoicedAmt(newAmt);
if (!project.save(get_TrxName()))
@@ -1777,7 +1802,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
}
} // project
-
+
// User Validation
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (valid != null)
@@ -1785,7 +1810,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = valid;
return DocAction.STATUS_Invalid;
}
-
+
// Set the definite document number after completed (if needed)
setDefiniteDocumentNo();
@@ -1799,8 +1824,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
} // completeIt
-
- // Elaine 2008/6/20
+
+ // Elaine 2008/6/20
private String createMatchInvCostDetail(MMatchInv inv, MInvoiceLine m_invoiceLine, MInOutLine m_receiptLine)
{
// Get Account Schemas to create MCostDetail
@@ -1808,13 +1833,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
for(int asn = 0; asn < acctschemas.length; asn++)
{
MAcctSchema as = acctschemas[asn];
-
+
boolean skip = false;
if (as.getAD_OrgOnly_ID() != 0)
{
if (as.getOnlyOrgs() == null)
- as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
- 0, MAcctSchemaElement.ELEMENTTYPE_Organization,
+ as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
+ 0, MAcctSchemaElement.ELEMENTTYPE_Organization,
as.getAD_OrgOnly_ID()));
// Header Level Org
@@ -1824,7 +1849,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
if (skip)
continue;
-
+
BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt();
BigDecimal multiplier = inv.getQty()
.divide(m_invoiceLine.getQtyInvoiced(), 12, BigDecimal.ROUND_HALF_UP)
@@ -1849,12 +1874,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
tAmt = tAmt.add(m_invoiceLine.getLineNetAmt().multiply(multiplier));
}
}
-
+
// Different currency
MInvoice invoice = m_invoiceLine.getParent();
if (as.getC_Currency_ID() != invoice.getC_Currency_ID())
{
- tAmt = MConversionRate.convert(getCtx(), tAmt,
+ tAmt = MConversionRate.convert(getCtx(), tAmt,
invoice.getC_Currency_ID(), as.getC_Currency_ID(),
invoice.getDateAcct(), invoice.getC_ConversionType_ID(),
invoice.getAD_Client_ID(), invoice.getAD_Org_ID());
@@ -1863,7 +1888,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return "AP Invoice not convertible - " + as.getName();
}
}
-
+
tAmt = tAmt.add(LineNetAmt); //Invoice Price
// set Qty to negative value when MovementType is Vendor Returns
MInOut receipt = m_receiptLine.getParent();
@@ -1871,16 +1896,16 @@ public class MInvoice extends X_C_Invoice implements DocAction
tQty = tQty.add(inv.getQty().negate()); // Qty is set to negative value
else
tQty = tQty.add(inv.getQty());
-
- // Set Total Amount and Total Quantity from Matched Invoice
- MCostDetail.createInvoice(as, getAD_Org_ID(),
+
+ // Set Total Amount and Total Quantity from Matched Invoice
+ MCostDetail.createInvoice(as, getAD_Org_ID(),
inv.getM_Product_ID(), inv.getM_AttributeSetInstance_ID(),
m_invoiceLine.getC_InvoiceLine_ID(), 0, // No cost element
tAmt, tQty, getDescription(), inv.get_TrxName());
// end MZ
// end
}
-
+
return "";
}
//
@@ -1912,15 +1937,15 @@ public class MInvoice extends X_C_Invoice implements DocAction
// Org Must be linked to BPartner
MOrg org = MOrg.get(getCtx(), getAD_Org_ID());
- int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
+ int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
if (counterC_BPartner_ID == 0)
return null;
// Business Partner needs to be linked to Org
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
- int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
+ int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
if (counterAD_Org_ID == 0)
return null;
-
+
MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null);
// MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID);
log.info("Counter BP=" + counterBP.getName());
@@ -1944,7 +1969,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
// Deep Copy
- MInvoice counter = copyFrom(this, getDateInvoiced(),
+ MInvoice counter = copyFrom(this, getDateInvoiced(),
C_DocTypeTarget_ID, !isSOTrx(), true, get_TrxName(), true);
//
counter.setAD_Org_ID(counterAD_Org_ID);
@@ -1954,7 +1979,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
// Refernces (Should not be required
counter.setSalesRep_ID(getSalesRep_ID());
counter.save(get_TrxName());
-
+
// Update copied lines
MInvoiceLine[] counterLines = counter.getLines(true);
for (int i = 0; i < counterLines.length; i++)
@@ -1967,9 +1992,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
//
counterLine.save(get_TrxName());
}
-
+
log.fine(counter.toString());
-
+
// Document Action
if (counterDT != null)
{
@@ -1982,10 +2007,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
return counter;
} // createCounterDoc
-
+
/**
* Void Document.
- * @return true if success
+ * @return true if success
*/
public boolean voidIt()
{
@@ -1994,7 +2019,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID);
if (m_processMsg != null)
return false;
-
+
if (DOCSTATUS_Closed.equals(getDocStatus())
|| DOCSTATUS_Reversed.equals(getDocStatus())
|| DOCSTATUS_Voided.equals(getDocStatus()))
@@ -2043,20 +2068,20 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return reverseCorrectIt();
}
-
+
// After Void
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID);
if (m_processMsg != null)
return false;
-
+
setProcessed(true);
setDocAction(DOCACTION_None);
return true;
} // voidIt
-
+
/**
* Close Document.
- * @return true if success
+ * @return true if success
*/
public boolean closeIt()
{
@@ -2065,20 +2090,20 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE);
if (m_processMsg != null)
return false;
-
+
// After Close
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE);
if (m_processMsg != null)
return false;
-
+
setProcessed(true);
setDocAction(DOCACTION_None);
return true;
} // closeIt
-
+
/**
* Reverse Correction - same date
- * @return true if success
+ * @return true if success
*/
public boolean reverseCorrectIt()
{
@@ -2087,10 +2112,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT);
if (m_processMsg != null)
return false;
-
+
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());
//
- MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(),
+ MAllocationHdr[] allocations = MAllocationHdr.getOfInvoice(getCtx(),
getC_Invoice_ID(), get_TrxName());
for (int i = 0; i < allocations.length; i++)
{
@@ -2120,7 +2145,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
load(get_TrxName()); // reload allocation reversal info
// Deep Copy
- MInvoice reversal = copyFrom (this, getDateInvoiced(),
+ MInvoice reversal = copyFrom (this, getDateInvoiced(),
getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true);
if (reversal == null)
{
@@ -2128,7 +2153,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return false;
}
reversal.setReversal(true);
-
+
// Reverse Line Qty
MInvoiceLine[] rLines = reversal.getLines(false);
for (int i = 0; i < rLines.length; i++)
@@ -2167,7 +2192,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = reversal.getDocumentNo();
//
addDescription("(" + reversal.getDocumentNo() + "<-)");
-
+
// Clean up Reversed (this)
MInvoiceLine[] iLines = getLines(false);
for (int i = 0; i < iLines.length; i++)
@@ -2195,11 +2220,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDocAction(DOCACTION_None);
setC_Payment_ID(0);
setIsPaid(true);
-
+
// Create Allocation
- MAllocationHdr alloc = new MAllocationHdr(getCtx(), false, getDateAcct(),
- getC_Currency_ID(),
- Msg.translate(getCtx(), "C_Invoice_ID") + ": " + getDocumentNo() + "/" + reversal.getDocumentNo(),
+ MAllocationHdr alloc = new MAllocationHdr(getCtx(), false, getDateAcct(),
+ getC_Currency_ID(),
+ Msg.translate(getCtx(), "C_Invoice_ID") + ": " + getDocumentNo() + "/" + reversal.getDocumentNo(),
get_TrxName());
alloc.setAD_Org_ID(getAD_Org_ID());
if (alloc.save())
@@ -2209,12 +2234,12 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (!isSOTrx())
gt = gt.negate();
// Orig Line
- MAllocationLine aLine = new MAllocationLine (alloc, gt,
+ MAllocationLine aLine = new MAllocationLine (alloc, gt,
Env.ZERO, Env.ZERO, Env.ZERO);
aLine.setC_Invoice_ID(getC_Invoice_ID());
aLine.save();
// Reversal Line
- MAllocationLine rLine = new MAllocationLine (alloc, gt.negate(),
+ MAllocationLine rLine = new MAllocationLine (alloc, gt.negate(),
Env.ZERO, Env.ZERO, Env.ZERO);
rLine.setC_Invoice_ID(reversal.getC_Invoice_ID());
rLine.save();
@@ -2222,7 +2247,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (alloc.processIt(DocAction.ACTION_Complete))
alloc.save();
}
-
+
// After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
if (m_processMsg != null)
@@ -2230,10 +2255,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
return true;
} // reverseCorrectIt
-
+
/**
* Reverse Accrual - none
- * @return false
+ * @return false
*/
public boolean reverseAccrualIt()
{
@@ -2242,18 +2267,18 @@ public class MInvoice extends X_C_Invoice implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
// After reverseAccrual
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
return false;
} // reverseAccrualIt
-
- /**
+
+ /**
* Re-activate
- * @return false
+ * @return false
*/
public boolean reActivateIt()
{
@@ -2261,18 +2286,18 @@ public class MInvoice extends X_C_Invoice implements DocAction
// Before reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE);
if (m_processMsg != null)
- return false;
-
+ return false;
+
// After reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE);
if (m_processMsg != null)
return false;
-
-
+
+
return false;
} // reActivateIt
-
-
+
+
/*************************************************************************
* Get Summary
* @return Summary of Document
@@ -2290,7 +2315,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
sb.append(" - ").append(getDescription());
return sb.toString();
} // getSummary
-
+
/**
* Get Process Message
* @return clear text error message
@@ -2299,7 +2324,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return m_processMsg;
} // getProcessMsg
-
+
/**
* Get Document Owner (Responsible)
* @return AD_User_ID
@@ -2317,9 +2342,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
return getGrandTotal();
} // getApprovalAmt
-
+
/**
- *
+ *
* @param rma
*/
public void setRMA(MRMA rma)
@@ -2329,18 +2354,18 @@ public class MInvoice extends X_C_Invoice implements DocAction
setDescription(rma.getDescription());
setC_BPartner_ID(rma.getC_BPartner_ID());
setSalesRep_ID(rma.getSalesRep_ID());
-
+
setGrandTotal(rma.getAmt());
setIsSOTrx(rma.isSOTrx());
setTotalLines(rma.getAmt());
-
+
MInvoice originalInvoice = rma.getOriginalInvoice();
-
+
if (originalInvoice == null)
{
throw new IllegalStateException("Not invoiced - RMA: " + rma.getDocumentNo());
}
-
+
setC_BPartner_Location_ID(originalInvoice.getC_BPartner_Location_ID());
setAD_User_ID(originalInvoice.getAD_User_ID());
setC_Currency_ID(originalInvoice.getC_Currency_ID());
@@ -2352,7 +2377,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
setUser1_ID(originalInvoice.getUser1_ID());
setUser2_ID(originalInvoice.getUser2_ID());
}
-
+
//AZ Goodwill
private String deleteMatchInvCostDetail(MInvoiceLine line)
{
@@ -2361,22 +2386,22 @@ public class MInvoice extends X_C_Invoice implements DocAction
for(int asn = 0; asn < acctschemas.length; asn++)
{
MAcctSchema as = acctschemas[asn];
-
+
boolean skip = false;
if (as.getAD_OrgOnly_ID() != 0)
{
if (as.getOnlyOrgs() == null)
- as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
- 0, MAcctSchemaElement.ELEMENTTYPE_Organization,
+ as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
+ 0, MAcctSchemaElement.ELEMENTTYPE_Organization,
as.getAD_OrgOnly_ID()));
skip = as.isSkipOrg(getAD_Org_ID());
}
if (skip)
continue;
-
+
// update/delete Cost Detail and recalculate Current Cost
- MCostDetail cd = MCostDetail.get (getCtx(), "C_InvoiceLine_ID=?",
- line.getC_InvoiceLine_ID(), line.getM_AttributeSetInstance_ID(),
+ MCostDetail cd = MCostDetail.get (getCtx(), "C_InvoiceLine_ID=?",
+ line.getC_InvoiceLine_ID(), line.getM_AttributeSetInstance_ID(),
as.getC_AcctSchema_ID(), get_TrxName());
if (cd != null)
{
@@ -2384,7 +2409,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
cd.delete(true);
}
}
-
+
return "";
}
@@ -2395,9 +2420,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
public boolean isComplete()
{
String ds = getDocStatus();
- return DOCSTATUS_Completed.equals(ds)
+ return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
-
+
} // MInvoice
diff --git a/base/src/org/compiere/model/MInvoiceLine.java b/base/src/org/compiere/model/MInvoiceLine.java
index ca819b5997..e499869c1a 100644
--- a/base/src/org/compiere/model/MInvoiceLine.java
+++ b/base/src/org/compiere/model/MInvoiceLine.java
@@ -38,8 +38,9 @@ import org.compiere.util.Msg;
*/
public class MInvoiceLine extends X_C_InvoiceLine
{
+
/**
- *
+ *
*/
private static final long serialVersionUID = 4264055057724565805L;
@@ -73,7 +74,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
catch (Exception e)
{
- s_log.log(Level.SEVERE, sql, e);
+ s_log.log(Level.SEVERE, sql, e);
}
try
{
@@ -87,11 +88,11 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
return retValue;
} // getOfInOutLine
-
+
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MInvoiceLine.class);
-
+
/**************************************************************************
* Invoice Line Constructor
* @param ctx context
@@ -117,7 +118,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setQtyInvoiced(Env.ZERO);
}
} // MInvoiceLine
-
+
/**
* Parent Constructor
* @param invoice parent
@@ -151,7 +152,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
private boolean m_IsSOTrx = true;
private boolean m_priceSet = false;
private MProduct m_product = null;
-
+
/** Cached Name of the line */
private String m_name = null;
/** Cached Precision */
@@ -188,7 +189,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
m_parent = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName());
return m_parent;
} // getParent
-
+
/**
* Set values from Order Line.
* Does not set quantity!
@@ -230,7 +231,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setRRAmt(oLine.getRRAmt());
setRRStartDate(oLine.getRRStartDate());
} // setOrderLine
-
+
/**
* Set values from Shipment Line.
* Does not set quantity!
@@ -242,7 +243,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setC_OrderLine_ID(sLine.getC_OrderLine_ID());
// Set RMALine ID if shipment/receipt is based on RMA Doc
setM_RMALine_ID(sLine.getM_RMALine_ID());
-
+
//
setLine(sLine.getLine());
setIsDescription(sLine.isDescription());
@@ -282,7 +283,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
{
// Set Pricing details from the RMA Line on which it is based
MRMALine rmaLine = new MRMALine(getCtx(), sLine.getM_RMALine_ID(), get_TrxName());
-
+
setPrice();
setPrice(rmaLine.getAmt());
setC_Tax_ID(rmaLine.getC_Tax_ID());
@@ -329,7 +330,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
super.setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID);
} // setM_AttributeSetInstance_ID
-
+
/**************************************************************************
* Set Price for Product and PriceList.
* Uses standard SO price list of not set by invoice constructor
@@ -344,7 +345,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
throw new IllegalStateException("setPrice - PriceList unknown!");
setPrice (m_M_PriceList_ID, m_C_BPartner_ID);
} // setPrice
-
+
/**
* Set Price for Product and PriceList
* @param M_PriceList_ID price list
@@ -356,7 +357,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
return;
//
log.fine("M_PriceList_ID=" + M_PriceList_ID);
- m_productPricing = new MProductPricing (getM_Product_ID(),
+ m_productPricing = new MProductPricing (getM_Product_ID(),
C_BPartner_ID, getQtyInvoiced(), m_IsSOTrx);
m_productPricing.setM_PriceList_ID(M_PriceList_ID);
m_productPricing.setPriceDate(m_DateInvoiced);
@@ -379,7 +380,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
/**
* Set Price Entered/Actual.
- * Use this Method if the Line UOM is the Product UOM
+ * Use this Method if the Line UOM is the Product UOM
* @param PriceActual price
*/
public void setPrice (BigDecimal PriceActual)
@@ -395,12 +396,12 @@ public class MInvoiceLine extends X_C_InvoiceLine
*/
public void setPriceActual (BigDecimal PriceActual)
{
- if (PriceActual == null)
+ if (PriceActual == null)
throw new IllegalArgumentException ("PriceActual is mandatory");
set_ValueNoCheck("PriceActual", PriceActual);
} // setPriceActual
-
+
/**
* Set Tax - requires Warehouse
* @return true if found
@@ -425,14 +426,14 @@ public class MInvoiceLine extends X_C_InvoiceLine
return true;
} // setTax
-
+
/**
* Calculare Tax Amt.
* Assumes Line Net is calculated
*/
public void setTaxAmt ()
{
- BigDecimal TaxAmt = Env.ZERO;
+ BigDecimal TaxAmt = Env.ZERO;
if (getC_Tax_ID() == 0)
return;
// setLineNetAmt();
@@ -447,7 +448,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setLineTotalAmt(getLineNetAmt().add(TaxAmt));
super.setTaxAmt (TaxAmt);
} // setTaxAmt
-
+
/**
* Calculate Extended Amt.
* May or may not include tax
@@ -455,12 +456,12 @@ public class MInvoiceLine extends X_C_InvoiceLine
public void setLineNetAmt ()
{
// Calculations & Rounding
- BigDecimal net = getPriceActual().multiply(getQtyInvoiced());
+ BigDecimal net = getPriceActual().multiply(getQtyInvoiced());
if (net.scale() > getPrecision())
net = net.setScale(getPrecision(), BigDecimal.ROUND_HALF_UP);
super.setLineNetAmt (net);
} // setLineNetAmt
-
+
/**
* Set Qty Invoiced/Entered.
* @param Qty Invoiced/Ordered
@@ -481,7 +482,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
} // setQtyInvoiced
/**
- * Set Qty Entered - enforce entered UOM
+ * Set Qty Entered - enforce entered UOM
* @param QtyEntered
*/
public void setQtyEntered (BigDecimal QtyEntered)
@@ -495,7 +496,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
} // setQtyEntered
/**
- * Set Qty Invoiced - enforce Product UOM
+ * Set Qty Invoiced - enforce Product UOM
* @param QtyInvoiced
*/
public void setQtyInvoiced (BigDecimal QtyInvoiced)
@@ -529,7 +530,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setM_AttributeSetInstance_ID(0);
} // setProduct
-
+
/**
* Set M_Product_ID
* @param M_Product_ID product
@@ -543,7 +544,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
super.setM_Product_ID (M_Product_ID);
setM_AttributeSetInstance_ID(0);
} // setM_Product_ID
-
+
/**
* Set Product and UOM
* @param M_Product_ID product
@@ -555,7 +556,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
super.setC_UOM_ID(C_UOM_ID);
setM_AttributeSetInstance_ID(0);
} // setM_Product_ID
-
+
/**
* Get Product
* @return product or null
@@ -578,7 +579,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
ii = getParent().getC_Project_ID();
return ii;
} // getC_Project_ID
-
+
/**
* Get C_Activity_ID
* @return Activity
@@ -590,7 +591,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
ii = getParent().getC_Activity_ID();
return ii;
} // getC_Activity_ID
-
+
/**
* Get C_Campaign_ID
* @return Campaign
@@ -602,7 +603,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
ii = getParent().getC_Campaign_ID();
return ii;
} // getC_Campaign_ID
-
+
/**
* Get User2_ID
* @return User2
@@ -726,7 +727,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
{
if (m_precision != null)
return m_precision.intValue();
-
+
String sql = "SELECT c.StdPrecision "
+ "FROM C_Currency c INNER JOIN C_Invoice x ON (x.C_Currency_ID=c.C_Currency_ID) "
+ "WHERE x.C_Invoice_ID=?";
@@ -739,7 +740,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
m_precision = new Integer(i);
return m_precision.intValue();
} // getPrecision
-
+
/**
* Is Tax Included in Amount
* @return true if tax is included
@@ -755,8 +756,8 @@ public class MInvoiceLine extends X_C_InvoiceLine
MPriceList pl = MPriceList.get(getCtx(), m_M_PriceList_ID, get_TrxName());
return pl.isTaxIncluded();
} // isTaxIncluded
-
-
+
+
/**************************************************************************
* Before Save
* @param newRecord
@@ -779,12 +780,12 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
else // Set Product Price
{
- if (!m_priceSet
+ if (!m_priceSet
&& Env.ZERO.compareTo(getPriceActual()) == 0
&& Env.ZERO.compareTo(getPriceList()) == 0)
setPrice();
}
-
+
// Set Tax
if (getC_Tax_ID() == 0)
setTax();
@@ -818,12 +819,12 @@ public class MInvoiceLine extends X_C_InvoiceLine
//
return true;
} // beforeSave
-
+
/**
* Recalculate invoice tax
* @param oldTax true if the old C_Tax_ID should be used
* @return true if success, false otherwise
- *
+ *
* @author teo_sarca [ 1583825 ]
*/
private boolean updateInvoiceTax(boolean oldTax) {
@@ -837,7 +838,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
return true;
}
-
+
/**
* After Save
* @param newRecord new
@@ -868,21 +869,21 @@ public class MInvoiceLine extends X_C_InvoiceLine
return success;
return updateHeaderTax();
} // afterDelete
-
+
/**
* Update Tax & Header
* @return true if header updated with tax
*/
private boolean updateHeaderTax()
{
- // Update header only if the document is not processed - teo_sarca BF [ 2317305 ]
+ // Update header only if the document is not processed - teo_sarca BF [ 2317305 ]
if (isProcessed() && !is_ValueChanged(COLUMNNAME_Processed))
return true;
-
+
// Recalculate Tax for this Tax
if (!updateInvoiceTax(false))
return false;
-
+
// Update Invoice Header
String sql = "UPDATE C_Invoice i"
+ " SET TotalLines="
@@ -905,11 +906,11 @@ public class MInvoiceLine extends X_C_InvoiceLine
if (no != 1)
log.warning("(2) #" + no);
m_parent = null;
-
+
return no == 1;
} // updateHeaderTax
-
-
+
+
/**************************************************************************
* Allocate Landed Costs
* @return error message or ""
@@ -925,7 +926,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
int no = DB.executeUpdate(sql, get_TrxName());
if (no != 0)
log.info("Deleted #" + no);
-
+
int inserted = 0;
// *** Single Criteria ***
if (lcs.length == 1)
@@ -963,7 +964,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
MLandedCostAllocation lca = new MLandedCostAllocation (this, lc.getM_CostElement_ID());
lca.setM_Product_ID(iol.getM_Product_ID());
lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID());
- BigDecimal base = iol.getBase(lc.getLandedCostDistribution());
+ BigDecimal base = iol.getBase(lc.getLandedCostDistribution());
lca.setBase(base);
// MZ Goodwill
// add set Qty from InOutLine
@@ -999,22 +1000,22 @@ public class MInvoiceLine extends X_C_InvoiceLine
// end MZ
if (lca.save())
return "";
- return "Cannot save single line Allocation = " + lc;
+ return "Cannot save single line Allocation = " + lc;
}
// Single Product
else if (lc.getM_Product_ID() != 0)
{
- MLandedCostAllocation lca = new MLandedCostAllocation (this, lc.getM_CostElement_ID());
+ MLandedCostAllocation lca = new MLandedCostAllocation (this, lc.getM_CostElement_ID());
lca.setM_Product_ID(lc.getM_Product_ID()); // No ASI
lca.setAmt(getLineNetAmt());
if (lca.save())
return "";
- return "Cannot save Product Allocation = " + lc;
+ return "Cannot save Product Allocation = " + lc;
}
else
return "No Reference for " + lc;
}
-
+
// *** Multiple Criteria ***
String LandedCostDistribution = lcs[0].getLandedCostDistribution();
int M_CostElement_ID = lcs[0].getM_CostElement_ID();
@@ -1039,7 +1040,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
MInOutLine[] lines = ship.getLines();
for (int i = 0; i < lines.length; i++)
{
- if (lines[i].isDescription() // decription or no product
+ if (lines[i].isDescription() // decription or no product
|| lines[i].getM_Product_ID() == 0)
continue;
if (lc.getM_Product_ID() == 0 // no restriction or product match
@@ -1072,7 +1073,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
MLandedCostAllocation lca = new MLandedCostAllocation (this, lcs[0].getM_CostElement_ID());
lca.setM_Product_ID(iol.getM_Product_ID());
lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID());
- BigDecimal base = iol.getBase(LandedCostDistribution);
+ BigDecimal base = iol.getBase(LandedCostDistribution);
lca.setBase(base);
// MZ Goodwill
// add set Qty from InOutLine
@@ -1088,7 +1089,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
return "Cannot save line Allocation = " + lca;
inserted++;
}
-
+
log.info("Inserted " + inserted);
allocateLandedCostRounding();
return "";
@@ -1106,7 +1107,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
for (int i = 0; i < allocations.length; i++)
{
MLandedCostAllocation allocation = allocations[i];
- if (largestAmtAllocation == null
+ if (largestAmtAllocation == null
|| allocation.getAmt().compareTo(largestAmtAllocation.getAmt()) > 0)
largestAmtAllocation = allocation;
allocationAmt = allocationAmt.add(allocation.getAmt());
@@ -1116,7 +1117,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
{
largestAmtAllocation.setAmt(largestAmtAllocation.getAmt().add(difference));
largestAmtAllocation.save();
- log.config("Difference=" + difference
+ log.config("Difference=" + difference
+ ", C_LandedCostAllocation_ID=" + largestAmtAllocation.getC_LandedCostAllocation_ID()
+ ", Amt" + largestAmtAllocation.getAmt());
}
@@ -1170,7 +1171,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
list.toArray(landedCost);
return landedCost;
} // getLandedCost
-
+
/**
* Copy LandedCost From other InvoiceLine.
* @param otherInvoiceLine invoiceline
@@ -1197,7 +1198,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
return count;
} // copyLinesFrom
// end MZ
-
+
/**
* @param rmaline
*/
@@ -1212,7 +1213,6 @@ public class MInvoiceLine extends X_C_InvoiceLine
setC_UOM_ID(rmaLine.getC_UOM_ID());
setC_Tax_ID(rmaLine.getC_Tax_ID());
setPrice(rmaLine.getAmt());
- setQty(rmaLine.getQty());
setLineNetAmt();
setTaxAmt();
setLineTotalAmt(rmaLine.getLineNetAmt());
@@ -1220,7 +1220,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
setC_Activity_ID(rmaLine.getC_Activity_ID());
setC_Campaign_ID(rmaLine.getC_Campaign_ID());
}
-
+
/**
* @return matched qty
*/
diff --git a/base/src/org/compiere/model/MRMA.java b/base/src/org/compiere/model/MRMA.java
index 5e5979ff89..759f901e11 100644
--- a/base/src/org/compiere/model/MRMA.java
+++ b/base/src/org/compiere/model/MRMA.java
@@ -32,7 +32,7 @@ import org.compiere.util.Msg;
/**
* RMA Model
- *
+ *
* @author Jorg Janke
* @version $Id: MRMA.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*
@@ -41,9 +41,9 @@ import org.compiere.util.Msg;
public class MRMA extends X_M_RMA implements DocAction
{
/**
- *
+ *
*/
- private static final long serialVersionUID = -2967208431264929454L;
+ private static final long serialVersionUID = -3310525910645254261L;
/**
* Standard Constructor
@@ -77,12 +77,12 @@ public class MRMA extends X_M_RMA implements DocAction
{
super(ctx, rs, trxName);
} // MRMA
-
+
/** Lines */
private MRMALine[] m_lines = null;
/** The Shipment */
private MInOut m_inout = null;
-
+
/**
* Get Lines
* @param requery requery
@@ -123,12 +123,12 @@ public class MRMA extends X_M_RMA implements DocAction
{
pstmt = null;
}
-
+
m_lines = new MRMALine[list.size ()];
list.toArray (m_lines);
return m_lines;
} // getLines
-
+
/**
* Get Shipment
* @return shipment
@@ -139,7 +139,7 @@ public class MRMA extends X_M_RMA implements DocAction
m_inout = new MInOut (getCtx(), getInOut_ID(), get_TrxName());
return m_inout;
} // getShipment
-
+
/**
* Get the original order on which the shipment/receipt defined is based upon.
* @return order
@@ -153,7 +153,7 @@ public class MRMA extends X_M_RMA implements DocAction
}
return new MOrder(getCtx(), shipment.getC_Order_ID(), get_TrxName());
}
-
+
/**
* Get the original invoice on which the shipment/receipt defined is based upon.
* @return invoice
@@ -165,9 +165,9 @@ public class MRMA extends X_M_RMA implements DocAction
{
return null;
}
-
+
int invId = 0;
-
+
if (shipment.getC_Invoice_ID() != 0)
{
invId = shipment.getC_Invoice_ID();
@@ -177,15 +177,15 @@ public class MRMA extends X_M_RMA implements DocAction
String sqlStmt = "SELECT C_Invoice_ID FROM C_Invoice WHERE C_Order_ID=?";
invId = DB.getSQLValue(null, sqlStmt, shipment.getC_Order_ID());
}
-
+
if (invId <= 0)
{
return null;
}
-
+
return new MInvoice(getCtx(), invId, get_TrxName());
}
-
+
/**
* Set M_InOut_ID
* @param M_InOut_ID id
@@ -198,8 +198,8 @@ public class MRMA extends X_M_RMA implements DocAction
setC_BPartner_ID(0);
m_inout = null;
} // setM_InOut_ID
-
-
+
+
/**
* Get Document Info
* @return document info (untranslated)
@@ -241,7 +241,7 @@ public class MRMA extends X_M_RMA implements DocAction
// return re.getPDF(file);
} // createPDF
-
+
/**
* Before Save
* Set BPartner, Currency
@@ -266,7 +266,7 @@ public class MRMA extends X_M_RMA implements DocAction
{
MOrder order = new MOrder (getCtx(), m_inout.getC_Order_ID(), get_TrxName());
setC_Currency_ID(order.getC_Currency_ID());
- }
+ }
else if (m_inout.getC_Invoice_ID() != 0)
{
MInvoice invoice = new MInvoice (getCtx(), m_inout.getC_Invoice_ID(), get_TrxName());
@@ -274,18 +274,18 @@ public class MRMA extends X_M_RMA implements DocAction
}
}
}
-
+
// Verification whether Shipment/Receipt matches RMA for sales transaction
if (m_inout != null && m_inout.isSOTrx() != isSOTrx())
{
log.saveError("RMA.IsSOTrx <> InOut.IsSOTrx", "");
return false;
}
-
+
return true;
} // beforeSave
-
-
+
+
/**************************************************************************
* Process document
* @param processAction document action
@@ -297,7 +297,7 @@ public class MRMA extends X_M_RMA implements DocAction
DocumentEngine engine = new DocumentEngine (this, getDocStatus());
return engine.processIt (processAction, getDocAction());
} // process
-
+
/** Process Message */
private String m_processMsg = null;
/** Just Prepared Flag */
@@ -305,7 +305,7 @@ public class MRMA extends X_M_RMA implements DocAction
/**
* Unlock Document.
- * @return true if success
+ * @return true if success
*/
public boolean unlockIt()
{
@@ -313,20 +313,20 @@ public class MRMA extends X_M_RMA implements DocAction
setProcessing(false);
return true;
} // unlockIt
-
+
/**
* Invalidate Document
- * @return true if success
+ * @return true if success
*/
public boolean invalidateIt()
{
log.info("invalidateIt - " + toString());
return true;
} // invalidateIt
-
+
/**
* Prepare Document
- * @return new status (In Progress or Invalid)
+ * @return new status (In Progress or Invalid)
*/
public String prepareIt()
{
@@ -335,17 +335,16 @@ public class MRMA extends X_M_RMA implements DocAction
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
- MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
MRMALine[] lines = getLines(false);
if (lines.length == 0)
{
m_processMsg = "@NoLines@";
return DocAction.STATUS_Invalid;
}
-
+
// Updates Amount
setAmt(getTotalAmount());
-
+
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@@ -353,10 +352,10 @@ public class MRMA extends X_M_RMA implements DocAction
m_justPrepared = true;
return DocAction.STATUS_InProgress;
} // prepareIt
-
+
/**
* Approve Document
- * @return true if success
+ * @return true if success
*/
public boolean approveIt()
{
@@ -364,10 +363,10 @@ public class MRMA extends X_M_RMA implements DocAction
setIsApproved(true);
return true;
} // approveIt
-
+
/**
* Reject Approval
- * @return true if success
+ * @return true if success
*/
public boolean rejectIt()
{
@@ -375,7 +374,7 @@ public class MRMA extends X_M_RMA implements DocAction
setIsApproved(false);
return true;
} // rejectIt
-
+
/**
* Complete Document
* @return new status (Complete, In Progress, Invalid, Waiting ..)
@@ -389,7 +388,7 @@ public class MRMA extends X_M_RMA implements DocAction
if (!DocAction.STATUS_InProgress.equals(status))
return status;
}
-
+
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE);
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
@@ -407,6 +406,12 @@ public class MRMA extends X_M_RMA implements DocAction
return DocAction.STATUS_InProgress;
}
*/
+
+ // Counter Documents
+ MRMA counter = createCounterDoc();
+ if (counter != null)
+ m_processMsg = "@CounterDoc@: RMA=" + counter.getDocumentNo();
+
// User Validation
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
if (valid != null)
@@ -423,7 +428,7 @@ public class MRMA extends X_M_RMA implements DocAction
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
} // completeIt
-
+
/**
* Set the definite document number after completed
*/
@@ -441,9 +446,189 @@ public class MRMA extends X_M_RMA implements DocAction
}
}
+ /**************************************************************************
+ * Create Counter Document
+ * @return InOut
+ */
+ private MRMA createCounterDoc()
+ {
+ // Is this a counter doc ?
+ if (getRef_RMA_ID() > 0)
+ return null;
+
+ // Org Must be linked to BPartner
+ MOrg org = MOrg.get(getCtx(), getAD_Org_ID());
+ int counterC_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
+ if (counterC_BPartner_ID == 0)
+ return null;
+ // Business Partner needs to be linked to Org
+ MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
+ int counterAD_Org_ID = bp.getAD_OrgBP_ID_Int();
+ if (counterAD_Org_ID == 0)
+ return null;
+
+ // Document Type
+ int C_DocTypeTarget_ID = 0;
+ MDocTypeCounter counterDT = MDocTypeCounter.getCounterDocType(getCtx(), getC_DocType_ID());
+ if (counterDT != null)
+ {
+ log.fine(counterDT.toString());
+ if (!counterDT.isCreateCounter() || !counterDT.isValid())
+ return null;
+ C_DocTypeTarget_ID = counterDT.getCounter_C_DocType_ID();
+ }
+ else // indirect
+ {
+ C_DocTypeTarget_ID = MDocTypeCounter.getCounterDocType_ID(getCtx(), getC_DocType_ID());
+ log.fine("Indirect C_DocTypeTarget_ID=" + C_DocTypeTarget_ID);
+ if (C_DocTypeTarget_ID <= 0)
+ return null;
+ }
+
+ // Deep Copy
+ MRMA counter = copyFrom(this, C_DocTypeTarget_ID, !isSOTrx(), true, get_TrxName());
+
+ //
+ counter.setAD_Org_ID(counterAD_Org_ID);
+ counter.setC_BPartner_ID(counterC_BPartner_ID);
+ counter.save(get_TrxName());
+
+ // Update copied lines
+ MRMALine[] counterLines = counter.getLines(true);
+ for (int i = 0; i < counterLines.length; i++)
+ {
+ MRMALine counterLine = counterLines[i];
+ counterLine.setClientOrg(counter);
+ //
+ counterLine.save(get_TrxName());
+ }
+
+ log.fine(counter.toString());
+
+ // Document Action
+ if (counterDT != null)
+ {
+ if (counterDT.getDocAction() != null)
+ {
+ counter.setDocAction(counterDT.getDocAction());
+ counter.processIt(counterDT.getDocAction());
+ counter.save(get_TrxName());
+ }
+ }
+ return counter;
+ } // createCounterDoc
+
+ /**
+ * Create new RMA by copying
+ * @param from RMA
+ * @param C_DocType_ID doc type
+ * @param isSOTrx sales order
+ * @param counter create counter links
+ * @param trxName trx
+ * @return MRMA
+ */
+ public static MRMA copyFrom (MRMA from, int C_DocType_ID, boolean isSOTrx, boolean counter, String trxName)
+ {
+ MRMA to = new MRMA (from.getCtx(), 0, null);
+ to.set_TrxName(trxName);
+ copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID());
+ to.set_ValueNoCheck ("M_RMA_ID", I_ZERO);
+ to.set_ValueNoCheck ("DocumentNo", null);
+ to.setDocStatus (DOCSTATUS_Drafted); // Draft
+ to.setDocAction(DOCACTION_Complete);
+ to.setC_DocType_ID (C_DocType_ID);
+ to.setIsSOTrx(isSOTrx);
+ to.setIsApproved (false);
+ to.setProcessed (false);
+ to.setProcessing(false);
+
+ to.setName(from.getName());
+ to.setDescription(from.getDescription());
+ to.setSalesRep_ID(from.getSalesRep_ID());
+ to.setHelp(from.getHelp());
+ to.setM_RMAType_ID(from.getM_RMAType_ID());
+ to.setAmt(from.getAmt());
+
+ to.setC_Order_ID(0);
+ // Try to find Order/Shipment/Receipt link
+ if (from.getC_Order_ID() != 0)
+ {
+ MOrder peer = new MOrder (from.getCtx(), from.getC_Order_ID(), from.get_TrxName());
+ if (peer.getRef_Order_ID() != 0)
+ to.setC_Order_ID(peer.getRef_Order_ID());
+ }
+ if (from.getInOut_ID() != 0)
+ {
+ MInOut peer = new MInOut (from.getCtx(), from.getInOut_ID(), from.get_TrxName());
+ if (peer.getRef_InOut_ID() != 0)
+ to.setInOut_ID(peer.getRef_InOut_ID());
+ }
+ to.set_Value("Ref_RMA_ID", from.getM_RMA_ID());
+
+ if (!to.save(trxName))
+ throw new IllegalStateException("Could not create RMA");
+ if (counter)
+ from.set_Value("Ref_RMA_ID", to.getM_RMA_ID());
+
+ if (to.copyLinesFrom(from, counter) == 0)
+ throw new IllegalStateException("Could not create RMA Lines");
+
+ return to;
+ } // copyFrom
+
+ /**
+ * Copy Lines From other RMA
+ * @param otherRMA
+ * @param counter set counter info
+ * @param setOrder set order link
+ * @return number of lines copied
+ */
+ public int copyLinesFrom (MRMA otherRMA, boolean counter)
+ {
+ if (isProcessed() || otherRMA == null)
+ return 0;
+ MRMALine[] fromLines = otherRMA.getLines(false);
+ int count = 0;
+ for (int i = 0; i < fromLines.length; i++)
+ {
+ MRMALine line = new MRMALine(getCtx(), 0, null);
+ MRMALine fromLine = fromLines[i];
+ line.set_TrxName(get_TrxName());
+ if (counter) // header
+ PO.copyValues(fromLine, line, getAD_Client_ID(), getAD_Org_ID());
+ else
+ PO.copyValues(fromLine, line, fromLine.getAD_Client_ID(), fromLine.getAD_Org_ID());
+ line.setM_RMA_ID(getM_RMA_ID());
+ line.set_ValueNoCheck ("M_RMALine_ID", I_ZERO); // new
+ if (counter)
+ {
+ line.set_Value("Ref_RMALine_ID", fromLine.getM_RMALine_ID());
+ if (fromLine.getM_InOutLine_ID() != 0)
+ {
+ MInOutLine peer = new MInOutLine (getCtx(), fromLine.getM_InOutLine_ID(), get_TrxName());
+ if (peer.getRef_InOutLine_ID() != 0)
+ line.setM_InOutLine_ID(peer.getRef_InOutLine_ID());
+ }
+ }
+ //
+ line.setProcessed(false);
+ if (line.save(get_TrxName()))
+ count++;
+ // Cross Link
+ if (counter)
+ {
+ fromLine.set_Value("Ref_RMALine_ID", line.getM_RMALine_ID());
+ fromLine.save(get_TrxName());
+ }
+ }
+ if (fromLines.length != count)
+ log.log(Level.SEVERE, "Line difference - From=" + fromLines.length + " <> Saved=" + count);
+ return count;
+ } // copyLinesFrom
+
/**
* Void Document.
- * @return true if success
+ * @return true if success
*/
public boolean voidIt()
{
@@ -452,7 +637,7 @@ public class MRMA extends X_M_RMA implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID);
if (m_processMsg != null)
return false;
-
+
MRMALine lines[] = getLines(true);
// Set Qty and Amt on all lines to be Zero
for (MRMALine rmaLine : lines)
@@ -460,30 +645,30 @@ public class MRMA extends X_M_RMA implements DocAction
rmaLine.addDescription(Msg.getMsg(getCtx(), "Voided") + " (" + rmaLine.getQty() + ")");
rmaLine.setQty(Env.ZERO);
rmaLine.setAmt(Env.ZERO);
-
+
if (!rmaLine.save())
{
m_processMsg = "Could not update line";
}
}
-
+
addDescription(Msg.getMsg(getCtx(), "Voided"));
setAmt(Env.ZERO);
-
+
// After Void
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID);
if (m_processMsg != null)
return false;
-
+
setProcessed(true);
setDocAction(DOCACTION_None);
return true;
} // voidIt
-
+
/**
* Close Document.
* Cancel not delivered Qunatities
- * @return true if success
+ * @return true if success
*/
public boolean closeIt()
{
@@ -496,13 +681,13 @@ public class MRMA extends X_M_RMA implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE);
if (m_processMsg != null)
return false;
-
+
return true;
} // closeIt
-
+
/**
* Reverse Correction
- * @return true if success
+ * @return true if success
*/
public boolean reverseCorrectIt()
{
@@ -511,18 +696,18 @@ public class MRMA extends X_M_RMA implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT);
if (m_processMsg != null)
return false;
-
+
// After reverseCorrect
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT);
if (m_processMsg != null)
return false;
-
+
return false;
} // reverseCorrectionIt
-
+
/**
* Reverse Accrual - none
- * @return true if success
+ * @return true if success
*/
public boolean reverseAccrualIt()
{
@@ -531,18 +716,18 @@ public class MRMA extends X_M_RMA implements DocAction
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
// After reverseAccrual
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL);
if (m_processMsg != null)
return false;
-
+
return false;
} // reverseAccrualIt
-
- /**
+
+ /**
* Re-activate
- * @return true if success
+ * @return true if success
*/
public boolean reActivateIt()
{
@@ -550,16 +735,16 @@ public class MRMA extends X_M_RMA implements DocAction
// Before reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE);
if (m_processMsg != null)
- return false;
-
+ return false;
+
// After reActivate
m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE);
if (m_processMsg != null)
return false;
-
+
return false;
} // reActivateIt
-
+
/**
* Set Processed.
* Propagate to Lines
@@ -577,7 +762,7 @@ public class MRMA extends X_M_RMA implements DocAction
m_lines = null;
log.fine("setProcessed - " + processed + " - Lines=" + noLine);
} // setProcessed
-
+
/**
* Add to Description
* @param description text
@@ -590,7 +775,7 @@ public class MRMA extends X_M_RMA implements DocAction
else
setDescription(desc + " | " + description);
} // addDescription
-
+
/**
* Get the total amount based on the lines
* @return Total Amount
@@ -598,17 +783,17 @@ public class MRMA extends X_M_RMA implements DocAction
public BigDecimal getTotalAmount()
{
MRMALine lines[] = this.getLines(true);
-
+
BigDecimal amt = Env.ZERO;
-
+
for (MRMALine line : lines)
{
amt = amt.add(line.getLineNetAmt());
}
-
+
return amt;
}
-
+
/**
* Updates the amount on the document
*/
@@ -616,7 +801,7 @@ public class MRMA extends X_M_RMA implements DocAction
{
setAmt(getTotalAmount());
}
-
+
/*************************************************************************
* Get Summary
* @return Summary of Document
@@ -634,7 +819,7 @@ public class MRMA extends X_M_RMA implements DocAction
sb.append(" - ").append(getDescription());
return sb.toString();
} // getSummary
-
+
/**
* Retrieves all the charge lines that is present on the document
* @return Charge Lines
@@ -645,39 +830,39 @@ public class MRMA extends X_M_RMA implements DocAction
whereClause.append("IsActive='Y' AND M_RMA_ID=");
whereClause.append(get_ID());
whereClause.append(" AND C_Charge_ID IS NOT null");
-
+
int rmaLineIds[] = MRMALine.getAllIDs(MRMALine.Table_Name, whereClause.toString(), get_TrxName());
-
+
ArrayList chargeLineList = new ArrayList();
-
+
for (int i = 0; i < rmaLineIds.length; i++)
{
MRMALine rmaLine = new MRMALine(getCtx(), rmaLineIds[i], get_TrxName());
chargeLineList.add(rmaLine);
}
-
+
MRMALine lines[] = new MRMALine[chargeLineList.size()];
chargeLineList.toArray(lines);
-
+
return lines;
}
-
+
/**
- * Get whether Tax is included (based on the original order)
+ * Get whether Tax is included (based on the original order)
* @return True if tax is included
*/
public boolean isTaxIncluded()
{
MOrder order = getOriginalOrder();
-
+
if (order != null && order.get_ID() != 0)
{
return order.isTaxIncluded();
}
-
+
return true;
}
-
+
/**
* Get Process Message
* @return clear text error message
@@ -686,7 +871,7 @@ public class MRMA extends X_M_RMA implements DocAction
{
return m_processMsg;
} // getProcessMsg
-
+
/**
* Get Document Owner (Responsible)
* @return AD_User_ID
@@ -712,9 +897,9 @@ public class MRMA extends X_M_RMA implements DocAction
public boolean isComplete()
{
String ds = getDocStatus();
- return DOCSTATUS_Completed.equals(ds)
+ return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
-
+
} // MRMA
diff --git a/base/src/org/compiere/model/X_M_RMA.java b/base/src/org/compiere/model/X_M_RMA.java
index 1ea76b0166..7f845444e5 100644
--- a/base/src/org/compiere/model/X_M_RMA.java
+++ b/base/src/org/compiere/model/X_M_RMA.java
@@ -26,15 +26,15 @@ import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
/** Generated Model for M_RMA
- * @author Adempiere (generated)
+ * @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
-public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
+public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
{
/**
*
*/
- private static final long serialVersionUID = 20081221L;
+ private static final long serialVersionUID = 20090601L;
/** Standard Constructor */
public X_M_RMA (Properties ctx, int M_RMA_ID, String trxName)
@@ -52,8 +52,8 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
setIsApproved (false);
setIsSOTrx (false);
// @IsSOTrx@
- setM_RMA_ID (0);
setM_RMAType_ID (0);
+ setM_RMA_ID (0);
setName (null);
setProcessed (false);
setSalesRep_ID (0);
@@ -67,7 +67,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** AccessLevel
- * @return 1 - Org
+ * @return 1 - Org
*/
protected int get_AccessLevel()
{
@@ -89,7 +89,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Amount.
- @param Amt
+ @param Amt
Amount
*/
public void setAmt (BigDecimal Amt)
@@ -100,7 +100,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Amount.
@return Amount
*/
- public BigDecimal getAmt ()
+ public BigDecimal getAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Amt);
if (bd == null)
@@ -108,7 +108,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
return bd;
}
- public I_C_BPartner getC_BPartner() throws RuntimeException
+ public I_C_BPartner getC_BPartner() throws RuntimeException
{
Class> clazz = MTable.getClass(I_C_BPartner.Table_Name);
I_C_BPartner result = null;
@@ -125,21 +125,21 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Business Partner .
- @param C_BPartner_ID
+ @param C_BPartner_ID
Identifies a Business Partner
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
- if (C_BPartner_ID < 1)
+ if (C_BPartner_ID < 1)
set_Value (COLUMNNAME_C_BPartner_ID, null);
- else
+ else
set_Value (COLUMNNAME_C_BPartner_ID, Integer.valueOf(C_BPartner_ID));
}
/** Get Business Partner .
@return Identifies a Business Partner
*/
- public int getC_BPartner_ID ()
+ public int getC_BPartner_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_BPartner_ID);
if (ii == null)
@@ -147,7 +147,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
return ii.intValue();
}
- public I_C_Currency getC_Currency() throws RuntimeException
+ public I_C_Currency getC_Currency() throws RuntimeException
{
Class> clazz = MTable.getClass(I_C_Currency.Table_Name);
I_C_Currency result = null;
@@ -164,21 +164,21 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Currency.
- @param C_Currency_ID
+ @param C_Currency_ID
The Currency for this record
*/
public void setC_Currency_ID (int C_Currency_ID)
{
- if (C_Currency_ID < 1)
+ if (C_Currency_ID < 1)
set_Value (COLUMNNAME_C_Currency_ID, null);
- else
+ else
set_Value (COLUMNNAME_C_Currency_ID, Integer.valueOf(C_Currency_ID));
}
/** Get Currency.
@return The Currency for this record
*/
- public int getC_Currency_ID ()
+ public int getC_Currency_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Currency_ID);
if (ii == null)
@@ -187,20 +187,21 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Document Type.
- @param C_DocType_ID
+ @param C_DocType_ID
Document type or rules
*/
public void setC_DocType_ID (int C_DocType_ID)
{
if (C_DocType_ID < 0)
- throw new IllegalArgumentException ("C_DocType_ID is mandatory.");
- set_Value (COLUMNNAME_C_DocType_ID, Integer.valueOf(C_DocType_ID));
+ set_Value (COLUMNNAME_C_DocType_ID, null);
+ else
+ set_Value (COLUMNNAME_C_DocType_ID, Integer.valueOf(C_DocType_ID));
}
/** Get Document Type.
@return Document type or rules
*/
- public int getC_DocType_ID ()
+ public int getC_DocType_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_DocType_ID);
if (ii == null)
@@ -208,7 +209,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
return ii.intValue();
}
- public I_C_Order getC_Order() throws RuntimeException
+ public I_C_Order getC_Order() throws RuntimeException
{
Class> clazz = MTable.getClass(I_C_Order.Table_Name);
I_C_Order result = null;
@@ -225,21 +226,21 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Order.
- @param C_Order_ID
+ @param C_Order_ID
Order
*/
public void setC_Order_ID (int C_Order_ID)
{
- if (C_Order_ID < 1)
+ if (C_Order_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_Order_ID, null);
- else
+ else
set_ValueNoCheck (COLUMNNAME_C_Order_ID, Integer.valueOf(C_Order_ID));
}
/** Get Order.
@return Order
*/
- public int getC_Order_ID ()
+ public int getC_Order_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Order_ID);
if (ii == null)
@@ -248,7 +249,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Description.
- @param Description
+ @param Description
Optional short description of the record
*/
public void setDescription (String Description)
@@ -259,7 +260,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Description.
@return Optional short description of the record
*/
- public String getDescription ()
+ public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
@@ -295,19 +296,19 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Wait Complete = WC */
public static final String DOCACTION_WaitComplete = "WC";
/** Set Document Action.
- @param DocAction
+ @param DocAction
The targeted status of the document
*/
public void setDocAction (String DocAction)
{
- if (DocAction == null) throw new IllegalArgumentException ("DocAction is mandatory");
+
set_Value (COLUMNNAME_DocAction, DocAction);
}
/** Get Document Action.
@return The targeted status of the document
*/
- public String getDocAction ()
+ public String getDocAction ()
{
return (String)get_Value(COLUMNNAME_DocAction);
}
@@ -339,38 +340,36 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Waiting Confirmation = WC */
public static final String DOCSTATUS_WaitingConfirmation = "WC";
/** Set Document Status.
- @param DocStatus
+ @param DocStatus
The current status of the document
*/
public void setDocStatus (String DocStatus)
{
- if (DocStatus == null) throw new IllegalArgumentException ("DocStatus is mandatory");
+
set_Value (COLUMNNAME_DocStatus, DocStatus);
}
/** Get Document Status.
@return The current status of the document
*/
- public String getDocStatus ()
+ public String getDocStatus ()
{
return (String)get_Value(COLUMNNAME_DocStatus);
}
/** Set Document No.
- @param DocumentNo
+ @param DocumentNo
Document sequence number of the document
*/
public void setDocumentNo (String DocumentNo)
{
- if (DocumentNo == null)
- throw new IllegalArgumentException ("DocumentNo is mandatory.");
set_Value (COLUMNNAME_DocumentNo, DocumentNo);
}
/** Get Document No.
@return Document sequence number of the document
*/
- public String getDocumentNo ()
+ public String getDocumentNo ()
{
return (String)get_Value(COLUMNNAME_DocumentNo);
}
@@ -378,13 +377,13 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
- public KeyNamePair getKeyNamePair()
+ public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), getDocumentNo());
}
/** Set Generate To.
- @param GenerateTo
+ @param GenerateTo
Generate To
*/
public void setGenerateTo (String GenerateTo)
@@ -395,13 +394,13 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Generate To.
@return Generate To
*/
- public String getGenerateTo ()
+ public String getGenerateTo ()
{
return (String)get_Value(COLUMNNAME_GenerateTo);
}
/** Set Comment/Help.
- @param Help
+ @param Help
Comment or Hint
*/
public void setHelp (String Help)
@@ -412,26 +411,27 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Comment/Help.
@return Comment or Hint
*/
- public String getHelp ()
+ public String getHelp ()
{
return (String)get_Value(COLUMNNAME_Help);
}
/** Set Shipment/Receipt.
- @param InOut_ID
+ @param InOut_ID
MaterialShipment Document
*/
public void setInOut_ID (int InOut_ID)
{
if (InOut_ID < 1)
- throw new IllegalArgumentException ("InOut_ID is mandatory.");
- set_ValueNoCheck (COLUMNNAME_InOut_ID, Integer.valueOf(InOut_ID));
+ set_ValueNoCheck (COLUMNNAME_InOut_ID, null);
+ else
+ set_ValueNoCheck (COLUMNNAME_InOut_ID, Integer.valueOf(InOut_ID));
}
/** Get Shipment/Receipt.
@return MaterialShipment Document
*/
- public int getInOut_ID ()
+ public int getInOut_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_InOut_ID);
if (ii == null)
@@ -440,7 +440,7 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set Approved.
- @param IsApproved
+ @param IsApproved
Indicates if this document requires approval
*/
public void setIsApproved (boolean IsApproved)
@@ -451,20 +451,20 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Approved.
@return Indicates if this document requires approval
*/
- public boolean isApproved ()
+ public boolean isApproved ()
{
Object oo = get_Value(COLUMNNAME_IsApproved);
- if (oo != null)
+ if (oo != null)
{
- if (oo instanceof Boolean)
- return ((Boolean)oo).booleanValue();
+ if (oo instanceof Boolean)
+ return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Sales Transaction.
- @param IsSOTrx
+ @param IsSOTrx
This is a Sales Transaction
*/
public void setIsSOTrx (boolean IsSOTrx)
@@ -475,41 +475,19 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Sales Transaction.
@return This is a Sales Transaction
*/
- public boolean isSOTrx ()
+ public boolean isSOTrx ()
{
Object oo = get_Value(COLUMNNAME_IsSOTrx);
- if (oo != null)
+ if (oo != null)
{
- if (oo instanceof Boolean)
- return ((Boolean)oo).booleanValue();
+ if (oo instanceof Boolean)
+ return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
- /** Set RMA.
- @param M_RMA_ID
- Return Material Authorization
- */
- public void setM_RMA_ID (int M_RMA_ID)
- {
- if (M_RMA_ID < 1)
- throw new IllegalArgumentException ("M_RMA_ID is mandatory.");
- set_ValueNoCheck (COLUMNNAME_M_RMA_ID, Integer.valueOf(M_RMA_ID));
- }
-
- /** Get RMA.
- @return Return Material Authorization
- */
- public int getM_RMA_ID ()
- {
- Integer ii = (Integer)get_Value(COLUMNNAME_M_RMA_ID);
- if (ii == null)
- return 0;
- return ii.intValue();
- }
-
- public I_M_RMAType getM_RMAType() throws RuntimeException
+ public I_M_RMAType getM_RMAType() throws RuntimeException
{
Class> clazz = MTable.getClass(I_M_RMAType.Table_Name);
I_M_RMAType result = null;
@@ -526,20 +504,21 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
}
/** Set RMA Type.
- @param M_RMAType_ID
+ @param M_RMAType_ID
Return Material Authorization Type
*/
public void setM_RMAType_ID (int M_RMAType_ID)
{
if (M_RMAType_ID < 1)
- throw new IllegalArgumentException ("M_RMAType_ID is mandatory.");
- set_Value (COLUMNNAME_M_RMAType_ID, Integer.valueOf(M_RMAType_ID));
+ set_Value (COLUMNNAME_M_RMAType_ID, null);
+ else
+ set_Value (COLUMNNAME_M_RMAType_ID, Integer.valueOf(M_RMAType_ID));
}
/** Get RMA Type.
@return Return Material Authorization Type
*/
- public int getM_RMAType_ID ()
+ public int getM_RMAType_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_RMAType_ID);
if (ii == null)
@@ -547,27 +526,48 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
return ii.intValue();
}
+ /** Set RMA.
+ @param M_RMA_ID
+ Return Material Authorization
+ */
+ public void setM_RMA_ID (int M_RMA_ID)
+ {
+ if (M_RMA_ID < 1)
+ set_ValueNoCheck (COLUMNNAME_M_RMA_ID, null);
+ else
+ set_ValueNoCheck (COLUMNNAME_M_RMA_ID, Integer.valueOf(M_RMA_ID));
+ }
+
+ /** Get RMA.
+ @return Return Material Authorization
+ */
+ public int getM_RMA_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_M_RMA_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
+
/** Set Name.
- @param Name
+ @param Name
Alphanumeric identifier of the entity
*/
public void setName (String Name)
{
- if (Name == null)
- throw new IllegalArgumentException ("Name is mandatory.");
set_Value (COLUMNNAME_Name, Name);
}
/** Get Name.
@return Alphanumeric identifier of the entity
*/
- public String getName ()
+ public String getName ()
{
return (String)get_Value(COLUMNNAME_Name);
}
/** Set Processed.
- @param Processed
+ @param Processed
The document has been processed
*/
public void setProcessed (boolean Processed)
@@ -578,13 +578,13 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Processed.
@return The document has been processed
*/
- public boolean isProcessed ()
+ public boolean isProcessed ()
{
Object oo = get_Value(COLUMNNAME_Processed);
- if (oo != null)
+ if (oo != null)
{
- if (oo instanceof Boolean)
- return ((Boolean)oo).booleanValue();
+ if (oo instanceof Boolean)
+ return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
@@ -599,33 +599,54 @@ public class X_M_RMA extends PO implements I_M_RMA, I_Persistent
/** Get Process Now.
@return Process Now */
- public boolean isProcessing ()
+ public boolean isProcessing ()
{
Object oo = get_Value(COLUMNNAME_Processing);
- if (oo != null)
+ if (oo != null)
{
- if (oo instanceof Boolean)
- return ((Boolean)oo).booleanValue();
+ if (oo instanceof Boolean)
+ return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
+ /** Set Referenced RMA.
+ @param Ref_RMA_ID Referenced RMA */
+ public void setRef_RMA_ID (int Ref_RMA_ID)
+ {
+ if (Ref_RMA_ID < 1)
+ set_Value (COLUMNNAME_Ref_RMA_ID, null);
+ else
+ set_Value (COLUMNNAME_Ref_RMA_ID, Integer.valueOf(Ref_RMA_ID));
+ }
+
+ /** Get Referenced RMA.
+ @return Referenced RMA */
+ public int getRef_RMA_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_Ref_RMA_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
+
/** Set Sales Representative.
- @param SalesRep_ID
+ @param SalesRep_ID
Sales Representative or Company Agent
*/
public void setSalesRep_ID (int SalesRep_ID)
{
if (SalesRep_ID < 1)
- throw new IllegalArgumentException ("SalesRep_ID is mandatory.");
- set_Value (COLUMNNAME_SalesRep_ID, Integer.valueOf(SalesRep_ID));
+ set_Value (COLUMNNAME_SalesRep_ID, null);
+ else
+ set_Value (COLUMNNAME_SalesRep_ID, Integer.valueOf(SalesRep_ID));
}
/** Get Sales Representative.
@return Sales Representative or Company Agent
*/
- public int getSalesRep_ID ()
+ public int getSalesRep_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_SalesRep_ID);
if (ii == null)
diff --git a/base/src/org/compiere/model/X_M_RMALine.java b/base/src/org/compiere/model/X_M_RMALine.java
index 58193f49f0..75ba78e83d 100644
--- a/base/src/org/compiere/model/X_M_RMALine.java
+++ b/base/src/org/compiere/model/X_M_RMALine.java
@@ -26,15 +26,15 @@ import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
/** Generated Model for M_RMALine
- * @author Adempiere (generated)
+ * @author Adempiere (generated)
* @version Release 3.5.3a - $Id$ */
-public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
+public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
{
/**
*
*/
- private static final long serialVersionUID = 20081221L;
+ private static final long serialVersionUID = 20090601;
/** Standard Constructor */
public X_M_RMALine (Properties ctx, int M_RMALine_ID, String trxName)
@@ -42,8 +42,8 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
super (ctx, M_RMALine_ID, trxName);
/** if (M_RMALine_ID == 0)
{
- setM_RMA_ID (0);
setM_RMALine_ID (0);
+ setM_RMA_ID (0);
setProcessed (false);
setQty (Env.ZERO);
} */
@@ -56,7 +56,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** AccessLevel
- * @return 1 - Org
+ * @return 1 - Org
*/
protected int get_AccessLevel()
{
@@ -78,7 +78,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Amount.
- @param Amt
+ @param Amt
Amount
*/
public void setAmt (BigDecimal Amt)
@@ -89,7 +89,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Amount.
@return Amount
*/
- public BigDecimal getAmt ()
+ public BigDecimal getAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Amt);
if (bd == null)
@@ -97,7 +97,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
return bd;
}
- public I_C_Charge getC_Charge() throws RuntimeException
+ public I_C_Charge getC_Charge() throws RuntimeException
{
Class> clazz = MTable.getClass(I_C_Charge.Table_Name);
I_C_Charge result = null;
@@ -114,21 +114,21 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Charge.
- @param C_Charge_ID
+ @param C_Charge_ID
Additional document charges
*/
public void setC_Charge_ID (int C_Charge_ID)
{
- if (C_Charge_ID < 1)
+ if (C_Charge_ID < 1)
set_Value (COLUMNNAME_C_Charge_ID, null);
- else
+ else
set_Value (COLUMNNAME_C_Charge_ID, Integer.valueOf(C_Charge_ID));
}
/** Get Charge.
@return Additional document charges
*/
- public int getC_Charge_ID ()
+ public int getC_Charge_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Charge_ID);
if (ii == null)
@@ -137,7 +137,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Description.
- @param Description
+ @param Description
Optional short description of the record
*/
public void setDescription (String Description)
@@ -148,13 +148,13 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Description.
@return Optional short description of the record
*/
- public String getDescription ()
+ public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Line No.
- @param Line
+ @param Line
Unique line for this document
*/
public void setLine (int Line)
@@ -165,7 +165,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Line No.
@return Unique line for this document
*/
- public int getLine ()
+ public int getLine ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_Line);
if (ii == null)
@@ -174,7 +174,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Line Amount.
- @param LineNetAmt
+ @param LineNetAmt
Line Extended Amount (Quantity * Actual Price) without Freight and Charges
*/
public void setLineNetAmt (BigDecimal LineNetAmt)
@@ -185,7 +185,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Line Amount.
@return Line Extended Amount (Quantity * Actual Price) without Freight and Charges
*/
- public BigDecimal getLineNetAmt ()
+ public BigDecimal getLineNetAmt ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_LineNetAmt);
if (bd == null)
@@ -193,7 +193,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
return bd;
}
- public I_M_InOutLine getM_InOutLine() throws RuntimeException
+ public I_M_InOutLine getM_InOutLine() throws RuntimeException
{
Class> clazz = MTable.getClass(I_M_InOutLine.Table_Name);
I_M_InOutLine result = null;
@@ -210,21 +210,21 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Shipment/Receipt Line.
- @param M_InOutLine_ID
+ @param M_InOutLine_ID
Line on Shipment or Receipt document
*/
public void setM_InOutLine_ID (int M_InOutLine_ID)
{
- if (M_InOutLine_ID < 1)
+ if (M_InOutLine_ID < 1)
set_Value (COLUMNNAME_M_InOutLine_ID, null);
- else
+ else
set_Value (COLUMNNAME_M_InOutLine_ID, Integer.valueOf(M_InOutLine_ID));
}
/** Get Shipment/Receipt Line.
@return Line on Shipment or Receipt document
*/
- public int getM_InOutLine_ID ()
+ public int getM_InOutLine_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_InOutLine_ID);
if (ii == null)
@@ -232,7 +232,30 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
return ii.intValue();
}
- public I_M_RMA getM_RMA() throws RuntimeException
+ /** Set RMA Line.
+ @param M_RMALine_ID
+ Return Material Authorization Line
+ */
+ public void setM_RMALine_ID (int M_RMALine_ID)
+ {
+ if (M_RMALine_ID < 1)
+ set_ValueNoCheck (COLUMNNAME_M_RMALine_ID, null);
+ else
+ set_ValueNoCheck (COLUMNNAME_M_RMALine_ID, Integer.valueOf(M_RMALine_ID));
+ }
+
+ /** Get RMA Line.
+ @return Return Material Authorization Line
+ */
+ public int getM_RMALine_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_M_RMALine_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
+
+ public I_M_RMA getM_RMA() throws RuntimeException
{
Class> clazz = MTable.getClass(I_M_RMA.Table_Name);
I_M_RMA result = null;
@@ -249,20 +272,21 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set RMA.
- @param M_RMA_ID
+ @param M_RMA_ID
Return Material Authorization
*/
public void setM_RMA_ID (int M_RMA_ID)
{
if (M_RMA_ID < 1)
- throw new IllegalArgumentException ("M_RMA_ID is mandatory.");
- set_ValueNoCheck (COLUMNNAME_M_RMA_ID, Integer.valueOf(M_RMA_ID));
+ set_ValueNoCheck (COLUMNNAME_M_RMA_ID, null);
+ else
+ set_ValueNoCheck (COLUMNNAME_M_RMA_ID, Integer.valueOf(M_RMA_ID));
}
/** Get RMA.
@return Return Material Authorization
*/
- public int getM_RMA_ID ()
+ public int getM_RMA_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_M_RMA_ID);
if (ii == null)
@@ -273,35 +297,13 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
- public KeyNamePair getKeyNamePair()
+ public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), String.valueOf(getM_RMA_ID()));
}
- /** Set RMA Line.
- @param M_RMALine_ID
- Return Material Authorization Line
- */
- public void setM_RMALine_ID (int M_RMALine_ID)
- {
- if (M_RMALine_ID < 1)
- throw new IllegalArgumentException ("M_RMALine_ID is mandatory.");
- set_ValueNoCheck (COLUMNNAME_M_RMALine_ID, Integer.valueOf(M_RMALine_ID));
- }
-
- /** Get RMA Line.
- @return Return Material Authorization Line
- */
- public int getM_RMALine_ID ()
- {
- Integer ii = (Integer)get_Value(COLUMNNAME_M_RMALine_ID);
- if (ii == null)
- return 0;
- return ii.intValue();
- }
-
/** Set Processed.
- @param Processed
+ @param Processed
The document has been processed
*/
public void setProcessed (boolean Processed)
@@ -312,33 +314,31 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Processed.
@return The document has been processed
*/
- public boolean isProcessed ()
+ public boolean isProcessed ()
{
Object oo = get_Value(COLUMNNAME_Processed);
- if (oo != null)
+ if (oo != null)
{
- if (oo instanceof Boolean)
- return ((Boolean)oo).booleanValue();
+ if (oo instanceof Boolean)
+ return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Quantity.
- @param Qty
+ @param Qty
Quantity
*/
public void setQty (BigDecimal Qty)
{
- if (Qty == null)
- throw new IllegalArgumentException ("Qty is mandatory.");
set_Value (COLUMNNAME_Qty, Qty);
}
/** Get Quantity.
@return Quantity
*/
- public BigDecimal getQty ()
+ public BigDecimal getQty ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_Qty);
if (bd == null)
@@ -347,7 +347,7 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
}
/** Set Delivered Quantity.
- @param QtyDelivered
+ @param QtyDelivered
Delivered Quantity
*/
public void setQtyDelivered (BigDecimal QtyDelivered)
@@ -358,11 +358,51 @@ public class X_M_RMALine extends PO implements I_M_RMALine, I_Persistent
/** Get Delivered Quantity.
@return Delivered Quantity
*/
- public BigDecimal getQtyDelivered ()
+ public BigDecimal getQtyDelivered ()
{
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyDelivered);
if (bd == null)
return Env.ZERO;
return bd;
}
+
+ /** Set Quantity Invoiced.
+ @param QtyInvoiced
+ Invoiced Quantity
+ */
+ public void setQtyInvoiced (BigDecimal QtyInvoiced)
+ {
+ set_Value (COLUMNNAME_QtyInvoiced, QtyInvoiced);
+ }
+
+ /** Get Quantity Invoiced.
+ @return Invoiced Quantity
+ */
+ public BigDecimal getQtyInvoiced ()
+ {
+ BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_QtyInvoiced);
+ if (bd == null)
+ return Env.ZERO;
+ return bd;
+ }
+
+ /** Set Referenced RMA Line.
+ @param Ref_RMALine_ID Referenced RMA Line */
+ public void setRef_RMALine_ID (int Ref_RMALine_ID)
+ {
+ if (Ref_RMALine_ID < 1)
+ set_Value (COLUMNNAME_Ref_RMALine_ID, null);
+ else
+ set_Value (COLUMNNAME_Ref_RMALine_ID, Integer.valueOf(Ref_RMALine_ID));
+ }
+
+ /** Get Referenced RMA Line.
+ @return Referenced RMA Line */
+ public int getRef_RMALine_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_Ref_RMALine_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
}
\ No newline at end of file
diff --git a/client/src/org/compiere/grid/CreateFrom.java b/client/src/org/compiere/grid/CreateFrom.java
index 7e2f6b9210..bfd18fa80a 100644
--- a/client/src/org/compiere/grid/CreateFrom.java
+++ b/client/src/org/compiere/grid/CreateFrom.java
@@ -24,37 +24,40 @@ import java.util.logging.Level;
import org.compiere.minigrid.IMiniTable;
import org.compiere.model.GridTab;
import org.compiere.model.MOrder;
+import org.compiere.model.MRMA;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
-import org.compiere.util.Msg;
public abstract class CreateFrom implements ICreateFrom
{
/** Logger */
protected CLogger log = CLogger.getCLogger(getClass());
-
+
/** Loaded Order */
protected MOrder p_order = null;
+ /** Loaded RMA */
+ protected MRMA m_rma = null;
+
private GridTab gridTab;
private String title;
-
+
private boolean initOK = false;
-
+
public CreateFrom(GridTab gridTab) {
this.gridTab = gridTab;
}
-
+
public abstract boolean dynInit() throws Exception;
public abstract void info();
public abstract boolean save(IMiniTable miniTable, String trxName);
-
+
/**
* Init OK to be able to make changes?
* @return on if initialized
@@ -63,12 +66,12 @@ public abstract class CreateFrom implements ICreateFrom
{
return initOK;
}
-
+
public void setInitOK(boolean initOK)
{
this.initOK = initOK;
}
-
+
/**
* Load PBartner dependent Order/Invoice/Shipment Field.
* @param C_BPartner_ID BPartner
@@ -77,7 +80,7 @@ public abstract class CreateFrom implements ICreateFrom
protected ArrayList loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly)
{
ArrayList list = new ArrayList();
-
+
// Display
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||")
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
@@ -125,10 +128,10 @@ public abstract class CreateFrom implements ICreateFrom
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
-
+
return list;
} // initBPartnerOIS
-
+
/**
* Load Data - Order
* @param C_Order_ID Order
@@ -212,21 +215,21 @@ public abstract class CreateFrom implements ICreateFrom
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
-
+
return data;
} // LoadOrder
-
+
public void showWindow()
{
-
+
}
-
+
public void closeWindow()
{
-
+
}
-
- public GridTab getGridTab()
+
+ public GridTab getGridTab()
{
return gridTab;
}
@@ -239,7 +242,7 @@ public abstract class CreateFrom implements ICreateFrom
{
return Env.getContextAsInt(Env.getCtx(), gridTab.getWindowNo(), "M_Warehouse_ID");
}
-
+
public String getTitle() {
return title;
}
diff --git a/client/src/org/compiere/grid/CreateFromInvoice.java b/client/src/org/compiere/grid/CreateFromInvoice.java
index d9a95b9f9c..8043e728eb 100644
--- a/client/src/org/compiere/grid/CreateFromInvoice.java
+++ b/client/src/org/compiere/grid/CreateFromInvoice.java
@@ -30,6 +30,8 @@ import org.compiere.model.MInvoiceLine;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MProduct;
+import org.compiere.model.MRMA;
+import org.compiere.model.MRMALine;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
@@ -41,12 +43,12 @@ import org.compiere.util.Msg;
*
* @author Jorg Janke
* @version $Id: VCreateFromInvoice.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $
- *
+ *
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* BF [ 1896947 ] Generate invoice from Order error
* BF [ 2007837 ] VCreateFrom.save() should run in trx
*/
-public class CreateFromInvoice extends CreateFrom
+public class CreateFromInvoice extends CreateFrom
{
/**
* Protected Constructor
@@ -66,7 +68,7 @@ public class CreateFromInvoice extends CreateFrom
{
log.config("");
setTitle(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
-
+
return true;
} // dynInit
@@ -77,7 +79,7 @@ public class CreateFromInvoice extends CreateFrom
protected ArrayList loadShipmentData (int C_BPartner_ID)
{
ArrayList list = new ArrayList();
-
+
// Display
StringBuffer display = new StringBuffer("s.DocumentNo||' - '||")
.append(DB.TO_CHAR("s.MovementDate", DisplayType.Date, Env.getAD_Language(Env.getCtx())));
@@ -111,10 +113,10 @@ public class CreateFromInvoice extends CreateFrom
{
log.log(Level.SEVERE, sql.toString(), e);
}
-
+
return list;
}
-
+
/**
* Load PBartner dependent Order/Invoice/Shipment Field.
* @param C_BPartner_ID BPartner
@@ -164,6 +166,10 @@ public class CreateFromInvoice extends CreateFrom
if (inout.getC_Order_ID() != 0)
p_order = new MOrder (Env.getCtx(), inout.getC_Order_ID(), null);
+ m_rma = null;
+ if (inout.getM_RMA_ID() != 0)
+ m_rma = new MRMA (Env.getCtx(), inout.getM_RMA_ID(), null);
+
//
Vector> data = new Vector>();
StringBuffer sql = new StringBuffer("SELECT " // QtyEntered
@@ -172,18 +178,18 @@ public class CreateFromInvoice extends CreateFrom
+ " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
+ " l.C_OrderLine_ID " // 10
+ " FROM M_InOutLine l "
- );
+ );
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
else
sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='")
.append(Env.getAD_Language(Env.getCtx())).append("')");
-
+
sql.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)")
.append(" INNER JOIN M_InOut io ON (l.M_InOut_ID=io.M_InOut_ID)")
.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND io.C_BPartner_ID = po.C_BPartner_ID)")
.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.M_InOutLine_ID=mi.M_InOutLine_ID)")
-
+
.append(" WHERE l.M_InOut_ID=? AND l.MovementQty<>0 ")
.append("GROUP BY l.MovementQty, l.QtyEntered/l.MovementQty, "
+ "l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name), "
@@ -225,10 +231,10 @@ public class CreateFromInvoice extends CreateFrom
{
log.log(Level.SEVERE, sql.toString(), e);
}
-
+
return data;
} // loadShipment
-
+
/**
* Load RMA details
* @param M_RMA_ID RMA
@@ -236,14 +242,14 @@ public class CreateFromInvoice extends CreateFrom
protected Vector> getRMAData(int M_RMA_ID)
{
p_order = null;
-
+
// MRMA m_rma = new MRMA(Env.getCtx(), M_RMA_ID, null);
-
+
Vector> data = new Vector>();
StringBuffer sqlStmt = new StringBuffer();
- sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - rl.QtyDelivered, iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
+ sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - COALESCE(rl.QtyInvoiced, 0), iol.M_Product_ID, p.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
sqlStmt.append("FROM M_RMALine rl INNER JOIN M_InOutLine iol ON rl.M_InOutLine_ID=iol.M_InOutLine_ID ");
-
+
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
{
sqlStmt.append("LEFT OUTER JOIN C_UOM uom ON (uom.C_UOM_ID=iol.C_UOM_ID) ");
@@ -256,9 +262,9 @@ public class CreateFromInvoice extends CreateFrom
sqlStmt.append("LEFT OUTER JOIN M_Product p ON p.M_Product_ID=iol.M_Product_ID ");
sqlStmt.append("WHERE rl.M_RMA_ID=? ");
sqlStmt.append("AND rl.M_INOUTLINE_ID IS NOT NULL");
-
+
sqlStmt.append(" UNION ");
-
+
sqlStmt.append("SELECT rl.M_RMALine_ID, rl.line, rl.Qty - rl.QtyDelivered, 0, c.Name, uom.C_UOM_ID, COALESCE(uom.UOMSymbol,uom.Name) ");
sqlStmt.append("FROM M_RMALine rl INNER JOIN C_Charge c ON c.C_Charge_ID = rl.C_Charge_ID ");
if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
@@ -272,7 +278,7 @@ public class CreateFromInvoice extends CreateFrom
}
sqlStmt.append("WHERE rl.M_RMA_ID=? ");
sqlStmt.append("AND rl.C_Charge_ID IS NOT NULL");
-
+
PreparedStatement pstmt = null;
ResultSet rs = null;
try
@@ -281,7 +287,7 @@ public class CreateFromInvoice extends CreateFrom
pstmt.setInt(1, M_RMA_ID);
pstmt.setInt(2, M_RMA_ID);
rs = pstmt.executeQuery();
-
+
while (rs.next())
{
Vector