dolibarr 25.0.0-alpha
calcmens.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015 Florian HENRY <florian.henry@open-concept.pro>
3 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOTOKENRENEWAL')) {
27 define('NOTOKENRENEWAL', '1'); // Disables token renewal
28}
29if (!defined('NOREQUIREMENU')) {
30 define('NOREQUIREMENU', '1');
31}
32if (!defined('NOREQUIREAJAX')) {
33 define('NOREQUIREAJAX', '1');
34}
35
36// Load Dolibarr environment
37require '../main.inc.php';
45require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
46
47$mens = (float) price2num(GETPOST('mens'));
48$amort = GETPOSTISSET('amort') ? (float) price2num(GETPOST('amort')) : null;
49$interet = GETPOSTISSET('interet') ? (float) price2num(GETPOST('interet')) : null;
50$source = GETPOST('source', 'aZ09') ? GETPOST('source', 'aZ09') : 'mens';
51$capital = (float) price2num(GETPOST('capital'));
52$rate = (float) price2num(GETPOST('rate'));
53$echance = GETPOSTINT('echeance');
54$nbterm = GETPOSTINT('nbterm');
55$grace_period = GETPOSTINT('grace_period');
56
58
59$output = array();
60
61$output = loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm, $amort, $source, $grace_period, $interet);
62
63echo json_encode($output);
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
loanCalcMonthlyPayment($mens, $capital, $rate, $numactualloadterm, $nbterm, $amort=null, $source='mens', $grace_period=0, $int=null)
Calculate remaining loan mensuality and interests.
Definition loan.lib.php:107
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.