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); }
@Override protected Result onFinish(Context context) { Double amount = getRequirement(AMOUNT_TO_USE).getValue(); this.initialCredits.clear(); for (ClientCreditsAndPayments ccap : totalCredits) { if (ccap.getAmtTouse() > 0) { ClientTransactionCreditsAndPayments ctcap = new ClientTransactionCreditsAndPayments(); ctcap.setAmountToUse(ccap.getAmtTouse()); ctcap.setCreditsAndPayments(ccap.getID()); initialCredits.add(ctcap); } ccap.setBalance(ccap.getRemaoningBalance()); } setValue(amount); return null; }