Пример #1
0
 /** Factory method for convenient creation. */
 public static EgDemandDetails fromReasonAndAmounts(
     BigDecimal demandAmount, EgDemandReason egDemandReason, BigDecimal collectedAmount) {
   EgDemandDetails dd = new EgDemandDetails();
   dd.setAmount(demandAmount);
   dd.setEgDemandReason(egDemandReason);
   dd.setAmtCollected(collectedAmount);
   dd.setModifiedDate(new Date());
   dd.setCreateDate(new Date());
   return dd;
 }
Пример #2
0
 /**
  * Add an amount to the existing collected amount, allowing a "tolerance" of exceeding the
  * balance.
  */
 public void addCollectedWithTolerance(BigDecimal amount, BigDecimal tolerance) {
   BigDecimal collected = getAmtCollected() != null ? getAmtCollected() : BigDecimal.ZERO;
   if (amount.compareTo(getAmount().subtract(collected).add(tolerance)) > 0) {
     throw new ApplicationRuntimeException(
         "Amount being added "
             + amount
             + " is greater than "
             + getAmount()
             + " - "
             + collected
             + " + tolerance "
             + tolerance
             + ", for demand detail "
             + this.toString());
   } else {
     setAmtCollected(collected.add(amount));
   }
 }