List of usage examples for java.math BigDecimal signum
public int signum()
From source file:org.openbravo.advpaymentmngt.actionHandler.AddPaymentActionHandler.java
private boolean getDocumentConfirmation(FIN_FinancialAccount finAccount, FIN_PaymentMethod finPaymentMethod, boolean isReceipt, String strPaymentAmount, boolean isPayment) { // Checks if this step is configured to generate accounting for the selected financial account boolean confirmation = false; OBContext.setAdminMode(true);//from w w w . j a va 2 s . c om try { OBCriteria<FinAccPaymentMethod> obCriteria = OBDal.getInstance() .createCriteria(FinAccPaymentMethod.class); obCriteria.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, finAccount)); obCriteria.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, finPaymentMethod)); obCriteria.setFilterOnReadableClients(false); obCriteria.setFilterOnReadableOrganization(false); obCriteria.setMaxResults(1); FinAccPaymentMethod finAccPayMethod = (FinAccPaymentMethod) obCriteria.uniqueResult(); String uponUse = ""; if (isPayment) { if (isReceipt) { uponUse = finAccPayMethod.getUponReceiptUse(); } else { uponUse = finAccPayMethod.getUponPaymentUse(); } } else { if (isReceipt) { uponUse = finAccPayMethod.getUponDepositUse(); } else { uponUse = finAccPayMethod.getUponWithdrawalUse(); } } for (FIN_FinancialAccountAccounting account : finAccount.getFINFinancialAccountAcctList()) { if (confirmation) { return confirmation; } if (isReceipt) { if ("INT".equals(uponUse) && account.getInTransitPaymentAccountIN() != null) { confirmation = true; } else if ("DEP".equals(uponUse) && account.getDepositAccount() != null) { confirmation = true; } else if ("CLE".equals(uponUse) && account.getClearedPaymentAccount() != null) { confirmation = true; } } else { if ("INT".equals(uponUse) && account.getFINOutIntransitAcct() != null) { confirmation = true; } else if ("WIT".equals(uponUse) && account.getWithdrawalAccount() != null) { confirmation = true; } else if ("CLE".equals(uponUse) && account.getClearedPaymentAccountOUT() != null) { confirmation = true; } } // For payments with Amount ZERO always create an entry as no transaction will be created if (isPayment) { BigDecimal amount = new BigDecimal(strPaymentAmount); if (amount.signum() == 0) { confirmation = true; } } } } catch (Exception e) { return confirmation; } finally { OBContext.restorePreviousMode(); } return confirmation; }
From source file:org.egov.wtms.application.service.collection.WaterTaxExternalService.java
public WaterTaxDetails getWaterTaxDetails(WaterTaxDetails waterTaxDetails, WaterConnectionDetails waterConnectionDetails) { String propertyIdentifier = waterConnectionDetails.getConnection().getPropertyIdentifier(); BasicProperty basicProperty = basicPropertyDAO.getAllBasicPropertyByPropertyID(propertyIdentifier); waterTaxDetails.setPropertyAddress(basicProperty.getAddress().toString()); waterTaxDetails.setLocalityName(basicProperty.getPropertyID().getLocality().getName()); waterTaxDetails.setConsumerNo(waterConnectionDetails.getConnection().getConsumerCode()); List<PropertyOwnerInfo> propOwnerInfos = basicProperty.getPropertyOwnerInfo(); if (!propOwnerInfos.isEmpty()) { waterTaxDetails.setOwnerName(propOwnerInfos.get(0).getOwner().getName()); waterTaxDetails.setMobileNo(propOwnerInfos.get(0).getOwner().getMobileNumber()); }//from w w w .j av a2s. co m waterTaxDetails.setTaxDetails(new ArrayList<>(0)); BigDecimal waterTaxDueAmount = waterConnectionDetailsService.getWaterTaxDueAmount(waterConnectionDetails); RestPropertyTaxDetails arrearDetails = new RestPropertyTaxDetails(); arrearDetails.setTotalAmount(waterTaxDueAmount.signum() >= 0 ? waterTaxDueAmount : ZERO); arrearDetails.setTaxAmount(waterTaxDueAmount.signum() >= 0 ? waterTaxDueAmount : ZERO); arrearDetails.setInstallment(financialYearDAO.getFinancialYearByDate(new Date()).getFinYearRange()); waterTaxDetails.getTaxDetails().add(arrearDetails); ErrorDetails errorDetails = new ErrorDetails(); errorDetails.setErrorCode(WaterTaxConstants.THIRD_PARTY_ERR_CODE_SUCCESS); errorDetails.setErrorMessage(WaterTaxConstants.THIRD_PARTY_ERR_MSG_SUCCESS); waterTaxDetails.setErrorDetails(errorDetails); return waterTaxDetails; }
From source file:org.opentaps.dataimport.CustomerDecoder.java
/** * Helper function to generate a percentage discount term. Make sure that the percentage is represented as a decimal number * and not a whole number./*from ww w .j av a 2 s. co m*/ * Used by createSalesAgreementTerms(). * TODO: This term isn't really used anywhere. * TODO: In validating discount rate, throw illegal argument if it's not valid */ public List<GenericValue> createAgreementDiscountTerm(String agreementId, String customerCurrencyUomId, int seqId, Delegator delegator, BigDecimal discountRate, Long discountDays) { List<GenericValue> toBeStored = new FastList<GenericValue>(); if (discountRate != null && discountRate.signum() > 0) { return createAgreementTerm(agreementId, "AGREEMENT_PAYMENT", "FIN_PAYMENT_DISC", discountRate, discountDays, customerCurrencyUomId, seqId, delegator); } return toBeStored; }
From source file:com.esd.cs.audit.AuditsController.java
/** * ??//w w w . java2 s.co m * * @param calculateModel * @return */ @RequestMapping(value = "/calculate", method = RequestMethod.POST) @ResponseBody public CalculateModel calculateModel(CalculateModel calculateModel) { logger.debug(calculateModel.toString()); Integer companyId = calculateModel.getCompanyId(); String year = calculateModel.getYear(); AuditParameter auditParameter = auditParameterService.getByYear(year); // ? Integer zaiZhiYuanGongZongShu = calculateModel.getZaiZhiYuanGongZongShu(); if (zaiZhiYuanGongZongShu == null) { zaiZhiYuanGongZongShu = 0; } // BigDecimal putScale = auditParameter.getPutScale(); // // =????* BigDecimal yingAnPaiCanJiRen = putScale.multiply(new BigDecimal(zaiZhiYuanGongZongShu)).setScale(2, BigDecimal.ROUND_HALF_UP); calculateModel.setYingAnPaiCanJiRen(yingAnPaiCanJiRen);// // ======================================================================================== // Integer yiLuRuCanJiRen = calculateModel.getYiLuRuCanJiRen(); // ??? List<WorkerCalculator> list = auditParameterService.getSpecialSetting(year); for (WorkerCalculator workerCalculator : list) { Integer per = workerCalculator.getPer().intValue(); Integer type = workerCalculator.getType(); Integer lvl = workerCalculator.getLvl(); Integer num = auditParameterService.getSpecialCount(companyId, year, type, lvl); logger.debug("type:{},lvl:{},per:{}", type, lvl, per); yiLuRuCanJiRen = ((yiLuRuCanJiRen - num) + (num * per)); } // Integer yuDingCanJiRen = calculateModel.getYuDingCanJiRen(); // Integer yiAnPaiCanJiRen = yiLuRuCanJiRen + yuDingCanJiRen; calculateModel.setYiAnPaiCanJiRen(yiAnPaiCanJiRen);// ; // ========================================================================================= // ?? BigDecimal averageSalary = auditParameter.getAverageSalary(); // ? // ??*() BigDecimal yingJiaoJinE = averageSalary .multiply(yingAnPaiCanJiRen.subtract(new BigDecimal(yiAnPaiCanJiRen))); if (yingJiaoJinE.signum() == 1) {// 0 calculateModel.setYingJiaoJinE(yingJiaoJinE); } else { yingJiaoJinE = Constants.ZERO; calculateModel.setYingJiaoJinE(yingJiaoJinE); } // ?? BigDecimal jianJiaoJinE = calculateModel.getJianJiaoJinE(); // ?=?-?? BigDecimal shiJiaoJinE = yingJiaoJinE.subtract(jianJiaoJinE); // ? --------? // ============================================================? List<AccountModel> qianJiaoMingXi = new ArrayList<AccountModel>(); BigDecimal qianJiao = getSectionPaid(year, companyId, qianJiaoMingXi); calculateModel.setQianJiaoMingXi(qianJiaoMingXi); // ============================================================ List<AccountModel> weiShenMingXi = new ArrayList<AccountModel>(); BigDecimal weiShen = getUnAudits(year, companyId, new BigDecimal(zaiZhiYuanGongZongShu), weiShenMingXi); calculateModel.setWeiShenMingXi(weiShenMingXi); // ============================================================= List<AccountModel> weiJiaoMingXi = new ArrayList<AccountModel>(); BigDecimal weiJiao = getUnpaid(year, companyId, weiJiaoMingXi); calculateModel.setWeiJiaoMingXi(weiJiaoMingXi); // ==================================================================? logger.debug("qianJiao:{} weiShen:{} weiJiao{}", qianJiao, weiShen, weiJiao); // ? =++ BigDecimal shangNianDuWeiJiaoBaoZhangJin = qianJiao.add(weiShen).add(weiJiao); calculateModel.setShangNianDuWeiJiaoBaoZhangJin(shangNianDuWeiJiaoBaoZhangJin); // ===================================================================================================== // ?=?-??+?+? BigDecimal real_yingJiaoJinE = shiJiaoJinE.add(shangNianDuWeiJiaoBaoZhangJin); // BigDecimal real_yingJiaoJinE = shiJiaoJinE; calculateModel.setShiJiaoJinE(real_yingJiaoJinE);// ? // ============================================================================================ // Date date = auditParameter.getAuditDelayDate(); // BigDecimal zhiNaJinBiLi = auditParameter.getAuditDelayRate(); // int zhiNanJinTianshu = CalendarUtil.getDaySub(date, new Date()); if (zhiNanJinTianshu < 0) { zhiNanJinTianshu = 0; } calculateModel.setZhiNaJinTianShu(zhiNanJinTianshu);// // BigDecimal zhiNaJin = real_yingJiaoJinE.multiply(zhiNaJinBiLi).multiply(new BigDecimal(zhiNanJinTianshu)); // ?? Boolean mian = calculateModel.getMianZhiNaJin(); if (mian) { zhiNaJin = new BigDecimal(0.00); } calculateModel.setZhiNaJin(zhiNaJin);// // =============================================================================================== // ?=?+ BigDecimal shiJiaoZongJinE = real_yingJiaoJinE.add(zhiNaJin); Boolean mianJiao = calculateModel.getMianJiao();// ??? if (mianJiao) { shiJiaoZongJinE = new BigDecimal(0.00); } calculateModel.setShiJiaoZongJinE(shiJiaoZongJinE); return calculateModel; }
From source file:org.openbravo.erpCommon.ad_forms.DocLandedCost.java
/** * Get the account for Accounting Schema * //from w w w . ja va 2 s .com * @param as * accounting schema * @return Account */ public final Account getLandedCostAccount(String lcTypeId, BigDecimal amount, AcctSchema as, ConnectionProvider conn) { String Account_ID = ""; DocLineLandedCostData[] data = null; Account acct = null; try { DocLineLandedCostData[] dataAcctType = DocLineLandedCostData.selectLCAccount(conn, lcTypeId); if (!"".equals(dataAcctType[0].accountId)) { data = DocLineLandedCostData.selectGlitem(conn, dataAcctType[0].accountId, as.getC_AcctSchema_ID()); if (data.length > 0) { Account_ID = data[0].glitemDebitAcct; if (amount != null && amount.signum() < 0) { Account_ID = data[0].glitemCreditAcct; } } } else if (!"".equals(dataAcctType[0].mProductId)) { data = DocLineLandedCostData.selectLCProduct(conn, dataAcctType[0].mProductId, as.getC_AcctSchema_ID()); if (data.length > 0) { Account_ID = data[0].accountId; } } else { log4jDocLandedCost .warn("getLandedCostAccount - NO account for landed cost type " + dataAcctType[0].name); return null; } // No account if (Account_ID.equals("")) { log4jDocLandedCost .warn("getLandedCostAccount - NO account for landed cost type =" + dataAcctType[0].name); return null; } // Return Account acct = Account.getAccount(conn, Account_ID); } catch (ServletException e) { log4jDocLandedCost.warn(e); } return acct; }
From source file:org.openbravo.erpCommon.ad_forms.DocLCCost.java
/** * Get the account for Accounting Schema * /*from w ww .j a v a 2 s .c om*/ * @param as * accounting schema * @return Account */ public final Account getLandedCostAccount(String lcTypeId, BigDecimal amount, AcctSchema as, ConnectionProvider conn) { String Account_ID = ""; DocLineLCCostData[] data = null; Account acct = null; try { DocLineLCCostData[] dataAcctType = DocLineLCCostData.selectLCAccount(conn, lcTypeId); if (!"".equals(dataAcctType[0].accountId)) { data = DocLineLCCostData.selectGlitem(conn, dataAcctType[0].accountId, as.getC_AcctSchema_ID()); if (data.length > 0) { Account_ID = data[0].glitemDebitAcct; if (amount != null && amount.signum() < 0) { Account_ID = data[0].glitemCreditAcct; } } } else if (!"".equals(dataAcctType[0].mProductId)) { data = DocLineLCCostData.selectLCProduct(conn, dataAcctType[0].mProductId, as.getC_AcctSchema_ID()); if (data.length > 0) { Account_ID = data[0].accountId; } } else { log4jDocLCCost.warn("getLCCostAccount - NO account for landed cost type " + dataAcctType[0].name); return null; } // No account if (Account_ID.equals("")) { log4jDocLCCost.warn("getLCCostAccount - NO account for landed cost type =" + dataAcctType[0].name); return null; } // Return Account acct = Account.getAccount(conn, Account_ID); } catch (ServletException e) { log4jDocLCCost.warn(e); } return acct; }
From source file:com.heliumv.api.production.ProductionApi.java
private LosistmaterialDto createLosistmaterialDto(Integer stockId, BigDecimal amount) { LosistmaterialDto losistmaterialDto = new LosistmaterialDto(); losistmaterialDto.setLagerIId(stockId); losistmaterialDto.setBAbgang(new Short((short) (amount.signum() > 0 ? 1 : 0))); losistmaterialDto.setNMenge(amount); return losistmaterialDto; }
From source file:org.egov.wtms.application.service.ConnectionDemandService.java
public BindingResult getWaterTaxDue(WaterConnectionDetails waterConnectionDetails, BindingResult resultBinder) { if (isBlank(waterConnectionDetails.getEstimationNumber())) resultBinder.reject("err.demandnote.not.present"); else {//from w w w . j a v a 2s . c om BigDecimal waterChargesDue = waterConnectionDetailsService.getTotalAmount(waterConnectionDetails); if (waterChargesDue.signum() > 0) resultBinder.reject("err.water.charges.due", new Double[] { waterChargesDue.doubleValue() }, null); } return resultBinder; }
From source file:org.efaps.esjp.accounting.transaction.Recalculate_Base.java
/** * Method for obtain map with values to validate accounts. * * @param _parameter Parameter as passed from the eFaps API. * @param _gainloss BigDecimal of the gain or loss in the document. * @return map./* www.j av a 2s .c om*/ * @throws EFapsException on error. */ private Map<String, String[]> validateInfo(final Parameter _parameter, final BigDecimal _gainloss) throws EFapsException { final Properties gainLoss = Accounting.getSysConfig() .getObjectAttributeValueAsProperties(_parameter.getInstance()); final String accStr; if (_gainloss.signum() > 0) { accStr = gainLoss.getProperty(AccountingSettings.PERIOD_EXCHANGELOSS); } else { accStr = gainLoss.getProperty(AccountingSettings.PERIOD_EXCHANGEGAIN); } String[] accs = new String[2]; final String[] check = new String[2]; final String[] accOids = new String[2]; if (accStr != null) { accs = accStr.split(";"); if (accs.length > 0) { for (int i = 0; i < accs.length; i++) { final QueryBuilder queryBldr = new QueryBuilder(CIAccounting.AccountAbstract); queryBldr.addWhereAttrEqValue(CIAccounting.AccountAbstract.PeriodAbstractLink, _parameter.getInstance().getId()); queryBldr.addWhereAttrEqValue(CIAccounting.AccountAbstract.Name, accs[i].toString()); final MultiPrintQuery multi = queryBldr.getPrint(); multi.addAttribute(CIAccounting.AccountAbstract.OID); multi.execute(); while (multi.next()) { check[i] = "true"; accOids[i] = multi.<String>getAttribute(CIAccounting.AccountAbstract.OID); } } } } final Map<String, String[]> map = new HashMap<>(); map.put("check", check); map.put("accs", accs); map.put("accountOids", accOids); return map; }
From source file:com.heliumv.api.production.ProductionApi.java
@POST @Path("/materialwithdrawal/") @Consumes({ "application/json", "application/xml" }) public void bucheMaterialNachtraeglichVomLagerAb(@HeaderParam(ParamInHeader.TOKEN) String headerUserId, MaterialWithdrawalEntry materialEntry, @QueryParam("userId") String userId) { ArtikelDto itemDto = null;//from ww w . j a va2 s . c o m LagerDto lagerDto = null; try { if (materialEntry == null) { respondBadRequestValueMissing("materialwithdrawal"); return; } if (StringHelper.isEmpty(materialEntry.getLotCnr())) { respondBadRequestValueMissing("lotCnr"); return; } if (StringHelper.isEmpty(materialEntry.getItemCnr())) { respondBadRequestValueMissing("itemCnr"); return; } if (materialEntry.getAmount() == null || materialEntry.getAmount().signum() == 0) { respondBadRequest("amount", "null/0"); return; } if (connectClient(headerUserId, userId) == null) return; // if(!judgeCall.hasFertLosCUD()) { if (!mandantCall.hasModulLos()) { respondNotFound(); return; } if (!fertigungCall.darfGebeMaterialNachtraeglichAus()) { respondUnauthorized(); return; } LosDto losDto = findLosByCnr(materialEntry.getLotCnr()); if (losDto == null) { respondNotFound("lotCnr", materialEntry.getLotCnr()); return; } if (!isValidLosState(losDto)) return; itemDto = findItemByCnr(materialEntry.getItemCnr()); if (itemDto == null) { respondNotFound("itemCnr", materialEntry.getItemCnr()); return; } MontageartDto montageartDto = getMontageart(); if (montageartDto == null) { respondBadRequest("montageart", "no value defined"); return; } lagerDto = getLager(materialEntry.getStockCnr(), materialEntry.getStockId()); if (lagerDto == null) { return; } if (materialEntry.getAmount().signum() > 0) { MaterialRuecknahme ausgabe = new MaterialRuecknahme(losDto.getIId(), lagerDto.getIId(), itemDto); if (!ausgabe.verifyAmounts(materialEntry.getAmount(), materialEntry.getIdentities())) { return; } gebeMaterialNachtraeglichAus(lagerDto.getIId(), losDto, itemDto, montageartDto, materialEntry.getAmount(), materialEntry.getIdentities()); } else { BigDecimal amountToReturn = materialEntry.getAmount().abs(); MaterialRuecknahme ruecknahme = new MaterialRuecknahme(losDto.getIId(), lagerDto.getIId(), itemDto); ruecknahme.setReturn(materialEntry.getReturn()); if (!ruecknahme.verifyAmounts(amountToReturn, materialEntry.getIdentities())) { return; } BigDecimal amountNotReturned = ruecknahme.returnItem(amountToReturn, materialEntry.getIdentities(), false); if (amountNotReturned.signum() == 0) { amountNotReturned = ruecknahme.returnItem(amountToReturn, materialEntry.getIdentities(), true); } if (amountNotReturned.signum() != 0) { respondBadRequest(EJBExceptionLP.FEHLER_ZUWENIG_AUF_LAGER); appendBadRequestData("stock-available", amountToReturn.subtract(amountNotReturned).toPlainString()); } } } catch (NamingException e) { respondUnavailable(e); } catch (RemoteException e) { respondUnavailable(e); } catch (EJBExceptionLP e) { respondBadRequest(e); if (e.getCode() == EJBExceptionLP.FEHLER_ZUWENIG_AUF_LAGER) { try { BigDecimal lagerStand = getLagerCall().getLagerstandOhneExc(itemDto.getIId(), lagerDto.getIId()); appendBadRequestData("stock-available", lagerStand.toPlainString()); } catch (NamingException n) { respondUnavailable(n); } catch (RemoteException r) { respondUnavailable(r); } } } }