Added checking for location selected in the info bpartner window whether the location is a shipping location, a billing location or both.

This commit is contained in:
Heng Sin Low 2011-02-10 12:16:29 +08:00
parent e573983f5f
commit d4286e392f
1 changed files with 102 additions and 83 deletions

View File

@ -310,21 +310,35 @@ public class CalloutOrder extends CalloutEngine
// Bill-To
mTab.setValue("Bill_BPartner_ID", C_BPartner_ID);
int bill_Location_ID = rs.getInt("Bill_Location_ID");
int shipTo_ID = 0;
int bill_Location_ID =0;
// overwritten by InfoBP selection - works only if InfoWindow
// was used otherwise creates error (uses last value, may belong to different BP)
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_ID")))
{
String loc = Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_Location_ID");
int locationId = 0;
if (loc.length() > 0)
locationId = Integer.parseInt(loc);
if (locationId > 0) {
MBPartnerLocation bpLocation = new MBPartnerLocation(ctx, locationId, null);
if (bpLocation.isBillTo())
bill_Location_ID = locationId;
if (bpLocation.isShipTo())
shipTo_ID = locationId;
}
}
if (bill_Location_ID == 0)
bill_Location_ID = rs.getInt("Bill_Location_ID");
if (bill_Location_ID == 0)
mTab.setValue("Bill_Location_ID", null);
else
mTab.setValue("Bill_Location_ID", new Integer(bill_Location_ID));
// Ship-To Location
int shipTo_ID = rs.getInt("C_BPartner_Location_ID");
// overwritten by InfoBP selection - works only if InfoWindow
// was used otherwise creates error (uses last value, may belong to differnt BP)
if (C_BPartner_ID.toString().equals(Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_ID")))
{
String loc = Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_Location_ID");
if (loc.length() > 0)
shipTo_ID = Integer.parseInt(loc);
}
if (shipTo_ID == 0)
shipTo_ID = rs.getInt("C_BPartner_Location_ID");
if (shipTo_ID == 0)
mTab.setValue("C_BPartner_Location_ID", null);
else
@ -350,7 +364,6 @@ public class CalloutOrder extends CalloutEngine
if (IsSOTrx)
{
double CreditLimit = rs.getDouble("SO_CreditLimit");
String SOCreditStatus = rs.getString("SOCreditStatus");
if (CreditLimit != 0)
{
double CreditAvailable = rs.getDouble("CreditAvailable");
@ -505,9 +518,15 @@ public class CalloutOrder extends CalloutEngine
// was used otherwise creates error (uses last value, may belong to differnt BP)
if (bill_BPartner_ID.toString().equals(Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_ID")))
{
int locationId = 0;
String loc = Env.getContext(ctx, WindowNo, Env.TAB_INFO, "C_BPartner_Location_ID");
if (loc.length() > 0)
bill_Location_ID = Integer.parseInt(loc);
locationId = Integer.parseInt(loc);
if (locationId > 0) {
MBPartnerLocation bpLocation = new MBPartnerLocation(ctx, locationId, null);
if (bpLocation.isBillTo())
bill_Location_ID = locationId;
}
}
if (bill_Location_ID == 0)
mTab.setValue("Bill_Location_ID", null);
@ -763,7 +782,7 @@ public class CalloutOrder extends CalloutEngine
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
BigDecimal available = MStorage.getQtyAvailable
(M_Warehouse_ID, M_Product_ID.intValue(), M_AttributeSetInstance_ID, null);
(M_Warehouse_ID, 0, M_Product_ID.intValue(), M_AttributeSetInstance_ID, null);
if (available == null)
available = Env.ZERO;
if (available.signum() == 0)
@ -1234,7 +1253,7 @@ public class CalloutOrder extends CalloutEngine
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
BigDecimal available = MStorage.getQtyAvailable
(M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, null);
(M_Warehouse_ID, 0, M_Product_ID, M_AttributeSetInstance_ID, null);
if (available == null)
available = Env.ZERO;
if (available.signum() == 0)