SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Calculate Past Due Principal and Past Due Interest Based on Due Dates


Calculate Past Due Principal and Past Due Interest Based on Due Dates

Author
Message
shiva.reddy06
shiva.reddy06
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 29
Hi with respect to my subject, need to calculate

-Calculate Due Amount Principle + Interest after Due Date, this is for 1 installment (if non payment),

--Suppose he ll not pay 2, 3 installments, need to add past Due Amount principle + past Interest with respect to current Month due

Hope i ll get good solutions
Thank You
Shiva Reddy
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90009 Visits: 38942
shiva.reddy06 (7/24/2012)
Hi with respect to my subject, need to calculate

-Calculate Due Amount Principle + Interest after Due Date, this is for 1 installment (if non payment),

--Suppose he ll not pay 2, 3 installments, need to add past Due Amount principle + past Interest with respect to current Month due

Hope i ll get good solutions
Thank You
Shiva Reddy


Not going to happen with what you have provided. There really isn't enough information to provide you with any code.

Please read the first article I reference below in my signature block regarding asking for help. It will walk you through what you need to post and how to get the best possible answers.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63623 Visits: 18570
I think a fair amount more information would be useful for this thread. There are different terms, interest rates, methods of applying and calculating interest, penalties, fees etc that should be factored into the equation.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

shiva.reddy06
shiva.reddy06
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 29
Hi, am new for this forum, so couldn't post properly...

1. This is my table

CREATE TABLE [dbo].[tblWeeklyTransactionSheet](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Period] [float] NOT NULL,
[PayDate] [smalldatetime] NOT NULL,
[Payment] [decimal](12, 2) NOT NULL,
[Current_Balance] [decimal](12, 2) NOT NULL,
[Interest] [decimal](12, 2) NOT NULL,
CONSTRAINT [PK_tblWeeklyTransactionSheet] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

2. this is my Stored Procedure to Shedule Weekly Trsansaction Sheet

ALTER PROCEDURE [dbo].[Sp_SelectWeeklyTransactionSheet]
-- Add the parameters for the stored procedure here

AS
BEGIN
Declare
@Loan decimal(12,2,
@InterestRate FLOAT,
@PeriodInWeeks FLOAT,
@PaymentStartDate SMALLDATETIME,
@Particular varchar(20) ,
@PaidAmount decimal(12,2),
@Payment decimal(12,2),
@Period FLOAT,

@CompoundingPeriod FLOAT,
@CompoundingInterest FLOAT,

/*** CALCULATED LOAN VARIABLES ***/
@CurrentBalance decimal(12,2),
@Interest FLOAT,

/*** Loan TIME VARIABLES ***/
@LoanPaymentEndDate SMALLDATETIME,
@LoanPayDate SMALLDATETIME,
@LoanDueDate SMALLDATETIME ,


/*** USER VARIABLES ***/
SET @InterestRate = @InterestRate/100
SET @CompoundingPeriod = 12
SET @Loan =20,000
SET @PeriodInWeeks = 10
SET @PaymentStartDate = '2012-09-13 00:00:00'
/*** END USER VARIABLES ***/


SET @CompoundingInterest = @InterestRate/@CompoundingPeriod
SET @Payment = @Loan / @PeriodInWeeks


SET @Period = 1
SET @LoanPaymentEndDate = DATEADD(WEEK,@PeriodInWeeks,@PaymentStartDate)
SET @LoanPayDate = @PaymentStartDate
BEGIN

WHILE (@Period < = @PeriodInWeeks)
BEGIN
SET @CurrentBalance = @Payment +@Interest


SET @Interest = 0
SET @LoanDueDate = @LoanPayDate

insert into tblWeeklyTransactionSheet(Period, PayDate,Payment,Current_Balance,Interest)
SELECT
@col_WeeklyID,
@col_ApplicantNumber,
@Period,
@LoanDueDate,
@Payment,
@CurrentBalance,
@Interest,
@PaidAmount

SET @Period = @Period + 1
SET @LoanPayDate = DATEADD(WK,1,@LoanPayDate)
END

END
select col_WeeklyID,col_ApplicantNumber,Period as Installments, PayDate,Payment,PaidAmount,Interest,Current_Balance from tblWeeklyTransactionSheet
END

3. Am getting shedule table, but i need to calculate Due Interest + Due Amount for if non payable based on due date, INITIALLY INTEREST WILL BE 0 (for regular payment),

Thanks
Shiva Reddy
shiva.reddy06
shiva.reddy06
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 29
Hi, am new for this forum, so couldn't post properly...

1. This is my table

CREATE TABLE [dbo].[tblWeeklyTransactionSheet](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Period] [float] NOT NULL,
[PayDate] [smalldatetime] NOT NULL,
[Payment] [decimal](12, 2) NOT NULL,
[Current_Balance] [decimal](12, 2) NOT NULL,
[Interest] [decimal](12, 2) NOT NULL,
[AmountPaid][decimal](12,2) NOT NULL,
CONSTRAINT [PK_tblWeeklyTransactionSheet] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

2. this is my Stored Procedure to Shedule Weekly Trsansaction Sheet

ALTER PROCEDURE [dbo].[Sp_SelectWeeklyTransactionSheet]
-- Add the parameters for the stored procedure here

AS
BEGIN
Declare
@Loan decimal(12,2)
@InterestRate FLOAT,
@PeriodInWeeks FLOAT,
@PaymentStartDate SMALLDATETIME,
@Particular varchar(20) ,
@PaidAmount decimal(12,2),
@Payment decimal(12,2),
@Period FLOAT,
@AmountPaid decimal(12,2) --- This record will fetch from different table

@CompoundingPeriod FLOAT,
@CompoundingInterest FLOAT,

/*** CALCULATED LOAN VARIABLES ***/
@CurrentBalance decimal(12,2),
@Interest FLOAT,

/*** Loan TIME VARIABLES ***/
@LoanPaymentEndDate SMALLDATETIME,
@LoanPayDate SMALLDATETIME,
@LoanDueDate SMALLDATETIME ,


/*** USER VARIABLES ***/
SET @InterestRate = @InterestRate/100
SET @CompoundingPeriod = 12
SET @Loan =20,000
SET @PeriodInWeeks = 10
SET @PaymentStartDate = '2012-09-13 00:00:00'
/*** END USER VARIABLES ***/


SET @CompoundingInterest = @InterestRate/@CompoundingPeriod
SET @Payment = @Loan / @PeriodInWeeks


SET @Period = 1
SET @LoanPaymentEndDate = DATEADD(WEEK,@PeriodInWeeks,@PaymentStartDate)
SET @LoanPayDate = @PaymentStartDate
BEGIN

WHILE (@Period < = @PeriodInWeeks)
BEGIN
SET @CurrentBalance = @Payment +@Interest


SET @Interest = 0
SET @LoanDueDate = @LoanPayDate

insert into tblWeeklyTransactionSheet(Period, PayDate,Payment,Current_Balance,Interest, AmountPaid)
SELECT
@col_WeeklyID,
@col_ApplicantNumber,
@Period,
@LoanDueDate,
@Payment,
@CurrentBalance,
@Interest,
@PaidAmount

SET @Period = @Period + 1
SET @LoanPayDate = DATEADD(WK,1,@LoanPayDate)
END

END
select col_WeeklyID,col_ApplicantNumber,Period as Installments, PayDate,Payment,PaidAmount,Interest,Current_Balance from tblWeeklyTransactionSheet
END

3. Am getting shedule table, but i need to calculate Due Interest + Due Amount for if non payable based on due date, INITIALLY INTEREST WILL BE 0 (for regular payment),

The final Result Will be like below mention Table

Date Amount Interest Amount Paid Amount Balance
8/7/2012 2000 2000 0
15/7/2012 Due 500 0 Due + 500

Thanks
Shiva Reddy :-)
Sean Lange
Sean Lange
SSC Guru
SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)

Group: General Forum Members
Points: 59136 Visits: 17947
OK so you tried to post some code but you missed the mark. The code you posted is full of syntax errors and variables not declared. There are columns referenced in your table that don't exist, etc. It seems you must have tried to simplify this but it just didn't work.

I don't understand what you mean about calculating interest. There are a lot of ways to calculate interest and we still don't know how you are doing it.

The while loop could be greatly simplified to a single insert statement instead of looping but getting this to work is incredibly difficult because none of the ddl supplied matches the insert and such. In short, if you can provide something that is more accurate we can help with the calculations but as it sits it doesn't work. As you provided it, it will not even compile.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90009 Visits: 38942
Something you should do when posting code. Before posing it, create an empty database, run your code there. If it doesn't work, rework it until it does run successfully in an empty database.

You wouldn't give flawed code to your users, don't give it to us either. It just makes it harder for us to help you.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Sean Lange
Sean Lange
SSC Guru
SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)SSC Guru (59K reputation)

Group: General Forum Members
Points: 59136 Visits: 17947
louie_vuittion (2/5/2014)
Not everybody is good at math.


Reported as spam.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search