IDEMPIERE-1999 Adding support for over shipment.
This commit is contained in:
parent
ec78079e40
commit
97dabc75b5
|
@ -758,10 +758,9 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
line.setM_RMALine_ID(peer.getRef_RMALine_ID());
|
||||
}
|
||||
}
|
||||
else if (!isSOTrx())
|
||||
{
|
||||
line.setQtyOverReceipt(fromLine.getQtyOverReceipt());
|
||||
}
|
||||
|
||||
line.setQtyOverReceipt(fromLine.getQtyOverReceipt());
|
||||
|
||||
//
|
||||
line.setProcessed(false);
|
||||
if (line.save(get_TrxName()))
|
||||
|
@ -1290,7 +1289,6 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
BigDecimal Qty = sLine.getMovementQty();
|
||||
if (MovementType.charAt(1) == '-') // C- Customer Shipment - V- Vendor Return
|
||||
Qty = Qty.negate();
|
||||
BigDecimal QtySO = Env.ZERO;
|
||||
|
||||
// Update Order Line
|
||||
MOrderLine oLine = null;
|
||||
|
@ -1299,8 +1297,6 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
oLine = new MOrderLine (getCtx(), sLine.getC_OrderLine_ID(), get_TrxName());
|
||||
if (log.isLoggable(Level.FINE)) log.fine("OrderLine - Reserved=" + oLine.getQtyReserved()
|
||||
+ ", Delivered=" + oLine.getQtyDelivered());
|
||||
if (isSOTrx())
|
||||
QtySO = sLine.getMovementQty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1326,41 +1322,29 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
|
||||
log.fine("Material Transaction");
|
||||
MTransaction mtrx = null;
|
||||
//same warehouse in order and receipt?
|
||||
boolean sameWarehouse = true;
|
||||
// Reservation ASI - assume none
|
||||
int reservationAttributeSetInstance_ID = 0; // sLine.getM_AttributeSetInstance_ID();
|
||||
int reservationWarehouse_ID = getM_Warehouse_ID();
|
||||
if (oLine != null) {
|
||||
reservationAttributeSetInstance_ID = oLine.getM_AttributeSetInstance_ID();
|
||||
sameWarehouse = oLine.getM_Warehouse_ID()==getM_Warehouse_ID();
|
||||
}
|
||||
if(!sameWarehouse){
|
||||
reservationWarehouse_ID = oLine.getM_Warehouse_ID();
|
||||
}
|
||||
|
||||
//
|
||||
BigDecimal overReceipt = BigDecimal.ZERO;
|
||||
if (!isSOTrx())
|
||||
{
|
||||
if (!isReversal())
|
||||
if (!isReversal())
|
||||
{
|
||||
if (oLine != null)
|
||||
{
|
||||
if (oLine != null)
|
||||
BigDecimal toDelivered = oLine.getQtyOrdered()
|
||||
.subtract(oLine.getQtyDelivered());
|
||||
if (sLine.getMovementQty().compareTo(toDelivered) > 0)
|
||||
overReceipt = sLine.getMovementQty().subtract(
|
||||
toDelivered);
|
||||
if (overReceipt.signum() != 0)
|
||||
{
|
||||
BigDecimal toDelivered = oLine.getQtyOrdered().subtract(oLine.getQtyDelivered());
|
||||
if (sLine.getMovementQty().compareTo(toDelivered) > 0)
|
||||
overReceipt = sLine.getMovementQty().subtract(toDelivered);
|
||||
if (overReceipt.signum() != 0)
|
||||
{
|
||||
sLine.setQtyOverReceipt(overReceipt);
|
||||
sLine.saveEx();
|
||||
}
|
||||
sLine.setQtyOverReceipt(overReceipt);
|
||||
sLine.saveEx();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
overReceipt = sLine.getQtyOverReceipt();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
overReceipt = sLine.getQtyOverReceipt();
|
||||
}
|
||||
BigDecimal orderedQtyToUpdate = sLine.getMovementQty().subtract(overReceipt);
|
||||
//
|
||||
if (sLine.getM_AttributeSetInstance_ID() == 0)
|
||||
|
@ -1373,27 +1357,6 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
BigDecimal QtyMA = ma.getMovementQty();
|
||||
if (MovementType.charAt(1) == '-') // C- Customer Shipment - V- Vendor Return
|
||||
QtyMA = QtyMA.negate();
|
||||
BigDecimal reservedDiff = Env.ZERO;
|
||||
if (sLine.getC_OrderLine_ID() != 0)
|
||||
{
|
||||
if (isSOTrx())
|
||||
{
|
||||
reservedDiff = ma.getMovementQty().negate();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (orderedQtyToUpdate.compareTo(ma.getMovementQty()) >= 0)
|
||||
{
|
||||
orderedQtyToUpdate = orderedQtyToUpdate.subtract(ma.getMovementQty());
|
||||
reservedDiff = ma.getMovementQty().negate();
|
||||
}
|
||||
else
|
||||
{
|
||||
reservedDiff = orderedQtyToUpdate.negate();
|
||||
orderedQtyToUpdate = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update Storage - see also VMatch.createMatchRecord
|
||||
if (!MStorageOnHand.add(getCtx(), getM_Warehouse_ID(),
|
||||
|
@ -1406,20 +1369,7 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
String lastError = CLogger.retrieveErrorString("");
|
||||
m_processMsg = "Cannot correct Inventory OnHand (MA) [" + product.getValue() + "] - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
if (reservedDiff.signum() != 0) {
|
||||
if (!MStorageReservation.add(getCtx(), reservationWarehouse_ID,
|
||||
sLine.getM_Product_ID(),
|
||||
ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
||||
reservedDiff,
|
||||
isSOTrx(),
|
||||
get_TrxName()))
|
||||
{
|
||||
String lastError = CLogger.retrieveErrorString("");
|
||||
m_processMsg = "Cannot correct Inventory " + (isSOTrx()? "Reserved" : "Ordered") + " (MA) - [" + product.getValue() + "] - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create Transaction
|
||||
mtrx = new MTransaction (getCtx(), sLine.getAD_Org_ID(),
|
||||
|
@ -1433,16 +1383,29 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
if (oLine!=null && mtrx!=null)
|
||||
{
|
||||
if (sLine.getC_OrderLine_ID() != 0)
|
||||
{
|
||||
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
|
||||
sLine.getM_Product_ID(),
|
||||
oLine.getM_AttributeSetInstance_ID(),
|
||||
orderedQtyToUpdate.negate(),
|
||||
isSOTrx(),
|
||||
get_TrxName()))
|
||||
{
|
||||
String lastError = CLogger.retrieveErrorString("");
|
||||
m_processMsg = "Cannot correct Inventory " + (isSOTrx()? "Reserved" : "Ordered") + " (MA) - [" + product.getValue() + "] - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// sLine.getM_AttributeSetInstance_ID() != 0
|
||||
if (mtrx == null)
|
||||
{
|
||||
BigDecimal reservedDiff = null;
|
||||
if(isSOTrx())
|
||||
reservedDiff = QtySO.negate();
|
||||
else
|
||||
reservedDiff = orderedQtyToUpdate.negate();
|
||||
|
||||
Timestamp dateMPolicy = getMovementDate();
|
||||
if(sLine.getM_AttributeSetInstance_ID()>0){
|
||||
I_M_AttributeSetInstance asi = sLine.getM_AttributeSetInstance();
|
||||
|
@ -1460,11 +1423,12 @@ public class MInOut extends X_M_InOut implements DocAction
|
|||
m_processMsg = "Cannot correct Inventory OnHand [" + product.getValue() + "] - " + lastError;
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
if (reservedDiff.signum() != 0) {
|
||||
if (!MStorageReservation.add(getCtx(), reservationWarehouse_ID,
|
||||
if (oLine!=null)
|
||||
{
|
||||
if (!MStorageReservation.add(getCtx(), oLine.getM_Warehouse_ID(),
|
||||
sLine.getM_Product_ID(),
|
||||
sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID,
|
||||
reservedDiff, isSOTrx(), get_TrxName()))
|
||||
oLine.getM_AttributeSetInstance_ID(),
|
||||
orderedQtyToUpdate.negate(), isSOTrx(), get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Cannot correct Inventory Reserved " + (isSOTrx()? "Reserved [" :"Ordered [") + product.getValue() + "]";
|
||||
return DocAction.STATUS_Invalid;
|
||||
|
|
|
@ -1747,7 +1747,7 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
// Update Reservation Storage
|
||||
if (!MStorageReservation.add(getCtx(), line.getM_Warehouse_ID(),
|
||||
line.getM_Product_ID(),
|
||||
line.getM_AttributeSetInstance_ID(), line.getM_AttributeSetInstance_ID(),
|
||||
line.getM_AttributeSetInstance_ID(),
|
||||
difference, isSOTrx, get_TrxName()))
|
||||
return false;
|
||||
} // stocked
|
||||
|
|
|
@ -210,22 +210,20 @@ public class MStorageReservation extends X_M_StorageReservation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update Storage Info add.
|
||||
* Called from MProjectIssue
|
||||
* @param ctx context
|
||||
* @param M_Warehouse_ID warehouse
|
||||
* @param M_Product_ID product
|
||||
* @param M_AttributeSetInstance_ID AS Instance
|
||||
* @param reservationAttributeSetInstance_ID reservation AS Instance
|
||||
* @param diffQty add
|
||||
* @param isSOTrx
|
||||
* @param trxName transaction
|
||||
* @return true if updated
|
||||
*
|
||||
* @param ctx
|
||||
* @param M_Warehouse_ID
|
||||
* @param M_Product_ID
|
||||
* @param M_AttributeSetInstance_ID
|
||||
* @param diffQty
|
||||
* @param isSOTrx
|
||||
* @param trxName
|
||||
* @return
|
||||
*/
|
||||
public static boolean add (Properties ctx, int M_Warehouse_ID,
|
||||
int M_Product_ID, int M_AttributeSetInstance_ID, int reservationAttributeSetInstance_ID,
|
||||
BigDecimal diffQty, boolean isSOTrx, String trxName)
|
||||
{
|
||||
int M_Product_ID, int M_AttributeSetInstance_ID,
|
||||
BigDecimal diffQty, boolean isSOTrx, String trxName){
|
||||
|
||||
if (diffQty == null || diffQty.signum() == 0)
|
||||
return true;
|
||||
|
||||
|
@ -233,13 +231,8 @@ public class MStorageReservation extends X_M_StorageReservation {
|
|||
MProduct prd = new MProduct(ctx, M_Product_ID, trxName);
|
||||
if (prd.getM_AttributeSet_ID() == 0 || ! prd.getM_AttributeSet().isInstanceAttribute()) {
|
||||
// Product doesn't manage attribute set, always reserved with 0
|
||||
reservationAttributeSetInstance_ID = 0;
|
||||
M_AttributeSetInstance_ID = 0;
|
||||
}
|
||||
//
|
||||
if (M_AttributeSetInstance_ID != reservationAttributeSetInstance_ID) {
|
||||
M_AttributeSetInstance_ID = reservationAttributeSetInstance_ID;
|
||||
}
|
||||
|
||||
// Get Storage
|
||||
MStorageReservation storage = getCreate (ctx, M_Warehouse_ID,
|
||||
|
@ -261,6 +254,28 @@ public class MStorageReservation extends X_M_StorageReservation {
|
|||
s_log.fine(diffText.toString());
|
||||
}
|
||||
return storage.save (trxName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Storage Info add.
|
||||
* Called from MProjectIssue
|
||||
* @param ctx context
|
||||
* @param M_Warehouse_ID warehouse
|
||||
* @param M_Product_ID product
|
||||
* @param M_AttributeSetInstance_ID AS Instance
|
||||
* @param reservationAttributeSetInstance_ID reservation AS Instance
|
||||
* @param diffQty add
|
||||
* @param isSOTrx
|
||||
* @param trxName transaction
|
||||
* @return true if updated
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean add (Properties ctx, int M_Warehouse_ID,
|
||||
int M_Product_ID, int M_AttributeSetInstance_ID, int reservationAttributeSetInstance_ID,
|
||||
BigDecimal diffQty, boolean isSOTrx, String trxName)
|
||||
{
|
||||
|
||||
return add(ctx, M_Warehouse_ID, M_Product_ID, reservationAttributeSetInstance_ID, diffQty, isSOTrx, trxName);
|
||||
} // add
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue