ConstantPaymentAmount
Updated 2024-02-16 15:00:52.257000
Syntax
SELECT * FROM [westclintech].[wct].[ConstantPaymentAmount](
<@OutstandingAmount, float,>
,<@InterestBasis, nvarchar(4000),>
,<@InterestRate, float,>
,<@PaymentFrequency, int,>
,<@PaymentAmount, float,>
,<@ReferenceDate, datetime,>
,<@PrevPayDate, datetime,>
,<@StartDate, datetime,>
,<@FirstPayDate, datetime,>
,<@GracePeriodStartDate, datetime,>
,<@GracePeriodEndDate, datetime,>)
Description
Use the table-valued function ConstantPaymentAmount to return the cash flow schedule for a loan with a fixed payment amount but no fixed maturity date. ConstantPaymentAmount computes the periodic interest and principal amounts until the loan balance has been brought to zero.
The payment period is entered in ConstantPaymentAmount as the number of months between payments. For example, a loan with monthly payments would have a frequency of 1. A loan with quarterly payments would have frequency of 3. A loan with annual payments would have a frequency of 12.
ConstantPaymentAmount supports both an initial grace period and an additional grace period during the life of the loan. All payments and their associated dates are calculated with respect to the reference date supplied to the function (which should not be confused with the start date). If an initial grace period is entered in ConstantPaymentAmount and it is greater than the reference rate, then it becomes the first interest payment date and subsequent interest payments are calculated from that date forward.
If any payments would otherwise occur in the specified grace period, then that payment is moved to the end of the grace period and all remaining payments are calculated from the end of the grace period.
If no initial grace period is specified then the first payment date is calculated using the interest payment frequency. If the start date has been entered and the number of months between the start date and the reference date is less than the frequency, then the first payment date is calculated by adding the frequency (as a number of months) to the start date.
If no start date has been entered but a previous payment date has been entered and the number of months between the previous payment date and the reference date is less than the frequency, then the first payment date is calculated by adding the frequency (as a number of months) to the previous payment date.
If there is no start date and previous payment dates or the number of months between those dates and the reference date is greater than the frequency, then the first payment date is calculated by adding the frequency (as a number of months) to the reference date.
All payments in the resultant table are moved to the end of the month and interest is calculated using these end-of-month dates.
The interest payment is calculated as:
I=P\times\left[\left(\left(1+\frac{R\times{F}}{12}\right)^{12\slash{F}}\right)^T\right]-1
Where:
{"columns":[{"field":"column 1"},{"field":"column 2"},{"field":"column 3"}],"rows":[{"column 1":"I","column 2":"=","column 3":"InterestPayment"},{"column 1":"P","column 2":"=","column 3":"@OutstandingAmount"},{"column 1":"R","column 2":"=","column 3":"@InterestRate"},{"column 1":"F","column 2":"=","column 3":"@Frequency"},{"column 1":"T","column 2":"=","column 3":"Time, in years, from PaymentDate ( Period -1) to PaymentDate"}]}
If the irregular period is longer than the regular period then the interest amount is broken out into the regular interest amount and a 'grace' interest amount.
Arguments
@InterestRate
the annual rate of interest for the loan. @InterestRate is an expression of type float or of a type that can be implicitly converted to float.
@FirstPayDate
the first payment date of the loan if other than a regular periodic payment. @FirstPayDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@OutstandingAmount
the principal amount of the loan. @OutstandingAmount is an expression of type float or of a type that can be implicitly converted to float.
@PaymentAmount
the amount of the periodic payment. @PaymentAmount is an expression that returns a float or float value, or a character string in date format.
@GracePeriodStartDate
the date on which the (interim) grace period commences. @GracePeriodStartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@PaymentFrequency
the number of months in a regular interest payment. @PaymentFrequency is an expression of type int or of a type that can be implicitly converted to int.
@PrevPayDate
the last interest payment date prior to the reference date. @PrevPayDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@ReferenceDate
the starting date for the number of months with respect to all other dates. @ReferenceDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@StartDate
the start date of the loan. @StartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@GracePeriodEndDate
the date on which the (interim) grace period concludes. @GracePeriodEndDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@InterestBasis
the day count convention used to calculate the interest amount. @InterestBasis can be 30/360, Actual/360, Actual/365, or Actual/Actual. @InterestBasis is an expression of the character string data type category.
Return Type
table
{"columns": [{"field": "colName", "headerName": "Name", "header": "name"}, {"field": "colDatatype", "headerName": "Type", "header": "type"}, {"field": "colDesc", "headerName": "Description", "header": "description", "minWidth": 1000}], "rows": [{"id": "a5c8ee6c-c340-4380-8a62-f535e67f58d5", "colName": "Period", "colDatatype": "int", "colDesc": "A reference number uniquely identifying a row in the resultant table."}, {"id": "226c8ef4-13f5-40b9-a684-1e445a4e069b", "colName": "PrincipalPayment", "colDatatype": "float", "colDesc": "w in the resultant table. PrincipalPayment"}, {"id": "a679cc12-f098-4242-8ea1-ab2b7b2b84f1", "colName": "InterestPayment", "colDatatype": "float", "colDesc": "The amount of the regular interest payment."}, {"id": "b26eb276-1371-4500-8c89-f8a5b106bbb4", "colName": "CashFlow", "colDatatype": "float", "colDesc": "PrincipalPayment + InterestPayment + GraceInterest."}, {"id": "9277cedc-1289-4e94-9038-90713330c3f8", "colName": "OutstandingExposure", "colDatatype": "float", "colDesc": "When Period = 0 then @OutstandingAmount. For Period > 0 then OutstandingExposure(Period-1) + InterestPayment."}, {"id": "f38bd7a6-6b8f-4824-ba0b-e8f6677b9fae", "colName": "CapitalAmountInDebt", "colDatatype": "float", "colDesc": "When Period = 0, @OutstandingAmount. For Period > 0 then CapitalAmountInDebt(Period-1) \u2013 PrincipalPayment"}, {"id": "2459e38e-3bb3-413a-96e2-91d70ce5e5a9", "colName": "TotalExposure", "colDatatype": "float", "colDesc": "When Period = 0, @OutstandingAmount. For Period > 0 then CapitalAmountInDebt(Period-1) + InterestPayment"}, {"id": "93d0b87d-5789-4447-a294-b605425be136", "colName": "NumberOfMonth", "colDatatype": "int", "colDesc": "The number of months between the @ReferenceDate and the PaymentDate."}, {"id": "0d2df6ae-6dd9-4591-9467-16b4d330e57e", "colName": "PaymentDate", "colDatatype": "datetime", "colDesc": "The end-of-month date of the payment."}, {"id": "ec501853-6b5b-4228-95f1-068b505a935a", "colName": "GraceInterest", "colDatatype": "float", "colDesc": "The amount of the grace interest"}, {"id": "4a0efb97-ebf7-425e-9578-60ed65d13333", "colName": "InterestRate", "colDatatype": "float", "colDesc": "The interest amount from PaymentDate(Period-1) to PaymentDate assuming a principal amount of 1"}]}
Remarks
The PaymentDate for all rows is generated as the last day of the month.
For Period = 0, PrincipalPayment, InterestPayment, CashFlow, NumberOfMonth, GraceInterest, and InterestRate are set to 0.
If @Frequency is NULL then @Frequency = 1.
If @InterestRate is NULL then @InterestRate = 0.
If @ReferenceDate is NULL then @ReferenceDate = GETDATE().
GraceInterest is only calculated on @FirstPayDate and @GracePeriodEndDate.
GraceInterest is only calculated if NumberOfMonth – NumberOfMonth(Period-1) > @PaymentFrequency.
GraceInterest is the difference between the interest for the period from the previous row to the current row minus interest that would have been calculated for a period with length equal to @PaymentFrequency.
CashFlow may not equal PaymentAmount on @FirstPayDate or @GracePeriodEndDate due to GraceInterest.
The final payment is adjusted for CapitalAmountInDebt(Period-1) and the length of the period if it is less than @PaymentFrequency.
The last row returned will always be for the maturity date and may be shorter than a regular period depending on the combination of dates and @PaymentFrequency.
Examples
This is a simple 300,000 loan with quarterly payments of 17,500 and an interest rate of 5%.
SELECT *
FROM wct.ConstantPaymentAmount( 300000, --@OutstandingAmount
'Actual/360', --@InterestBasis
.05, --@InterestRate
3, --@PaymentFrequency
17500, --@PaymentAmount
'2014-12-15', --@ReferenceDate
NULL, --@PrevPayDate
NULL, --@StartDate
NULL, --@FirstPayDate
NULL, --@GracePeriodStartDate
NULL --@InterestGracePeriodEndDate
);
This produces the following result.
{"columns":[{"field":"Period","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PrincipalPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CashFlow","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"OutstandingExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CapitalAmountInDebt","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"TotalExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"NumberOfMonth","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PaymentDate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GraceInterest","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestRate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Period":"0","PrincipalPayment":"0","InterestPayment":"0","CashFlow":"0","OutstandingExposure":"300000","CapitalAmountInDebt":"300000","TotalExposure":"300000","NumberOfMonth":"0","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13750","InterestPayment":"3749.99999999999","CashFlow":"17500","OutstandingExposure":"303750","CapitalAmountInDebt":"286250","TotalExposure":"303750","NumberOfMonth":"3","PaymentDate":"2015-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"2","PrincipalPayment":"13881.8678425767","InterestPayment":"3618.13215742328","CashFlow":"17500","OutstandingExposure":"307368.132157423","CapitalAmountInDebt":"272368.132157423","TotalExposure":"289868.132157423","NumberOfMonth":"6","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"3","PrincipalPayment":"14019.2591213749","InterestPayment":"3480.74087862509","CashFlow":"17500","OutstandingExposure":"310848.873036048","CapitalAmountInDebt":"258348.873036048","TotalExposure":"275848.873036048","NumberOfMonth":"9","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"4","PrincipalPayment":"14198.4188781544","InterestPayment":"3301.5811218456","CashFlow":"17500","OutstandingExposure":"314150.454157894","CapitalAmountInDebt":"244150.454157894","TotalExposure":"261650.454157894","NumberOfMonth":"12","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"5","PrincipalPayment":"14413.9961242335","InterestPayment":"3086.00387576655","CashFlow":"17500","OutstandingExposure":"317236.45803366","CapitalAmountInDebt":"229736.458033661","TotalExposure":"247236.458033661","NumberOfMonth":"15","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"6","PrincipalPayment":"14596.1856190599","InterestPayment":"2903.81438094013","CashFlow":"17500","OutstandingExposure":"320140.272414601","CapitalAmountInDebt":"215140.272414601","TotalExposure":"232640.272414601","NumberOfMonth":"18","PaymentDate":"2016-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"7","PrincipalPayment":"14750.6051464229","InterestPayment":"2749.39485357714","CashFlow":"17500","OutstandingExposure":"322889.667268178","CapitalAmountInDebt":"200389.667268178","TotalExposure":"217889.667268178","NumberOfMonth":"21","PaymentDate":"2016-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"8","PrincipalPayment":"14939.1111728472","InterestPayment":"2560.88882715281","CashFlow":"17500","OutstandingExposure":"325450.556095331","CapitalAmountInDebt":"185450.556095331","TotalExposure":"202950.556095331","NumberOfMonth":"24","PaymentDate":"2016-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"9","PrincipalPayment":"15181.8680488084","InterestPayment":"2318.13195119162","CashFlow":"17500","OutstandingExposure":"327768.688046522","CapitalAmountInDebt":"170268.688046522","TotalExposure":"187768.688046522","NumberOfMonth":"27","PaymentDate":"2017-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"10","PrincipalPayment":"15347.8441375602","InterestPayment":"2152.15586243981","CashFlow":"17500","OutstandingExposure":"329920.843908962","CapitalAmountInDebt":"154920.843908962","TotalExposure":"172420.843908962","NumberOfMonth":"30","PaymentDate":"2017-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"11","PrincipalPayment":"15520.1820599432","InterestPayment":"1979.81794005677","CashFlow":"17500","OutstandingExposure":"331900.661849019","CapitalAmountInDebt":"139400.661849019","TotalExposure":"156900.661849019","NumberOfMonth":"33","PaymentDate":"2017-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"12","PrincipalPayment":"15718.5229293828","InterestPayment":"1781.47707061715","CashFlow":"17500","OutstandingExposure":"333682.138919636","CapitalAmountInDebt":"123682.138919636","TotalExposure":"141182.138919636","NumberOfMonth":"36","PaymentDate":"2017-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"13","PrincipalPayment":"15953.9732635046","InterestPayment":"1546.02673649544","CashFlow":"17500","OutstandingExposure":"335228.165656131","CapitalAmountInDebt":"107728.165656131","TotalExposure":"125228.165656131","NumberOfMonth":"39","PaymentDate":"2018-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"14","PrincipalPayment":"16138.3415181811","InterestPayment":"1361.65848181894","CashFlow":"17500","OutstandingExposure":"336589.82413795","CapitalAmountInDebt":"91589.8241379504","TotalExposure":"109089.82413795","NumberOfMonth":"42","PaymentDate":"2018-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"15","PrincipalPayment":"16329.5236949425","InterestPayment":"1170.47630505755","CashFlow":"17500","OutstandingExposure":"337760.300443008","CapitalAmountInDebt":"75260.3004430079","TotalExposure":"92760.3004430079","NumberOfMonth":"45","PaymentDate":"2018-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"16","PrincipalPayment":"16538.2075824562","InterestPayment":"961.792417543822","CashFlow":"17500","OutstandingExposure":"338722.092860552","CapitalAmountInDebt":"58722.0928605517","TotalExposure":"76222.0928605517","NumberOfMonth":"48","PaymentDate":"2018-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"17","PrincipalPayment":"16765.9738392431","InterestPayment":"734.026160756894","CashFlow":"17500","OutstandingExposure":"339456.119021309","CapitalAmountInDebt":"41956.1190213086","TotalExposure":"59456.1190213086","NumberOfMonth":"51","PaymentDate":"2019-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"18","PrincipalPayment":"16969.6845993653","InterestPayment":"530.315400634674","CashFlow":"17500","OutstandingExposure":"339986.434421943","CapitalAmountInDebt":"24986.4344219433","TotalExposure":"42486.4344219433","NumberOfMonth":"54","PaymentDate":"2019-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"19","PrincipalPayment":"17180.6847298374","InterestPayment":"319.315270162647","CashFlow":"17500","OutstandingExposure":"340305.749692106","CapitalAmountInDebt":"7805.74969210596","TotalExposure":"25305.749692106","NumberOfMonth":"57","PaymentDate":"2019-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"20","PrincipalPayment":"7805.74969210596","InterestPayment":"99.7539316601283","CashFlow":"7905.50362376609","OutstandingExposure":"340405.503623766","CapitalAmountInDebt":"0","TotalExposure":"7905.50362376609","NumberOfMonth":"60","PaymentDate":"2019-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"}]}
In this example, using the same basic SQL, we add a first payment date so that the first payment will not be paid until 30-June-2015.
SELECT *
FROM wct.ConstantPaymentAmount( 300000, --@OutstandingAmount
'Actual/360', --@InterestBasis
.05, --@InterestRate
3, --@PaymentFrequency
17500, --@PaymentAmount
'2014-12-15', --@ReferenceDate
NULL, --@PrevPayDate
NULL, --@StartDate
'2015-06-30', --@FirstPayDate
NULL, --@GracePeriodStartDate
NULL --@InterestGracePeriodEndDate
);
This produces the following result.
{"columns":[{"field":"Period","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PrincipalPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CashFlow","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"OutstandingExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CapitalAmountInDebt","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"TotalExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"NumberOfMonth","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PaymentDate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GraceInterest","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestRate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Period":"0","PrincipalPayment":"0","InterestPayment":"0","CashFlow":"0","OutstandingExposure":"300000","CapitalAmountInDebt":"300000","TotalExposure":"300000","NumberOfMonth":"0","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13708.0711013904","InterestPayment":"3791.92889860955","CashFlow":"21297.3991112326","OutstandingExposure":"303791.92889861","CapitalAmountInDebt":"286291.92889861","TotalExposure":"303791.92889861","NumberOfMonth":"6","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"3797.39911123262","InterestRate":"0.0252977600328073"},{"Period":"2","PrincipalPayment":"13841.3193304059","InterestPayment":"3658.6806695941","CashFlow":"17500","OutstandingExposure":"307450.609568204","CapitalAmountInDebt":"272450.609568204","TotalExposure":"289950.609568204","NumberOfMonth":"9","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"3","PrincipalPayment":"14018.205097569","InterestPayment":"3481.794902431","CashFlow":"17500","OutstandingExposure":"310932.404470635","CapitalAmountInDebt":"258432.404470635","TotalExposure":"275932.404470635","NumberOfMonth":"12","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"4","PrincipalPayment":"14233.4756571688","InterestPayment":"3266.52434283117","CashFlow":"17500","OutstandingExposure":"314198.928813466","CapitalAmountInDebt":"244198.928813466","TotalExposure":"261698.928813466","NumberOfMonth":"15","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"5","PrincipalPayment":"14413.3834160757","InterestPayment":"3086.61658392426","CashFlow":"17500","OutstandingExposure":"317285.54539739","CapitalAmountInDebt":"229785.54539739","TotalExposure":"247285.54539739","NumberOfMonth":"18","PaymentDate":"2016-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"6","PrincipalPayment":"14563.4452171535","InterestPayment":"2936.55478284653","CashFlow":"17500","OutstandingExposure":"320222.100180237","CapitalAmountInDebt":"215222.100180237","TotalExposure":"232722.100180237","NumberOfMonth":"21","PaymentDate":"2016-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"7","PrincipalPayment":"14749.5594247865","InterestPayment":"2750.44057521351","CashFlow":"17500","OutstandingExposure":"322972.54075545","CapitalAmountInDebt":"200472.54075545","TotalExposure":"217972.54075545","NumberOfMonth":"24","PaymentDate":"2016-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"8","PrincipalPayment":"14994.0932405569","InterestPayment":"2505.90675944312","CashFlow":"17500","OutstandingExposure":"325478.447514893","CapitalAmountInDebt":"185478.447514893","TotalExposure":"202978.447514893","NumberOfMonth":"27","PaymentDate":"2017-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"9","PrincipalPayment":"15155.5963826635","InterestPayment":"2344.40361733653","CashFlow":"17500","OutstandingExposure":"327822.85113223","CapitalAmountInDebt":"170322.85113223","TotalExposure":"187822.85113223","NumberOfMonth":"30","PaymentDate":"2017-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"10","PrincipalPayment":"15323.3514111802","InterestPayment":"2176.64858881975","CashFlow":"17500","OutstandingExposure":"329999.49972105","CapitalAmountInDebt":"154999.499721049","TotalExposure":"172499.499721049","NumberOfMonth":"33","PaymentDate":"2017-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"11","PrincipalPayment":"15519.1768744309","InterestPayment":"1980.82312556914","CashFlow":"17500","OutstandingExposure":"331980.322846619","CapitalAmountInDebt":"139480.322846619","TotalExposure":"156980.322846619","NumberOfMonth":"36","PaymentDate":"2017-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"12","PrincipalPayment":"15756.4959644173","InterestPayment":"1743.50403558273","CashFlow":"17500","OutstandingExposure":"333723.826882201","CapitalAmountInDebt":"123723.826882201","TotalExposure":"141223.826882201","NumberOfMonth":"39","PaymentDate":"2018-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"13","PrincipalPayment":"15936.1601513294","InterestPayment":"1563.83984867062","CashFlow":"17500","OutstandingExposure":"335287.666730872","CapitalAmountInDebt":"107787.666730872","TotalExposure":"125287.666730872","NumberOfMonth":"42","PaymentDate":"2018-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"14","PrincipalPayment":"16122.522632035","InterestPayment":"1377.47736796505","CashFlow":"17500","OutstandingExposure":"336665.144098837","CapitalAmountInDebt":"91665.144098837","TotalExposure":"109165.144098837","NumberOfMonth":"45","PaymentDate":"2018-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"15","PrincipalPayment":"16328.5611400916","InterestPayment":"1171.43885990843","CashFlow":"17500","OutstandingExposure":"337836.582958746","CapitalAmountInDebt":"75336.5829587454","TotalExposure":"92836.5829587454","NumberOfMonth":"48","PaymentDate":"2018-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"16","PrincipalPayment":"16558.2927130157","InterestPayment":"941.707286984314","CashFlow":"17500","OutstandingExposure":"338778.29024573","CapitalAmountInDebt":"58778.2902457297","TotalExposure":"76278.2902457297","NumberOfMonth":"51","PaymentDate":"2019-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"17","PrincipalPayment":"16757.0563420212","InterestPayment":"742.943657978809","CashFlow":"17500","OutstandingExposure":"339521.233903709","CapitalAmountInDebt":"42021.2339037085","TotalExposure":"59521.2339037085","NumberOfMonth":"54","PaymentDate":"2019-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"18","PrincipalPayment":"16962.9877384687","InterestPayment":"537.012261531267","CashFlow":"17500","OutstandingExposure":"340058.24616524","CapitalAmountInDebt":"25058.2461652398","TotalExposure":"42558.2461652398","NumberOfMonth":"57","PaymentDate":"2019-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"19","PrincipalPayment":"17179.767008412","InterestPayment":"320.232991587975","CashFlow":"17500","OutstandingExposure":"340378.479156828","CapitalAmountInDebt":"7878.47915682778","TotalExposure":"25378.4791568278","NumberOfMonth":"60","PaymentDate":"2019-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"20","PrincipalPayment":"7878.47915682778","InterestPayment":"99.5821093062276","CashFlow":"7978.06126613401","OutstandingExposure":"340478.061266134","CapitalAmountInDebt":"0","TotalExposure":"7978.06126613401","NumberOfMonth":"63","PaymentDate":"2020-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"}]}
We modify the SQL so that there are no payments in 2018.
SELECT *
FROM wct.ConstantPaymentAmount( 300000, --@OutstandingAmount
'Actual/360', --@InterestBasis
.05, --@InterestRate
3, --@PaymentFrequency
17500, --@PaymentAmount
'2014-12-15', --@ReferenceDate
NULL, --@PrevPayDate
NULL, --@StartDate
'2015-06-30', --@FirstPayDate
'2018-01-01', --@GracePeriodStartDate
'2019-01-01' --@GracePeriodEndDate
);
This produces the following result.
{"columns":[{"field":"Period","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PrincipalPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CashFlow","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"OutstandingExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CapitalAmountInDebt","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"TotalExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"NumberOfMonth","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PaymentDate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GraceInterest","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestRate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Period":"0","PrincipalPayment":"0","InterestPayment":"0","CashFlow":"0","OutstandingExposure":"300000","CapitalAmountInDebt":"300000","TotalExposure":"300000","NumberOfMonth":"0","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13708.0711013904","InterestPayment":"3791.92889860955","CashFlow":"21297.3991112326","OutstandingExposure":"303791.92889861","CapitalAmountInDebt":"286291.92889861","TotalExposure":"303791.92889861","NumberOfMonth":"6","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"3797.39911123262","InterestRate":"0.0252977600328073"},{"Period":"2","PrincipalPayment":"13841.3193304059","InterestPayment":"3658.6806695941","CashFlow":"17500","OutstandingExposure":"307450.609568204","CapitalAmountInDebt":"272450.609568204","TotalExposure":"289950.609568204","NumberOfMonth":"9","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"3","PrincipalPayment":"14018.205097569","InterestPayment":"3481.794902431","CashFlow":"17500","OutstandingExposure":"310932.404470635","CapitalAmountInDebt":"258432.404470635","TotalExposure":"275932.404470635","NumberOfMonth":"12","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"4","PrincipalPayment":"14233.4756571688","InterestPayment":"3266.52434283117","CashFlow":"17500","OutstandingExposure":"314198.928813466","CapitalAmountInDebt":"244198.928813466","TotalExposure":"261698.928813466","NumberOfMonth":"15","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"5","PrincipalPayment":"14413.3834160757","InterestPayment":"3086.61658392426","CashFlow":"17500","OutstandingExposure":"317285.54539739","CapitalAmountInDebt":"229785.54539739","TotalExposure":"247285.54539739","NumberOfMonth":"18","PaymentDate":"2016-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"6","PrincipalPayment":"14563.4452171535","InterestPayment":"2936.55478284653","CashFlow":"17500","OutstandingExposure":"320222.100180237","CapitalAmountInDebt":"215222.100180237","TotalExposure":"232722.100180237","NumberOfMonth":"21","PaymentDate":"2016-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"7","PrincipalPayment":"14749.5594247865","InterestPayment":"2750.44057521351","CashFlow":"17500","OutstandingExposure":"322972.54075545","CapitalAmountInDebt":"200472.54075545","TotalExposure":"217972.54075545","NumberOfMonth":"24","PaymentDate":"2016-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"8","PrincipalPayment":"14994.0932405569","InterestPayment":"2505.90675944312","CashFlow":"17500","OutstandingExposure":"325478.447514893","CapitalAmountInDebt":"185478.447514893","TotalExposure":"202978.447514893","NumberOfMonth":"27","PaymentDate":"2017-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"9","PrincipalPayment":"15155.5963826635","InterestPayment":"2344.40361733653","CashFlow":"17500","OutstandingExposure":"327822.85113223","CapitalAmountInDebt":"170322.85113223","TotalExposure":"187822.85113223","NumberOfMonth":"30","PaymentDate":"2017-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"10","PrincipalPayment":"15323.3514111802","InterestPayment":"2176.64858881975","CashFlow":"17500","OutstandingExposure":"329999.49972105","CapitalAmountInDebt":"154999.499721049","TotalExposure":"172499.499721049","NumberOfMonth":"33","PaymentDate":"2017-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"11","PrincipalPayment":"15519.1768744309","InterestPayment":"1980.82312556914","CashFlow":"17500","OutstandingExposure":"331980.322846619","CapitalAmountInDebt":"139480.322846619","TotalExposure":"156980.322846619","NumberOfMonth":"36","PaymentDate":"2017-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"12","PrincipalPayment":"15717.5048980567","InterestPayment":"1782.49510194329","CashFlow":"23553.5775973653","OutstandingExposure":"333762.817948562","CapitalAmountInDebt":"123762.817948562","TotalExposure":"141262.817948562","NumberOfMonth":"49","PaymentDate":"2019-01-31 00:00:00.000","GraceInterest":"6053.57759736527","InterestRate":"0.0561804886838813"},{"Period":"13","PrincipalPayment":"15970.259850425","InterestPayment":"1529.74014957503","CashFlow":"17500","OutstandingExposure":"335292.558098137","CapitalAmountInDebt":"107792.558098137","TotalExposure":"125292.558098137","NumberOfMonth":"52","PaymentDate":"2019-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"14","PrincipalPayment":"16122.4601225855","InterestPayment":"1377.53987741451","CashFlow":"17500","OutstandingExposure":"336670.097975552","CapitalAmountInDebt":"91670.0979755514","TotalExposure":"109170.097975551","NumberOfMonth":"55","PaymentDate":"2019-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"15","PrincipalPayment":"16328.4978317998","InterestPayment":"1171.50216820023","CashFlow":"17500","OutstandingExposure":"337841.600143752","CapitalAmountInDebt":"75341.6001437517","TotalExposure":"92841.6001437517","NumberOfMonth":"58","PaymentDate":"2019-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"16","PrincipalPayment":"16537.168609249","InterestPayment":"962.831390750993","CashFlow":"17500","OutstandingExposure":"338804.431534503","CapitalAmountInDebt":"58804.4315345027","TotalExposure":"76304.4315345027","NumberOfMonth":"61","PaymentDate":"2020-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"17","PrincipalPayment":"16764.9446058187","InterestPayment":"735.055394181281","CashFlow":"17500","OutstandingExposure":"339539.486928684","CapitalAmountInDebt":"42039.4869286839","TotalExposure":"59539.4869286839","NumberOfMonth":"64","PaymentDate":"2020-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"18","PrincipalPayment":"16962.7544731095","InterestPayment":"537.245526890496","CashFlow":"17500","OutstandingExposure":"340076.732455575","CapitalAmountInDebt":"25076.7324555744","TotalExposure":"42576.7324555744","NumberOfMonth":"67","PaymentDate":"2020-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"19","PrincipalPayment":"17179.5307620276","InterestPayment":"320.469237972426","CashFlow":"17500","OutstandingExposure":"340397.201693547","CapitalAmountInDebt":"7897.20169354686","TotalExposure":"25397.2016935469","NumberOfMonth":"70","PaymentDate":"2020-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"20","PrincipalPayment":"7897.20169354686","InterestPayment":"100.922646653788","CashFlow":"7998.12434020065","OutstandingExposure":"340498.124340201","CapitalAmountInDebt":"0","TotalExposure":"7998.12434020065","NumberOfMonth":"73","PaymentDate":"2021-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"}]}
Using the same basic SQL, we get rid of the first payment date and calculate the first interest payment using the previous payment date.
SELECT *
FROM wct.ConstantPaymentAmount( 300000, --@OutstandingAmount
'Actual/360', --@InterestBasis
.05, --@InterestRate
3, --@PaymentFrequency
17500, --@PaymentAmount
'2014-12-15', --@ReferenceDate
'2014-11-15', --@PrevPayDate
NULL, --@StartDate
NULL, --@FirstPayDate
'2018-01-01', --@GracePeriodStartDate
'2019-01-01' --@GracePeriodEndDate
);
This produces the following result.
{"columns":[{"field":"Period","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PrincipalPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CashFlow","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"OutstandingExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CapitalAmountInDebt","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"TotalExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"NumberOfMonth","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PaymentDate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GraceInterest","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestRate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Period":"0","PrincipalPayment":"0","InterestPayment":"0","CashFlow":"0","OutstandingExposure":"300000","CapitalAmountInDebt":"300000","TotalExposure":"300000","NumberOfMonth":"0","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"15046.9294810636","InterestPayment":"2453.07051893637","CashFlow":"17500","OutstandingExposure":"302453.070518936","CapitalAmountInDebt":"284953.070518936","TotalExposure":"302453.070518936","NumberOfMonth":"2","PaymentDate":"2015-02-28 00:00:00.000","GraceInterest":"0","InterestRate":"0.00817690172978791"},{"Period":"2","PrincipalPayment":"13858.4293316968","InterestPayment":"3641.57066830319","CashFlow":"17500","OutstandingExposure":"306094.64118724","CapitalAmountInDebt":"271094.64118724","TotalExposure":"288594.64118724","NumberOfMonth":"5","PaymentDate":"2015-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"3","PrincipalPayment":"14035.5337568962","InterestPayment":"3464.46624310379","CashFlow":"17500","OutstandingExposure":"309559.107430343","CapitalAmountInDebt":"257059.107430343","TotalExposure":"274559.107430343","NumberOfMonth":"8","PaymentDate":"2015-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"4","PrincipalPayment":"14250.8338062803","InterestPayment":"3249.16619371966","CashFlow":"17500","OutstandingExposure":"312808.273624063","CapitalAmountInDebt":"242808.273624063","TotalExposure":"260308.273624063","NumberOfMonth":"11","PaymentDate":"2015-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"5","PrincipalPayment":"14430.9609680781","InterestPayment":"3069.03903192193","CashFlow":"17500","OutstandingExposure":"315877.312655985","CapitalAmountInDebt":"228377.312655985","TotalExposure":"245877.312655985","NumberOfMonth":"14","PaymentDate":"2016-02-29 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"6","PrincipalPayment":"14581.4417912416","InterestPayment":"2918.55820875836","CashFlow":"17500","OutstandingExposure":"318795.870864743","CapitalAmountInDebt":"213795.870864743","TotalExposure":"231295.870864743","NumberOfMonth":"17","PaymentDate":"2016-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"7","PrincipalPayment":"14767.7859869082","InterestPayment":"2732.21401309184","CashFlow":"17500","OutstandingExposure":"321528.084877835","CapitalAmountInDebt":"199028.084877835","TotalExposure":"216528.084877835","NumberOfMonth":"20","PaymentDate":"2016-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"8","PrincipalPayment":"14984.3321777227","InterestPayment":"2515.66782227726","CashFlow":"17500","OutstandingExposure":"324043.752700112","CapitalAmountInDebt":"184043.752700112","TotalExposure":"201543.752700112","NumberOfMonth":"23","PaymentDate":"2016-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"9","PrincipalPayment":"15199.4530912486","InterestPayment":"2300.5469087514","CashFlow":"17500","OutstandingExposure":"326344.299608864","CapitalAmountInDebt":"168844.299608864","TotalExposure":"186344.299608864","NumberOfMonth":"26","PaymentDate":"2017-02-28 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"10","PrincipalPayment":"15342.2466273267","InterestPayment":"2157.75337267325","CashFlow":"17500","OutstandingExposure":"328502.052981537","CapitalAmountInDebt":"153502.052981537","TotalExposure":"171002.052981537","NumberOfMonth":"29","PaymentDate":"2017-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"11","PrincipalPayment":"15538.3135628477","InterestPayment":"1961.68643715225","CashFlow":"17500","OutstandingExposure":"330463.739418689","CapitalAmountInDebt":"137963.739418689","TotalExposure":"155463.739418689","NumberOfMonth":"32","PaymentDate":"2017-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"12","PrincipalPayment":"15756.1710317934","InterestPayment":"1743.82896820655","CashFlow":"17500","OutstandingExposure":"332207.568386896","CapitalAmountInDebt":"122207.568386896","TotalExposure":"139707.568386896","NumberOfMonth":"35","PaymentDate":"2017-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0126397629953652"},{"Period":"13","PrincipalPayment":"15938.2428458415","InterestPayment":"1561.75715415848","CashFlow":"23357.3944242221","OutstandingExposure":"333769.325541054","CapitalAmountInDebt":"106269.325541054","TotalExposure":"123769.325541054","NumberOfMonth":"49","PaymentDate":"2019-01-31 00:00:00.000","GraceInterest":"5857.39442422213","InterestRate":"0.0607094280355238"},{"Period":"14","PrincipalPayment":"16186.4839000678","InterestPayment":"1313.51609993217","CashFlow":"17500","OutstandingExposure":"335082.841640987","CapitalAmountInDebt":"90082.8416409865","TotalExposure":"107582.841640987","NumberOfMonth":"52","PaymentDate":"2019-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"15","PrincipalPayment":"16348.7822460035","InterestPayment":"1151.2177539965","CashFlow":"17500","OutstandingExposure":"336234.059394983","CapitalAmountInDebt":"73734.059394983","TotalExposure":"91234.059394983","NumberOfMonth":"55","PaymentDate":"2019-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"16","PrincipalPayment":"16557.7122490426","InterestPayment":"942.287750957405","CashFlow":"17500","OutstandingExposure":"337176.34714594","CapitalAmountInDebt":"57176.3471459404","TotalExposure":"74676.3471459404","NumberOfMonth":"58","PaymentDate":"2019-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"17","PrincipalPayment":"16769.3122825166","InterestPayment":"730.687717483433","CashFlow":"17500","OutstandingExposure":"337907.034863424","CapitalAmountInDebt":"40407.0348634239","TotalExposure":"57907.0348634239","NumberOfMonth":"61","PaymentDate":"2020-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"18","PrincipalPayment":"16994.9120642072","InterestPayment":"505.087935792797","CashFlow":"17500","OutstandingExposure":"338412.122799217","CapitalAmountInDebt":"23412.1227992167","TotalExposure":"40912.1227992167","NumberOfMonth":"64","PaymentDate":"2020-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"19","PrincipalPayment":"17200.80371651","InterestPayment":"299.196283490035","CashFlow":"17500","OutstandingExposure":"338711.319082707","CapitalAmountInDebt":"6211.31908270671","TotalExposure":"23711.3190827067","NumberOfMonth":"67","PaymentDate":"2020-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"20","PrincipalPayment":"6211.31908270671","InterestPayment":"79.377833486281","CashFlow":"6290.69691619299","OutstandingExposure":"338790.696916193","CapitalAmountInDebt":"0","TotalExposure":"6290.69691619299","NumberOfMonth":"70","PaymentDate":"2020-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"}]}
I n this example, we eliminate the grace period and the previous payment date and add a start date.
SELECT *
FROM wct.ConstantPaymentAmount( 300000, --@OutstandingAmount
'Actual/360', --@InterestBasis
.05, --@InterestRate
3, --@PaymentFrequency
17500, --@PaymentAmount
'2014-12-15', --@ReferenceDate
NULL, --@PrevPayDate
'2014-10-15', --@StartDate
NULL, --@FirstPayDate
NULL, --@GracePeriodStartDate
NULL --@GracePeriodEndDate
);
This produces the following result.
{"columns":[{"field":"Period","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PrincipalPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestPayment","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CashFlow","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"OutstandingExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"CapitalAmountInDebt","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"TotalExposure","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"NumberOfMonth","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"PaymentDate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"GraceInterest","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"InterestRate","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Period":"0","PrincipalPayment":"0","InterestPayment":"0","CashFlow":"0","OutstandingExposure":"300000","CapitalAmountInDebt":"300000","TotalExposure":"300000","NumberOfMonth":"0","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"16213.5893722239","InterestPayment":"1286.41062777615","CashFlow":"17500","OutstandingExposure":"301286.410627776","CapitalAmountInDebt":"283786.410627776","TotalExposure":"301286.410627776","NumberOfMonth":"1","PaymentDate":"2015-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00428803542592049"},{"Period":"2","PrincipalPayment":"13992.3272317416","InterestPayment":"3507.67276825843","CashFlow":"17500","OutstandingExposure":"304794.083396035","CapitalAmountInDebt":"269794.083396035","TotalExposure":"287294.083396035","NumberOfMonth":"4","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"3","PrincipalPayment":"14052.1542940824","InterestPayment":"3447.84570591758","CashFlow":"17500","OutstandingExposure":"308241.929101952","CapitalAmountInDebt":"255741.929101952","TotalExposure":"273241.929101952","NumberOfMonth":"7","PaymentDate":"2015-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"4","PrincipalPayment":"14231.7344362111","InterestPayment":"3268.26556378887","CashFlow":"17500","OutstandingExposure":"311510.194665741","CapitalAmountInDebt":"241510.194665741","TotalExposure":"259010.194665741","NumberOfMonth":"10","PaymentDate":"2015-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"5","PrincipalPayment":"14413.6095308981","InterestPayment":"3086.39046910186","CashFlow":"17500","OutstandingExposure":"314596.585134843","CapitalAmountInDebt":"227096.585134843","TotalExposure":"244596.585134843","NumberOfMonth":"13","PaymentDate":"2016-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"6","PrincipalPayment":"14661.2926858145","InterestPayment":"2838.70731418553","CashFlow":"17500","OutstandingExposure":"317435.292449028","CapitalAmountInDebt":"212435.292449028","TotalExposure":"229935.292449028","NumberOfMonth":"16","PaymentDate":"2016-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125"},{"Period":"7","PrincipalPayment":"14785.1735603832","InterestPayment":"2714.82643961677","CashFlow":"17500","OutstandingExposure":"320150.118888645","CapitalAmountInDebt":"197650.118888645","TotalExposure":"215150.118888645","NumberOfMonth":"19","PaymentDate":"2016-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"8","PrincipalPayment":"14974.1213554191","InterestPayment":"2525.87864458087","CashFlow":"17500","OutstandingExposure":"322675.997533226","CapitalAmountInDebt":"182675.997533226","TotalExposure":"200175.997533226","NumberOfMonth":"22","PaymentDate":"2016-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"9","PrincipalPayment":"15165.4838173579","InterestPayment":"2334.51618264213","CashFlow":"17500","OutstandingExposure":"325010.513715868","CapitalAmountInDebt":"167510.513715868","TotalExposure":"185010.513715868","NumberOfMonth":"25","PaymentDate":"2017-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"10","PrincipalPayment":"15429.5271184468","InterestPayment":"2070.4728815532","CashFlow":"17500","OutstandingExposure":"327080.986597421","CapitalAmountInDebt":"152080.986597421","TotalExposure":"169580.986597421","NumberOfMonth":"28","PaymentDate":"2017-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"11","PrincipalPayment":"15556.4741450541","InterestPayment":"1943.52585494592","CashFlow":"17500","OutstandingExposure":"329024.512452367","CapitalAmountInDebt":"136524.512452367","TotalExposure":"154024.512452367","NumberOfMonth":"31","PaymentDate":"2017-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"12","PrincipalPayment":"15755.2788108388","InterestPayment":"1744.7211891612","CashFlow":"17500","OutstandingExposure":"330769.233641529","CapitalAmountInDebt":"120769.233641529","TotalExposure":"138269.233641529","NumberOfMonth":"34","PaymentDate":"2017-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"13","PrincipalPayment":"15956.6241098524","InterestPayment":"1543.37589014756","CashFlow":"17500","OutstandingExposure":"332312.609531676","CapitalAmountInDebt":"104812.609531676","TotalExposure":"122312.609531676","NumberOfMonth":"37","PaymentDate":"2018-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"14","PrincipalPayment":"16204.4892832921","InterestPayment":"1295.51071670794","CashFlow":"17500","OutstandingExposure":"333608.120248384","CapitalAmountInDebt":"88608.120248384","TotalExposure":"106108.120248384","NumberOfMonth":"40","PaymentDate":"2018-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"15","PrincipalPayment":"16367.6285148205","InterestPayment":"1132.37148517954","CashFlow":"17500","OutstandingExposure":"334740.491733564","CapitalAmountInDebt":"72240.4917335636","TotalExposure":"89740.4917335636","NumberOfMonth":"43","PaymentDate":"2018-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"16","PrincipalPayment":"16576.7993646053","InterestPayment":"923.200635394669","CashFlow":"17500","OutstandingExposure":"335663.692368958","CapitalAmountInDebt":"55663.6923689583","TotalExposure":"73163.6923689582","NumberOfMonth":"46","PaymentDate":"2018-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"17","PrincipalPayment":"16788.643322737","InterestPayment":"711.356677263037","CashFlow":"17500","OutstandingExposure":"336375.049046221","CapitalAmountInDebt":"38875.0490462213","TotalExposure":"56375.0490462213","NumberOfMonth":"49","PaymentDate":"2019-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"18","PrincipalPayment":"17019.494430327","InterestPayment":"480.50556967295","CashFlow":"17500","OutstandingExposure":"336855.554615894","CapitalAmountInDebt":"21855.5546158942","TotalExposure":"39355.5546158942","NumberOfMonth":"52","PaymentDate":"2019-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123602562945102"},{"Period":"19","PrincipalPayment":"17220.6959500952","InterestPayment":"279.304049904771","CashFlow":"17500","OutstandingExposure":"337134.858665799","CapitalAmountInDebt":"4634.85866579901","TotalExposure":"22134.858665799","NumberOfMonth":"55","PaymentDate":"2019-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"},{"Period":"20","PrincipalPayment":"4634.85866579901","InterestPayment":"59.2313862011285","CashFlow":"4694.09005200014","OutstandingExposure":"337194.090052","CapitalAmountInDebt":"0","TotalExposure":"4694.09005200014","NumberOfMonth":"58","PaymentDate":"2019-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0127795452832686"}]}
See Also
BALLOON - Schedule with periodic interest payments and principal repaid at maturity
BULLET - Schedule with single interest and principal payment at maturity
CONSTANTCASHFLOW - Schedule with equal periodic cash flows
CONSTANTPRINCIPALAMOUNT - Schedule with no fixed maturity with a fixed periodic principal payment
CONSTANTPRINCIPALRATE - Schedule with no fixed maturity where a fixed percentage principal payment