Correct from frederic34

This commit is contained in:
aspangaro 2015-03-22 20:57:41 +01:00
parent ad0f1aae6b
commit c4d852ffd7
6 changed files with 65 additions and 54 deletions

View File

@ -20,6 +20,7 @@ ErrorLoanInterest=<font color=red>Annual interest</font> has to be numeric and g
# Calc # Calc
Totalsforyear=Totals for year Totalsforyear=Totals for year
MonthlyPayment=Monthly Payment MonthlyPayment=Monthly Payment
LoanCalcDesc=This <b>mortgage calculator</b> can be used to figure out monthly payments of a home mortgage loan, based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate.<br> This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken into consideration are the town property taxes, and their effect on the total monthly mortgage payment.<br>
# Admin # Admin
ConfigLoan=Configuration of the module loan ConfigLoan=Configuration of the module loan
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default

View File

@ -121,10 +121,7 @@ if (! empty($errors)) {
llxHeader(); llxHeader();
echo "<font size='-1' color='#000000'>This <b>mortgage calculator</b> can be used to figure out monthly payments of a home mortgage loan, print $langs->trans('LoanCalcDesc');
based on the home's sale price, the term of the loan desired, buyer's down payment percentage, and the loan's interest rate.
This calculator factors in PMI (Private Mortgage Insurance) for loans where less than 20% is put as a down payment. Also taken
into consideration are the town property taxes, and their effect on the total monthly mortgage payment.<br></font>";
print '<form method="GET" name="information" action="'.$_SERVER['PHP_SELF'].'">'; print '<form method="GET" name="information" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="form_complete" value="1">'; print '<input type="hidden" name="form_complete" value="1">';
@ -190,7 +187,7 @@ if ($form_complete && $monthly_payment)
print '<td align="right">Monthly Payment:</td>'; print '<td align="right">Monthly Payment:</td>';
print '<td><b>' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b><br><font>(Principal &amp; Interest ONLY)</font></td>'; print '<td><b>' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b><br><font>(Principal &amp; Interest ONLY)</font></td>';
print '</tr>'; print '</tr>';
if ($down_percent < 20) if ($down_percent < 20)
{ {
$pmi_per_month = 55 * ($financing_price / 100000); $pmi_per_month = 55 * ($financing_price / 100000);
@ -216,11 +213,11 @@ if ($form_complete && $monthly_payment)
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print '<td>'; print '<td>';
print '<br>'; print '<br>';
$assessed_price = ($sale_price * .85); $assessed_price = ($sale_price * .85);
$residential_yearly_tax = ($assessed_price / 1000) * 14; $residential_yearly_tax = ($assessed_price / 1000) * 14;
$residential_monthly_tax = $residential_yearly_tax / 12; $residential_monthly_tax = $residential_yearly_tax / 12;
if ($pmi_per_month) if ($pmi_per_month)
{ {
$pmi_text = "PMI and "; $pmi_text = "PMI and ";
@ -304,8 +301,8 @@ if ($form_complete && $show_progress) {
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
// Set some base variables // Set some base variables
$principal = $financing_price; $principal = $financing_price;
$current_month = 1; $current_month = 1;
@ -315,11 +312,11 @@ if ($form_complete && $show_progress) {
$power = -($month_term); $power = -($month_term);
$denom = pow((1 + $monthly_interest_rate), $power); $denom = pow((1 + $monthly_interest_rate), $power);
$monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom)); $monthly_payment = $principal * ($monthly_interest_rate / (1 - $denom));
print "<br><br><a name=\"amortization\"></a>Amortization For Monthly Payment: <b>" . number_format($monthly_payment, "2", ".", ",") . "</b> over " . $year_term . " years<br>\n"); print "<br><br><a name=\"amortization\"></a>Amortization For Monthly Payment: <b>" . number_format($monthly_payment, "2", ".", ",") . "</b> over " . $year_term . " years<br>\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// This LEGEND will get reprinted every 12 months // This LEGEND will get reprinted every 12 months
$legend = '<tr class="liste_titre">'; $legend = '<tr class="liste_titre">';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Month") . '</td>'; $legend.= '<td class="liste_titre" align="center">' . $langs->trans("Month") . '</td>';
@ -327,7 +324,7 @@ if ($form_complete && $show_progress) {
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Capital") . '</td>'; $legend.= '<td class="liste_titre" align="center">' . $langs->trans("Capital") . '</td>';
$legend.= '<td class="liste_titre" align="center">' . $langs->trans("Position") . '</td>'; $legend.= '<td class="liste_titre" align="center">' . $langs->trans("Position") . '</td>';
$legend.= '</tr>'; $legend.= '</tr>';
print $legend; print $legend;
// Loop through and get the current month's payments for // Loop through and get the current month's payments for
@ -348,14 +345,14 @@ if ($form_complete && $show_progress) {
print '<td align="right">' . number_format($principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>'; print '<td align="right">' . number_format($principal_paid, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
print '<td align="right">' . number_format($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>'; print '<td align="right">' . number_format($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
print '</tr>'; print '</tr>';
($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE; ($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE;
if ($show_legend) { if ($show_legend) {
print '<tr>'; print '<tr>';
print '<td colspan="4"><b>' . $langs->trans("Totalsforyear") . ' ' . $current_year . '</td>'; print '<td colspan="4"><b>' . $langs->trans("Totalsforyear") . ' ' . $current_year . '</td>';
print '</tr>'; print '</tr>';
$total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid; $total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid;
print '<tr>'; print '<tr>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -369,11 +366,11 @@ if ($form_complete && $show_progress) {
print '<tr>'; print '<tr>';
print '<td colspan="4">&nbsp;<br></td>'; print '<td colspan="4">&nbsp;<br></td>';
print '</tr>'; print '</tr>';
$current_year++; $current_year++;
$this_year_interest_paid = 0; $this_year_interest_paid = 0;
$this_year_principal_paid = 0; $this_year_principal_paid = 0;
if (($current_month + 6) < $month_term) if (($current_month + 6) < $month_term)
{ {
echo $legend; echo $legend;

View File

@ -69,7 +69,7 @@ class Loan extends CommonObject
* Load object in memory from database * Load object in memory from database
* *
* @param int $id id object * @param int $id id object
* @return void * @return int <0 error , >=0 no error
*/ */
function fetch($id) function fetch($id)
{ {
@ -146,8 +146,8 @@ class Loan extends CommonObject
if (($conf->accounting->enabled) && empty($this->account_capital) && empty($this->account_insurance) && empty($this->account_interest)) if (($conf->accounting->enabled) && empty($this->account_capital) && empty($this->account_insurance) && empty($this->account_interest))
{ {
$this->error="ErrorAccountingParameter"; $this->error="ErrorAccountingParameter";
return -2; return -2;
} }
$this->db->begin(); $this->db->begin();
@ -304,8 +304,12 @@ class Loan extends CommonObject
$sql.= " paid = 1"; $sql.= " paid = 1";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$return = $this->db->query($sql); $return = $this->db->query($sql);
if ($return) return 1; if ($return) {
else return -1; return 1;
} else {
$this->error=$this->db->lasterror();
return -1;
}
} }
/** /**
@ -423,7 +427,8 @@ class Loan extends CommonObject
} }
else else
{ {
return -1; $this->error=$this->db->lasterror();
return -1;
} }
} }
@ -464,12 +469,19 @@ class Loan extends CommonObject
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
if (empty($obj->fk_user_modif)) $obj->tms = ""; if (empty($obj->fk_user_modif)) $obj->tms = "";
$this->date_modification = $this->db->jdate($obj->tms); $this->date_modification = $this->db->jdate($obj->tms);
return 1;
}
else
{
return 0;
} }
$this->db->free($result); $this->db->free($result);
} }
else else
{ {
dol_print_error($this->db); $this->error=$this->db->lasterror();
return -1;
} }
} }
} }

View File

@ -50,7 +50,8 @@ $search_label=GETPOST('search_label','alpha');
$search_amount=GETPOST('search_amount','alpha'); $search_amount=GETPOST('search_amount','alpha');
$filtre=GETPOST("filtre"); $filtre=GETPOST("filtre");
if (GETPOST("button_removefilter")) // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{ {
$search_ref=""; $search_ref="";
$search_label=""; $search_label="";
@ -112,11 +113,11 @@ if ($resql)
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var = !$var; $var = !$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
@ -135,7 +136,7 @@ if ($resql)
print '<td align="right" class="nowrap">'.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'</a></td>'; print '<td align="right" class="nowrap">'.$loan_static->LibStatut($obj->paid,5,$obj->alreadypayed).'</a></td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
@ -147,6 +148,6 @@ else
{ {
dol_print_error($db); dol_print_error($db);
} }
$db->close();
llxFooter(); llxFooter();
$db->close();

View File

@ -46,20 +46,25 @@ $result = restrictedArea($user, 'loan', $id, '','');
$help_url='EN:Module_Loan|FR:Module_Emprunt'; $help_url='EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$langs->trans("Loan"),$help_url); llxHeader("",$langs->trans("Loan"),$help_url);
$loan = new Loan($db); if ($id > 0) {
$loan->fetch($id); $loan = new Loan($db);
$loan->info($id); $loan->fetch($id);
$loan->info($id);
$head = loan_prepare_head($loan); $head = loan_prepare_head($loan);
dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill');
print '<table width="100%"><tr><td>';
dol_print_object_info($loan);
print '</td></tr></table>';
print '<table width="100%"><tr><td>'; print '</div>';
dol_print_object_info($loan); }
print '</td></tr></table>'; else
{
print '</div>'; // $id ?
}
llxFooter(); llxFooter();

View File

@ -133,7 +133,6 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment');
if ($action == 'delete') if ($action == 'delete')
{ {
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
} }
/* /*
@ -142,8 +141,7 @@ if ($action == 'delete')
if ($action == 'valide') if ($action == 'valide')
{ {
$facid = $_GET['facid']; $facid = $_GET['facid'];
print $form->formconfirm('card.php?id='.$payment->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); print $form->formconfirm('card.php?id='.$payment->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
} }
@ -283,18 +281,15 @@ if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
} }
*/ */
if ($_GET['action'] == '') if (empty($action) && ! empty($user->rights->loan->delete))
{ {
if ($user->rights->loan->delete) if (! $disable_delete)
{ {
if (! $disable_delete) print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
{ }
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>'; else
} {
else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
}
} }
} }