Hi Philipp,
Yes, we read the BPMN and DMN started guides, even, we bought the book Real-Life BPMN Book and we were playing with the platform for a few days.
The specific question is the following:
1.- Business department give us the process definition about Mortgage Simulator.
2.- We expected obtain the following from of the Simulation:
We map the requirements in point 1 to a Camunda BMPN model to be executed in Camunda but to obtain the Amortization Schedule on the right (Monthly Payment):
public List<Payment> calculatePaymentList(Date startDate, double initialBalance, int durationInMonths, int paymentType, double interestRate, double futureValue)
{
List<Payment> paymentList = new ArrayList<Payment>();
Date loopDate = startDate;
double balance = initialBalance;
double accumulatedInterest = 0;
for (int paymentNumber = 1; paymentNumber <= durationInMonths; paymentNumber++)
{
if (paymentType == 0)
{
loopDate = addOneMonth(loopDate);
}
double principalPaid = paymentService.ppmt(paymentService.getMonthlyInterestRate(interestRate), paymentNumber, durationInMonths, initialBalance, futureValue, paymentType);
double interestPaid = paymentService.ipmt(paymentService.getMonthlyInterestRate(interestRate), paymentNumber, durationInMonths, initialBalance, futureValue, paymentType);
balance = balance + principalPaid;
accumulatedInterest += interestPaid;
Payment payment = new Payment(paymentNumber, loopDate, balance, principalPaid, interestPaid, accumulatedInterest);
paymentList.add(payment);
if (paymentType == 1)
{
loopDate = addOneMonth(loopDate);
}
}
return paymentList;
}
/**
* Emulates PMT(interest_rate, number_payments, PV, FV, Type) function, which calculates
* the mortgage or annuity payment/yield per period.
*
* @param r periodic interest rate represented as a decimal.
* @param nper number of total payments or periods.
* @param pv present value – borrowed or invested principal.
* @param fv future value of loan or annuity.
* @param type when payment is made: beginning of period is 1; end, 0.
* @return double
representing periodic payment amount.
*/
public double pmt(double r, int nper, double pv, double fv, int type)
{
if (r == 0) {
return -(pv + fv) / nper;
}
// i.e., pmt = r / ((1 + r)^N - 1) * -(pv * (1 + r)^N + fv)
double pmt = r / (Math.pow(1 + r, nper) - 1) * -(pv * Math.pow(1 + r, nper) + fv);
// account for payments at beginning of period versus end.
if (type == 1) {
pmt /= (1 + r);
}
// return results to caller.
return pmt;
}
/**
* Emulates IPMT(interest_rate, period, number_payments, PV, FV, Type) function, which calculates
* the portion of the payment at a given period that is the interest on previous balance.
*
* @param r periodic interest rate represented as a decimal.
* @param per period (payment number) to check value at.
* @param nper number of total payments or periods.
* @param pv present value – borrowed or invested principal.
* @param fv future value of loan or annuity.
* @param type when payment is made: beginning of period is 1; end, 0.
* @return double
representing interest portion of payment.
* @see #pmt(double, int, double, double, int)
* @see #fv(double, int, double, double, int)
*/
public double ipmt(double r, int per, int nper, double pv, double fv, int type)
{
// Prior period (i.e., per-1) balance times periodic interest rate.
// i.e., ipmt = fv(r, per-1, c, pv, type) * r
// where c = pmt(r, nper, pv, fv, type)
double ipmt = fv(r, per - 1, pmt(r, nper, pv, fv, type), pv, type) * r;
// account for payments at beginning of period versus end.
if (type == 1) {
ipmt /= (1 + r);
}
// return results to caller.
return ipmt;
}
The problem is we don`t able to understand how to invoke this in the bpmn/dmn process and return the List.
Thank you in advanced
Best regards,
JE