Logo

ConstantPrincipalRate

Updated 2024-02-16 15:03:30.337000

Syntax

SELECT * FROM [westclintech].[wct].[ConstantPrincipalRate](
  <@OutstandingAmount, float,>
 ,<@InterestBasis, nvarchar(4000),>
 ,<@InterestRate, float,>
 ,<@FreqPayPrincipal, int,>
 ,<@FreqPayInterest, int,>
 ,<@AmortizationRate, float,>
 ,<@MinimumPayment, float,>
 ,<@ReferenceDate, datetime,>
 ,<@PrevPrincipalPayDate, datetime,>
 ,<@PrevInterestPayDate, datetime,>
 ,<@StartDate, datetime,>
 ,<@FirstPrincipalPayDate, datetime,>
 ,<@FirstInterestPayDate, datetime,>
 ,<@PrincipalGracePeriodStartDate, datetime,>
 ,<@PrincipalGracePeriodEndDate, datetime,>
 ,<@InterestGracePeriodStartDate, datetime,>
 ,<@InterestGracePeriodEndDate, datetime,>)

Description

Use the table-valued function ConstantPrincipalRate to return the cash flow schedule for a loan with no fixed maturity date where the principal is reduced on using a fixed rate. ConstantPrincipalRate computes the periodic interest and principal amounts until the loan balance has been brought to zero. ConstantPrincipalRate supports separate interest and principal repayment schedules.

The interest and principal payment periods are entered in ConstantPrincipalRate as the number of months between payments. For example, a loan with monthly payments of interest would have an interest frequency of 1. If principal is to be repaid every months, then it would have a principal payment frequency of 6.

ConstantPrincipalRate supports both an initial grace period and an additional grace period during the life of the loan, for principal and/or interest. 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 interest grace period is entered in ConstantPrincipalRate and it is greater than the reference date, then it becomes the first interest payment date and subsequent interest payments are calculated from that date forward. The same principle applies for principal payments.

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 respective 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 respective 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 respective 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 respective 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 rate 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":"InterestRate"},{"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 the previous interest payment date to PaymentDate"}]}

In the case where there are one or more principal payments between interest payment dates, the interest payment amount is calculated using the outstanding principal balances during the interest payment period.

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.

@PrevPrincipalPayDate

the last principal payment date prior to the reference date. @PrevPrincipalPayDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@PrincipalGracePeriodStartDate

the date on which the (interim) principal grace period commences. @PrincipalGracePeriodStartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@AmortizationRate

the percentage, as a decimal (1% = .01), of the outstanding principal amount due on a principal payment date. @AmortizationRate is an expression of type float or of a type that can be implicitly converted to float.

@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.

@FirstInterestPayDate

the first interest payment date of the loan if other than a regular periodic payment. @FirstInterestPayDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@InterestGracePeriodStartDate

the date on which the (interim) interest grace period commences. @InterestGracePeriodStartDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@InterestGracePeriodEndDate

the date on which the (interim) interest grace period concludes. @GracePeriodEndDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@PrincipalGracePeriodEndDate

the date on which the (interim) principal grace period concludes. @PrincipalGracePeriodEndDate 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.

@FreqPayPrincipal

the number of months between principal payments. @FreqPayPrincipal is an expression of type int or of a type that can be implicitly converted to int.

@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.

@MinimumPayment

the specified smallest payment amount prior to the last payment. @MinimumPayment is an expression of type float or of a type that can be implicitly converted to float.

@PrevInterestPayDate

the last interest payment date prior to the reference date. @PrevPrincipalPayDate is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@FreqPayInterest

the number of months in a regular interest payment. @FreqPayInterest is an expression of type int or of a type that can be implicitly converted to int.

@FirstPrincipalPayDate

the first principal payment date of the loan if other than a regular periodic payment. @FirstPrincipalPayDate 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": "5d424911-1a0e-4e39-9d61-1d2d7be3bd8c", "colName": "Period", "colDatatype": "int", "colDesc": "A reference number uniquely identifying a row in the resultant table."}, {"id": "34c08235-cc77-4c2a-8db7-c34620d377ce", "colName": "PrincipalPayment", "colDatatype": "float", "colDesc": "The amount of the principal payment."}, {"id": "b4d72fe0-d3db-4563-9b0d-5a3a4c418c3a", "colName": "InterestPayment", "colDatatype": "float", "colDesc": "\t The amount of the regular interest payment."}, {"id": "ef885953-9974-46a6-b7fb-efb03b56d997", "colName": "CashFlow", "colDatatype": "float", "colDesc": "PrincipalPayment + InterestPayment + GraceInterest."}, {"id": "d0b9ea74-6149-4911-b086-2de39bbbe358", "colName": "OutstandingExposure", "colDatatype": "float", "colDesc": "When Period = 0 then @OutstandingAmount. For Period > 0 then OutstandingExposure(Period-1) + InterestPayment."}, {"id": "232672c9-eaef-42eb-a521-9a363d2dc241", "colName": "CapitalAmountInDebt", "colDatatype": "float", "colDesc": "When Period = 0, @OutstandingAmount. For Period > 0 then CapitalAmountInDebt(Period-1) \u2013 PrincipalPayment"}, {"id": "6496afb6-ba35-4f0b-a20c-04c66489a580", "colName": "TotalExposure", "colDatatype": "float", "colDesc": "When Period = 0, @OutstandingAmount. For Period > 0 then CapitalAmountInDebt(Period-1) + InterestPayment"}, {"id": "fa5f9942-61f1-4120-8ba7-298c48a85509", "colName": "NumberOfMonth", "colDatatype": "int", "colDesc": "The number of months between the @ReferenceDate and the PaymentDate."}, {"id": "c0bc5355-462d-4fbd-af1c-c185ed85c145", "colName": "PaymentDate", "colDatatype": "datetime", "colDesc": "The end-of-month date of the payment."}, {"id": "e9e3301b-51a0-440d-af5a-86f698da9e51", "colName": "GraceInterest", "colDatatype": "float", "colDesc": "The amount of the grace interest"}, {"id": "75dce50c-65ec-47ac-8ad1-ffe97832726f", "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 @FirstInterestPayDate and @InterestGracePeriodEndDate.

GraceInterest is only calculated if length of the grace interest period is greater than @FreqPayInterest.

GraceInterest is the difference between the interest for the period from the previous interest payment to PaymentDate and interest that would have been calculated for a period with length equal to @FreqPayInterest.

PrincipalPayment = MIN(MAX(@AmortizationRate * CapitalAmountInDebt(Period-1), @MinimumPayment), CapitalAmountInDebt(Period-1).

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 @FreqPayInterest.

Examples

This is a 100,000 loan with quarterly payments of principal and interest and an interest rate of 3.0%. The principal payments are calculated as 13.0% of the outstanding principal balance, with a minimum payment of 2,500.00.

SELECT *
FROM wct.ConstantPrincipalRate(   100000,       --@OutstandingAmount
                                  'Actual/365', --@InterestBasis
                                  .03,          --@InterestRate
                                  3,            --@FreqPayPrincipal
                                  3,            --@FreqPayInterest
                                  .13,          --@AmortizationRate
                                  2500,         --@MinimumPayment
                                  '2014-10-01', --@ReferenceDate
                                  NULL,         --@PrevPrincipalPayDate
                                  NULL,         --@PrevInterestPayDate
                                  NULL,         --@StartDate
                                  NULL,         --@FirstPrincipalPayDate
                                  NULL,         --@FirstInterestPayDate
                                  NULL,         --@PrincipalGracePeriodStartDate
                                  NULL,         --@PrincipalGracePeriodEndDate
                                  NULL,         --@InterestGracePeriodStartDate
                                  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":"100000","CapitalAmountInDebt":"100000","TotalExposure":"100000","NumberOfMonth":"0","PaymentDate":"2014-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13000","InterestPayment":"756.187632425776","CashFlow":"13756.1876324258","OutstandingExposure":"100756.187632426","CapitalAmountInDebt":"87000","TotalExposure":"100756.187632426","NumberOfMonth":"3","PaymentDate":"2015-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"2","PrincipalPayment":"11310","InterestPayment":"636.352262858684","CashFlow":"11946.3522628587","OutstandingExposure":"101392.539895284","CapitalAmountInDebt":"75690","TotalExposure":"87636.3522628587","NumberOfMonth":"6","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00731439382596188"},{"Period":"3","PrincipalPayment":"9839.7","InterestPayment":"572.358418983069","CashFlow":"10412.0584189831","OutstandingExposure":"101964.898314268","CapitalAmountInDebt":"65850.3","TotalExposure":"76262.3584189831","NumberOfMonth":"9","PaymentDate":"2015-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"4","PrincipalPayment":"8560.539","InterestPayment":"497.95182451527","CashFlow":"9058.49082451527","OutstandingExposure":"102462.850138783","CapitalAmountInDebt":"57289.761","TotalExposure":"66348.2518245153","NumberOfMonth":"12","PaymentDate":"2015-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"5","PrincipalPayment":"7447.66893","InterestPayment":"433.218087328285","CashFlow":"7880.88701732828","OutstandingExposure":"102896.068226111","CapitalAmountInDebt":"49842.09207","TotalExposure":"57722.9790873283","NumberOfMonth":"15","PaymentDate":"2016-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"6","PrincipalPayment":"6479.4719691","InterestPayment":"368.676035650899","CashFlow":"6848.1480047509","OutstandingExposure":"103264.744261762","CapitalAmountInDebt":"43362.6201009","TotalExposure":"50210.7681056509","NumberOfMonth":"18","PaymentDate":"2016-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00739688123711013"},{"Period":"7","PrincipalPayment":"5637.140613117","InterestPayment":"327.902770298779","CashFlow":"5965.04338341578","OutstandingExposure":"103592.647032061","CapitalAmountInDebt":"37725.479487783","TotalExposure":"43690.5228711988","NumberOfMonth":"21","PaymentDate":"2016-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"8","PrincipalPayment":"4904.31233341179","InterestPayment":"285.275410159938","CashFlow":"5189.58774357173","OutstandingExposure":"103877.922442221","CapitalAmountInDebt":"32821.1671543712","TotalExposure":"38010.7548979429","NumberOfMonth":"24","PaymentDate":"2016-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"9","PrincipalPayment":"4266.75173006826","InterestPayment":"248.189606839146","CashFlow":"4514.9413369074","OutstandingExposure":"104126.11204906","CapitalAmountInDebt":"28554.4154243029","TotalExposure":"33069.3567612104","NumberOfMonth":"27","PaymentDate":"2017-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"10","PrincipalPayment":"3712.07400515938","InterestPayment":"208.858239883472","CashFlow":"3920.93224504286","OutstandingExposure":"104334.970288943","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"28763.2736641864","NumberOfMonth":"30","PaymentDate":"2017-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00731439382596188"},{"Period":"11","PrincipalPayment":"3229.50438448866","InterestPayment":"187.85471341655","CashFlow":"3417.35909790521","OutstandingExposure":"104522.82500236","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"25030.1961325601","NumberOfMonth":"33","PaymentDate":"2017-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"12","PrincipalPayment":"2809.66881450514","InterestPayment":"163.433600672398","CashFlow":"2973.10241517754","OutstandingExposure":"104686.258603032","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"21776.2706353273","NumberOfMonth":"36","PaymentDate":"2017-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"13","PrincipalPayment":"2500","InterestPayment":"142.187232584986","CashFlow":"2642.18723258499","OutstandingExposure":"104828.445835617","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"18945.3554527348","NumberOfMonth":"39","PaymentDate":"2018-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"14","PrincipalPayment":"2500","InterestPayment":"119.247792973081","CashFlow":"2619.24779297308","OutstandingExposure":"104947.69362859","CapitalAmountInDebt":"13803.1682201498","TotalExposure":"16422.4160131228","NumberOfMonth":"42","PaymentDate":"2018-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00731439382596188"},{"Period":"15","PrincipalPayment":"2500","InterestPayment":"104.377850963698","CashFlow":"2604.3778509637","OutstandingExposure":"105052.071479554","CapitalAmountInDebt":"11303.1682201498","TotalExposure":"13907.5460711135","NumberOfMonth":"45","PaymentDate":"2018-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"16","PrincipalPayment":"2500","InterestPayment":"85.4731601530532","CashFlow":"2585.47316015305","OutstandingExposure":"105137.544639707","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"11388.6413803028","NumberOfMonth":"48","PaymentDate":"2018-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"17","PrincipalPayment":"2500","InterestPayment":"66.5684693424088","CashFlow":"2566.56846934241","OutstandingExposure":"105204.11310905","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"8869.73668949217","NumberOfMonth":"51","PaymentDate":"2019-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"18","PrincipalPayment":"2500","InterestPayment":"46.1038547134626","CashFlow":"2546.10385471346","OutstandingExposure":"105250.216963763","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"6349.27207486323","NumberOfMonth":"54","PaymentDate":"2019-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00731439382596188"},{"Period":"19","PrincipalPayment":"2500","InterestPayment":"28.75908772112","CashFlow":"2528.75908772112","OutstandingExposure":"105278.976051484","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"3831.92730787088","NumberOfMonth":"57","PaymentDate":"2019-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"},{"Period":"20","PrincipalPayment":"1303.16822014976","InterestPayment":"9.85439691047562","CashFlow":"1313.02261706024","OutstandingExposure":"105288.830448395","CapitalAmountInDebt":"0","TotalExposure":"1313.02261706024","NumberOfMonth":"60","PaymentDate":"2019-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00756187632425775"}]}

The same basic SQL with monthly payments of principal and semi-annual payments of interest.

SELECT *
FROM wct.ConstantPrincipalRate(   100000,       --@OutstandingAmount
                                  'Actual/365', --@InterestBasis
                                  .03,          --@InterestRate
                                  1,            --@FreqPayPrincipal
                                  6,            --@FreqPayInterest
                                  .13,          --@AmortizationRate
                                  2500,         --@MinimumPayment
                                  '2014-10-01', --@ReferenceDate
                                  NULL,         --@PrevPrincipalPayDate
                                  NULL,         --@PrevInterestPayDate
                                  NULL,         --@StartDate
                                  NULL,         --@FirstPrincipalPayDate
                                  NULL,         --@FirstInterestPayDate
                                  NULL,         --@PrincipalGracePeriodStartDate
                                  NULL,         --@PrincipalGracePeriodEndDate
                                  NULL,         --@InterestGracePeriodStartDate
                                  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":"100000","CapitalAmountInDebt":"100000","TotalExposure":"100000","NumberOfMonth":"0","PaymentDate":"2014-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13000","InterestPayment":"0","CashFlow":"13000","OutstandingExposure":"100000","CapitalAmountInDebt":"87000","TotalExposure":"100000","NumberOfMonth":"1","PaymentDate":"2014-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00245044058349375"},{"Period":"2","PrincipalPayment":"11310","InterestPayment":"0","CashFlow":"11310","OutstandingExposure":"100000","CapitalAmountInDebt":"75690","TotalExposure":"87000","NumberOfMonth":"2","PaymentDate":"2014-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"3","PrincipalPayment":"9839.7","InterestPayment":"0","CashFlow":"9839.7","OutstandingExposure":"100000","CapitalAmountInDebt":"65850.3","TotalExposure":"75690","NumberOfMonth":"3","PaymentDate":"2015-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"4","PrincipalPayment":"8560.539","InterestPayment":"0","CashFlow":"8560.539","OutstandingExposure":"100000","CapitalAmountInDebt":"57289.761","TotalExposure":"65850.3","NumberOfMonth":"4","PaymentDate":"2015-02-28 00:00:00.000","GraceInterest":"0","InterestRate":"0.00983784918059172"},{"Period":"5","PrincipalPayment":"7447.66893","InterestPayment":"0","CashFlow":"7447.66893","OutstandingExposure":"100000","CapitalAmountInDebt":"49842.09207","TotalExposure":"57289.761","NumberOfMonth":"5","PaymentDate":"2015-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123949860991661"},{"Period":"6","PrincipalPayment":"6479.4719691","InterestPayment":"1082.51802017388","CashFlow":"7561.98998927388","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"43362.6201009","TotalExposure":"50924.6100901739","NumberOfMonth":"6","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0148757998596294"},{"Period":"7","PrincipalPayment":"5637.140613117","InterestPayment":"0","CashFlow":"5637.140613117","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"37725.479487783","TotalExposure":"43362.6201009","NumberOfMonth":"7","PaymentDate":"2015-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"8","PrincipalPayment":"4904.31233341179","InterestPayment":"0","CashFlow":"4904.31233341179","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"32821.1671543712","TotalExposure":"37725.479487783","NumberOfMonth":"8","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"9","PrincipalPayment":"4266.75173006826","InterestPayment":"0","CashFlow":"4266.75173006826","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"28554.4154243029","TotalExposure":"32821.1671543712","NumberOfMonth":"9","PaymentDate":"2015-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"10","PrincipalPayment":"3712.07400515938","InterestPayment":"0","CashFlow":"3712.07400515938","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"28554.4154243029","NumberOfMonth":"10","PaymentDate":"2015-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100850315002157"},{"Period":"11","PrincipalPayment":"3229.50438448866","InterestPayment":"0","CashFlow":"3229.50438448866","OutstandingExposure":"101082.518020174","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"24842.3414191436","NumberOfMonth":"11","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125601848541834"},{"Period":"12","PrincipalPayment":"2809.66881450514","InterestPayment":"476.720489118981","CashFlow":"3286.38930362412","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"22089.5575237739","NumberOfMonth":"12","PaymentDate":"2015-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0151242153399396"},{"Period":"13","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"18803.1682201498","NumberOfMonth":"13","PaymentDate":"2015-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00245044058349375"},{"Period":"14","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"13803.1682201498","TotalExposure":"16303.1682201498","NumberOfMonth":"14","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"15","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"11303.1682201498","TotalExposure":"13803.1682201498","NumberOfMonth":"15","PaymentDate":"2016-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"16","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"11303.1682201498","NumberOfMonth":"16","PaymentDate":"2016-02-29 00:00:00.000","GraceInterest":"0","InterestRate":"0.00992023656539476"},{"Period":"17","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101559.238509293","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"8803.16822014976","NumberOfMonth":"17","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0124775821073868"},{"Period":"18","PrincipalPayment":"2500","InterestPayment":"188.252837960966","CashFlow":"2688.25283796097","OutstandingExposure":"101747.491347254","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"6491.42105811073","NumberOfMonth":"18","PaymentDate":"2016-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"19","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"101747.491347254","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"3803.16822014976","NumberOfMonth":"19","PaymentDate":"2016-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"20","PrincipalPayment":"1303.16822014976","InterestPayment":"12.8474138761726","CashFlow":"1316.01563402594","OutstandingExposure":"101760.33876113","CapitalAmountInDebt":"0","TotalExposure":"1316.01563402594","NumberOfMonth":"20","PaymentDate":"2016-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"}]}

In this example, we modify the SQL so that first interest payment isn't due until January of 2015 and the first principal payment isn't due until March of 2015.

SELECT *
FROM wct.ConstantPrincipalRate(   100000,       --@OutstandingAmount
                                  'Actual/365', --@InterestBasis
                                  .03,          --@InterestRate
                                  1,            --@FreqPayPrincipal
                                  6,            --@FreqPayInterest
                                  .13,          --@AmortizationRate
                                  2500,         --@MinimumPayment
                                  '2014-10-01', --@ReferenceDate
                                  NULL,         --@PrevPrincipalPayDate
                                  NULL,         --@PrevInterestPayDate
                                  NULL,         --@StartDate
                                  '2015-03-01', --@FirstPrincipalPayDate
                                  '2015-01-01', --@FirstInterestPayDate
                                  NULL,         --@PrincipalGracePeriodStartDate
                                  NULL,         --@PrincipalGracePeriodEndDate
                                  NULL,         --@InterestGracePeriodStartDate
                                  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":"100000","CapitalAmountInDebt":"100000","TotalExposure":"100000","NumberOfMonth":"0","PaymentDate":"2014-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"0","InterestPayment":"753.372913264783","CashFlow":"753.372913264783","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"100000","TotalExposure":"100753.372913265","NumberOfMonth":"3","PaymentDate":"2015-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"2","PrincipalPayment":"13000","InterestPayment":"0","CashFlow":"13000","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"87000","TotalExposure":"100000","NumberOfMonth":"5","PaymentDate":"2015-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00482490742091923"},{"Period":"3","PrincipalPayment":"11310","InterestPayment":"0","CashFlow":"11310","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"75690","TotalExposure":"87000","NumberOfMonth":"6","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00728717115336885"},{"Period":"4","PrincipalPayment":"9839.7","InterestPayment":"0","CashFlow":"9839.7","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"65850.3","TotalExposure":"75690","NumberOfMonth":"7","PaymentDate":"2015-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00983784918059172"},{"Period":"5","PrincipalPayment":"8560.539","InterestPayment":"0","CashFlow":"8560.539","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"57289.761","TotalExposure":"65850.3","NumberOfMonth":"8","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123123968289718"},{"Period":"6","PrincipalPayment":"7447.66893","InterestPayment":"1201.57310438872","CashFlow":"8649.24203438872","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"49842.09207","TotalExposure":"58491.3341043887","NumberOfMonth":"9","PaymentDate":"2015-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0148757998596294"},{"Period":"7","PrincipalPayment":"6479.4719691","InterestPayment":"0","CashFlow":"6479.4719691","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"43362.6201009","TotalExposure":"49842.09207","NumberOfMonth":"10","PaymentDate":"2015-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"8","PrincipalPayment":"5637.140613117","InterestPayment":"0","CashFlow":"5637.140613117","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"37725.479487783","TotalExposure":"43362.6201009","NumberOfMonth":"11","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"9","PrincipalPayment":"4904.31233341179","InterestPayment":"0","CashFlow":"4904.31233341179","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"32821.1671543712","TotalExposure":"37725.479487783","NumberOfMonth":"12","PaymentDate":"2015-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"10","PrincipalPayment":"4266.75173006826","InterestPayment":"0","CashFlow":"4266.75173006826","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"28554.4154243029","TotalExposure":"32821.1671543712","NumberOfMonth":"13","PaymentDate":"2015-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100026306717533"},{"Period":"11","PrincipalPayment":"3712.07400515938","InterestPayment":"0","CashFlow":"3712.07400515938","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"28554.4154243029","NumberOfMonth":"14","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125601848541834"},{"Period":"12","PrincipalPayment":"3229.50438448866","InterestPayment":"547.604746616338","CashFlow":"3777.109131105","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"25389.9461657599","NumberOfMonth":"15","PaymentDate":"2016-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0151242153399396"},{"Period":"13","PrincipalPayment":"2809.66881450514","InterestPayment":"0","CashFlow":"2809.66881450514","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"21612.8370346549","NumberOfMonth":"16","PaymentDate":"2016-02-29 00:00:00.000","GraceInterest":"0","InterestRate":"0.00236866257053392"},{"Period":"14","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"18803.1682201498","NumberOfMonth":"17","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00490688582604082"},{"Period":"15","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"13803.1682201498","TotalExposure":"16303.1682201498","NumberOfMonth":"18","PaymentDate":"2016-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00736935044170139"},{"Period":"16","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"11303.1682201498","TotalExposure":"13803.1682201498","NumberOfMonth":"19","PaymentDate":"2016-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00992023656539476"},{"Period":"17","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102502.55076427","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"11303.1682201498","NumberOfMonth":"20","PaymentDate":"2016-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123949860991661"},{"Period":"18","PrincipalPayment":"2500","InterestPayment":"225.364146887317","CashFlow":"2725.36414688732","OutstandingExposure":"102727.914911157","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"9028.53236703708","NumberOfMonth":"21","PaymentDate":"2016-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"19","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102727.914911157","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"6303.16822014976","NumberOfMonth":"22","PaymentDate":"2016-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"20","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102727.914911157","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"3803.16822014976","NumberOfMonth":"23","PaymentDate":"2016-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"21","PrincipalPayment":"1303.16822014976","InterestPayment":"28.6836215790071","CashFlow":"1331.85184172877","OutstandingExposure":"102756.598532736","CapitalAmountInDebt":"0","TotalExposure":"1331.85184172877","NumberOfMonth":"24","PaymentDate":"2016-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"}]}

We modify the SQL so that there are no payments in 2016.

SELECT *
FROM wct.ConstantPrincipalRate(   100000,       --@OutstandingAmount
                                  'Actual/365', --@InterestBasis
                                  .03,          --@InterestRate
                                  1,            --@FreqPayPrincipal
                                  6,            --@FreqPayInterest
                                  .13,          --@AmortizationRate
                                  2500,         --@MinimumPayment
                                  '2014-10-01', --@ReferenceDate
                                  NULL,         --@PrevPrincipalPayDate
                                  NULL,         --@PrevInterestPayDate
                                  NULL,         --@StartDate
                                  '2015-03-01', --@FirstPrincipalPayDate
                                  '2015-01-01', --@FirstInterestPayDate
                                  '2016-01-01', --@PrincipalGracePeriodStartDate
                                  '2017-01-01', --@PrincipalGracePeriodEndDate
                                  '2016-01-01', --@InterestGracePeriodStartDate
                                  '2017-01-01'  --@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":"100000","CapitalAmountInDebt":"100000","TotalExposure":"100000","NumberOfMonth":"0","PaymentDate":"2014-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"0","InterestPayment":"753.372913264783","CashFlow":"753.372913264783","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"100000","TotalExposure":"100753.372913265","NumberOfMonth":"3","PaymentDate":"2015-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"2","PrincipalPayment":"13000","InterestPayment":"0","CashFlow":"13000","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"87000","TotalExposure":"100000","NumberOfMonth":"5","PaymentDate":"2015-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00482490742091923"},{"Period":"3","PrincipalPayment":"11310","InterestPayment":"0","CashFlow":"11310","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"75690","TotalExposure":"87000","NumberOfMonth":"6","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00728717115336885"},{"Period":"4","PrincipalPayment":"9839.7","InterestPayment":"0","CashFlow":"9839.7","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"65850.3","TotalExposure":"75690","NumberOfMonth":"7","PaymentDate":"2015-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00983784918059172"},{"Period":"5","PrincipalPayment":"8560.539","InterestPayment":"0","CashFlow":"8560.539","OutstandingExposure":"100753.372913265","CapitalAmountInDebt":"57289.761","TotalExposure":"65850.3","NumberOfMonth":"8","PaymentDate":"2015-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123123968289718"},{"Period":"6","PrincipalPayment":"7447.66893","InterestPayment":"1201.57310438872","CashFlow":"8649.24203438872","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"49842.09207","TotalExposure":"58491.3341043887","NumberOfMonth":"9","PaymentDate":"2015-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0148757998596294"},{"Period":"7","PrincipalPayment":"6479.4719691","InterestPayment":"0","CashFlow":"6479.4719691","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"43362.6201009","TotalExposure":"49842.09207","NumberOfMonth":"10","PaymentDate":"2015-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"8","PrincipalPayment":"5637.140613117","InterestPayment":"0","CashFlow":"5637.140613117","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"37725.479487783","TotalExposure":"43362.6201009","NumberOfMonth":"11","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"9","PrincipalPayment":"4904.31233341179","InterestPayment":"0","CashFlow":"4904.31233341179","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"32821.1671543712","TotalExposure":"37725.479487783","NumberOfMonth":"12","PaymentDate":"2015-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"10","PrincipalPayment":"4266.75173006826","InterestPayment":"0","CashFlow":"4266.75173006826","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"28554.4154243029","TotalExposure":"32821.1671543712","NumberOfMonth":"13","PaymentDate":"2015-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100026306717533"},{"Period":"11","PrincipalPayment":"3712.07400515938","InterestPayment":"0","CashFlow":"3712.07400515938","OutstandingExposure":"101954.946017654","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"28554.4154243029","NumberOfMonth":"14","PaymentDate":"2015-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125601848541834"},{"Period":"12","PrincipalPayment":"3229.50438448866","InterestPayment":"817.760822799653","CashFlow":"4546.65429584331","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"25660.1022419432","NumberOfMonth":"27","PaymentDate":"2017-01-31 00:00:00.000","GraceInterest":"499.389088554998","InterestRate":"0.0458916666146927"},{"Period":"13","PrincipalPayment":"2809.66881450514","InterestPayment":"0","CashFlow":"2809.66881450514","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"21612.8370346549","NumberOfMonth":"28","PaymentDate":"2017-02-28 00:00:00.000","GraceInterest":"0","InterestRate":"0.00228689122886983"},{"Period":"14","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"18803.1682201498","NumberOfMonth":"29","PaymentDate":"2017-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00482490742091923"},{"Period":"15","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"13803.1682201498","TotalExposure":"16303.1682201498","NumberOfMonth":"30","PaymentDate":"2017-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00728717115336885"},{"Period":"16","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"11303.1682201498","TotalExposure":"13803.1682201498","NumberOfMonth":"31","PaymentDate":"2017-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00983784918059172"},{"Period":"17","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102772.706840453","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"11303.1682201498","NumberOfMonth":"32","PaymentDate":"2017-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123123968289718"},{"Period":"18","PrincipalPayment":"2500","InterestPayment":"223.574638456971","CashFlow":"2723.57463845697","OutstandingExposure":"102996.28147891","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"9026.74285860674","NumberOfMonth":"33","PaymentDate":"2017-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0148757998596294"},{"Period":"19","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102996.28147891","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"6303.16822014976","NumberOfMonth":"34","PaymentDate":"2017-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"20","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"102996.28147891","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"3803.16822014976","NumberOfMonth":"35","PaymentDate":"2017-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"21","PrincipalPayment":"1303.16822014976","InterestPayment":"28.6836215790071","CashFlow":"1331.85184172877","OutstandingExposure":"103024.965100489","CapitalAmountInDebt":"0","TotalExposure":"1331.85184172877","NumberOfMonth":"36","PaymentDate":"2017-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"}]}

In this example we change the SQL so that the principal payment frequency is every 5 months and to calculate the first payment dates from the previous interest and previous principal payment dates.

SELECT *
FROM wct.ConstantPrincipalRate(   100000,       --@OutstandingAmount
                                  'Actual/365', --@InterestBasis
                                  .03,          --@InterestRate
                                  5,            --@FreqPayPrincipal
                                  6,            --@FreqPayInterest
                                  .13,          --@AmortizationRate
                                  2500,         --@MinimumPayment
                                  '2014-10-01', --@ReferenceDate
                                  '2014-06-01', --@PrevPrincipalPayDate
                                  '2014-09-01', --@PrevInterestPayDate
                                  NULL,         --@StartDate
                                  NULL,         --@FirstPrincipalPayDate
                                  NULL,         --@FirstInterestPayDate
                                  NULL,         --@PrincipalGracePeriodStartDate
                                  NULL,         --@PrincipalGracePeriodEndDate
                                  NULL,         --@InterestGracePeriodStartDate
                                  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":"100000","CapitalAmountInDebt":"100000","TotalExposure":"100000","NumberOfMonth":"0","PaymentDate":"2014-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0"},{"Period":"1","PrincipalPayment":"13000","InterestPayment":"0","CashFlow":"13000","OutstandingExposure":"100000","CapitalAmountInDebt":"87000","TotalExposure":"100000","NumberOfMonth":"1","PaymentDate":"2014-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00245044058349375"},{"Period":"2","PrincipalPayment":"0","InterestPayment":"1110.53553456649","CashFlow":"1110.53553456649","OutstandingExposure":"101110.535534566","CapitalAmountInDebt":"87000","TotalExposure":"88110.5355345665","NumberOfMonth":"5","PaymentDate":"2015-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123949860991661"},{"Period":"3","PrincipalPayment":"11310","InterestPayment":"0","CashFlow":"11310","OutstandingExposure":"101110.535534566","CapitalAmountInDebt":"75690","TotalExposure":"87000","NumberOfMonth":"6","PaymentDate":"2015-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00245044058349375"},{"Period":"4","PrincipalPayment":"9839.7","InterestPayment":"1166.54640722025","CashFlow":"11006.2464072202","OutstandingExposure":"102277.081941787","CapitalAmountInDebt":"65850.3","TotalExposure":"76856.5464072202","NumberOfMonth":"11","PaymentDate":"2015-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"5","PrincipalPayment":"8560.539","InterestPayment":"0","CashFlow":"8560.539","OutstandingExposure":"102277.081941787","CapitalAmountInDebt":"57289.761","TotalExposure":"65850.3","NumberOfMonth":"16","PaymentDate":"2016-02-29 00:00:00.000","GraceInterest":"0","InterestRate":"0.0124775821073868"},{"Period":"6","PrincipalPayment":"0","InterestPayment":"968.803714750444","CashFlow":"968.803714750444","OutstandingExposure":"103245.885656537","CapitalAmountInDebt":"57289.761","TotalExposure":"58258.5647147504","NumberOfMonth":"17","PaymentDate":"2016-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"7","PrincipalPayment":"7447.66893","InterestPayment":"0","CashFlow":"7447.66893","OutstandingExposure":"103245.885656537","CapitalAmountInDebt":"49842.09207","TotalExposure":"57289.761","NumberOfMonth":"21","PaymentDate":"2016-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100026306717533"},{"Period":"8","PrincipalPayment":"0","InterestPayment":"824.562948345498","CashFlow":"824.562948345498","OutstandingExposure":"104070.448604883","CapitalAmountInDebt":"49842.09207","TotalExposure":"50666.6550183455","NumberOfMonth":"23","PaymentDate":"2016-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"9","PrincipalPayment":"6479.4719691","InterestPayment":"0","CashFlow":"6479.4719691","OutstandingExposure":"104070.448604883","CapitalAmountInDebt":"43362.6201009","TotalExposure":"49842.09207","NumberOfMonth":"26","PaymentDate":"2016-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"10","PrincipalPayment":"0","InterestPayment":"697.818332317906","CashFlow":"697.818332317906","OutstandingExposure":"104768.266937201","CapitalAmountInDebt":"43362.6201009","TotalExposure":"44060.4384332179","NumberOfMonth":"29","PaymentDate":"2017-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"11","PrincipalPayment":"5637.140613117","InterestPayment":"0","CashFlow":"5637.140613117","OutstandingExposure":"104768.266937201","CapitalAmountInDebt":"37725.479487783","TotalExposure":"43362.6201009","NumberOfMonth":"31","PaymentDate":"2017-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"12","PrincipalPayment":"0","InterestPayment":"595.848426878033","CashFlow":"595.848426878033","OutstandingExposure":"105364.115364079","CapitalAmountInDebt":"37725.479487783","TotalExposure":"38321.327914661","NumberOfMonth":"35","PaymentDate":"2017-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"13","PrincipalPayment":"4904.31233341179","InterestPayment":"0","CashFlow":"4904.31233341179","OutstandingExposure":"105364.115364079","CapitalAmountInDebt":"32821.1671543712","TotalExposure":"37725.479487783","NumberOfMonth":"36","PaymentDate":"2017-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"},{"Period":"14","PrincipalPayment":"4266.75173006826","InterestPayment":"503.531408793277","CashFlow":"4770.28313886154","OutstandingExposure":"105867.646772872","CapitalAmountInDebt":"28554.4154243029","TotalExposure":"33324.6985631645","NumberOfMonth":"41","PaymentDate":"2018-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"15","PrincipalPayment":"3712.07400515938","InterestPayment":"0","CashFlow":"3712.07400515938","OutstandingExposure":"105867.646772872","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"28554.4154243029","NumberOfMonth":"46","PaymentDate":"2018-08-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0125601848541834"},{"Period":"16","PrincipalPayment":"0","InterestPayment":"420.402265153106","CashFlow":"420.402265153106","OutstandingExposure":"106288.049038025","CapitalAmountInDebt":"24842.3414191436","TotalExposure":"25262.7436842967","NumberOfMonth":"47","PaymentDate":"2018-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"17","PrincipalPayment":"3229.50438448866","InterestPayment":"0","CashFlow":"3229.50438448866","OutstandingExposure":"106288.049038025","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"24842.3414191436","NumberOfMonth":"51","PaymentDate":"2019-01-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100850315002157"},{"Period":"18","PrincipalPayment":"0","InterestPayment":"356.024545566926","CashFlow":"356.024545566926","OutstandingExposure":"106644.073583592","CapitalAmountInDebt":"21612.8370346549","TotalExposure":"21968.8615802218","NumberOfMonth":"53","PaymentDate":"2019-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"19","PrincipalPayment":"2809.66881450514","InterestPayment":"0","CashFlow":"2809.66881450514","OutstandingExposure":"106644.073583592","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"21612.8370346549","NumberOfMonth":"56","PaymentDate":"2019-06-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00745153643461216"},{"Period":"20","PrincipalPayment":"0","InterestPayment":"303.920117182705","CashFlow":"303.920117182705","OutstandingExposure":"106947.993700775","CapitalAmountInDebt":"18803.1682201498","TotalExposure":"19107.0883373325","NumberOfMonth":"59","PaymentDate":"2019-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"21","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"106947.993700775","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"18803.1682201498","NumberOfMonth":"61","PaymentDate":"2019-11-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"22","PrincipalPayment":"0","InterestPayment":"257.819462176378","CashFlow":"257.819462176378","OutstandingExposure":"107205.813162951","CapitalAmountInDebt":"16303.1682201498","TotalExposure":"16560.9876823261","NumberOfMonth":"65","PaymentDate":"2020-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"23","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"107205.813162951","CapitalAmountInDebt":"13803.1682201498","TotalExposure":"16303.1682201498","NumberOfMonth":"66","PaymentDate":"2020-04-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.00245044058349375"},{"Period":"24","PrincipalPayment":"2500","InterestPayment":"213.822068159346","CashFlow":"2713.82206815935","OutstandingExposure":"107419.63523111","CapitalAmountInDebt":"11303.1682201498","TotalExposure":"14016.9902883091","NumberOfMonth":"71","PaymentDate":"2020-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"25","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"107419.63523111","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"11303.1682201498","NumberOfMonth":"76","PaymentDate":"2021-02-28 00:00:00.000","GraceInterest":"0","InterestRate":"0.0123949860991661"},{"Period":"26","PrincipalPayment":"0","InterestPayment":"162.748989350101","CashFlow":"162.748989350101","OutstandingExposure":"107582.38422046","CapitalAmountInDebt":"8803.16822014976","TotalExposure":"8965.91720949986","NumberOfMonth":"77","PaymentDate":"2021-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"27","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"107582.38422046","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"8803.16822014976","NumberOfMonth":"81","PaymentDate":"2021-07-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0100026306717533"},{"Period":"28","PrincipalPayment":"0","InterestPayment":"119.939827313578","CashFlow":"119.939827313578","OutstandingExposure":"107702.324047774","CapitalAmountInDebt":"6303.16822014976","TotalExposure":"6423.10804746334","NumberOfMonth":"83","PaymentDate":"2021-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"29","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"107702.324047774","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"6303.16822014976","NumberOfMonth":"86","PaymentDate":"2021-12-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00753372913264783"},{"Period":"30","PrincipalPayment":"0","InterestPayment":"75.8631850942817","CashFlow":"75.8631850942817","OutstandingExposure":"107778.187232868","CapitalAmountInDebt":"3803.16822014976","TotalExposure":"3879.03140524405","NumberOfMonth":"89","PaymentDate":"2022-03-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.0149585982644604"},{"Period":"31","PrincipalPayment":"2500","InterestPayment":"0","CashFlow":"2500","OutstandingExposure":"107778.187232868","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"3803.16822014976","NumberOfMonth":"91","PaymentDate":"2022-05-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00498887091935174"},{"Period":"32","PrincipalPayment":"0","InterestPayment":"32.198410810672","CashFlow":"32.198410810672","OutstandingExposure":"107810.385643679","CapitalAmountInDebt":"1303.16822014976","TotalExposure":"1335.36663096044","NumberOfMonth":"95","PaymentDate":"2022-09-30 00:00:00.000","GraceInterest":"0","InterestRate":"0.0150414034243802"},{"Period":"33","PrincipalPayment":"1303.16822014976","InterestPayment":"3.29991549590066","CashFlow":"1306.46813564566","OutstandingExposure":"107813.685559175","CapitalAmountInDebt":"0","TotalExposure":"1306.46813564566","NumberOfMonth":"96","PaymentDate":"2022-10-31 00:00:00.000","GraceInterest":"0","InterestRate":"0.00253222526829378"}]}

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

CONSTANTPAYMENTAMOUNT - Schedule with no maturity with fixed periodic payment amount

CONSTANTPRINCIPAL - Schedule with fixed maturity date where the periodic principal payment is calculated on a straight-line basis

CONSTANTPRINCIPALAMOUNT - Schedule with no fixed maturity with a fixed periodic principal payment

PAYMENTPERIODS - Number of months until first payment date, start of grace period, end of grace period, and total number payments for a loan