コード例 #1
0
 private void checkTotalAmount(Double totalAmount, List<ClientCreditsAndPayments> credits) {
   // if (totalAmount > amountDue) {
   // return getMessages().amountToUseMustLessthanTotal();
   // }
   for (ClientCreditsAndPayments credit : credits) {
     credit.setRemaoningBalance(credit.getRemaoningBalance() + credit.getAmtTouse());
   }
   double amountNeeded = totalAmount;
   for (ClientCreditsAndPayments credit : credits) {
     double balance = credit.getRemaoningBalance();
     double amountToUse = Math.min(amountNeeded, balance);
     credit.setAmtTouse(amountToUse);
     credit.setRemaoningBalance(credit.getRemaoningBalance() - amountToUse);
     amountNeeded -= amountToUse;
   }
   fullyApplied = amountNeeded == 0;
 }
コード例 #2
0
 public void setTransactionCreditsAndPayments(
     List<ClientTransactionCreditsAndPayments> creditsAndPayments) {
   for (ClientCreditsAndPayments ccap : this.totalCredits) {
     double balance = ccap.getBalance();
     double usedAmount = 0.0;
     for (ClientTransactionCreditsAndPayments ctcap : creditsAndPayments) {
       if (ctcap.getCreditsAndPayments() == ccap.getID()) {
         usedAmount += ctcap.getAmountToUse();
       }
     }
     ccap.setRemaoningBalance(balance);
     ccap.setAmtTouse(usedAmount);
   }
   this.initialCredits = creditsAndPayments;
   initialAmountUse(totalCredits);
 }
コード例 #3
0
  public void addCreditsAndPayments() {
    List<ClientCreditsAndPayments> list = getTotalCredits();
    this.totalCredits = list;
    if (getTransactionPayments() != null) {
      for (ClientTransactionReceivePayment ctrp : getTransactionPayments()) {
        for (ClientCreditsAndPayments ccap : totalCredits) {
          double balance = ccap.getBalance();
          double usedAmount = 0.0;
          for (ClientTransactionCreditsAndPayments ctcap :
              ctrp.getTransactionCreditsAndPayments()) {
            if (ctcap.getCreditsAndPayments() == ccap.getID()) {
              usedAmount += ctcap.getAmountToUse();
            }
          }
          ccap.setBalance(balance + usedAmount);
          ccap.setRemaoningBalance(balance);
          ccap.setAmtTouse(usedAmount);
        }
        ctrp.getTransactionCreditsAndPayments().clear();
      }
    }

    if (getPayBillPayments() != null) {
      for (ClientTransactionPayBill ctpb : getPayBillPayments()) {
        for (ClientCreditsAndPayments ccap : totalCredits) {
          double balance = ccap.getBalance();
          double usedAmount = 0.0;
          for (ClientTransactionCreditsAndPayments ctcap :
              ctpb.getTransactionCreditsAndPayments()) {
            if (ctcap.getCreditsAndPayments() == ccap.getID()) {
              usedAmount += ctcap.getAmountToUse();
            }
          }
          ccap.setBalance(balance + usedAmount);
        }
        ctpb.getTransactionCreditsAndPayments().clear();
      }
    }
  }