Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Before:
- List<InvoiceInstallment> installments = new ArrayList<InvoiceInstallment>();
- Money installmentAmt = amount.divide(numInstallments);
- Money amountAllocated = Money.ZERO;
- for (int i = 1; i <= numInstallments; i++) {
- if (i < numInstallments) {
- installments.add(new InvoiceInstallment(i,
- source.getPlan(),
- installmentType,
- installmentAmt,
- payeeType,
- discountPct,
- null));
- } else {
- installments.add(new InvoiceInstallment(i,
- source.getPlan(),
- installmentType,
- amount.subtract(amountAllocated),
- payeeType,
- discountPct,
- null));
- }
- amountAllocated = amountAllocated.add(installmentAmt);
- }
- return installments;
- // After:
- List<InvoiceInstallment> installments = new ArrayList<InvoiceInstallment>();
- Money installmentAmt = amount.divide(numInstallments);
- Money amountAllocated = Money.ZERO;
- for (int i = 1; i <= numInstallments; i++) {
- installments.add(new InvoiceInstallment(i,
- source.getPlan(),
- installmentType,
- // Ensure installments add back up to total
- i < numInstallments ? installmentAmt : amount.subtract(amountAllocated),
- payeeType,
- discountPct,
- null));
- amountAllocated = amountAllocated.add(installmentAmt);
- }
- return installments;
Add Comment
Please, Sign In to add comment