Skip to content

Commit

Permalink
fix #1184
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyqus committed Jan 9, 2024
1 parent ab6221c commit 3255844
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion main/SS/Formula/Functions/PPMT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ protected override double Eval(ValueEval[] args, int srcCellRow, int srcCellCol)
throw new EvaluationException(ErrorEval.VALUE_INVALID);

double result;
ValueEval v5 =null;
ValueEval v6 =null;

ValueEval v1 = OperandResolver.GetSingleValue(args[0], srcCellRow, srcCellCol);
ValueEval v2 = OperandResolver.GetSingleValue(args[1], srcCellRow, srcCellCol);
Expand All @@ -48,7 +50,24 @@ protected override double Eval(ValueEval[] args, int srcCellRow, int srcCellCol)
int numberPayments = OperandResolver.CoerceValueToInt(v3);
double PV = OperandResolver.CoerceValueToDouble(v4);

result = Finance.PPMT(interestRate, period, numberPayments, PV);
if(args.Length==4)
{
result = Finance.PPMT(interestRate, period, numberPayments, PV);
}
else if(args.Length==5)
{
v5=OperandResolver.GetSingleValue(args[4], srcCellRow, srcCellCol);
double FV = OperandResolver.CoerceValueToDouble(v5);
result = Finance.PPMT(interestRate, period, numberPayments, PV, FV);
}
else
{
v5=OperandResolver.GetSingleValue(args[4], srcCellRow, srcCellCol);
v6 = OperandResolver.GetSingleValue(args[5], srcCellRow, srcCellCol);
double FV = OperandResolver.CoerceValueToDouble(v5);
int type = OperandResolver.CoerceValueToInt(v6);
result = Finance.PPMT(interestRate, period, numberPayments, PV, FV,type);
}

CheckValue(result);

Expand Down

0 comments on commit 3255844

Please sign in to comment.