Package java.math

Examples of java.math.BigDecimal.abs()


    final Type type1 = parameters.getType(0);
    final Object value1 = parameters.getValue(0);
    final Number result = context.getTypeRegistry().convertToNumber(type1, value1);

    final BigDecimal num = NumberUtil.getAsBigDecimal(result);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, num.abs());
  }

  public String getCanonicalName()
  {
    return "ABS";
View Full Code Here


     */
    public void testAbsNeg() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "123809648392384754573567356745735635678902957849027687.87678287";
        assertEquals("incorrect value", result, aNumber.abs().toString());
    }

    /**
     * Abs() of a positive BigDecimal
     */
 
View Full Code Here

     */
    public void testAbsPos() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "123809648392384754573567356745735635678902957849027687.87678287";
        assertEquals("incorrect value", result, aNumber.abs().toString());
    }

    /**
     * Abs(MathContext) of a negative BigDecimal
     */
 
View Full Code Here

    if (strNegate.equals(""))
      strNegate = "Y";
    BigDecimal DebitAmt = new BigDecimal(debitAmt.equals("") ? "0.00" : debitAmt);
    BigDecimal CreditAmt = new BigDecimal(creditAmt.equals("") ? "0.00" : creditAmt);
    if (strNegate.equals("N") && (DebitAmt.compareTo(ZERO) < 0 || CreditAmt.compareTo(ZERO) < 0)) {
      return createLine(docLine, account, C_Currency_ID, CreditAmt.abs().toString(), DebitAmt.abs()
          .toString(), Fact_Acct_Group_ID, SeqNo, DocBaseType, conn);
    }

    log4jFact.debug("createLine - " + account + " - Dr=" + debitAmt + ", Cr=" + creditAmt);
    log4jFact.debug("Starting createline");
View Full Code Here

        m_Amt = new BigDecimal(Amt);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    if (m_Amt.compareTo(ZERO) < 0)
      return createLine(docLine, accountCr, C_Currency_ID, "", m_Amt.abs().toString(),
          Fact_Acct_Group_ID, SeqNo, DocBaseType, conn);
    else
      return createLine(docLine, accountDr, C_Currency_ID, m_Amt.toString(), "",
          Fact_Acct_Group_ID, SeqNo, DocBaseType, conn);
  } // createLine
View Full Code Here

        m_Amt = new BigDecimal(Amt);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    if (m_Amt.compareTo(ZERO) < 0)
      return createLine(docLine, account, C_Currency_ID, "", m_Amt.abs().toString(),
          Fact_Acct_Group_ID, SeqNo, DocBaseType, conn);
    else
      return createLine(docLine, account, C_Currency_ID, Amt.toString(), "", Fact_Acct_Group_ID,
          SeqNo, DocBaseType, conn);
  } // createLine
View Full Code Here

    line.setDocumentInfo(m_doc, null);
    line.setJournalInfo(m_doc.GL_Category_ID);
    line.setPostingType(m_postingType);
    // Amount
    if (diff.compareTo(ZERO) < 0) // negative balance => DR
      line.setAmtSource(m_doc.C_Currency_ID, diff.abs().toString(), ZERO.toString());
    else
      // positive balance => CR
      line.setAmtSource(m_doc.C_Currency_ID, ZERO.toString(), diff.toString());
    // Convert
    line.convert(m_acctSchema.getC_Currency_ID(), m_doc.DateAcct, m_acctSchema
View Full Code Here

          line.setDocumentInfo(m_doc, null);
          line.setJournalInfo(m_doc.GL_Category_ID);
          line.setPostingType(m_postingType);
          // Amount & Account
          if (diff.compareTo(ZERO) < 0) {
            line.setAmtSource(m_doc.C_Currency_ID, diff.abs().toString(), ZERO.toString());
            line.setAccount(m_acctSchema, m_acctSchema.m_DueFrom_Acct);
          } else {
            line.setAmtSource(m_doc.C_Currency_ID, ZERO.toString(), diff.abs().toString());
            line.setAccount(m_acctSchema, m_acctSchema.m_DueTo_Acct);
          }
View Full Code Here

          // Amount & Account
          if (diff.compareTo(ZERO) < 0) {
            line.setAmtSource(m_doc.C_Currency_ID, diff.abs().toString(), ZERO.toString());
            line.setAccount(m_acctSchema, m_acctSchema.m_DueFrom_Acct);
          } else {
            line.setAmtSource(m_doc.C_Currency_ID, ZERO.toString(), diff.abs().toString());
            line.setAccount(m_acctSchema, m_acctSchema.m_DueTo_Acct);
          }
          line.convert(m_acctSchema.getC_Currency_ID(), m_doc.DateAcct, m_acctSchema
              .getCurrencyRateType(), conn);
          line.setAD_Org_ID(key.toString());
View Full Code Here

      // Amount
      line.setAmtSource(m_doc.C_Currency_ID, ZERO.toString(), ZERO.toString());
      line.convert(m_acctSchema.getC_Currency_ID(), m_doc.DateAcct, m_acctSchema
          .getCurrencyRateType(), conn);
      if (diff.compareTo(ZERO) < 0)
        line.setAmtAcct(diff.abs().toString(), ZERO.toString());
      else
        line.setAmtAcct(ZERO.toString(), diff.abs().toString());
      line.setAccount(m_acctSchema, m_acctSchema.getCurrencyBalancing_Acct());
      log4jFact.debug("balanceAccounting - " + line.toString());
      log4jFact
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.