Jump to content
  • 0

Trouble finding correct syntax in triggers to calculate an amount in a loop


Mary99
 Share

Question

I've been trying to set triggers up to create a payment table for amortized loans.  I'm able to get all the fields to work correctly except updating the principal amount paid each month.  On the insert of a loan table, I'm creating a payment table based on the number of payments, loan loan amount and interest rate passed.  I also pass the initial principal payment although it seems like I should be able to do the necessary calculation in the triggers.   Most of the trigger works as expected buy I can seem to find the correct combination to correctly update the Principal Payment.  I've tried various combinations and keep running into various errors when I try different ways.  Please let me know what I'm doing wrong. 

 

 

Picture5.jpg

pmt table results.jpg

 

Pmt Table.png

Edited by Mary99
Included the wrong table image
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
On 10/27/2022 at 6:51 AM, Mary99 said:

I've been trying to set triggers up to create a payment table for amortized loans.  I'm able to get all the fields to work correctly except updating the principal amount paid each month.  On the insert of a loan table, I'm creating a payment table based on the number of payments, loan loan amount and interest rate passed.  I also pass the initial principal payment although it seems like I should be able to do the necessary calculation in the triggers.   Most of the trigger works as expected buy I can seem to find the correct combination to correctly update the Principal Payment.  I've tried various combinations and keep running into various errors when I try different ways.  Please let me know what I'm doing wrong. 

 

 

Picture5.jpg

pmt table results.jpg

 

Pmt Table.png

It is not very clear to me you expetctation.  From trigger you show it seems work as designed.
It would be useful for us, if you detail here some formula or numeric example that show field relationships.

Link to comment
Share on other sites

  • 0

I was able to get it to work by looping a bit differently.  But now I'm trying to figure out how to adjust the trigger to update the table in the case where the rate, loan term or loan amount is changed.  I'm including an example of the functioning insert trigger and a copy of the payment table that shows the correct insert response.  I'm new to triggers so I'm stumbling on how to now adjust the trigger for updates.  When any of the original amounts (rate, term, loan amt) change, I want to update this table to reflect the schedule based on those new amounts.  Any help is appreciated.

In the table below, you can see where the pmt_principal amount is getting updated correctly (pmt_amount_due - pmt_interest = pmt_principal).  

image.thumb.png.a7abc9693f8f965be0bc2503b4f8c757.png

image.png.f2e7a3980cc014b61e9f27efb484223e.pngimage.png.e09bdcb5883426b96af0fdc306cdd738.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...