Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
{hidden} DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING. THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden} {sub-section:description|text=}{sub-section}\\ {table:id=|class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[AmortizationCalculation]{span}{span:class=sWordList}[Polynomial]{span}{td}{tr}{table}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[AmortizationCalculation]{td}{td}[#newCalculation]\() Creates a new amortization calculation.{td}{tr}{tbody}{tbody}{tr}{td}[Polynomial]{td}{td}[#newPolynomial]\() Creates a new polynomial which is either 0 or a copy of the specified polynomial.{td}{tr}{tbody}{tbody}{tr}{td}[Polynomial]{td}{td}[#newPolynomial]\(polynomial) Creates a new polynomial which is either 0 or a copy of the specified polynomial.{td}{tr}{tbody}{tbody}{tr}{td}[Date]{td}{td}[#nextDate]\(start_date, period, startday) {td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=newCalculation|class=node}{tr:id=name}{td}h6.newCalculation{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[AmortizationCalculation]{span}{span:id=iets|style=float: left; font-weight: bold;}newCalculation{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:newCalculation_des|trigger=button|text=}{sub-section}{sub-section:newCalculation_des|trigger=none|class=sIndent}Creates a new amortization calculation.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:newCalculation_snc|trigger=button|text=}{sub-section}{sub-section:newCalculation_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:newCalculation_prs|trigger=button|text=}{sub-section}{sub-section:newCalculation_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:newCalculation_ret|trigger=button|text=}{sub-section}{sub-section:newCalculation_ret|trigger=none|class=sIndent}[AmortizationCalculation]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:newCalculation_see|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newCalculation_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:newCalculation_link|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newCalculation_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:newCalculation_sam|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newCalculation_sam|trigger=none}{code:language=javascript} // Calculate the interest rate for an amortization schedule // with a loan of 2000 dollars on January 1, 2005, and 5 // monthly payments of 500 dollars starting on Febuary 28th, // payments made on the last day of each month. // Get a new amortization calculation. var c = plugins.amortization.newCalculation(); // Set the rate to -1 for unknown. c.addRateChange(-1, new Date(2005, 0, 1)); // Set the compounding period to monthly. c.addCompoundPeriodChange(12, new Date(2005, 0, 1)); // Add the loan and the payments to the schedule. c.addLoan(2000
Wiki Markup
Div
styledisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
iddescription



HTML Table
id
classservoy sReturnTypes
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Return Types
Table Row (tr)
Table Cell (td)
Span
classsWordList
AmortizationCalculation
Span
classsWordList
Polynomial



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
AmortizationCalculation
Table Cell (td)
newCalculation()
Creates a new amortization calculation.
Table Row (tr)
Table Cell (td)
Polynomial
Table Cell (td)
newPolynomial()
Creates a new polynomial which is either 0 or a copy of the specified polynomial.
Table Row (tr)
Table Cell (td)
Polynomial
Table Cell (td)
newPolynomial(polynomial)
Creates a new polynomial which is either 0 or a copy of the specified polynomial.
Table Row (tr)
Table Cell (td)
Date
Table Cell (td)
nextDate(start_date, period, startday)



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idnewCalculation
Table Row (tr)
idname
Table Cell (td)

newCalculation

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
AmortizationCalculation
Span
stylefont-weight: bold;
newCalculation
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a new amortization calculation.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
AmortizationCalculation
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// Calculate the interest rate for an amortization schedule
// with a loan of 2000 dollars  on January 1, 2005, and 5
// monthly payments of 500 dollars starting on Febuary 28th,
// payments made on the last day of each month.

// Get a new amortization calculation.
var c = plugins.amortization.newCalculation();

// Set the rate to -1 for unknown.
c.addRateChange(-1, new Date(2005, 0, 1));

// Set the compounding period to monthly.
c.addCompoundPeriodChange(12, new Date(2005, 0, 1));

// Add the loan and the payments to the schedule.
c.addLoan(2000, new Date(2005, 0, 1));
var lastDate = null;
var period = 12;
//valid periods are:
//PERIOD_ANNUALY : 1
//PERIOD_BI_ANNUALLY : 2
//PERIOD_DAILY : 365
//PERIOD_FOUR_MONTHLY : 3
//PERIOD_FOUR_WEEKLY : 13
//PERIOD_MONTHLY : 12
//PERIOD_QUARTERLY : 4
//PERIOD_TWO_MONTHLY : 6
//PERIOD_TWO_WEEKLY : 26
//PERIOD_WEEKLY : 52
var number_count = 5;
var startday = 31;
c.addPayment(500, new Date(2005, 1, 28), lastDate, period, number_count, startday);

// Solve for the interest rate.
c.solveForUnknown();
// Get the interest rate and the error in the calculation.
// which should be small (otherwise the calculation did
// not converge for some reason.
var r = c.getUnknown();
var e = c.getError();

// When there are no unknowns you can calculate the
// actual amortization schedule.

// Same as before, use the calculated interest rate.
var c = plugins.amortization.newCalculation();
c.addRateChange(r, new Date(2005, 0, 1));
var lastDate = null; var period = 12; //valid periods are: //PERIOD_ANNUALY : 1 //PERIOD_BI_ANNUALLY : 2 //PERIOD_DAILY : 365 //PERIOD_FOUR_MONTHLY : 3 //PERIOD_FOUR_WEEKLY : 13 //PERIOD_MONTHLY : 12 //PERIOD_QUARTERLY : 4 //PERIOD_TWO_MONTHLY : 6 //PERIOD_TWO_WEEKLY : 26 //PERIOD_WEEKLY : 52 var number_count = 5; var startday = 31; c.addPayment(500, new Date(2005, 1, 28), lastDate, period, number_count, startday); // Solve for the interest rate. c.solveForUnknown();
c.addCompoundPeriodChange(12, new Date(2005, 0, 1));
c.addLoan(2000, new Date(2005, 0, 1));
c.addPayment(500, new Date(2005, 1, 28), null, 12, 5, 31);

// Calculate the actual amortization schedule.
c.calculateAmortizationSchedule();

// Get the amortization schedule (which is a JSDataSet) and
// convert it to html. This way you can put it on a label.
// As a JSDataSet you can just get the values stored in
// the rows and columns to use in your script.
var s = "<html>" + c.getAmortizationSchedule().getAsHTML();

// Get the rest 
interest
balance, 
rate
which 
and
is the 
error
amount 
in
left 
the
over 
calculation.
after
//
which should be small (otherwise the calculation did
 the amortization schedule. In our case (since we calculated
// 
not
the 
converge
rate 
for
to 
some
have 
reason.
nothing 
var
left, 
r
it 
= c.getUnknown(); var e = c.getError();
should amount to no more
// 
When
than 
there
1 
are
or 
no
2 
unknowns
cents 
you
due 
can calculate the // actual amortization schedule. // Same as before, use the calculated interest rate
to rounding).
var 
c
rb = 
plugins
c.
amortization.newCalculation(); c.addRateChange(r, new Date(2005, 0, 1)); c.addCompoundPeriodChange(12, new Date(2005, 0, 1)); c.addLoan(2000, new Date(2005, 0, 1)); c.addPayment(500, new Date(2005, 1, 28), null, 12, 5, 31
getRestBalance();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnewPolynomial
Table Row (tr)
idname
Table Cell (td)

newPolynomial

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Polynomial
Span
stylefont-weight: bold;
newPolynomial
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a new polynomial which is either 0 or a copy of the specified polynomial.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Polynomial
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// create a new polynomial
var p = plugins.amortization.newPolynomial();

// 
Calculate
make the 
actual amortization schedule. c.calculateAmortizationSchedule(
polynomial -4*x^2 + 9
p.addTerm(-4, 2); 
// 
Get the amortization schedule (which is a JSDataSet) and
-4*x^2
p.addTerm(9, 0); // 
convert
9
it

to
// 
html.
find 
This
the 
way
roots
you
var 
can
r1 
put it on a label. // As a JSDataSet you can just
= p.findRoot(1, 5E-15, 100);
var r2 = p.findRoot(-1, 5E-15, 100);

// get the 
values stored in
derivative
q = p.getDerivative();

// 
the
show 
rows
all 
and
this 
columns
information 
to
in 
use
a 
in
dialog
your script. var s = "<html>
plugins.dialogs.showInfoDialog(
	"polynomial",
	"polynomial: " + 
c.getAmortizationSchedule().getAsHTML(); // Get the rest balance, which is the amount left over after // the amortization schedule. In our case (since we calculated // the rate to have nothing left, it should amount to no more // than 1 or 2 cents due to rounding). var rb = c.getRestBalance(); {code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=newPolynomial|class=node}{tr:id=name}{td}h6.newPolynomial{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Polynomial]{span}{span:id=iets|style=float: left; font-weight: bold;}newPolynomial{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:newPolynomial_des|trigger=button|text=}{sub-section}{sub-section:newPolynomial_des|trigger=none|class=sIndent}Creates a new polynomial which is either 0 or a copy of the specified polynomial.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:newPolynomial_snc|trigger=button|text=}{sub-section}{sub-section:newPolynomial_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:newPolynomial_prs|trigger=button|text=}{sub-section}{sub-section:newPolynomial_prs|trigger=none|class=sIndent}{sub-section}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:newPolynomial_ret|trigger=button|text=}{sub-section}{sub-section:newPolynomial_ret|trigger=none|class=sIndent}[Polynomial]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:newPolynomial_see|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:newPolynomial_link|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:newPolynomial_sam|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial_sam|trigger=none}{code:language=javascript} // create a new polynomial var p = plugins.amortization.newPolynomial(); // make the polynomial -4*x^2 + 9 p.addTerm(-4, 2); // -4*x^2 p.addTerm(9, 0); // 9 // find the roots var r1 = p.findRoot(1, 5E-15, 100); var r2 = p.findRoot(-1, 5E-15, 100); // get the derivative q = p.getDerivative(); // show all this information in a dialog plugins.dialogs.showInfoDialog( "polynomial", "polynomial: " + p + "\n" + "derivative: " + q + "\n" + "value in 2: " + p.getValue(2) + "\n" + "derivative in 2: " + p.getDerivativeValue(2) + "\n" + "root near 1: " + r1 + "\n" + "root near -1: " + r2, "Ok" ); // set q to zero q.setToZero(); // make a copy of p, then add 1 and multiply by 3*x^2 var s = plugins.amortization.newPolynomial(p); s.addTerm(1, 0); // add 1 s.multiplyByTerm(3, 2); // mulitply by 3*x^2 // make a copy of s and add p var t = plugins.amortization.newPolynomial(s); t.addPolynomial(p); // make a copy of s and multiply by p var u = plugins.amortization.newPolynomial(s); u.multiplyByPolynomial(p); // show all this information in a dialog plugins.dialogs.showInfoDialog( "polynomial", "polynomial: " + p + "\n" + "polynomial: " + s + "\n" + "sum: " + t + "\n" + "sum in 2: " + p.getValue(2) + " + " + s.getValue(2) + " = " + t.getValue(2) + "\n" + "product: " + u + "\n" + "product in 2: " + p.getValue(2) + " * " + s.getValue(2) + " = " + u.getValue(2) + "\n", "Ok" ); {code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=newPolynomial-Polynomial|class=node}{tr:id=name}{td}h6.newPolynomial{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Polynomial]{span}{span:id=iets|style=float: left; font-weight: bold;}newPolynomial{span}{span:id=iets|style=float: left;}\(polynomial){span}{td}{tr}{tr:id=des}{td}{sub-section:newPolynomial-Polynomial_des|trigger=button|text=}{sub-section}{sub-section:newPolynomial-Polynomial_des|trigger=none|class=sIndent}Creates a new polynomial which is either 0 or a copy of the specified polynomial.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:newPolynomial-Polynomial_snc|trigger=button|text=}{sub-section}{sub-section:newPolynomial-Polynomial_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:newPolynomial-Polynomial_prs|trigger=button|text=}{sub-section}{sub-section:newPolynomial-Polynomial_prs|trigger=none|class=sIndent}\{[Polynomial]} polynomial {sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:newPolynomial-Polynomial_ret|trigger=button|text=}{sub-section}{sub-section:newPolynomial-Polynomial_ret|trigger=none|class=sIndent}[Polynomial]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:newPolynomial-Polynomial_see|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial-Polynomial_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:newPolynomial-Polynomial_link|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial-Polynomial_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:newPolynomial-Polynomial_sam|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:newPolynomial-Polynomial_sam|trigger=none}{code:language=javascript} // create a new polynomial var p = plugins.amortization.newPolynomial(); // make the polynomial -4*x^2 + 9 p.addTerm(-4, 2); // -4*x^2 p.addTerm(9, 0); // 9 // find the roots var r1 = p.findRoot(1, 5E-15, 100); var r2 = p.findRoot(-1, 5E-15, 100); // get the derivative q = p.getDerivative(); // show all this information in a dialog plugins.dialogs.showInfoDialog( "polynomial", "polynomial: " + p + "\n" + "derivative: " + q + "\n" + "value in 2: " + p.getValue(2) + "\n" + "derivative in 2: " + p.getDerivativeValue(2) + "\n" + "root near 1: " + r1 + "\n" + "root near -1: " + r2, "Ok" ); // set q to zero q.setToZero
p + "\n" +
	"derivative: " + q + "\n" +
	"value in 2: " + p.getValue(2) + "\n" +
	"derivative in 2: " + p.getDerivativeValue(2) + "\n" +
	"root near 1: " + r1 + "\n" +
	"root near -1: " + r2,
	"Ok"
);

// set q to zero
q.setToZero();

// make a copy of p, then add 1 and multiply by 3*x^2
var s = plugins.amortization.newPolynomial(p);
s.addTerm(1, 0); // add 1
s.multiplyByTerm(3, 2); // mulitply by 3*x^2

// make a copy of s and add p
var t = plugins.amortization.newPolynomial(s);
t.addPolynomial(p);

// make a copy of s and multiply by p
var u = plugins.amortization.newPolynomial(s);
u.multiplyByPolynomial(p);

// show all this information in a dialog
plugins.dialogs.showInfoDialog(
	"polynomial",
	"polynomial: " + p + "\n" +
	"polynomial: " + s + "\n" +
	"sum: " + t + "\n" +
	"sum in 2: " + p.getValue(2) + " + " + s.getValue(2) + " = " + t.getValue(2) + "\n" +
	"product: " + u + "\n" +
	"product in 2: " + p.getValue(2) + " * " + s.getValue(2) + " = " + u.getValue(2) + "\n",
	"Ok"
);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnewPolynomial-Polynomial
Table Row (tr)
idname
Table Cell (td)

newPolynomial

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Polynomial
Span
stylefont-weight: bold;
newPolynomial
Span
(polynomial)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a new polynomial which is either 0 or a copy of the specified polynomial.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Polynomial} polynomial
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Polynomial
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
// create a new polynomial
var p = plugins.amortization.newPolynomial();

// make 
a
the 
copy of p, then add 1 and multiply by 3
polynomial -4*x^2 
var
+ 
s = plugins.amortization.newPolynomial(p); s
9
p.addTerm(
1
-4, 
0
2); // 
add 1 s.multiplyByTerm(3, 2
-4*x^2
p.addTerm(9, 0); // 
mulitply by 3*x^2
9

// find 
make
the 
a
roots
copy
var 
of
r1 
s and add p
= p.findRoot(1, 5E-15, 100);
var 
t
r2 = 
plugins
p.
amortization.newPolynomial(s); t.addPolynomial(p
findRoot(-1, 5E-15, 100);

// 
make
get 
a
the 
copy
derivative
of
q 
s and multiply by p var u = plugins.amortization.newPolynomial(s); u.multiplyByPolynomial(p
= p.getDerivative();

// show all this information in a dialog
plugins.dialogs.showInfoDialog(
	"polynomial",
	"polynomial: " + p + "\n" +
	"
polynomial
derivative: " + 
s
q + "\n" +
	"
sum
value in 2: " + 
t
p.getValue(2) + "\n" +
	"
sum
derivative in 2: " + p.
getValue
getDerivativeValue(2) + "\n" +
	"root near 1: " + 
s.getValue(2)
r1 + "\n" 
=
+
	"root 
+ t.getValue(2) + "\n" + "product: " + u + "\n" + "product in 2: " + p.getValue(2) + " * " + s.getValue(2) + " = " + u.getValue(2) + "\n", "Ok" ); {code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=nextDate|class=node}{tr:id=name}{td}h6.nextDate{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Date]{span}{span:id=iets|style=float: left; font-weight: bold;}nextDate{span}{span:id=iets|style=float: left;}\(start_date, period, startday){span}{td}{tr}{builder-show:permission=edit}{tr:id=des}{td}{sub-section:nextDate_des|trigger=button|text=}{sub-section}{sub-section:nextDate_des|trigger=none|class=sIndent}Replace with description{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=snc}{td}*Since*\\{sub-section:nextDate_snc|trigger=button|text=}{sub-section}{sub-section:nextDate_snc|trigger=none|class=sIndent} Replace with version info{sub-section}{td}{tr}{builder-show}{tr:id=prs}{td}*Parameters*\\{sub-section:nextDate_prs|trigger=button|text=}{sub-section}{sub-section:nextDate_prs|trigger=none|class=sIndent}\{[Date]} start_date \{[Number]} period \{[Number]} startday {sub-section}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:nextDate_ret|trigger=button|text=}{sub-section}{sub-section:nextDate_ret|trigger=none|class=sIndent}[Date]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:nextDate_see|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:nextDate_see|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:nextDate_link|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:nextDate_link|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:nextDate_sam|trigger=button|text=}{sub-section}{div:class=sIndent}{sub-section:nextDate_sam|trigger=none}{code:language=javascript}
near -1: " + r2,
	"Ok"
);

// set q to zero
q.setToZero();

// make a copy of p, then add 1 and multiply by 3*x^2
var s = plugins.amortization.newPolynomial(p);
s.addTerm(1, 0); // add 1
s.multiplyByTerm(3, 2); // mulitply by 3*x^2

// make a copy of s and add p
var t = plugins.amortization.newPolynomial(s);
t.addPolynomial(p);

// make a copy of s and multiply by p
var u = plugins.amortization.newPolynomial(s);
u.multiplyByPolynomial(p);

// show all this information in a dialog
plugins.dialogs.showInfoDialog(
	"polynomial",
	"polynomial: " + p + "\n" +
	"polynomial: " + s + "\n" +
	"sum: " + t + "\n" +
	"sum in 2: " + p.getValue(2) + " + " + s.getValue(2) + " = " + t.getValue(2) + "\n" +
	"product: " + u + "\n" +
	"product in 2: " + p.getValue(2) + " * " + s.getValue(2) + " = " + u.getValue(2) + "\n",
	"Ok"
);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idnextDate-Date_Number_Number
Table Row (tr)
idname
Table Cell (td)

nextDate

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Date
Span
stylefont-weight: bold;
nextDate
Span
(start_date, period, startday)
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Date} start_date
{Number} period
{Number} startday
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Date
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
//Helper method to get the next date when a period is given;
//valid periods are:
//PERIOD_ANNUALY : 1
//PERIOD_BI_ANNUALLY : 2
//PERIOD_BI_MONTHLY : 365
//PERIOD_FOUR_MONTHLY : 3
//PERIOD_FOUR_WEEKLY : 13
//PERIOD_MONTHLY : 12
//PERIOD_QUARTERLY : 4
//PERIOD_TWO_MONTHLY : 6
//PERIOD_TWO_WEEKLY : 26
//PERIOD_WEEKLY : 52
var a_next_date = plugins.amortization.nextDate(new Date(2005, 1, 28),12,31);

//Sample to calculate intervals between 2 dates;
var startday = 31;
var d_start = new Date(2005, 1, 28)
var d_end = new Date(2005, 11, 20)
var allDates = new Array();
var next = d_start;
//loop over months
while (next.getTime() < d_end.getTime())
{
	next = plugins.amortization.nextDate(next,12,startday)
	allDates[allDates.length] = next;
}
if (allDates.length > 0) allDates.length = allDates.length-1 //clear was one to far
//now check how many days are left
if (allDates.length > 0)
{
	next = allDates[allDates.length-1]
}
else
{
	next = d_start;
}
var days = 0;
//loop over days
while (next.getTime() < d_end.getTime() || next.getDate() < d_end.getDate())
{
	next = plugins.amortization.nextDate(next,365,startday)
	days++;
}
//add total days
allDates[allDates.length] = '(and) '+days+' days'
//make array textual to show
application.output( allDates.join('\n') );
{code}{sub-section}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)