示例#1
0
 /**
  * Get Std Precision of accounting Currency
  *
  * @return precision
  */
 public int getStdPrecision() {
   if (m_stdPrecision < 0) {
     MCurrency cur = MCurrency.get(getCtx(), getC_Currency_ID());
     m_stdPrecision = cur.getStdPrecision();
     m_costPrecision = cur.getCostingPrecision();
   }
   return m_stdPrecision;
 } //	getStdPrecision
  /**
   * Parent Constructor
   *
   * @param invoice invoice
   * @param paySchedule payment schedule
   */
  public MInvoicePaySchedule(MInvoice invoice, MPaySchedule paySchedule) {
    super(invoice.getCtx(), 0, invoice.get_TrxName());
    m_parent = invoice;
    setClientOrg(invoice);
    setC_Invoice_ID(invoice.getC_Invoice_ID());
    setC_PaySchedule_ID(paySchedule.getC_PaySchedule_ID());

    //	Amounts
    int scale = MCurrency.getStdPrecision(getCtx(), invoice.getC_Currency_ID());
    BigDecimal due = invoice.getGrandTotal();
    if (due.compareTo(Env.ZERO) == 0) {
      setDueAmt(Env.ZERO);
      setDiscountAmt(Env.ZERO);
      setIsValid(false);
    } else {
      due =
          due.multiply(paySchedule.getPercentage())
              .divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP);
      setDueAmt(due);
      BigDecimal discount =
          due.multiply(paySchedule.getDiscount()).divide(HUNDRED, scale, BigDecimal.ROUND_HALF_UP);
      setDiscountAmt(discount);
      setIsValid(true);
    }

    //	Dates
    Timestamp dueDate = TimeUtil.addDays(invoice.getDateInvoiced(), paySchedule.getNetDays());
    setDueDate(dueDate);
    Timestamp discountDate =
        TimeUtil.addDays(invoice.getDateInvoiced(), paySchedule.getDiscountDays());
    setDiscountDate(discountDate);
  } //	MInvoicePaySchedule