Jump to content

aarontbarksdale

Members
  • Posts

    75
  • Joined

  • Last visited

Everything posted by aarontbarksdale

  1. Yes, interest begins accruing the DAY after they're due up until they pay. So if a person is due on the 1st and pay on the 10th, there will be 9 days of interest calculated, then that gets applied to the interest line $p = 0.08;$interest = $balance_due * ($p/365) * $days late; // 9 days late, balance_due is 500 should = $0.99 So, I just need to figure out a $dayslate calculation, I've tried a few things, but they didn't work.
  2. If you notice, for some reason, the payment made on 5.02.2010 is on there twice...only time that happens...any idea. UPDATE:It's not a code issue, there's actually 2 payments in the DB for that date...never mind THAT "error"
  3. Okay...so there's only ONE thing missing from everything...Days Late. The $dayslate variable is IMPORTANT because the interest is calculated on a daily basis. The interest in this case is 8%. So, I added to the interest line you have (.08/365)...however I need to add "* $dayslate" to the rest of that calculation for accurate reporting. Here's the output:Here's the code (with my tweaks): $payments = array();$report_lines = array();$date_due = 15; // payments are due on the 10th of each month. you can set this variable however you need to$amt_due = $row['supportamount']; // 500 is due each month$date_format = 'm.j.Y'; // see PHP's date function http://www.php.net/manual/en/function.date.php while ($row2 = mysql_fetch_assoc($data2)) { // convert the date to a timestamp $row2['pmt_date'] = strtotime($row2['pmt_date']); //echo 'found a payment paid on ' . date($date_format, $row2['pmt_date']) . '<br>'; $report_lines[] = $row2;} $monthStart = strtotime($row['datestart']);$today = strtotime('now'); while($monthStart <= $today) { $date_info = getdate($monthStart); // http://www.php.net/manual/en/function.getdate.php $due = mktime(0, 0, 0, $date_info['mon'], $date_due, $date_info['year']); // http://www.php.net/manual/en/function.mktime.php //echo 'adding payment due on ' . date($date_format, $due) . ' for ' . $amt_due . '<br>'; $report_lines[] = array( 'payment_due' => true, // this is a payment due line, not a payment line 'amount' => $amt_due, // same amount due each month 'pmt_date' => $due // due date for current month ); $monthStart = strtotime('+1 month', $monthStart);} // sort the report lines by datefunction cmp_pmt_date($x, $y){ return $x['pmt_date'] - $y['pmt_date'];}usort($report_lines, 'cmp_pmt_date'); $interest_owed = 0;$balance_due = 0; foreach ($report_lines as $line){ if (isset($line['payment_due'])) { // payment due line, add to balance due and calculate interest // in this section we only add to interest and balance due $interest = $balance_due * (.08/365); // * $dayslate; // interest for this month, on the previous balance $interest_owed += $interest; // add interest for this month to total interest owed $balance_due += $line['amount']; // add interest for this month and this month's amount due to total balance dueecho '<tr><td>'. date($date_format, $line['pmt_date']) . ' </td>';echo '<td>'. "$". number_format($line['amount'], 2, '.',',') .' </td>';echo '<td>$0.00 </td>'; echo '<td>'. "$". number_format($interest, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appint, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($balance_due, 2, '.',',') . ' </td></tr>'; //echo 'found a payment due on ' . date($date_format, $line['pmt_date']) . ' for ' . $line['amount'] . ', need to calculate interest and balance<br>'; //echo 'interest for this month is ' . $interest . ', total balance due is ' . $balance_due . '<br>'; } else { // payment line, apply payment amount to interest and principal // in this section we only subtract from interest and balance due if ($line['pmt_amt'] > $interest_owed) // they paid more than the interest owed { // they paid off interest $amt = $line['pmt_amt'] - $interest_owed; // subtract the interest from what they paid; $amt can then be applied to the principal $interest_owed = 0; // they don't owe interest any more } else // they owe more interest than what they paid { $interest_owed -= $line['pmt_amt']; // reduce what they paid from the interest owed $amt = 0; // nothing gets reduced from principal } $balance_due -= $line['pmt_amt']; // reduce the balance due by what they paid echo '<tr><td>'. date($date_format, $line['pmt_date']) .'</td>';echo '<td>$0.00</td>';echo '<td>'. "$". number_format($line['pmt_amt'], 2, '.',',') . '</td>'; echo '<td>'. "$". number_format($interest_owed , 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($interest , 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($amt, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($balance_due, 2, '.',',') . ' </td></tr>'; //echo 'found a payment made on ' . date($date_format, $line['pmt_date']) . ' for ' . $line['pmt_amt'] . '. total interest owed is now ' . $interest_owed . ', balance due is now ' . $balance_due . '<br>'; }}
  4. Why does it launch the dates well past today's date? Current Code: while ($row2 = mysql_fetch_assoc($data2)) { $payments[] = $row2;}$pmtdate = $payments['pmt_date'];$monthStart = strtotime($row['datestart']);$today = strtotime('now');while($monthStart <= $today) { $payments[] = array( 'payment_due' => true, 'amount' => $payments['pmt_amt'],'pmt_date' => $payments['pmt_date']); $monthStart = strtotime('+1 month', $monthStart);} function cmp_pmt_date($a, ${if ($a >= $ {return strtotime($a['pmt_date']) - strtotime($b['pmt_date']);} else {return strtotime($b['pmt_date']) - strtotime($b['pmt_date']);}} usort($payments, 'cmp_pmt_date'); foreach ($payments as $item) { if (isset($item['pmt_amt'])) { // this is a payment due line // add to balance due, calculate interest, etcif (strtotime($item['pmt_date']) < $monthStart) { // this is a payment line echo '<tr><td>'. date("m.d.Y", $monthStart) . ' </td>';echo '<td>'. "$". number_format($row['supportamount'], 2, '.',',') .' </td>';echo '<td>$0.00 </td>'; $totint = $int + $newint;echo '<td>'. "$". number_format($totint, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appint, 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>'; $bal = $bal - $item['pmt_amt'];echo '<td>'. "$". number_format($bal, 2, '.',',') . ' </td>';echo '<td>'. $dayslate . '</td></tr>'; $bal = $lastbal;$newint = $totint;} else {echo '<tr><td>'. date("m.d.Y", strtotime($item['pmt_date'])) .'</td>';echo '<td>$0.00</td>';echo '<td>'. "$". number_format($item['pmt_amt'], 2, '.',',') . '</td>'; echo '<td>'. "$". number_format($intacc , 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appint , 2, '.',',') . ' </td>';echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>';$bal = $bal - $item['pmt_amt'];echo '<td>'. "$". number_format($bal, 2, '.',',') . ' </td>';echo '<td>'. $dayslate . '</td></tr>';$dayslateP = ($monthStart - strtotime($item['pmt_date']))/(24*60*60); } } $newint = $totint; $monthStart = strtotime("+1 month", $monthStart);} Output:I specified that IF $monthStart <= $today...that should start it from the first due date and then NOT exceed today's date...which allows for the flexibility of an increasing date. I want to limit the entry into the database as much as possible, that way I can have everything created and calculated dynamically, and should things change...I want the changes quickly reflected.
  5. What I don't understand is how does comparing the payment dates determine's whether the payment date comes before the current $monthStart...
  6. I had a while loop stop, it's $today = strtotime('now'); which kept it from passing today's date. Now, it doesn't increase the payment due lines and then inserts the payments after it runs through several times (without increasing the date).
  7. Okay, so I did that...and the output went haywire. $payments = array();while ($row2 = mysql_fetch_assoc($data2)) { $payments[] = $row2;}$pmtdate = $payments['pmt_date'];$monthStart = strtotime($row['datestart']);$today = strtotime('now'); while($monthStart <= $today) { $payments[] = array( 'payment_due' => true, 'amount' => $payments['pmt_amt'], 'pmt_date' => $payments['pmt_date']); $monthStart = strtotime('+1 month', $monthStart); $monthEnd = strtotime('+1 month', $monthStart);} function cmp_pmt_date($a, ${ return strtotime($a['pmt_date']) - strtotime($b['pmt_date']);} usort($payments, 'cmp_pmt_date'); foreach ($payments as $item){ if (isset($item['pmt_amt'])) // this is a payment due line { // add to balance due, calculate interest, etc echo '<tr><td>'. date("m.d.Y", $monthStart) . ' </td>'; echo '<td>'. "$". number_format($row['supportamount'], 2, '.',',') .' </td>'; echo '<td>$0.00 </td>'; $totint = $int + $newint; echo '<td>'. "$". number_format($totint, 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appint, 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>'; $bal = $bal - $payments['pmt_amt']; echo '<td>'. "$". number_format($bal, 2, '.',',') . ' </td></tr>'; $bal = $lastbal; $newint = $totint; } else { // this is a payment line echo '<tr><td>'. date("m.d.Y", strtotime($payment['pmt_date'])) .'</td>'; echo '<td>$0.00</td>'; echo '<td>'. "$". number_format($payment['pmt_amt'], 2, '.',',') . '</td>'; echo '<td>'. "$". number_format($intacc , 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appint , 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>'; $bal = $bal - $payments['pmt_amt']; echo '<td>'. "$". number_format($bal, 2, '.',',') . ' </td></td>'; $dayslateP = ($monthEnd - strtotime($payment['pmt_date']))/(24*60*60); } $newint = $totint; $monthStart = strtotime('+1 month', $monthStart); $monthEnd = strtotime('+1 month', $monthStart);} And here's the output:
  8. If I add: $monthStart = strtotime('+1 month', $monthStart); $monthEnd = strtotime('+1 month', $monthStart); That's outside the main while loop, will that mess up my numbers inside the main loop?
  9. I'm getting an error: Line 68 is:[/b]while($monthStart <= $today) { $payments[] = array( 'payment_due' => true, //LINE 68'amount' => $payments['pmt_amt'],'pmt_date' => $payments['pmt_date']); }
  10. Yeah, I was making it SOOO much more complicated...
  11. Alright, I'm thoroughly confused about the "usort" function to compare dates. I'm sorry, I've tried, I think my brain is full and cannot allow for more information. Please help me understand it. Thanks
  12. And should all of the code snippet you provided go in the <head> tag or within the <body>? I'm assuming <head> and then the output for the table within the <body> Are my assumptions correct?
  13. usort($payments, 'function_to_compare_dates'); foreach ($payments as $item){ if (isset($item['payment_due'])) // this is a payment due line { // add to balance due, calculate interest, etc ... } else // this is a payment line { // apply payment to interest/principal, etc ... }} The 'function_to_compare_dates' would be the $dayslate = $monthEnd - $monthStart;?Also, in the IF...ELSE statement is where the lines for all calculations for what goes into the table...and where are the table outputs...within the IF...ELSE statement as well?
  14. Send me a message of what you would charge to do this, because you have flat out lost me. I've got an array already that retrieves everything from the payments table. $payments = array();while ($row2 = mysql_fetch_assoc($data2)) { $payments[] = $row2;}... // This is in the main body of the page$payment_found = false;foreach ($payments as $payment) { if (strtotime($payment['pmt_date']) >= $monthStart && strtotime($payment['pmt_date']) <= $monthEnd) { $payment_found = true; echo '<tr><td>'. date("m.d.Y", strtotime($payment['pmt_date'])) .'</td>'; echo '<td>$0.00</td>'; echo '<td>'. "$". number_format($payment['pmt_amt'], 2, '.',',') . '</td>'; echo '<td>'. "$". number_format($intacc , 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appint , 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($appprinc, 2, '.',',') . ' </td>'; echo '<td>'. "$". number_format($bal, 2, '.',',') . ' </td></td>'; } Is this something that you are talking about...of course it only pulls two pieces of the db information from the 'payments' table...the rest are eventual calculations.
  15. Okay...so, I will work on reconfiguring my code, but here's a road map (table.row)1. First line will be first due date, starting with user entered "Start Date" - clients.datestart (Start date will generate a new due date exactly 1 month from it, if it's due on the 10th, then the Due Date will be on the 10th of the following month)2. IF payment is made before next due date, enter line with payments. - payments.pmt_date, payments.pmt_amt a. Determine the interest accrued between Start Date or Due Date and the Payment Date (Payment due on 10th, and payment made on 20th, 9 days of interest will be accrued [interest calculated by (%/365)*Days Late*amt_due]) b.(1) IF payment is GREATER THAN Interest accrued (usually will be) then "Applied to Interest" will equal Interest Accrued. (2) IF payment is LESS THAN interest accrued then Interest Accrued LESS Payment amount. c. IF b(1) is TRUE, then Applied to Principle will equal Payment Amount LESS Interest Accrued3. Any remaining balance will be added into the interest accrued on the following line (whether another payment or another due date)4. If no other payments were made within the same month, then next due date line is automatically generated with interest calculation applied for UNPAID balance from previous line's (due date or payment) remaining balance, if any.5. Code will AUTOMATICALLY stop when $monthStart <= today();Hope that road map is as simple as it appears to me. Below is my db structure (table.row, if just .row then it applies to above table) ---- Table structure for table `clients`-- CREATE TABLE `clients` ( `client_id` int(10) NOT NULL auto_increment, `userid` varchar(20) NOT NULL, `cp_firstname` varchar(15) NOT NULL, `cp_lastname` varchar(20) NOT NULL, `cp_address` varchar(50) NOT NULL, `cp_city` varchar(25) NOT NULL, `cp_state` varchar(2) NOT NULL, `cp_zip` varchar(5) NOT NULL, `cp_zip4` varchar(4) NOT NULL, `cp_homeph` varchar(12) NOT NULL, `cp_workph` varchar(12) NOT NULL, `cp_cellph` varchar(12) NOT NULL, `cp_email` varchar(50) NOT NULL, `alt_firstname` varchar(15) NOT NULL, `alt_lastname` varchar(20) NOT NULL, `alt_homeph` varchar(12) NOT NULL, `alt_cellph` varchar(12) NOT NULL, `non_firstname` varchar(15) NOT NULL, `non_lastname` varchar(20) NOT NULL, `non_home` varchar(50) NOT NULL, `non_city` varchar(20) NOT NULL, `non_state` varchar(2) NOT NULL, `non_zip` varchar(5) NOT NULL, `non_zip4` varchar(4) NOT NULL, `non_homeph` varchar(12) NOT NULL, `non_workph` varchar(12) NOT NULL, `non_cellph` varchar(12) NOT NULL, `non_email` varchar(50) NOT NULL, `placeofemployment` varchar(50) NOT NULL, `datestart` date NOT NULL, `supportamount` varchar(10) NOT NULL, `judgmentdate` date NOT NULL, `judge` varchar(50) NOT NULL, PRIMARY KEY (`client_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=149 ; ---- Table structure for table `messages` !!!NOT USED YET!!!-- CREATE TABLE `messages` ( `msg_id` varchar(3) NOT NULL, `userid` varchar(20) NOT NULL, `message` longtext NOT NULL, PRIMARY KEY (`msg_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8; ---- Table structure for table `payments`-- CREATE TABLE `payments` ( `pay_id` int(5) NOT NULL auto_increment, `client_id` varchar(10) NOT NULL, `userid` varchar(20) NOT NULL, `pmt_date` date NOT NULL, `pmt_amt` varchar(5) NOT NULL, PRIMARY KEY (`pay_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=64 ; CREATE TABLE `users` ( `userid` mediumint(10) unsigned NOT NULL auto_increment, `entityid` varchar(10) character set utf8 collate utf8_bin NOT NULL, `first_name` varchar(30) NOT NULL, `last_name` varchar(30) NOT NULL, `username` varchar(25) NOT NULL, `password` varchar(25) NOT NULL, `email` varchar(40) default NULL, `reg_date` datetime NOT NULL default '0000-00-00 00:00:00', `superuser` varchar(1) default 'N', PRIMARY KEY (`userid`), UNIQUE KEY `entityid` (`entityid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
  16. OK....So no takers....I will be reevaluating my code...Any suggestions on where I should start? Should I move 100% of the calculations within each if statement to prevent conflicts of variables...and unset variables at the end of each if statement?
  17. Okay...so, this shows how much I DON'T know...1. No, $monthEnd is not unset ANYWHERE, there's no argument there.2. As for all of the isset($pmtamt) checks, that's because I was trying to determine if the previous line was a payment line, if not, the calculations would be different3. The reason for the two lines that it shows in the one loop is because I was trying to make sure that the Date Due line printed in the same month when a payment is due, otherwise it doesn't print at all, doesn't include the amount that is due for that month and the numbers don't add up.4. Thanks for the tip on the number_format5. It first part of the snippet you posted determine's if this is the first month and how to calculate the difference between monthStart and monthEnd...but I see the issue because the very next part changes the $interval. So....crap...aparently I don't understand the isset & empty functions do. That's what I've been trying to do, simplify my code...I'm very n00b with this, and I'm learning as I go...I've pleaded for help, I'm willing to pay, but NO ONE will help me out by showing me what I need to do and explaining to me WHAT and HOW the code corrections work. :-( Any takers???
  18. As you can see, there appears to be a redundancy whenever there are multiple payments within the same month. I know HOW this is happening, but no matter where I place my code, it doesn't rectify the situation. There are TWO "IF" statements within the "Payment = true" IF statement, one displays the Due date IF the payment is made after the next $monthStart (if I leave it out, it doesn't add the next Due date), in the above example, it would have 3.15.2010, but wouldn't have 4.15.2010. then when it loops back around to add the next payment, it's adding another Due Date line...still just not sure how to fix it... ANY feedback will help.
  19. Let's try this again...here's the code: while($monthStart <= $today) {$p = .08; //Percentage for MISSISSIPPI if (empty($monthEnd)){ $interval = $monthStart - $monthEnd; } else { $interval = $monthEnd - $monthStart; } if (isset($pmtamt)){ $interval = $pmtdate - $monthStart; } else { $interval = $monthEnd - $monthStart; }//If first line of report, there won't be a $monthEnd if ($monthEnd <= $row['datestart']) { $dayslate = 0; } else { $dayslate = ($interval/(24*60*60))*1; } $intacc = $dayslate * $bal * ($p/365); //Calculates Interest Accrued if (empty($newint)) { $newint = 0; } $totint = $intacc + $newint; $payment_found = false; foreach ($payments as $payment) { if (strtotime($payment['pmt_date']) >= $monthStart && strtotime($payment['pmt_date']) < $monthEnd) { $payment_found = true;////This segment displays the month's due date line if payment is made within that month // if (strtotime($payment['pmt_date']) > $monthStart) { echo '<tr><td>'. date("m.d.Y", $monthStart) . '</td>'; echo '<td>'. "$"; $due = $amtdue + $bal; echo $english_format_number = number_format($row['supportamount'], 2, '.', ',') .'</td>'; echo '<td>$0.00</td>'; echo '<td>'. "$"; if (empty($newint)) { $newint = 0; } $totint = 0; if(isset($monthEnd)){ $totint = $intacc + $newint; } echo $english_format_number = number_format($totint, 2, '.',',') . '</td>'; echo '<td>'. "$"; if (isset($pmtamt)){ if ($pmtamt > $totint) { $appint = $totint; //Calculates how much of payment is applied to Interest } else { $appint = $totint - $pmtamt; } } else { $appint = 0; } echo $english_format_number = number_format($appint, 2, '.',',') . '</td>'; echo '<td>'. "$"; if (isset($pmtamt)){ if ($pmtamt > $totint) { $appprinc = $pmtamt - $appint; } else { $appprinc = 0; } } echo $english_format_number = number_format($appprinc, 2, '.',',') . '</td>'; echo '<td>'. "$"; if (isset($bal)){ if (isset($pmtamt)){ $bal = ($row['supportamount'] + $bal)- $appprinc; } else { $bal = $row['supportamount'] + $bal; } } else { $bal = $row['supportamount']; } echo $english_format_number = number_format($bal, 2, '.',',') . '</td></tr>'; $newint = $totint; } //End Segment////This segment displays the Payment Line// $interval = strtotime($payment['pmt_date']) - $monthStart; echo '<tr><td>'. date("m.d.Y", strtotime($payment['pmt_date'])) .'</td>'; echo '<td>'. "$"; if ($pmtdate >= $monthStart && $pmtdate <= $monthEnd){ $due = $bal; } echo $english_format_number = number_format($row['supportamount'], 2, '.',',') . '</td>'; echo '<td>'. "$". $english_format_number = number_format($payment['pmt_amt'], 2, '.',',') . '</td>'; echo '<td>'. "$"; $dayslate = ($interval/(24*60*60)); $intacc = $dayslate * $bal * ($p/365); //Calculates Interest Accrued if (empty($newint)) { $newint = 0; } $totint = $intacc + $newint; echo $english_format_number = number_format($totint , 2, '.',',') . ' </td>'; echo '<td>'. "$"; if ($payment['pmt_amt'] > $totint) { $appint = $totint; //Calculates how much of payment is applied to Interest } else { $appint = $totint - $payment['pmt_amt']; } echo $english_format_number = number_format($appint , 2, '.',',') . ' </td>'; echo '<td>'. "$"; if ($payment['pmt_amt'] > $totint) { $appprinc = $payment['pmt_amt'] - $appint; } else { $appprinc = 0; } echo $english_format_number = number_format($appprinc, 2, '.',',') . ' </td>'; echo '<td>'. "$"; $bal = $bal - $appprinc; echo $english_format_number = number_format($bal, 2, '.',',') . ' </td></td>'; $newint = $totint; $dayslateP = ($monthEnd - strtotime($payment['pmt_date']))/(24*60*60); } //End Payment Line Segment }////This segment is the Due Date Line.// if (!$payment_found) { echo '<tr><td>'. date("m.d.Y", $monthStart) . ' </td>'; if ($appint > 0){ $interval = $dayslateP; $dayslate = $dayslateP; } else { $interval = $dayslate/(60*24*60); } echo '<td>'. "$"; $due = $amtdue + $bal; echo $english_format_number = number_format($row['supportamount'], 2, '.',',') .' </td>'; echo '<td>$0.00 </td>'; echo '<td>'. "$"; $intacc = $dayslate * $bal * ($p/365); //Calculates Interest Accrued if (empty($newint)) { $newint = 0; } if ($appint > 0){ $totint = $intacc; } else { $totint = $intacc + $newint; } echo $english_format_number = number_format($totint, 2, '.',',') . ' </td>'; echo '<td>'. "$"; if (isset($pmtamt)){ if ($pmtamt > $totint) { $appint = $totint; //Calculates how much of payment is applied to Interest } else { $appint = $totint - $pmtamt; } } else { $appint = 0; } echo $english_format_number = number_format($appint, 2, '.',',') . ' </td>'; echo '<td>'. "$"; if ($pmtamt > $totint) { $appprinc = $pmtamt - $appint; } else { $appprinc = 0; } echo $english_format_number = number_format($appprinc, 2, '.',',') . ' </td>'; echo '<td>'. "$"; if (isset($bal)){ if (isset($pmtamt)){ $bal = ($row['supportamount'] + $bal)- $appprinc; } else { $bal = $row['supportamount'] + $bal; } } else { $bal = $row['supportamount']; } echo $english_format_number = number_format($bal, 2, '.',',') . ' </td></tr>'; $newint = $totint; }$monthStart = strtotime('+1 month', $monthStart);$monthEnd = strtotime('+1 month', $monthStart);$amtdue = $due;} Here's part of the output with REAL WORLD Numbers: (I was going to highlight it...but after a few moments, you'll see why the entire image would have been highlighted.
  20. Well...with real life examples...the code messed up royally...will post output later....too tired...but thanks again.
  21. FINISHED!!!! THANK YOU niche AND justsomeguy for all of your help with this! I wish I knew your real names so I can thank you properly! THANK YOU THANK YOU THANK YOU for everything you've done to help me with this. Without your guidance I don't think I could have done it as quickly!
  22. Okay...got the Days Late corrected. Added the following code to the END of the Payment "IF" structure: $dayslateP = ($monthEnd - strtotime($payment['pmt_date']))/(24*60*60); And I added this to the Regular non-payment related IF structure: if ($appint > 0){$interval = $dayslateP;$dayslate = $dayslateP;} else {$interval = $dayslate/(60*24*60);[/size][/font][/color]} WORKS!!! Now to figure out the reason the interest isn't adding correctly...
  23. I think the problem is somewhere here...because this is the code segment that occurrs directly AFTER a payment line. if (!$payment_found) {echo '<tr><td>'. date("m.d.Y", $monthStart) . ' </td>';echo '<td>'. "$";$due = $amtdue + $bal; echo $english_format_number = number_format($row['supportamount'], 2, '.',',') .' </td>';echo '<td>$0.00 </td>'; echo '<td>'. "$";$intacc = $dayslate * $bal * ($p/365); //Calculates Interest Accruedif (empty($newint)) {$newint = 0;}if ($appint = 0){$totint = $intacc + $newint;} else {$totint = $intacc;}//$totint = $intacc + $newint;echo $english_format_number = number_format($totint, 2, '.',',') . ' </td>';echo '<td>'. "$";if (isset($pmtamt)){if ($pmtamt > $totint) {$appint = $totint; //Calculates how much of payment is applied to Interest} else {$appint = $totint - $pmtamt;}} else {$appint = 0;}echo $english_format_number = number_format($appint, 2, '.',',') . ' </td>';echo '<td>'. "$";if ($pmtamt > $totint) {$appprinc = $pmtamt - $appint;} else {$appprinc = 0; }echo $english_format_number = number_format($appprinc, 2, '.',',') . ' </td>';echo '<td>'. "$";if (isset($bal)){if (isset($pmtamt)){$bal = ($row['supportamount'] + $bal)- $appprinc;} else {$bal = $row['supportamount'] + $bal;}} else {$bal = $row['supportamount'];}echo $english_format_number = number_format($bal, 2, '.',',') . ' </td>';echo '<td>'. $dayslate .' </td></tr>';$newint = $totint;
  24. In the due date segment of the code...somewhere I imagine...
  25. Its not a problem with the code...is a calculation problem...its like when you misspell a word...but the word you misspelled is still spelled correctly... if you look at the pic...the day after a payment the days late should be the difference between the end of the month and the pmt date.
×
×
  • Create New...