Example usage for java.math BigDecimal compareTo

List of usage examples for java.math BigDecimal compareTo

Introduction

In this page you can find the example usage for java.math BigDecimal compareTo.

Prototype

@Override
public int compareTo(BigDecimal val) 

Source Link

Document

Compares this BigDecimal with the specified BigDecimal .

Usage

From source file:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
public BigDecimal getPartStorageNumber(String catalogNo, String company) {
    InventoryQtyAdjService inventoryQtyAdjService = new InventoryQtyAdjService();
    InventoryQtyAdjServiceSoap port = inventoryQtyAdjService.getInventoryQtyAdjServiceSoap();
    assertUserNameToken(port);// w  ww  . j a v  a  2 s.c o  m

    System.out.println("Invoking getInventoryQtyAdjBrw...");
    java.lang.String _getInventoryQtyAdjBrw_companyID = company;
    java.lang.String _getInventoryQtyAdjBrw_partNum = catalogNo;
    java.lang.String _getInventoryQtyAdjBrw_wareHouseCode = "US";
    if (company.equalsIgnoreCase("GSHK")) {
        _getInventoryQtyAdjBrw_wareHouseCode = "HK";
    }
    com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType _getInventoryQtyAdjBrw_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType> _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType>();
    javax.xml.ws.Holder<java.lang.String> _getInventoryQtyAdjBrw_primaryBin = new javax.xml.ws.Holder<java.lang.String>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType> _getInventoryQtyAdjBrw_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType>();
    try {
        port.getInventoryQtyAdjBrw(_getInventoryQtyAdjBrw_companyID, _getInventoryQtyAdjBrw_partNum,
                _getInventoryQtyAdjBrw_wareHouseCode, _getInventoryQtyAdjBrw_callContextIn,
                _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult, _getInventoryQtyAdjBrw_primaryBin,
                _getInventoryQtyAdjBrw_callContextOut);
    } catch (Exception e) {

    }
    if (_getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value == null) {
        return null;
    }
    List<BigDecimal> qtyList = new ArrayList<BigDecimal>();
    for (Object obj : _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value.getInventoryQtyAdjBrwDataSet()
            .getInventoryQtyAdjBrwOrWebServiceErrors()) {
        InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw inventoryQtyAdjBrw = (InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw) obj;
        qtyList.add(inventoryQtyAdjBrw.getBaseOnHandQty());
    }
    BigDecimal maxQty = new BigDecimal(0);
    for (BigDecimal d : qtyList) {
        if (d.compareTo(maxQty) > 0) {
            maxQty = d;
        }
    }
    return maxQty;
}

From source file:org.efaps.esjp.accounting.transaction.Create_Base.java

/**
 * Used form a from to create the transaction for opening a balance.
 *
 * @param _parameter Paramter as passed from the eFaps API
 * @return new Return/* w  w w  .j av  a2 s. c  om*/
 * @throws EFapsException on error
 */
public Return createTransactionOpeningBalance(final Parameter _parameter) throws EFapsException {
    final String debitAccOId = _parameter.getParameterValue("accountLink_Debit");
    final String[] amounts = _parameter.getParameterValues("amount");
    final String[] accounts = _parameter.getParameterValues("accountLink_Credit");
    final Instance periodInst = _parameter.getInstance();

    final Insert insert = new Insert(CIAccounting.TransactionOpeningBalance);
    insert.add(CIAccounting.TransactionOpeningBalance.Name, 0);
    insert.add(CIAccounting.TransactionOpeningBalance.Description,
            DBProperties.getProperty("org.efaps.esjp.accounting.Transaction.openingBalance.description"));
    insert.add(CIAccounting.TransactionOpeningBalance.Date, _parameter.getParameterValue("date"));
    insert.add(CIAccounting.TransactionOpeningBalance.PeriodLink, periodInst.getId());
    insert.add(CIAccounting.TransactionOpeningBalance.Status,
            ((Long) Status.find(CIAccounting.TransactionStatus.uuid, "Open").getId()).toString());
    insert.execute();

    BigDecimal debitAmount = BigDecimal.ZERO;
    final CurrencyInst curr = new Period().getCurrency(periodInst);
    final DecimalFormat formater = NumberFormatter.get().getFormatter(null, 2);
    for (int i = 0; i < amounts.length; i++) {
        final Instance accInst = Instance.get(accounts[i]);
        final PrintQuery print = new PrintQuery(accInst);
        print.addAttribute(CIAccounting.AccountAbstract.SumReport);
        print.execute();

        final BigDecimal sumreport = print.<BigDecimal>getAttribute(CIAccounting.AccountAbstract.SumReport);
        try {
            BigDecimal amount = (BigDecimal) formater.parse(amounts[i]);
            amount = amount.subtract(sumreport == null ? BigDecimal.ZERO : sumreport);
            final CIType type = amount.compareTo(BigDecimal.ZERO) > 0 ? CIAccounting.TransactionPositionCredit
                    : CIAccounting.TransactionPositionDebit;
            final Insert posInsert = new Insert(type);
            posInsert.add(CIAccounting.TransactionPositionAbstract.AccountLink, accInst.getId());
            posInsert.add(CIAccounting.TransactionPositionAbstract.Amount, amount);
            posInsert.add(CIAccounting.TransactionPositionAbstract.CurrencyLink, curr.getInstance().getId());
            posInsert.add(CIAccounting.TransactionPositionAbstract.Rate, new Object[] { 1, 1 });
            posInsert.add(CIAccounting.TransactionPositionAbstract.RateAmount, amount);
            posInsert.add(CIAccounting.TransactionPositionAbstract.RateCurrencyLink,
                    curr.getInstance().getId());
            posInsert.add(CIAccounting.TransactionPositionAbstract.TransactionLink,
                    insert.getInstance().getId());
            posInsert.execute();
            debitAmount = debitAmount.add(amount);
        } catch (final ParseException e) {
            throw new EFapsException(Create_Base.class, "createTransactionOpeningBalance", e);
        }
    }
    final Instance accInst = Instance.get(debitAccOId);
    final CIType type = debitAmount.compareTo(BigDecimal.ZERO) < 0 ? CIAccounting.TransactionPositionCredit
            : CIAccounting.TransactionPositionDebit;
    final Insert posInsert = new Insert(type);
    posInsert.add(CIAccounting.TransactionPositionAbstract.AccountLink, accInst.getId());
    posInsert.add(CIAccounting.TransactionPositionAbstract.Amount, debitAmount.negate());
    posInsert.add(CIAccounting.TransactionPositionAbstract.CurrencyLink, curr.getInstance().getId());
    posInsert.add(CIAccounting.TransactionPositionAbstract.Rate, new Object[] { 1, 1 });
    posInsert.add(CIAccounting.TransactionPositionAbstract.RateAmount, debitAmount.negate());
    posInsert.add(CIAccounting.TransactionPositionAbstract.RateCurrencyLink, curr.getInstance().getId());
    posInsert.add(CIAccounting.TransactionPositionAbstract.TransactionLink, insert.getInstance().getId());
    posInsert.execute();

    return new Return();
}

From source file:com.nkapps.billing.dao.BankStatementDaoImpl.java

private void insertFizClaimPaymentByDebtor(Session sessionQuery, Session sessionTransaction,
        Validator validator, BankStatement bs, LocalDateTime dateTime, String tin) throws Exception {
    Query query = sessionQuery//  ww  w. java  2  s.  co m
            .createQuery("SELECT COALESCE(SUM(da.summa),0) FROM DsApplication da WHERE da.tin = :tin")
            .setParameter("tin", tin);
    BigDecimal allClaimSum = (BigDecimal) query.uniqueResult();
    query = sessionQuery
            .createQuery("SELECT COALESCE(SUM(paymentSum),0) FROM Payment p WHERE p.tin = :tin AND p.claim = 1")
            .setParameter("tin", tin);
    BigDecimal paidClaimSum = (BigDecimal) query.uniqueResult();

    BigDecimal realClaimSum, realPaymentSum;

    BigDecimal needClaimSum = allClaimSum.subtract(paidClaimSum);

    if (needClaimSum.compareTo(BigDecimal.ZERO) == 0) {
        realClaimSum = BigDecimal.ZERO;
        realPaymentSum = bs.getPaymentSum();
    } else if (bs.getPaymentSum().compareTo(needClaimSum) <= 0) {
        realClaimSum = bs.getPaymentSum();
        realPaymentSum = BigDecimal.ZERO;
    } else {
        realClaimSum = needClaimSum;
        realPaymentSum = bs.getPaymentSum().subtract(needClaimSum);
    }

    String tinDebtor = tin.equals(bs.getTin()) ? null : bs.getTin();
    if (realClaimSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin);
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realClaimSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 1); //
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }
    if (realPaymentSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin);
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realPaymentSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 0); //
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }

    bs.setTransfered((short) 1);
    sessionTransaction.update(bs);

}

From source file:com.nkapps.billing.dao.BankStatementDaoImpl.java

private void insertClaimPaymentManually(Session sessionQuery, Session sessionTransaction, Validator validator,
        BankStatement bs, String tin, String tinDebtor, Long issuerSerialNumber, String issuerIp,
        LocalDateTime dateTime) throws Exception {
    Query query = sessionQuery/* www .  j a  v  a 2  s  . c  o  m*/
            .createQuery("SELECT COALESCE(SUM(da.summa),0) FROM DsApplication da WHERE da.tin = :tin")
            .setParameter("tin", tin);
    BigDecimal allClaimSum = (BigDecimal) query.uniqueResult();
    query = sessionQuery
            .createQuery("SELECT COALESCE(SUM(paymentSum),0) FROM Payment p WHERE p.tin = :tin AND p.claim = 1")
            .setParameter("tin", tin);
    BigDecimal paidClaimSum = (BigDecimal) query.uniqueResult();

    BigDecimal realClaimSum, realPaymentSum;

    BigDecimal needClaimSum = allClaimSum.subtract(paidClaimSum);

    if (needClaimSum.compareTo(BigDecimal.ZERO) == 0) {
        realClaimSum = BigDecimal.ZERO;
        realPaymentSum = bs.getPaymentSum();
    } else if (bs.getPaymentSum().compareTo(needClaimSum) <= 0) {
        realClaimSum = bs.getPaymentSum();
        realPaymentSum = BigDecimal.ZERO;
    } else {
        realClaimSum = needClaimSum;
        realPaymentSum = bs.getPaymentSum().subtract(needClaimSum);
    }

    if (realClaimSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin); //
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realClaimSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 1); //
        payment.setIssuerSerialNumber(issuerSerialNumber);
        payment.setIssuerIp(issuerIp);
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }
    if (realPaymentSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin); //
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realPaymentSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 0); //
        payment.setIssuerSerialNumber(issuerSerialNumber);
        payment.setIssuerIp(issuerIp);
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }

    bs.setTransfered((short) 1);
    sessionTransaction.update(bs);

}

From source file:com.nkapps.billing.dao.BankStatementDaoImpl.java

private void insertClaimPayment(Session sessionQuery, Session sessionTransaction, Validator validator,
        BankStatement bs, String yurTin, LocalDateTime dateTime) throws Exception {
    Query query = sessionQuery//from  w  w  w. ja  va2s .co  m
            .createQuery("SELECT COALESCE(SUM(da.summa),0) FROM DsApplication da WHERE da.tin = :tin")
            .setParameter("tin", bs.getTin());
    BigDecimal allClaimSum = (BigDecimal) query.uniqueResult();
    query = sessionQuery
            .createQuery("SELECT COALESCE(SUM(paymentSum),0) FROM Payment p WHERE p.tin = :tin AND p.claim = 1")
            .setParameter("tin", bs.getTin());
    BigDecimal paidClaimSum = (BigDecimal) query.uniqueResult();

    BigDecimal realClaimSum, realPaymentSum;

    BigDecimal needClaimSum = allClaimSum.subtract(paidClaimSum);

    if (needClaimSum.compareTo(BigDecimal.ZERO) == 0) {
        realClaimSum = BigDecimal.ZERO;
        realPaymentSum = bs.getPaymentSum();
    } else if (bs.getPaymentSum().compareTo(needClaimSum) <= 0) {
        realClaimSum = bs.getPaymentSum();
        realPaymentSum = BigDecimal.ZERO;
    } else {
        realClaimSum = needClaimSum;
        realPaymentSum = bs.getPaymentSum().subtract(needClaimSum);
    }

    String tin, tinDebtor;
    if ("201122919".equals(bs.getTin())) {
        tin = yurTin;
        tinDebtor = bs.getTin();
    } else {
        tin = bs.getTin();
        tinDebtor = null;
    }
    if (realClaimSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin);
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realClaimSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 1); //
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }
    if (realPaymentSum.compareTo(BigDecimal.ZERO) > 0) {
        Payment payment = new Payment();
        payment.setTin(tin);
        payment.setPaymentNum(bs.getPaymentNum());
        payment.setPaymentDate(bs.getPaymentDate());
        payment.setPaymentSum(realPaymentSum); //
        payment.setSourceCode((short) 1);
        payment.setState((short) 1);
        payment.setTinDebtor(tinDebtor);
        payment.setClaim((short) 0); //
        payment.setDateCreated(dateTime);
        payment.setDateUpdated(dateTime);

        Set<ConstraintViolation<Payment>> constraints = validator.validate(payment);
        if (constraints.isEmpty()) {
            sessionTransaction.save(payment);

            BankStatementPayment bsp = new BankStatementPayment();
            BankStatementPaymentId bspId = new BankStatementPaymentId();
            bspId.setBankStatement(bs);
            bspId.setPayment(payment);
            bsp.setId(bspId);

            sessionTransaction.save(bsp);

        } else {
            throw new Exception("payment isnot valid, tin = " + payment.getTin());
        }
    }

    bs.setTransfered((short) 1);
    sessionTransaction.update(bs);

}

From source file:com.gazbert.bxbot.core.engine.TradingEngine.java

private boolean isEmergencyStopLimitBreached() throws TradingApiException, ExchangeNetworkException {

    boolean isEmergencyStopLimitBreached = true;

    LOG.info(() -> "Performing Emergency Stop check...");

    BalanceInfo balanceInfo;/*from ww  w .  jav a2 s. c  om*/
    try {
        balanceInfo = exchangeAdapter.getBalanceInfo();
    } catch (TradingApiException e) {
        final String errorMsg = "Failed to get Balance info from exchange to perform Emergency Stop check - letting"
                + " Trade Engine error policy decide what to do next...";
        LOG.error(errorMsg, e);
        // re-throw to main loop - might only be connection issue and it will retry...
        throw e;
    }

    final Map<String, BigDecimal> balancesAvailable = balanceInfo.getBalancesAvailable();
    final BigDecimal currentBalance = balancesAvailable.get(emergencyStopCurrency);
    if (currentBalance == null) {
        final String errorMsg = "Emergency stop check: Failed to get current Emergency Stop Currency balance as '"
                + emergencyStopCurrency + "' key into Balances map " + "returned null. Balances returned: "
                + balancesAvailable;
        LOG.error(errorMsg);
        throw new IllegalStateException(errorMsg);
    } else {

        LOG.info(() -> "Emergency Stop Currency balance available on exchange is ["
                + new DecimalFormat("#.########").format(currentBalance) + "] " + emergencyStopCurrency);

        LOG.info(() -> "Balance that will stop ALL trading across ALL markets is ["
                + new DecimalFormat("#.########").format(emergencyStopBalance) + "] " + emergencyStopCurrency);

        if (currentBalance.compareTo(emergencyStopBalance) < 0) {
            final String balanceBlownErrorMsg = "EMERGENCY STOP triggered! - Current Emergency Stop Currency ["
                    + emergencyStopCurrency + "] wallet balance ["
                    + new DecimalFormat("#.########").format(currentBalance) + "] on exchange "
                    + "is lower than configured Emergency Stop balance ["
                    + new DecimalFormat("#.########").format(emergencyStopBalance) + "] "
                    + emergencyStopCurrency;

            LOG.fatal(balanceBlownErrorMsg);
            emailAlerter.sendMessage(CRITICAL_EMAIL_ALERT_SUBJECT,
                    buildCriticalEmailAlertMsgContent(balanceBlownErrorMsg, null));
        } else {

            isEmergencyStopLimitBreached = false;
            LOG.info(() -> "Emergency Stop check PASSED!");
        }
    }
    return isEmergencyStopLimitBreached;
}

From source file:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
public String getPartStorageLocation(String catalogNo, String company) {
    //      PartService partService = new PartService();
    //      PartServiceSoap port = partService.getPartServiceSoap();
    //      assertUserNameToken(port);
    //      //from  w w  w .  j  ava  2 s .c o m
    //      System.out.println("Invoking getByID...");
    //      java.lang.String _getByID_companyID = "GSUS";
    //      java.lang.String _getByID_partNum = catalogNo;
    //      com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType _getByID_callContextIn = null;
    //      javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.PartDataSetType> _getByID_getByIDResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.PartDataSetType>();
    //      javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType> _getByID_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType>();
    //      try{
    //      port.getByID(_getByID_companyID, _getByID_partNum,
    //            _getByID_callContextIn, _getByID_getByIDResult,
    //            _getByID_callContextOut);
    //      }catch(Exception e){
    //         e.printStackTrace();
    //      }
    //      if(_getByID_getByIDResult.value == null){
    //         return null;
    //      }
    //      PartWhse partWhse = (PartWhse)_getByID_getByIDResult.value.getPartDataSet().getPartOrPartAttchOrPartCOO().get(2);
    //      return partWhse.getWarehouseCode()+"-"+partWhse.getPrimBinNum();
    InventoryQtyAdjService inventoryQtyAdjService = new InventoryQtyAdjService();
    InventoryQtyAdjServiceSoap port = inventoryQtyAdjService.getInventoryQtyAdjServiceSoap();
    assertUserNameToken(port);

    System.out.println("Invoking getInventoryQtyAdjBrw...");
    java.lang.String _getInventoryQtyAdjBrw_companyID = company;
    java.lang.String _getInventoryQtyAdjBrw_partNum = catalogNo;

    java.lang.String _getInventoryQtyAdjBrw_wareHouseCode = "US";
    if (company.equalsIgnoreCase("GSHK")) {
        _getInventoryQtyAdjBrw_wareHouseCode = "HK";
    }
    com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType _getInventoryQtyAdjBrw_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType> _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType>();
    javax.xml.ws.Holder<java.lang.String> _getInventoryQtyAdjBrw_primaryBin = new javax.xml.ws.Holder<java.lang.String>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType> _getInventoryQtyAdjBrw_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType>();
    try {
        port.getInventoryQtyAdjBrw(_getInventoryQtyAdjBrw_companyID, _getInventoryQtyAdjBrw_partNum,
                _getInventoryQtyAdjBrw_wareHouseCode, _getInventoryQtyAdjBrw_callContextIn,
                _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult, _getInventoryQtyAdjBrw_primaryBin,
                _getInventoryQtyAdjBrw_callContextOut);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (_getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value == null) {
        return null;
    }
    List<BigDecimal> qtyList = new ArrayList<BigDecimal>();
    Map<String, String> map1 = new HashMap<String, String>();
    Map<String, String> map2 = new HashMap<String, String>();
    for (Object obj : _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value.getInventoryQtyAdjBrwDataSet()
            .getInventoryQtyAdjBrwOrWebServiceErrors()) {
        InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw inventoryQtyAdjBrw = (InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw) obj;
        System.out.println(inventoryQtyAdjBrw.toString());
        qtyList.add(inventoryQtyAdjBrw.getBaseOnHandQty());
        map1.put(inventoryQtyAdjBrw.getBaseOnHandQty() + "", inventoryQtyAdjBrw.getWareHseCode());
        map2.put(inventoryQtyAdjBrw.getBaseOnHandQty() + "", inventoryQtyAdjBrw.getBinNum());
    }
    BigDecimal maxQty = new BigDecimal(0);
    for (BigDecimal d : qtyList) {
        if (d.compareTo(maxQty) > 0) {
            maxQty = d;
        }
    }
    return map1.get(maxQty.toString()) + "-" + map2.get(maxQty.toString());
}

From source file:org.efaps.esjp.accounting.transaction.evaluation.DocumentInfo_Base.java

/**
 * Setter method for instance variable {@link #rounding}.
 *
 * @param _parameter Parameter as passed by the eFaps API
 * @throws EFapsException on error/*from  w  w  w . j  a va  2s  . c o m*/
 */
public void applyRounding(final Parameter _parameter) throws EFapsException {
    if (!isValid(_parameter)) {
        final Period period = new Period();
        final Instance periodInst = period.evaluateCurrentPeriod(_parameter);
        // is does not sum to 0 but is less then the max defined
        final Properties props = Accounting.getSysConfig().getObjectAttributeValueAsProperties(periodInst);
        final BigDecimal diffMax = new BigDecimal(
                props.getProperty(AccountingSettings.PERIOD_ROUNDINGMAXAMOUNT, "0"));
        final BigDecimal diff = getDebitSum(_parameter).subtract(getCreditSum(_parameter));
        if (diffMax.compareTo(diff.abs()) > 0) {
            final boolean debit = diff.compareTo(BigDecimal.ZERO) < 0;
            final AccountInfo accInfo;
            if (debit) {
                accInfo = AccountInfo.get4Config(_parameter, AccountingSettings.PERIOD_ROUNDINGDEBIT);
            } else {
                accInfo = AccountInfo.get4Config(_parameter, AccountingSettings.PERIOD_ROUNDINGCREDIT);
            }
            if (accInfo != null) {
                accInfo.setAmount(diff.abs());
                accInfo.setAmountRate(diff.abs());
                final CurrencyInst currInst = period.getCurrency(periodInst);
                accInfo.setCurrInstance(currInst.getInstance());
                accInfo.setRateInfo(RateInfo.getDummyRateInfo(), "");
                if (debit) {
                    addDebit(accInfo);
                } else {
                    addCredit(accInfo);
                }
            }
        }
    }
}

From source file:com.gst.portfolio.interestratechart.data.InterestRateChartSlabDataValidator.java

public void validateChartSlabsCreate(final JsonElement element, final DataValidatorBuilder baseDataValidator,
        final Locale locale, final Boolean isPrimaryGroupingByAmount) {

    if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
        final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element);
        baseDataValidator.reset().parameter(descriptionParamName).value(description).notNull();
    }//from   w w  w .java 2 s .  c  om

    final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale);
    if (this.fromApiJsonHelper.parameterExists(periodTypeParamName, element)) {
        baseDataValidator.reset().parameter(periodTypeParamName).value(periodType)
                .isOneOfTheseValues(PeriodFrequencyType.integerValues());
    }
    Integer toPeriod = null;

    final Integer fromPeriod = this.fromApiJsonHelper.extractIntegerNamed(fromPeriodParamName, element, locale);
    if (this.fromApiJsonHelper.parameterExists(fromPeriodParamName, element)) {
        baseDataValidator.reset().parameter(fromPeriodParamName).value(fromPeriod).integerZeroOrGreater();
    }

    if ((isPrimaryGroupingByAmount != null && !isPrimaryGroupingByAmount)
            || (periodType != null || fromPeriod != null)) {
        baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull();
        baseDataValidator.reset().parameter(fromPeriodParamName).value(fromPeriod).notNull();
    }

    if (this.fromApiJsonHelper.parameterExists(toPeriodParamName, element)) {
        toPeriod = this.fromApiJsonHelper.extractIntegerNamed(toPeriodParamName, element, locale);
        baseDataValidator.reset().parameter(toPeriodParamName).value(toPeriod).integerGreaterThanZero();
    }

    if (fromPeriod != null && toPeriod != null) {
        if (fromPeriod > toPeriod) {
            baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod)
                    .failWithCode("fromperiod.greater.than.to.period");
        }
    }
    final BigDecimal amountRangeFrom = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeFromParamName,
            element, locale);
    final BigDecimal amountRangeTo = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeToParamName,
            element, locale);
    if (this.fromApiJsonHelper.parameterExists(amountRangeFromParamName, element)) {
        baseDataValidator.reset().parameter(amountRangeFromParamName).value(amountRangeFrom)
                .zeroOrPositiveAmount();
        if (isPrimaryGroupingByAmount != null && isPrimaryGroupingByAmount) {
            baseDataValidator.reset().parameter(amountRangeFromParamName).value(amountRangeFrom).notNull();
        }
    }

    if (this.fromApiJsonHelper.parameterExists(amountRangeToParamName, element)) {
        baseDataValidator.reset().parameter(amountRangeToParamName).value(amountRangeTo).positiveAmount();
    }

    if (amountRangeFrom == null && fromPeriod == null) {
        baseDataValidator.failWithCodeNoParameterAddedToErrorCode("fromperiod.or.amountRangeFrom.required");
    }

    if (amountRangeFrom != null && amountRangeTo != null) {
        if (amountRangeFrom.compareTo(amountRangeTo) > 1) {
            baseDataValidator.parameter(amountRangeFromParamName).value(fromPeriod)
                    .failWithCode("from.amount.greater.than.to.amount");
        }
    }

    final BigDecimal annualInterestRate = this.fromApiJsonHelper
            .extractBigDecimalNamed(annualInterestRateParamName, element, locale);
    baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull()
            .zeroOrPositiveAmount();

    validateIncentives(element, baseDataValidator, locale);
}

From source file:com.farouk.projectapp.FirstGUI.java

private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
    String sub = jTextField3.getText();
    try {//from  ww  w.  ja va  2s  . c  o  m
        int test = Integer.parseInt(sub);
        if (sub.isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Please provide a valid input", "Bad input", WIDTH);
        } else {
            BigDecimal bud = new BigDecimal(sub);
            if (bud.compareTo(BigDecimal.ZERO) < 0) {
                JOptionPane.showMessageDialog(rootPane, "Enter a positive number !!", "No!", WIDTH);
            } else {
                SQLConnect.changeLimit(bud, userID);
            }
            jLabel12.setText("Your current buy limit is :"
                    + String.valueOf(SQLConnect.getBudgetFromDB(userID).doubleValue()) + ".");
            jTextField3.setText(null);
        }
    } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(rootPane, "Please provide a valid number", "Bad input", WIDTH);
    }

}