Fix #12496 : currency was € in loan schedule

This commit is contained in:
Maxime Kohlhaas 2019-11-29 23:43:42 +01:00
parent a4a805f618
commit d480da5629
2 changed files with 55 additions and 14 deletions

View File

@ -44,7 +44,7 @@ $object = new LoanSchedule($db);
$int = ($capital*($rate/12));
$int = round($int, 2, PHP_ROUND_HALF_UP);
$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency),'interet'=>$int,'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency),'mens'=>$mens);
$echance++;
$capital=$cap_rest;
@ -56,7 +56,7 @@ while ($echance<=$nbterm) {
$int = round($int, 2, PHP_ROUND_HALF_UP);
$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency),'interet'=>$int,'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency),'mens'=>$mens);
$capital=$cap_rest;
$echance++;

View File

@ -44,6 +44,47 @@ llxHeader("", $title, $help_url);
$head=loan_prepare_head($object);
dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill');
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/list.php">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->loadLangs(array("projects"));
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->loan->write)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
if ($action == 'createecheancier') {
$i=1;
@ -128,9 +169,9 @@ $(document).ready(function() {
var interet_res_str='#interets'+index;
var men_res='#mens'+index;
$(idcap_res).val(element.cap_rest);
$(idcap_res_srt).text(element.cap_rest_str+' €');
$(idcap_res_srt).text(element.cap_rest_str);
$(interet_res).val(element.interet);
$(interet_res_str).text(element.interet_str+' €');
$(interet_res_str).text(element.interet_str);
$(men_res).val(element.mens);
});
}
@ -166,7 +207,7 @@ print '<th width="15%" class="center">'.$langs->trans("Insurance");
print '<th width="15%" class="center">'.$langs->trans("InterestAmount").'</th>';
print '<th width="10%" class="center">'.$langs->trans("Amount").'</th>';
print '<th width="40%" class="center">'.$langs->trans("CapitalRemain");
print ' ('.price2num($object->capital).')';
print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';
if (count($echeance->lines)>0) print '<th>'.$langs->trans('DoPayment').'</th>';
@ -189,10 +230,10 @@ if ($object->nbterm > 0 && count($echeance->lines)==0)
print '<tr>';
print '<td class="center" id="n'.$i.'">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'), 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1).'</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).'</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"></td>';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).'</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="insurance'.$i.'">'.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . ($insurance+(($i == 1) ? $regulInsurance : 0)) . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"></td>';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).'</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '</tr>'."\n";
$i++;
$capital = $cap_rest;
@ -215,15 +256,15 @@ elseif(count($echeance->lines)>0)
print '<tr>';
print '<td class="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>';
print '<td class="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep, 'day') . '</td>';
print '<td class="center" id="insurance'.$i.'">'.price($insu, 0, '', 1).'</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . $insu . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1).'</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td class="center" id="insurance'.$i.'">'.price($insu, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_insurance' .$i .'" id ="hi_insurance' .$i .'" value="' . $insu . '">';
print '<td class="center" id="interets'.$i.'">'.price($int, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
if($line->datep > dol_now() && empty($line->fk_bank)){
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"></td>';
print '<td class="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"></td>';
}else{
print '<td class="center">' . price($mens) . '</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">';
print '<td class="center">' . price($mens, 0, '', 1, -1, -1, $conf->currency) . '</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">';
}
print '<td class="center" id="capital'.$i.'">'.price($cap_rest).'</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center" id="capital'.$i.'">'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '<td class="center">';
if (!empty($line->fk_bank)) print $langs->trans('Paid');
elseif (!$printed)