Correct from frederic34
This commit is contained in:
parent
ad0f1aae6b
commit
c4d852ffd7
@ -20,6 +20,7 @@ ErrorLoanInterest=<font color=red>Annual interest</font> has to be numeric and g
|
||||
# Calc
|
||||
Totalsforyear=Totals for year
|
||||
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
|
||||
ConfigLoan=Configuration of the module loan
|
||||
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default
|
||||
|
||||
@ -121,10 +121,7 @@ if (! empty($errors)) {
|
||||
|
||||
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,
|
||||
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 $langs->trans('LoanCalcDesc');
|
||||
|
||||
print '<form method="GET" name="information" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
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><b>' . number_format($monthly_payment, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</b><br><font>(Principal & Interest ONLY)</font></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
if ($down_percent < 20)
|
||||
{
|
||||
$pmi_per_month = 55 * ($financing_price / 100000);
|
||||
@ -216,11 +213,11 @@ if ($form_complete && $monthly_payment)
|
||||
print '<td align="right"> </td>';
|
||||
print '<td>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
$assessed_price = ($sale_price * .85);
|
||||
$residential_yearly_tax = ($assessed_price / 1000) * 14;
|
||||
$residential_monthly_tax = $residential_yearly_tax / 12;
|
||||
|
||||
|
||||
if ($pmi_per_month)
|
||||
{
|
||||
$pmi_text = "PMI and ";
|
||||
@ -304,8 +301,8 @@ if ($form_complete && $show_progress) {
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
|
||||
|
||||
// Set some base variables
|
||||
$principal = $financing_price;
|
||||
$current_month = 1;
|
||||
@ -315,11 +312,11 @@ if ($form_complete && $show_progress) {
|
||||
$power = -($month_term);
|
||||
$denom = pow((1 + $monthly_interest_rate), $power);
|
||||
$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%">';
|
||||
|
||||
|
||||
// This LEGEND will get reprinted every 12 months
|
||||
$legend = '<tr class="liste_titre">';
|
||||
$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("Position") . '</td>';
|
||||
$legend.= '</tr>';
|
||||
|
||||
|
||||
print $legend;
|
||||
|
||||
// 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($remaining_balance, "2", ".", ",") . ' ' . $langs->trans("Currency".$conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
($current_month % 12) ? $show_legend = FALSE : $show_legend = TRUE;
|
||||
|
||||
if ($show_legend) {
|
||||
print '<tr>';
|
||||
print '<td colspan="4"><b>' . $langs->trans("Totalsforyear") . ' ' . $current_year . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$total_spent_this_year = $this_year_interest_paid + $this_year_principal_paid;
|
||||
print '<tr>';
|
||||
print '<td> </td>';
|
||||
@ -369,11 +366,11 @@ if ($form_complete && $show_progress) {
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> <br></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$current_year++;
|
||||
$this_year_interest_paid = 0;
|
||||
$this_year_principal_paid = 0;
|
||||
|
||||
|
||||
if (($current_month + 6) < $month_term)
|
||||
{
|
||||
echo $legend;
|
||||
|
||||
@ -69,7 +69,7 @@ class Loan extends CommonObject
|
||||
* Load object in memory from database
|
||||
*
|
||||
* @param int $id id object
|
||||
* @return void
|
||||
* @return int <0 error , >=0 no error
|
||||
*/
|
||||
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))
|
||||
{
|
||||
$this->error="ErrorAccountingParameter";
|
||||
return -2;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -304,8 +304,12 @@ class Loan extends CommonObject
|
||||
$sql.= " paid = 1";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$return = $this->db->query($sql);
|
||||
if ($return) return 1;
|
||||
else return -1;
|
||||
if ($return) {
|
||||
return 1;
|
||||
} else {
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,7 +427,8 @@ class Loan extends CommonObject
|
||||
}
|
||||
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);
|
||||
if (empty($obj->fk_user_modif)) $obj->tms = "";
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,8 @@ $search_label=GETPOST('search_label','alpha');
|
||||
$search_amount=GETPOST('search_amount','alpha');
|
||||
$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_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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
|
||||
$var = !$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 "</tr>\n";
|
||||
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -147,6 +148,6 @@ else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -46,20 +46,25 @@ $result = restrictedArea($user, 'loan', $id, '','');
|
||||
$help_url='EN:Module_Loan|FR:Module_Emprunt';
|
||||
llxHeader("",$langs->trans("Loan"),$help_url);
|
||||
|
||||
$loan = new Loan($db);
|
||||
$loan->fetch($id);
|
||||
$loan->info($id);
|
||||
if ($id > 0) {
|
||||
$loan = new Loan($db);
|
||||
$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>';
|
||||
dol_print_object_info($loan);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// $id ?
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
|
||||
@ -133,7 +133,6 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment');
|
||||
if ($action == 'delete')
|
||||
{
|
||||
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')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
print $form->formconfirm('card.php?id='.$payment->id.'&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'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user