parent
0cbf81c9ef
commit
d3b1fdeeb4
|
|
@ -6,8 +6,6 @@ import org.compiere.model.MInventoryLineMA;
|
|||
import org.compiere.model.PO;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import andromedia.midsuit.model.MID_PPOLine;
|
||||
|
||||
public class MID_InventoryLineMAValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MInventoryLineMA inv = (MInventoryLineMA) po;
|
||||
|
|
@ -15,36 +13,25 @@ public class MID_InventoryLineMAValidator {
|
|||
return beforeSave(inv);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE))
|
||||
return beforeChange(inv);
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeChange(MInventoryLineMA invMA) {
|
||||
MInventoryLine inv = new MInventoryLine(invMA.getCtx(), invMA.getM_InventoryLine_ID(), invMA.get_TrxName());
|
||||
int PS_PPOLine_ID = inv.get_ValueAsInt("ps_ppoline_ID");
|
||||
if(! invMA.is_ValueChanged("QtyEntered")) return "";
|
||||
if(PS_PPOLine_ID>0 ) {
|
||||
MID_PPOLine line = new MID_PPOLine(inv.getCtx(), PS_PPOLine_ID,inv.get_TrxName());
|
||||
if(line.isEndProduct() && invMA.getMovementQty().signum()>0)
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
}
|
||||
else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) {
|
||||
if(invMA.getMovementQty().signum()>0)
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
if (!invMA.is_ValueChanged("QtyEntered") || inv.getReversalLine_ID() > 0)
|
||||
return "";
|
||||
if (inv.getQtyInternalUse().signum() < 0 && invMA.getMovementQty().signum() > 0) {
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeSave(MInventoryLineMA invMA){
|
||||
|
||||
private static String beforeSave(MInventoryLineMA invMA) {
|
||||
MInventoryLine inv = new MInventoryLine(invMA.getCtx(), invMA.getM_InventoryLine_ID(), invMA.get_TrxName());
|
||||
int PS_PPOLine_ID = inv.get_ValueAsInt("ps_ppoline_ID");
|
||||
if(PS_PPOLine_ID>0) {
|
||||
MID_PPOLine line = new MID_PPOLine(inv.getCtx(), PS_PPOLine_ID,inv.get_TrxName());
|
||||
if(line.isEndProduct() && invMA.getMovementQty().signum()>0)
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
}else if (inv.getM_Product().getM_Product_Category().getValue().contains("SCRAP")) {
|
||||
if(invMA.getMovementQty().signum()>0)
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
}
|
||||
if (inv.getReversalLine_ID() > 0)
|
||||
return "";
|
||||
if (inv.getQtyInternalUse().signum() < 0 && invMA.getMovementQty().signum() > 0)
|
||||
invMA.setMovementQty(invMA.getMovementQty().negate());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue