示例#1
0
  public static MOrder completeOrder(Properties ctx, MOrder order)
      throws BPartnerOverCreditLimitException, OperationException {
    if (order.isSOTrx() == true) {
      CreditCheckBean crBean =
          OrderManager.checkBPartnerCreditLimit(
              ctx, order.getC_BPartner_ID(), order.get_ID(), order.get_TrxName());
      if (crBean.getValid() == false) throw new BPartnerOverCreditLimitException(crBean.getMsg());
    }

    PoManager.processIt(order, DocumentEngine.ACTION_Complete);

    return order;
  }
示例#2
0
  public static CreditCheckBean checkBPartnerCreditLimit(
      Properties ctx, int bPartnerId, int orderId, String trxName) {
    MBPartner bp = new MBPartner(ctx, bPartnerId, trxName);
    String m_processMsg = null;

    MOrder order = new MOrder(ctx, orderId, trxName);
    CreditCheckBean bean = new CreditCheckBean();

    boolean valid = true;

    if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus())) {
      valid = false;

      m_processMsg =
          "BPartnerCreditStop - TotalOpenBalance= "
              + bp.getTotalOpenBalance()
              + ", CreditLimit= "
              + bp.getSO_CreditLimit();
    }
    if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus())) {
      valid = false;

      m_processMsg =
          "BPartnerCreditHold - TotalOpenBalance= "
              + bp.getTotalOpenBalance()
              + ", CreditLimit= "
              + bp.getSO_CreditLimit();
    }

    BigDecimal grandTotal =
        MConversionRate.convertBase(
            ctx,
            order.getGrandTotal(),
            order.getC_Currency_ID(),
            order.getDateOrdered(),
            order.getC_ConversionType_ID(),
            Env.getAD_Client_ID(ctx),
            Env.getAD_Org_ID(ctx));

    if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal))) {
      valid = false;

      m_processMsg =
          "BPartnerOverCreditHold - TotalOpenBalance= "
              + bp.getTotalOpenBalance()
              + ", GrandTotal = "
              + order.getGrandTotal()
              + ", CreditLimit= "
              + bp.getSO_CreditLimit();
    }

    if (MBPartner.SOCREDITSTATUS_NoCreditCheck.equals(bp.getSOCreditStatus())) {
      valid = true;

      m_processMsg =
          "BPartnerCreditHold - TotalOpenBalance= "
              + bp.getTotalOpenBalance()
              + ", CreditLimit= "
              + bp.getSO_CreditLimit();
    }

    if (MBPartner.SOCREDITSTATUS_NoCreditCheck.equals(
        bp.getSOCreditStatus(order.getGrandTotal()))) {
      valid = true;

      m_processMsg =
          "BPartnerOverCreditHold - TotalOpenBalance= "
              + bp.getTotalOpenBalance()
              + ", GrandTotal = "
              + order.getGrandTotal()
              + ", CreditLimit= "
              + bp.getSO_CreditLimit();
    }
    bean.setValid(valid);
    bean.setMsg(m_processMsg);
    return bean;
  }