Logo

SQL Server ConstantCashFlowFR Function

Updated 2024-02-22 16:59:48.163000

Description

Use the table-valued function ConstantCashFlowFR to return the cash flow schedule for a loan with a fixed maturity date and annuity-style payments using a table of forward rates to calculate each periodic payment. ConstantCashFlowFR computes the periodic interest and principal amount through to the maturity date.

The payment frequency is entered into ConstantCashFlowFR 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 a frequency of 3. A loan with annual payments would have a frequency of 12.

ConstantCashFlowFR supports both an initial grace period and an additional grace period during the life of the loan. All payments and payment 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 ConstantCashFlowFR and it is greater than the reference date then it becomes the first payment date and subsequent payments are calculated from that date forward.

If any payment 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 that first payment date is calculated using the 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 no previous payment date or the number of months between those dates and the reference date is greater than the frequency 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 periodic interest payment is calculated as:

\mathrm{I_p=C_{p-1}\times\left[\left(\left(1+\frac{R_p\times{F}}{12}\right)^{12\slash{F}}\right)^{\left(N_p-N_{p-1}\right)\slash{12}}-1\right]}

Where:

    Ip = Interest payment in period p

    Cp-1 = Capital Amount In Debt in period p-1

    Rp = Interest rate in period p

    F = @Frequency

    Np = Number of Month in period p

    Np-1 = Number of Month in period p-1

If the period is irregular and is longer than the regular period then the interest amount is broken out into a regular interest amount and a 'grace' interest amount. The regular interest amount is simply the normal periodic interest and the grace interest is the difference between the amount calculated using the above-formula and the normal periodic interest.

The principal payment is calculated as:

    PPAYp = -PPMT(Rp * F/12,1,N-(P-1),Cp-1,FV,0)

Where:

    PPAYp = Principal payment in period p

    PPMT = PPMT function

    Cp-1 = Capital Amount In Debt in period p-1

    Rp = Interest rate in period p

    F = @Frequency

    P-1 = Period – 1

    FV = @LastPrinPayAmount

Syntax

SELECT * FROM [westclintech].[wct].[ConstantCashFlowFR](
  <@OutstandingAmount, float,>
 ,<@LastPrinPayAmount, float,>
 ,<@PaymentFrequency, int,>
 ,<@MaturityDate, datetime,>
 ,<@ReferenceDate, datetime,>
 ,<@PrevPayDate, datetime,>
 ,<@StartDate, datetime,>
 ,<@FirstPayDate, datetime,>
 ,<@GracePeriodStartDate, datetime,>
 ,<@GracePeriodEndDate, datetime,>
 ,<@FutureRates, nvarchar(max),>)

Arguments

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

@LastPrinPayAmount

the amount of principal to be paid off on the maturity date. @OutstandingAmount is an expression of type float or of a type that can be implicitly converted to float.

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

@MaturityDate

the last payment date of the loan. @MaturityDate 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.

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

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

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

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

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

@FutureRates

a SELECT statement, as a string, which identifies the forward dates and rates to be used in the calculation. The resultant table should consist of 2 columns: a date and a rate. The rate is decimal format such that 1% = .01.

Return Type

table

colNamecolDatatypecolDesc
PeriodintA reference number uniquely identifying a row in the resultant table.
PrincipalPaymentfloatThe amount of the principal payment.
InterestPaymentfloatThe amount of the regular interest payment.
CashFlowfloatPrincipalPayment + InterestPayment + GraceInterest.
OutstandingExposurefloatWhen Period = 0 then @OutstandingAmount. For Period > 0 then OutstandingExposure(Period-1) + InterestPayment.
CapitalAmountInDebtfloatWhen Period = 0, @OutstandingAmount. For Period > 0 then CapitalAmountInDebt(Period-1) – PrincipalPayment
TotalExposurefloatWhen Period = 0, @OutstandingAmount. For Period > 0
NumberOfMonthintThe number of months between the @ReferenceDate and the PaymentDate.
PaymentDatedatetimeThe end-of-month date of the payment.
GraceInterestfloatThe amount of the grace interest
InterestRatefloatThe Interest Rate used in the calculation of the interest and principal payment

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 @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 the interest that would have been calculated for a period with length equal to @PaymentFrequency.

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.

The interest rate used in the calculation comes from the @FutureRates resultant table. The rate value for the maximum date less than or equal to the PaymentDate is used.

Examples

Use the following forward rates, which have been inserted into a #fwdrates table, for all the examples.

SELECT CAST(dt as datetime) as dt,
       rate
INTO #fwdrates
FROM
(
    VALUES
        ('2014-12-31', 0.025),
        ('2015-01-31', 0.025102),
        ('2015-02-28', 0.025205),
        ('2015-03-31', 0.025308),
        ('2015-04-30', 0.02541),
        ('2015-05-31', 0.025513),
        ('2015-06-30', 0.025615),
        ('2015-07-31', 0.025718),
        ('2015-08-31', 0.02582),
        ('2015-09-30', 0.025923),
        ('2015-10-31', 0.026025),
        ('2015-11-30', 0.026128),
        ('2015-12-31', 0.026231),
        ('2016-01-31', 0.026333),
        ('2016-02-29', 0.026436),
        ('2016-03-31', 0.026539),
        ('2016-04-30', 0.026641),
        ('2016-05-31', 0.026744),
        ('2016-06-30', 0.026847),
        ('2016-07-31', 0.026949),
        ('2016-08-31', 0.027052),
        ('2016-09-30', 0.027155),
        ('2016-10-31', 0.027257),
        ('2016-11-30', 0.02736),
        ('2016-12-31', 0.027463),
        ('2017-01-31', 0.027566),
        ('2017-02-28', 0.027668),
        ('2017-03-31', 0.027771),
        ('2017-04-30', 0.027874),
        ('2017-05-31', 0.027977),
        ('2017-06-30', 0.028079),
        ('2017-07-31', 0.028182),
        ('2017-08-31', 0.028285),
        ('2017-09-30', 0.028388),
        ('2017-10-31', 0.028491),
        ('2017-11-30', 0.028594),
        ('2017-12-31', 0.028696),
        ('2018-01-31', 0.028799),
        ('2018-02-28', 0.028902),
        ('2018-03-31', 0.029005),
        ('2018-04-30', 0.029108),
        ('2018-05-31', 0.029211),
        ('2018-06-30', 0.029314),
        ('2018-07-31', 0.029417),
        ('2018-08-31', 0.02952),
        ('2018-09-30', 0.029623),
        ('2018-10-31', 0.029726),
        ('2018-11-30', 0.029829),
        ('2018-12-31', 0.029932),
        ('2019-01-31', 0.030035),
        ('2019-02-28', 0.030138),
        ('2019-03-31', 0.030241),
        ('2019-04-30', 0.030344),
        ('2019-05-31', 0.030447),
        ('2019-06-30', 0.03055),
        ('2019-07-31', 0.030653),
        ('2019-08-31', 0.030756),
        ('2019-09-30', 0.030859),
        ('2019-10-31', 0.030962),
        ('2019-11-30', 0.031065),
        ('2019-12-31', 0.031168)
) n (dt, rate);

This is a simple 300,000 loan with quarterly payments with the interest rates coming from #fwdrates .

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               0,                        --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               NULL,                     --@PrevPayDate
                               NULL,                     --@StartDate
                               NULL,                     --@FirstPayDate
                               NULL,                     
                                         --@GracePeriodStartDate
                               NULL,                     --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following result.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
114118.29974114311898.116016.3997411431301898.1285881.700258857301898.132015-03-31 00:00:00.00000.006327
214197.67166095131830.7149380326516028.386598984303728.814938033271684.028597906287712.4151968962015-06-30 00:00:00.00000.00640375
314279.11221369081760.7162683358816039.8284820267305489.531206369257404.916384215273444.74486624192015-09-30 00:00:00.00000.00648075
414362.68734157111687.9970904185816050.6844319897307177.528296787243042.229042644259092.913474633122015-12-31 00:00:00.00000.00655775
514448.42811342721612.5244291406816060.9525425679308790.052725928228593.800929216244654.753471784152016-03-31 00:00:00.00000.00663475
614536.36647983091534.2644433866716070.6309232175310324.317169314214057.434449386230128.065372603182016-06-30 00:00:00.00000.00671175
714626.53529139311453.1824081182716079.7176995114311777.499577433199430.899157992215510.616857504212016-09-30 00:00:00.00000.00678875
814718.96831760651369.2426958939916088.2110135004313146.742273327184711.930840386200800.141853886242016-12-31 00:00:00.00000.00686575
914813.70026625861282.4087578420916096.1090241007314429.151031169169898.230574127185994.339598228272017-03-31 00:00:00.00000.00694275
1014910.76680341781192.6431040727316103.4099074905315621.794135242154987.46377071171090.8736782302017-06-30 00:00:00.00000.00701975
1115010.18758916431099.9460303807316110.133619545316721.740165622139977.276181545156087.40980109332017-09-30 00:00:00.00000.007097
1215112.03787355131004.1969793264116116.2348528777317725.937144949124865.238307994140981.473160872362017-12-31 00:00:00.00000.007174
1315216.3223904572905.42905928084216121.7514497381318631.36620423109648.915917537125770.667367275392018-03-31 00:00:00.00000.00725125
1415323.0997654969803.56208030166916126.6618457985319434.92828453194325.8161520399110452.477997838422018-06-30 00:00:00.00000.0073285
1515432.4108906194698.5534129679716130.9643035874320133.48169749978893.405261420595024.3695650079452018-09-30 00:00:00.00000.00740575
1615544.2977541982590.3593515712116134.6571057694320723.8410490763349.107507222379483.7646129917482018-12-31 00:00:00.00000.007483
1715658.8034656363478.93509003147716137.7385556678321202.77613910247690.30404158663828.0425972538512019-03-31 00:00:00.00000.00756025
1815775.9722806856364.23469711761316140.2069778033321567.01083621931914.331760900348054.5387387036542019-06-30 00:00:00.00000.0076375
1915895.849627493246.21109095240616142.0607184454321813.22192717216018.482133407332160.5428518527572019-09-30 00:00:00.00000.00771475
2016018.4821334073124.8160127835116143.2981461908321938.037939955016143.2981461908602019-12-31 00:00:00.00000.00779200000000002

In this example the SQL reflects a final principal payment of 172,000.

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               172000,                   --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               NULL,                     --@PrevPayDate
                               NULL,                     --@StartDate
                               NULL,                     --@FirstPayDate
                               NULL,                     
                                         --@GracePeriodStartDate
                               NULL,                     --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following result.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
16023.807889554391898.17921.90788955439301898.1293976.192110446301898.132015-03-31 00:00:00.00000.006327
26057.67324200591882.550040227277940.22328223317303780.650040227287918.51886844295858.74215067362015-06-30 00:00:00.00000.00640375
36092.421211174751865.927941156647958.3491523314305646.577981384281826.097657265289784.44680959692015-09-30 00:00:00.00000.00648075
46128.079932403691848.145091911937976.22502431562307494.723073296275698.017724861283674.242749177122015-12-31 00:00:00.00000.00655775
56164.662661728931829.187423100027993.85008482895309323.910496396269533.355063132277527.205147961152016-03-31 00:00:00.00000.00663475
66202.18303139451809.040495844988011.22352723947311132.950992241263331.172031738271342.395558977182016-06-30 00:00:00.00000.00671175
76240.655057661061787.689494130468028.34455179152312920.640486371257090.516974077265118.861525868212016-09-30 00:00:00.00000.00678875
86280.093148845421765.119216914778045.21236576019314685.759703286250810.423825231258855.636190991242016-12-31 00:00:00.00000.00686575
96320.512113603691741.314070012628061.82618361631316427.073773299244489.911711628252551.737895244272017-03-31 00:00:00.00000.00694275
106361.927169458241716.25805773778078.18522719594318143.331831036238127.984542169246206.169769365302017-06-30 00:00:00.00000.00701975
116404.346704710091689.994306295788094.34101100587319833.326137332231723.637837459239817.978848465332017-09-30 00:00:00.00000.007097
126447.802826048541662.385377845938110.18820389447321495.711515178225275.835011411233386.023215305362017-12-31 00:00:00.00000.007174
136492.297553261741633.531398626498125.82895188823323129.242913805218783.537458149226909.366410037392018-03-31 00:00:00.00000.00725125
146537.855899945331603.355154262058141.21105420738324732.598068067212245.681558204220386.892612411422018-06-30 00:00:00.00000.0073285
156584.495313330941571.838456199678156.33376953061326304.436524266205661.186244873213817.520014403452018-09-30 00:00:00.00000.00740575
166632.233708457911538.962656670388171.1963651283327843.399180937199028.952536415207200.148901543482018-12-31 00:00:00.00000.007483
176681.089478671491504.708638413438185.79811708492329348.10781935192347.863057743200533.661174828512019-03-31 00:00:00.00000.00756025
186731.081506425871469.056804103518200.13831052939330817.164623454185616.781551317193816.919861847542019-06-30 00:00:00.00000.0076375
196782.229174397021431.987065473038214.21623987005332249.151688927178834.55237692187048.768616791572019-09-30 00:00:00.00000.00771475
20178834.552376921393.47883212097180228.031209041333642.6305210480180228.031209041602019-12-31 00:00:00.00000.00779200000000002

In this example the last principal payment amount has been set to zero and a first payment date of 15-June-2015 has been added.

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               0,                        --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               NULL,                     --@PrevPayDate
                               NULL,                     --@StartDate
                               '2015-06-15',             --@FirstPayDate
                               NULL,                     
                                         --@GracePeriodStartDate
                               NULL,                     --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following result.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
114898.82526383721921.12518753.377668056301921.125285101.174736163301921.12562015-06-30 00:00:00.0001933.427404218770.0128485080140626
214984.28776738231847.6694381713916831.9572055537303768.794438171270116.88696878286948.84417433492015-09-30 00:00:00.00000.00648075
315071.99026230031771.3590155195216843.3492778198305540.153453691255044.89670648271888.2459843122015-12-31 00:00:00.00000.00655775
415161.96535176391692.1591284233216854.1244801873307232.312582114239882.931354716256737.055834903152016-03-31 00:00:00.00000.00663475
515254.24656422781610.0342645200216864.2808287478308842.346846634224628.684790488241492.965619236182016-06-30 00:00:00.00000.00671175
615348.86837263371524.9479838714316873.8163565052310367.294830506209279.816417855226153.63277436212016-09-30 00:00:00.00000.00678875
715445.86621418461436.8628995708916882.7291137555311804.157730077193833.95020367210716.679317426242016-12-31 00:00:00.00000.00686575
815545.27651071611345.7406577765316891.0171684927313149.898387853178288.673692954195179.690861447272017-03-31 00:00:00.00000.00694275
915647.1366896691251.5419171561116898.6786068251314401.440305009162641.537003285179540.21561011302017-06-30 00:00:00.00000.00701975
1015751.46738203921154.2669881123116905.7343701515315555.707293122146890.069621246163795.803991397332017-09-30 00:00:00.00000.007097
1115858.34755411191053.7893594628216912.1369135747316609.496652584131031.722067134147943.858980709362017-12-31 00:00:00.00000.007174
1215967.7821735487950.14377463930416917.925948188317559.640427224115063.939893585131981.865841773392018-03-31 00:00:00.00000.00725125
1316079.832761197843.24608351013916923.0788447071318402.88651073498984.1071323882115907.185977095422018-06-30 00:00:00.00000.0073285
1416194.5422284594733.05155139568416927.5937798551319135.93806212982789.564903928899717.1586837839452018-09-30 00:00:00.00000.00740575
1516311.9546373098619.51431417609916931.4689514859319755.45237630666477.61026661983409.0792181049482018-12-31 00:00:00.00000.007483
1616432.1152261139502.58735301820616934.7025791321320258.03972932450045.495040505166980.1976196372512019-03-31 00:00:00.00000.00756025
1716555.070436199382.22246837185816937.2929045708320640.26219769633490.424604306250427.717508877542019-06-30 00:00:00.00000.0076375
1816680.8679391858258.37025321607116939.2381924019320898.63245091216809.556665120333748.7948575222572019-09-30 00:00:00.00000.00771475
1916809.5566651203130.98006553461816940.536730655321029.612516446016940.536730655602019-12-31 00:00:00.00000.00779200000000002

In this example there are no payments in 2018.

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               0,                        --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               NULL,                     --@PrevPayDate
                               NULL,                     --@StartDate
                               '2015-06-15',             --@FirstPayDate
                               '2018-01-01',             
                                         --@GracePeriodStartDate
                               '2019-01-01',             --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following results.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
117865.75685136171921.12521720.3092555805301921.125282134.243148638301921.12562015-06-30 00:00:00.0001933.427404218770.0128485080140626
217970.37321594861828.4414962855419798.8147122342303749.566496286264163.86993269283962.68464492492015-09-30 00:00:00.00000.00648075
318077.69710685031732.320618051119810.0177249014305481.887114337246086.172825839265896.190550741122015-12-31 00:00:00.00000.00655775
418187.76842052771632.7202351562419820.4886556839307114.607349493227898.404405312247718.893060996152016-03-31 00:00:00.00000.00663475
518300.62817621291529.5971157673519830.2252919802308644.20446526209597.776229099229428.001521079182016-06-30 00:00:00.00000.00671175
618416.31853936891422.9069033752919839.2254427442310067.111368636191181.45768973211020.683132474212016-09-30 00:00:00.00000.00678875
718534.88284583761312.6040931332619847.4869389709311379.715461769172646.574843892192494.061782863242016-12-31 00:00:00.00000.00686575
818656.36562671541198.6420074974319855.0076342128312578.357469266153990.209217177173845.21685139272017-03-31 00:00:00.00000.00694275
918780.8126339581080.9727711522819861.7854051103313659.330240418135209.396583219155071.181988329302017-06-30 00:00:00.00000.00701975
1018908.2566527075959.58108755110419867.8377402586314618.91132797116301.139930511136168.97767077332017-09-30 00:00:00.00000.007097
1119038.7790124555834.34437786148919873.1233903169315453.25570583197262.3609180559117135.484308373362017-12-31 00:00:00.00000.007174
1219162.5299477012730.31875254345222367.0815049798316183.57445837578099.830970354797992.6796705994492019-01-31 00:00:00.0002474.232804735210.0329474991870546
1319304.1824383589592.46531774111119896.6477561316776.03977611658795.648531995878692.2962880959522019-04-30 00:00:00.00000.007586
1419449.1252821227450.56575361281719899.6910357355317226.60552972839346.523249873159246.2142856086552019-07-31 00:00:00.00000.00766325
1519597.4147305756304.56176321564319901.9764937913317531.16729294419749.108519297539651.0850130887582019-10-31 00:00:00.00000.0077405
1619749.1085192975102.45726476670119851.5657840642317633.624557711019851.5657840642602019-12-31 00:00:00.00000.00518794378321363

In this example the first payment date is set to NULL and the previous payment date is set to '2014-11-15' so that the first payment date will be calculated using the previous payment date.

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               0,                        --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               '2014-11-15',             --@PrevPayDate
                               NULL,                     --@StartDate
                               NULL,                     --@FirstPayDate
                               '2018-01-01',             
                                         --@GracePeriodStartDate
                               '2019-01-01',             --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following result.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
116774.2311845741890.37518664.606184574301890.375283225.768815426301890.37522015-02-28 00:00:00.00000.00630125
216870.0725196961806.4847599469918676.557279643303696.859759947266355.69629573285032.25357537352015-05-31 00:00:00.00000.00637825
316968.45890122051719.3260195889418687.7849208094305416.185779536249387.237394509268075.02231531982015-08-31 00:00:00.00000.006455
417069.36269589981628.9974346609418698.3601305607307045.183214197232317.87469861251016.23482917112015-11-30 00:00:00.00000.006532
517172.85540668941535.3888338831118708.2442405725308580.57204808215145.01929192233853.263532493142016-02-29 00:00:00.00000.006609
617278.97556927461438.4595989857818717.4351682604310019.031647066197866.043722646216583.478890906172016-05-31 00:00:00.00000.006686
717387.76279771391338.1680536962518725.9308514101311357.199700762180478.280924932199204.211776342202016-08-31 00:00:00.00000.006763
817499.25780711831234.4714415265318733.7292486449312591.671142288162979.023117813181712.752366458232016-11-30 00:00:00.00000.00684
917613.50243699491127.3259029059218740.8283399008313718.997045194145365.520680819164106.349020719262017-02-28 00:00:00.00000.006917
1017730.52410776851016.7227930218118747.2469007903314735.719838216127634.99657305146382.24347384292017-05-31 00:00:00.00000.00699425
1117850.4024416384902.5389695171818752.9414111556315638.258807733109784.594131412128537.535542567322017-08-31 00:00:00.00000.00707125
1217973.1517169457784.79517114839618757.9468880941316423.05397888291811.442414466110569.38930256352017-11-30 00:00:00.00000.0071485
1318088.5956109075689.38916822962121350.3289956606317112.44314711173722.846803558592500.8315826956492019-01-31 00:00:00.0002572.34421652350.0355264365636325
1418222.3094069344559.26151585179518781.5709227862317671.70466296355500.537396624174282.1083194103522019-04-30 00:00:00.00000.007586
1518359.1291533193425.3144932046818784.443646524318097.01915616837141.408243304855925.8518898288552019-07-31 00:00:00.00000.00766325
1618499.1079491124287.49307050730118786.6010196197318384.51222667518642.300294192437428.9013138121582019-10-31 00:00:00.00000.0077405
1718642.300294192496.71520591605718739.0155001084318481.227432591018739.0155001084602019-12-31 00:00:00.00000.00518794378321363

In this example the grace period and the previous payment date are eliminated and a start date has been added.

SELECT *
FROM wct.ConstantCashFlowFR(   300000,                   --@OutstandingAmount
                               0,                        --@LastPrinPayAmount
                               3,                        --@PaymentFrequency
                               '2019-12-15',             --@MaturityDate
                               '2014-12-15',             --@ReferenceDate
                               '2014-11-15',             --@PrevPayDate
                               NULL,                     --@StartDate
                               '2014-10-15',             --@FirstPayDate
                               NULL,                     
                                         --@GracePeriodStartDate
                               NULL,                     --@GracePeriodEndDate,
                               'SELECT * FROM #fwdrates' --@FutureRates
                           );

This produces the following result.

PeriodPrincipalPaymentInterestPaymentCashFlowOutstandingExposureCapitalAmountInDebtTotalExposureNumberOfMonthPaymentDateGraceInterestInterestRate
000030000030000030000002014-12-31 00:00:00.00000
113406.26268769871890.37515296.6376876987301890.375286593.737312301301890.37522015-02-28 00:00:00.00000.00630125
213480.71946838091827.9665050121915308.6859733931303718.341505012273113.01784392288421.70381731452015-05-31 00:00:00.00000.00637825
313557.19627268851762.9445301825115320.1408028711305481.286035195259555.821571232274875.96237410382015-08-31 00:00:00.00000.006455
413635.65631375311695.4186265032915331.0749402563307176.704661698245920.165257479261251.240197735112015-11-30 00:00:00.00000.006532
513716.16286333711625.2863721866815341.4492355238308801.991033885232204.002394142247545.451629666142016-02-29 00:00:00.00000.006609
613798.74589726251552.5159600072315351.2618572698310354.506993892218405.256496879233756.518354149172016-05-31 00:00:00.00000.006686
713883.43623940451477.0747496883915360.5109890929311831.58174358204521.820257475219882.331246568202016-08-31 00:00:00.00000.006763
813970.26557937511398.9292505611315369.1948299363313230.510994141190551.5546781205920.749508036232016-11-30 00:00:00.00000.00684
914059.2664907291318.0451037084115377.3115944374314548.55609785176492.288187371191869.599781808262017-02-28 00:00:00.00000.006917
1014150.4528362241234.4311866545215384.8840228785315782.987284504162341.835351147177726.719374025292017-05-31 00:00:00.00000.00699425
1114243.90164649351147.959703226815391.8613497203316930.946987731148097.933704653163489.795054373322017-08-31 00:00:00.00000.00707125
1214339.60906049781058.6780790877115398.2871395855317989.625066819133758.324644155149156.611783741352017-11-30 00:00:00.00000.0071485
1314437.6473079351966.47077471634415404.1180826515318956.095841535119320.67733622134724.795418872382018-02-28 00:00:00.00000.0072255
1414538.0212582812871.36907641708215409.3903346983319827.464917952104782.656077939120192.046412637412018-05-31 00:00:00.00000.00730275
1514640.7872748072773.2960018551915414.0832766624320600.76091980790141.8688031317105555.952079794442018-08-31 00:00:00.00000.00738
1614745.9847868253672.21045113215415418.1952379574321272.97137093975395.884016306590814.0792542639472018-11-30 00:00:00.00000.00745725
1714853.6542790982568.07028812086115421.7245672191321841.0416590660542.229737208275963.9543044273502019-02-28 00:00:00.00000.0075345
1814963.8373156011460.83231720219515424.6696328033322301.87397626345578.392421607161003.0620544104532019-05-31 00:00:00.00000.00761175
1915076.5765639763350.45225932973715427.0288233061322652.32623559230501.815857630845928.8446809369562019-08-31 00:00:00.00000.007689
2015191.9158206942236.88472740432515428.8005480985322889.21096299715309.900036936630738.7005850351592019-11-30 00:00:00.00000.00776625
2115309.900036936639.662075750242715349.5621126869322928.873038747015349.5621126869602019-12-31 00:00:00.00000.00259061624534151

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

CONSTANTPRINCIPALRATE - Schedule with no fixed maturity where a fixed percentage 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