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();
      }
    }
  }
 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);
 }