1 14 package org.compiere.model; 15 16 import java.math.*; 17 import java.util.*; 18 import java.sql.*; 19 20 import org.compiere.util.*; 21 22 28 public class CalloutOrder extends CalloutEngine 29 { 30 31 48 public String docType (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 49 { 50 Integer C_DocType_ID = (Integer )value; if (C_DocType_ID == null || C_DocType_ID.intValue() == 0) 52 return ""; 53 54 String oldDocNo = (String )mTab.getValue("DocumentNo"); 57 boolean newDocNo = (oldDocNo == null); 58 if (!newDocNo && oldDocNo.startsWith("<") && oldDocNo.endsWith(">")) 59 newDocNo = true; 60 Integer oldC_DocType_ID = (Integer )mTab.getValue("C_DocType_ID"); 61 62 try 63 { 64 String SQL = "SELECT d.DocSubTypeSO,d.HasCharges,d.IsApproved," + "d.IsDocNoControlled,s.CurrentNext,s.CurrentNextSys," + "s.AD_Sequence_ID,d.IsSOTrx " + "FROM C_DocType d, AD_Sequence s " 68 + "WHERE C_DocType_ID=?" + " AND d.DocNoSequence_ID=s.AD_Sequence_ID(+)"; 70 int AD_Sequence_ID = 0; 71 72 if (!newDocNo && oldC_DocType_ID.intValue() != 0) 74 { 75 PreparedStatement pstmt = DB.prepareStatement(SQL); 76 pstmt.setInt(1, oldC_DocType_ID.intValue()); 77 ResultSet rs = pstmt.executeQuery(); 78 if (rs.next()) 79 AD_Sequence_ID = rs.getInt(6); 80 rs.close(); 81 pstmt.close(); 82 } 83 84 PreparedStatement pstmt = DB.prepareStatement(SQL); 85 pstmt.setInt(1, C_DocType_ID.intValue()); 86 ResultSet rs = pstmt.executeQuery(); 87 String DocSubTypeSO = ""; 88 boolean IsSOTrx = true; 89 if (rs.next()) { 91 DocSubTypeSO = rs.getString(1); 93 if (DocSubTypeSO == null) 94 DocSubTypeSO = "--"; 95 Env.setContext(ctx, WindowNo, "OrderType", DocSubTypeSO); 96 97 if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay)) 98 { 99 mTab.setValue ("InvoiceRule", MOrder.INVOICERULE_Immediate); 100 mTab.setValue ("DeliveryRule", MOrder.DELIVERYRULE_AfterReceipt); 101 } 102 else 103 { 104 mTab.setValue ("InvoiceRule", MOrder.INVOICERULE_AfterDelivery); 105 mTab.setValue ("DeliveryRule", MOrder.DELIVERYRULE_Availability); 106 } 107 if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS)) mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_Cash); 109 else 110 mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_OnCredit); 111 112 if ("N".equals(rs.getString(8))) 114 IsSOTrx = false; 115 116 Env.setContext(ctx, WindowNo, "HasCharges", rs.getString(2)); 118 String YN = "Y"; 120 if (rs.getString(3).equals("Y")) 121 YN = "N"; 122 mTab.setValue("IsApproved", YN); 123 Env.setContext(ctx, WindowNo, "IsApproved", YN); if (rs.getString(4).equals("Y")) { 127 if (!newDocNo && AD_Sequence_ID != rs.getInt(7)) 128 newDocNo = true; 129 if (newDocNo) 130 if (Ini.getPropertyBool(Ini.P_COMPIERESYS) && Env.getAD_Client_ID(Env.getCtx()) < 1000000) 131 mTab.setValue("DocumentNo", "<" + rs.getString(6) + ">"); 132 else 133 mTab.setValue("DocumentNo", "<" + rs.getString(5) + ">"); 134 } 135 } 136 rs.close(); 137 pstmt.close(); 138 if (DocSubTypeSO.equals(MOrder.DocSubTypeSO_POS) || DocSubTypeSO.equals(MOrder.DocSubTypeSO_Prepay)) ; 143 else 144 { 145 SQL = "SELECT PaymentRule,C_PaymentTerm_ID," + "InvoiceRule,DeliveryRule," + "FreightCostRule,DeliveryViaRule, " + "PaymentRulePO,PO_PaymentTerm_ID " 149 + "FROM C_BPartner " 150 + "WHERE C_BPartner_ID=?"; pstmt = DB.prepareStatement(SQL); 152 int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); 153 pstmt.setInt(1, C_BPartner_ID); 154 rs = pstmt.executeQuery(); 156 if (rs.next()) 157 { 158 String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); 160 if (s != null && s.length() != 0) 161 { 162 if (IsSOTrx && (s.equals("B") || s.equals("S") || s.equals("U"))) s = "P"; if (!IsSOTrx && (s.equals("B"))) s = "P"; mTab.setValue("PaymentRule", s); 167 } 168 Integer ii =new Integer (rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); 170 if (!rs.wasNull()) 171 mTab.setValue("C_PaymentTerm_ID", ii); 172 s = rs.getString(3); 174 if (s != null && s.length() != 0) 175 mTab.setValue("InvoiceRule", s); 176 s = rs.getString(4); 178 if (s != null && s.length() != 0) 179 mTab.setValue("DeliveryRule", s); 180 s = rs.getString(5); 182 if (s != null && s.length() != 0) 183 mTab.setValue("FreightCostRule", s); 184 s = rs.getString(6); 186 if (s != null && s.length() != 0) 187 mTab.setValue("DeliveryViaRule", s); 188 } 189 rs.close(); 190 pstmt.close(); 191 } } 193 catch (SQLException e) 194 { 195 log.error("docType", e); 196 return e.getLocalizedMessage(); 197 } 198 199 return ""; 200 } 202 203 221 public String bPartner (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 222 { 223 Integer C_BPartner_ID = (Integer )value; 224 if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0) 225 return ""; 226 227 String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID," 228 + "p.M_PriceList_ID,p.PaymentRule,p.POReference," 229 + "p.SO_Description,p.IsDiscountPrinted," 230 + "p.InvoiceRule,p.DeliveryRule,p.FreightCostRule,DeliveryViaRule," 231 + "p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," 232 + "lship.C_BPartner_Location_ID,c.AD_User_ID," 233 + "p.PO_PriceList_ID, p.PaymentRulePO, p.PO_PaymentTerm_ID," 234 + "lbill.C_BPartner_Location_ID AS BillTo_ID " 235 + "FROM C_BPartner p" 236 + " LEFT OUTER JOIN C_BPartner_Location lbill ON (p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.IsActive='Y')" 237 + " LEFT OUTER JOIN C_BPartner_Location lship ON (p.C_BPartner_ID=lship.C_BPartner_ID AND lship.IsShipTo='Y' AND lship.IsActive='Y')" 238 + " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) " 239 + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; 241 boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx")); 242 243 try 244 { 245 PreparedStatement pstmt = DB.prepareStatement(sql); 246 pstmt.setInt(1, C_BPartner_ID.intValue()); 247 ResultSet rs = pstmt.executeQuery(); 248 if (rs.next()) 249 { 250 Integer ii = new Integer (rs.getInt(IsSOTrx ? "M_PriceList_ID" : "PO_PriceList_ID")); 252 if (!rs.wasNull()) 253 mTab.setValue("M_PriceList_ID", ii); 254 else 255 { int i = Env.getContextAsInt(ctx, "#M_PriceList_ID"); 257 if (i != 0) 258 mTab.setValue("M_PriceList_ID", new Integer (i)); 259 } 260 261 int billTo_ID = rs.getInt("BillTo_ID"); 263 if (billTo_ID == 0) 264 mTab.setValue("BillTo_ID", null); 265 else 266 mTab.setValue("BillTo_ID", new Integer (billTo_ID)); 267 int shipTo_ID = rs.getInt("C_BPartner_Location_ID"); 269 if (C_BPartner_ID.toString().equals(Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_ID"))) 272 { 273 String loc = Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_Location_ID"); 274 if (loc.length() > 0) 275 shipTo_ID = Integer.parseInt(loc); 276 } 277 if (shipTo_ID == 0) 278 mTab.setValue("C_BPartner_Location_ID", null); 279 else 280 mTab.setValue("C_BPartner_Location_ID", new Integer (shipTo_ID)); 281 282 int contID = rs.getInt("AD_User_ID"); 284 if (C_BPartner_ID.toString().equals(Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "C_BPartner_ID"))) 285 { 286 String cont = Env.getContext(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "AD_User_ID"); 287 if (cont.length() > 0) 288 contID = Integer.parseInt(cont); 289 } 290 if (contID == 0) 291 mTab.setValue("AD_User_ID", null); 292 else 293 mTab.setValue("AD_User_ID", new Integer (contID)); 294 295 double CreditAvailable = rs.getDouble("CreditAvailable"); 297 if (!rs.wasNull() && CreditAvailable < 0) 298 mTab.fireDataStatusEEvent("CreditLimitOver", 299 DisplayType.getNumberFormat(DisplayType.Amount).format(CreditAvailable)); 300 301 String s = rs.getString("POReference"); 303 if (s != null && s.length() != 0) 304 mTab.setValue("POReference", s); 305 else 306 mTab.setValue("POReference", null); 307 s = rs.getString("SO_Description"); 309 if (s != null && s.trim().length() != 0) 310 mTab.setValue("Description", s); 311 s = rs.getString("IsDiscountPrinted"); 313 if (s != null && s.length() != 0) 314 mTab.setValue("IsDiscountPrinted", s); 315 else 316 mTab.setValue("IsDiscountPrinted", "N"); 317 318 String OrderType = Env.getContext(ctx, WindowNo, "OrderType"); 320 mTab.setValue("InvoiceRule", MOrder.INVOICERULE_AfterDelivery); 321 mTab.setValue("DeliveryRule", MOrder.DELIVERYRULE_Availability); 322 mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_OnCredit); 323 if (OrderType.equals(MOrder.DocSubTypeSO_Prepay)) 324 { 325 mTab.setValue("InvoiceRule", MOrder.INVOICERULE_Immediate); 326 mTab.setValue("DeliveryRule", MOrder.DELIVERYRULE_AfterReceipt); 327 } 328 else if (OrderType.equals(MOrder.DocSubTypeSO_POS)) mTab.setValue("PaymentRule", MOrder.PAYMENTRULE_Cash); 330 else 331 { 332 s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); 334 if (s != null && s.length() != 0) 335 { 336 if (s.equals("B")) s = "P"; 338 if (IsSOTrx && (s.equals("S") || s.equals("U"))) s = "P"; mTab.setValue("PaymentRule", s); 341 } 342 ii = new Integer (rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); 344 if (!rs.wasNull()) 345 mTab.setValue("C_PaymentTerm_ID", ii); 346 s = rs.getString("InvoiceRule"); 348 if (s != null && s.length() != 0) 349 mTab.setValue("InvoiceRule", s); 350 s = rs.getString("DeliveryRule"); 352 if (s != null && s.length() != 0) 353 mTab.setValue("DeliveryRule", s); 354 s = rs.getString("FreightCostRule"); 356 if (s != null && s.length() != 0) 357 mTab.setValue("FreightCostRule", s); 358 s = rs.getString("DeliveryViaRule"); 360 if (s != null && s.length() != 0) 361 mTab.setValue("DeliveryViaRule", s); 362 } 363 } 364 rs.close(); 365 pstmt.close(); 366 } 367 catch (SQLException e) 368 { 369 log.error("bPartner", e); 370 return e.getLocalizedMessage(); 371 } 372 373 return ""; 374 } 376 377 392 public String priceList (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 393 { 394 Integer M_PriceList_ID = (Integer )value; 395 if (M_PriceList_ID == null || M_PriceList_ID.intValue()== 0) 396 return ""; 397 398 String SQL = "SELECT pl.IsTaxIncluded,pl.EnforcePriceLimit,pl.C_Currency_ID,c.StdPrecision," 399 + "plv.M_PriceList_Version_ID,plv.ValidFrom " 400 + "FROM M_PriceList pl,C_Currency c,M_PriceList_Version plv " 401 + "WHERE pl.C_Currency_ID=c.C_Currency_ID" 402 + " AND pl.M_PriceList_ID=plv.M_PriceList_ID" 403 + " AND pl.M_PriceList_ID=? " + "ORDER BY plv.ValidFrom DESC"; 405 try 407 { 408 PreparedStatement pstmt = DB.prepareStatement(SQL); 409 pstmt.setInt(1, M_PriceList_ID.intValue()); 410 ResultSet rs = pstmt.executeQuery(); 411 if (rs.next()) 412 { 413 mTab.setValue("IsTaxIncluded", rs.getString(1)); 415 Env.setContext(ctx, WindowNo, "EnforcePriceLimit", rs.getString(2)); 417 Integer ii = new Integer (rs.getInt(3)); 419 mTab.setValue("C_Currency_ID", ii); 420 Env.setContext(ctx, WindowNo, "StdPrecision", rs.getInt(4)); 422 Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", rs.getInt(5)); 424 } 425 rs.close(); 426 pstmt.close(); 427 } 428 catch (SQLException e) 429 { 430 log.error("priceList", e); 431 return e.getLocalizedMessage(); 432 } 433 434 return ""; 435 } 437 438 439 440 453 public String product (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 454 { 455 Integer M_Product_ID = (Integer )value; 456 if (M_Product_ID == null || M_Product_ID.intValue() == 0) 457 return ""; 458 setCalloutActive(true); 459 mTab.setValue("C_Charge_ID", null); 460 if (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID.intValue() 462 && Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID") != 0) 463 mTab.setValue("M_AttributeSetInstance_ID", new Integer (Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID"))); 464 else 465 mTab.setValue("M_AttributeSetInstance_ID", null); 466 467 Timestamp orderDate = (Timestamp)mTab.getValue("DateOrdered"); 469 if (orderDate == null) 470 orderDate = new Timestamp(System.currentTimeMillis()); 471 472 int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); 473 MProductPriceVO pp = MProductPriceVO.getBOMPricesPLV(M_Product_ID.intValue(), M_PriceList_Version_ID); 474 if (pp == null) 476 { 477 int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); 478 pp = MProductPriceVO.getBOMPricesPL(M_Product_ID.intValue(), M_PriceList_ID, orderDate); 479 } 480 if (pp == null) 482 { 483 boolean isSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx")); 484 pp = MProductPriceVO.getBOMPrices(M_Product_ID.intValue(), isSOTrx, orderDate); 485 } 486 487 if (pp != null) 489 { 490 mTab.setValue("PriceList", pp.PriceList); 491 mTab.setValue("PriceLimit", pp.PriceLimit); 492 mTab.setValue("PriceActual", pp.PriceStd); 493 mTab.setValue("C_Currency_ID", new Integer (pp.getC_Currency_ID())); 494 Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N"); 495 } 496 497 506 int C_UOM_ID = DB.getSQLValue("SELECT C_UOM_ID FROM M_Product WHERE M_Product_ID=?", M_Product_ID.intValue()); 507 if (C_UOM_ID != 0) 508 mTab.setValue("C_UOM_ID", new Integer (C_UOM_ID)); 509 setCalloutActive(false); 510 return tax (ctx, WindowNo, mTab, mField, value); 512 } 514 525 public String charge (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 526 { 527 Integer C_Charge_ID = (Integer )value; 528 if (C_Charge_ID == null || C_Charge_ID.intValue() == 0) 529 return ""; 530 if (mTab.getValue("M_Product_ID") != null) 532 { 533 mTab.setValue("C_Charge_ID", null); 534 return "ChargeExclusively"; 535 } 536 537 try 538 { 539 String SQL = "SELECT ChargeAmt FROM C_Charge WHERE C_Charge_ID=?"; 540 PreparedStatement pstmt = DB.prepareStatement(SQL); 541 pstmt.setInt(1, C_Charge_ID.intValue()); 542 ResultSet rs = pstmt.executeQuery(); 543 if (rs.next()) 544 { 545 mTab.setValue ("PriceActual", rs.getBigDecimal (1)); 546 mTab.setValue ("PriceLimit", Env.ZERO); 547 mTab.setValue ("PriceList", Env.ZERO); 548 mTab.setValue ("Discount", Env.ZERO); 549 } 550 rs.close(); 551 pstmt.close(); 552 } 553 catch (SQLException e) 554 { 555 log.error("charge" + e); 556 return e.getLocalizedMessage(); 557 } 558 return tax (ctx, WindowNo, mTab, mField, value); 560 } 562 563 574 public String tax (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 575 { 576 String column = mField.getColumnName(); 577 if (value == null) 578 return ""; 579 580 int M_Product_ID = 0; 582 if (column.equals("M_Product_ID")) 583 M_Product_ID = ((Integer )value).intValue(); 584 else 585 M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID"); 586 int C_Charge_ID = 0; 587 if (column.equals("C_Charge_ID")) 588 C_Charge_ID = ((Integer )value).intValue(); 589 else 590 C_Charge_ID = Env.getContextAsInt(ctx, WindowNo, "C_Charge_ID"); 591 log.debug("Product=" + M_Product_ID + ", C_Charge_ID=" + C_Charge_ID); 592 if (M_Product_ID == 0 && C_Charge_ID == 0) 593 return ""; 594 595 int shipC_BPartner_Location_ID = 0; 597 if (column.equals("C_BPartner_Location_ID")) 598 shipC_BPartner_Location_ID = ((Integer )value).intValue(); 599 else 600 shipC_BPartner_Location_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_Location_ID"); 601 if (shipC_BPartner_Location_ID == 0) 602 return ""; 603 log.debug("Ship BP_Location=" + shipC_BPartner_Location_ID); 604 605 Timestamp billDate = Env.getContextAsDate(ctx, WindowNo, "DateOrdered"); 607 log.debug("Bill Date=" + billDate); 608 609 Timestamp shipDate = Env.getContextAsDate(ctx, WindowNo, "DatePromised"); 610 log.debug("Ship Date=" + shipDate); 611 612 int AD_Org_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Org_ID"); 613 log.debug("Org=" + AD_Org_ID); 614 615 int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID"); 616 log.debug("Warehouse=" + M_Warehouse_ID); 617 618 int billC_BPartner_Location_ID = Env.getContextAsInt(ctx, WindowNo, "BillTo_ID"); 619 if (billC_BPartner_Location_ID == 0) 620 billC_BPartner_Location_ID = shipC_BPartner_Location_ID; 621 log.debug("Bill BP_Location=" + billC_BPartner_Location_ID); 622 623 int C_Tax_ID = Tax.get (ctx, M_Product_ID, C_Charge_ID, billDate, shipDate, 625 AD_Org_ID, M_Warehouse_ID, billC_BPartner_Location_ID, shipC_BPartner_Location_ID, 626 "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"))); 627 log.debug("Tax ID=" + C_Tax_ID); 628 if (C_Tax_ID == 0) 630 mTab.fireDataStatusEEvent(Log.retrieveError()); 631 else 632 mTab.setValue("C_Tax_ID", new Integer (C_Tax_ID)); 633 return amt(ctx, WindowNo, mTab, mField, value); 635 } 637 638 650 public String amt (Properties ctx, int WindowNo, MTab mTab, MField mField, Object value) 651 { 652 if (isCalloutActive() || value == null) 653 return ""; 654 setCalloutActive(true); 655 656 BigDecimal QtyOrdered, PriceActual, PriceLimit, Discount, PriceList; 657 int StdPrecision = Env.getContextAsInt(ctx, WindowNo, "StdPrecision"); 658 659 660 QtyOrdered = (BigDecimal)mTab.getValue("QtyOrdered"); 662 PriceActual = ((BigDecimal)mTab.getValue("PriceActual")).setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); 663 Discount = (BigDecimal)mTab.getValue("Discount"); 664 PriceLimit = ((BigDecimal)mTab.getValue("PriceLimit")).setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); 666 PriceList = (BigDecimal)mTab.getValue("PriceList"); 667 log.debug("Ordered=" + QtyOrdered + ", List=" + PriceList + ", Limit=" + PriceLimit + ", Precision=" + StdPrecision); 668 log.debug("~ Actual=" + PriceActual + ", Discount=" + Discount); 669 670 if (mField.getColumnName().equals("Discount")) 672 { 673 PriceActual = new BigDecimal ((100.0 - Discount.doubleValue()) / 100.0 * PriceList.doubleValue()); 674 if (PriceActual.scale() > StdPrecision) 675 PriceActual = PriceActual.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); 676 mTab.setValue("PriceActual", PriceActual); 677 } 678 else 680 { 681 if (PriceList.intValue() == 0) 682 Discount = Env.ZERO; 683 else 684 Discount = new BigDecimal ((PriceList.doubleValue() - PriceActual.doubleValue()) / PriceList.doubleValue() * 100.0); 685 if (Discount.scale() > 2) 686 Discount = Discount.setScale(2, BigDecimal.ROUND_HALF_UP); 687 mTab.setValue("Discount", Discount); 688 } 689 log.debug("= Actual=" + PriceActual + ", Discount=" + Discount); 690 691 if (!mField.getColumnName().equals("QtyOrdered")) 693 { 694 String epl = Env.getContext(ctx, WindowNo, "EnforcePriceLimit"); 695 if (epl != null && epl.equals("Y") && PriceLimit.doubleValue() != 0.0 697 && PriceActual.compareTo(PriceLimit) < 0) 698 { 699 mTab.setValue ("PriceActual", PriceLimit); 700 mTab.fireDataStatusEEvent ("UnderLimitPrice", ""); 701 PriceActual = PriceLimit; 702 if (PriceList.intValue() != 0) 704 { 705 Discount = new BigDecimal ((PriceList.doubleValue () - PriceActual.doubleValue ()) / PriceList.doubleValue () * 100.0); 706 if (Discount.scale () > 2) 707 Discount = Discount.setScale (2, BigDecimal.ROUND_HALF_UP); 708 mTab.setValue ("Discount", Discount); 709 } 710 } 711 } 712 713 BigDecimal LineNetAmt = QtyOrdered.multiply(PriceActual); 715 if (LineNetAmt.scale() > StdPrecision) 716 LineNetAmt = LineNetAmt.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP); 717 mTab.setValue("LineNetAmt", LineNetAmt); 718 log.debug("LineNetAmt=" + LineNetAmt); 719 setCalloutActive(false); 721 return ""; 722 } 724 } 726 | Popular Tags |