|
dolibarr 25.0.0-alpha
|
Library for loan module. More...
Go to the source code of this file.
Functions | |
| loan_prepare_head ($object) | |
| Prepare array with list of tabs. | |
| loanCalcMonthlyPayment ($mens, $capital, $rate, $numactualloadterm, $nbterm, $amort=null, $source='mens', $grace_period=0, $int=null, $frequency=12, $interest_basis=0, $datestart=0, $balloon=0) | |
| Calculate remaining loan mensuality and interests. | |
| loanFrequencies () | |
| Payment frequencies of a loan. | |
| loanTermDate ($datestart, $index, $frequency=12) | |
| Date of a payment of a loan. | |
| loanPeriodDays ($datestart, $term, $frequency=12) | |
| Number of days of the period that ends with a payment (used by the daily interest basis). | |
| loanPeriodRate ($rate, $frequency=12, $interest_basis=0, $days=0) | |
| Interest rate of one period of a loan. | |
| loanChargeTypes () | |
| Kinds of charge the "insurance" amount of a loan can be. | |
| loanChargeLabel ($charge_type, $outputlangs) | |
| Label of the charge of a loan (Insurance, Account-keeping fee, Other fee). | |
| loanChargePerPayment ($amount, $per_payment, $nbterm) | |
| Charge of each payment of a loan. | |
| loanRecalculateSchedule ($db, $user, $loan, $lines, $from, $capital, $rate, $keep, $payment=0.0) | |
| Recalculate the unpaid payments of a loan schedule, from one payment to the end, after a rate change or a payment that differs from the schedule. | |
| loanRecordChange ($db, $user, $loanid, $reason, $datechange, $rate_old, $rate_new, $keep, $payment_old, $payment_new, $nbterm_old, $nbterm_new, $fk_payment=0) | |
| Record a change of a loan (rate change, or a payment that differs from the schedule) in its history. | |
| loanFetchChanges ($db, $loanid) | |
| History of the changes of a loan, most recent first. | |
| loanRateAt ($history, $current, $date) | |
| Annual rate of a loan in force on a date, from the history of its rate changes: the rate of the most recently recorded change that applies on or before the date; before the first change, the rate the loan had before it; without any change, the current rate of the loan. | |
| loanNextPayment ($db, $loan) | |
| Next payment of a loan that has no schedule, worked out from the loan and the payments already made: due on the first payment date after the last payment; interest on the capital left for that period, at the rate in force on that date (daily or per period); capital so that the remaining payments repay the capital left (less the balloon), the last payment repaying all that is left; charge from the charge type of the loan. | |
Library for loan module.
Definition in file loan.lib.php.
| loan_prepare_head | ( | $object | ) |
Prepare array with list of tabs.
| Loan | $object | Object related to tabs |
Definition at line 34 of file loan.lib.php.
References $conf, $object, complete_head_from_modules(), Link\count(), dol_dir_list(), dol_sanitizeFileName(), and getDolGlobalString().
| loanCalcMonthlyPayment | ( | $mens, | |
| $capital, | |||
| $rate, | |||
| $numactualloadterm, | |||
| $nbterm, | |||
| $amort = null, | |||
| $source = 'mens', | |||
| $grace_period = 0, | |||
| $int = null, | |||
| $frequency = 12, | |||
| $interest_basis = 0, | |||
| $datestart = 0, | |||
| $balloon = 0 ) |
Calculate remaining loan mensuality and interests.
| float | $mens | Value of this mensuality (interests include, set 0 if we don't paid interests for this mensuality) |
| float | $capital | Remaining capital for this mensuality |
| float | $rate | Loan rate |
| int | $numactualloadterm | Actual loan term |
| int | $nbterm | Total number of term for this loan |
| null | float | string | $amort | Capital amortization for this term (optional) |
| string | $source | Source of modification ('mens', 'amort' or 'interet') |
| int | $grace_period | Number of terms with grace period (amortization = 0) |
| null | float | string | $int | Interest amount for this term (optional) |
| int | $frequency | Number of payments per year (52, 26, 12, 4, 2 or 1) |
| int | $interest_basis | 0 = rate / number of payments per year, 1 = daily (rate x days in the period / 365) |
| int | $datestart | Date of the first payment (needed for the daily basis) |
| float | $balloon | Balloon / residual paid with the last payment (0 = none) |
Definition at line 111 of file loan.lib.php.
References $conf, $object, loanPeriodDays(), loanPeriodRate(), price(), and price2num().
| loanChargeLabel | ( | $charge_type, | |
| $outputlangs ) |
Label of the charge of a loan (Insurance, Account-keeping fee, Other fee).
| int | $charge_type | charge_type of the loan |
| Translate | $outputlangs | Language |
Definition at line 328 of file loan.lib.php.
References loanChargeTypes().
| loanChargePerPayment | ( | $amount, | |
| $per_payment, | |||
| $nbterm ) |
Charge of each payment of a loan.
| float | $amount | insurance_amount of the loan |
| int | $per_payment | 1 = the amount is due with every payment, 0 = it is a total spread over the payments |
| float | $nbterm | Number of payments |
Definition at line 342 of file loan.lib.php.
References price2num().
Referenced by loanNextPayment(), and loanRecalculateSchedule().
| loanChargeTypes | ( | ) |
Kinds of charge the "insurance" amount of a loan can be.
Definition at line 312 of file loan.lib.php.
Referenced by loanChargeLabel().
| loanFetchChanges | ( | $db, | |
| $loanid ) |
History of the changes of a loan, most recent first.
Definition at line 553 of file loan.lib.php.
Referenced by loanNextPayment(), and loanRecalculateSchedule().
| loanFrequencies | ( | ) |
Payment frequencies of a loan.
Definition at line 231 of file loan.lib.php.
| loanNextPayment | ( | $db, | |
| $loan ) |
Next payment of a loan that has no schedule, worked out from the loan and the payments already made: due on the first payment date after the last payment; interest on the capital left for that period, at the rate in force on that date (daily or per period); capital so that the remaining payments repay the capital left (less the balloon), the last payment repaying all that is left; charge from the charge type of the loan.
Definition at line 606 of file loan.lib.php.
References loanChargePerPayment(), loanFetchChanges(), loanPeriodDays(), loanPeriodRate(), loanRateAt(), loanTermDate(), and price2num().
| loanPeriodDays | ( | $datestart, | |
| $term, | |||
| $frequency = 12 ) |
Number of days of the period that ends with a payment (used by the daily interest basis).
| int | $datestart | Date of the first payment |
| int | $term | Payment number, 1 for the first payment |
| int | $frequency | Number of payments per year |
Definition at line 280 of file loan.lib.php.
References loanTermDate().
Referenced by loanCalcMonthlyPayment(), loanNextPayment(), and loanRecalculateSchedule().
| loanPeriodRate | ( | $rate, | |
| $frequency = 12, | |||
| $interest_basis = 0, | |||
| $days = 0 ) |
Interest rate of one period of a loan.
| float | $rate | Annual rate (as a fraction, or in percent: the result is in the same unit) |
| int | $frequency | Number of payments per year |
| int | $interest_basis | 0 = rate / number of payments per year, 1 = daily (rate x days in the period / 365) |
| int | $days | Days in the period, for the daily basis (0 = the average period: 7 days weekly, 14 days fortnightly, else 365 / number of payments) |
Definition at line 294 of file loan.lib.php.
Referenced by LoanSchedule\calcMonthlyPayments(), loanCalcMonthlyPayment(), loanNextPayment(), and loanRecalculateSchedule().
| loanRateAt | ( | $history, | |
| $current, | |||
| $date ) |
Annual rate of a loan in force on a date, from the history of its rate changes: the rate of the most recently recorded change that applies on or before the date; before the first change, the rate the loan had before it; without any change, the current rate of the loan.
| array<int,stdClass> | $history From loanFetchChanges() | |
| float | $current | Current rate of the loan (percent) |
| int | $date | Date |
Definition at line 577 of file loan.lib.php.
References $c.
Referenced by loanNextPayment(), and loanRecalculateSchedule().
| loanRecalculateSchedule | ( | $db, | |
| $user, | |||
| $loan, | |||
| $lines, | |||
| $from, | |||
| $capital, | |||
| $rate, | |||
| $keep, | |||
| $payment = 0.0 ) |
Recalculate the unpaid payments of a loan schedule, from one payment to the end, after a rate change or a payment that differs from the schedule.
Paid payments are never changed. The loan's number of payments and end date are updated, and its rate when a new rate is given.
| DoliDB | $db | Database handler |
| User | $user | User making the change |
| Loan | $loan | Loan (its rate is replaced by $rate) |
| LoanSchedule[] | $lines | All the schedule lines of the loan, in date order |
| int | $from | Index (0 = first line) of the first line to recalculate; it and all the following lines must be unpaid |
| float | $capital | Capital left to repay before that line |
| ?float | $rate | Annual rate in percent for the recalculated lines (a rate change), or null to use, for each payment, the rate in force on its date (see loanRateAt()) |
| string | $keep | 'term' = keep the number of payments (the repayment changes), 'payment' = keep the repayment (the number of payments changes) |
| float | $payment | With 'payment': repayment (capital + interest) for every recalculated payment, or 0 = each payment keeps its current repayment (added payments: the last regular one) |
Definition at line 370 of file loan.lib.php.
References dol_now(), loanChargePerPayment(), loanFetchChanges(), loanPeriodDays(), loanPeriodRate(), loanRateAt(), loanTermDate(), and price2num().
| loanRecordChange | ( | $db, | |
| $user, | |||
| $loanid, | |||
| $reason, | |||
| $datechange, | |||
| $rate_old, | |||
| $rate_new, | |||
| $keep, | |||
| $payment_old, | |||
| $payment_new, | |||
| $nbterm_old, | |||
| $nbterm_new, | |||
| $fk_payment = 0 ) |
Record a change of a loan (rate change, or a payment that differs from the schedule) in its history.
| DoliDB | $db | Database handler |
| User | $user | User making the change |
| int | $loanid | Loan id |
| string | $reason | 'rate' or 'payment' |
| int | $datechange | Date from which the change applies |
| float | $rate_old | Rate before (percent) |
| float | $rate_new | Rate after (percent) |
| string | $keep | 'term', 'payment' or '' (no schedule recalculated) |
| float | $payment_old | Repayment before |
| float | $payment_new | Repayment after |
| float | $nbterm_old | Number of payments before |
| float | $nbterm_new | Number of payments after |
| int | $fk_payment | Payment that caused the change (reason 'payment'), 0 if none |
Definition at line 531 of file loan.lib.php.
References $conf, dol_now(), and price2num().
| loanTermDate | ( | $datestart, | |
| $index, | |||
| $frequency = 12 ) |
Date of a payment of a loan.
| int | $datestart | Date of the first payment |
| int | $index | 0 for the first payment, 1 for the second, ... |
| int | $frequency | Number of payments per year (52, 26, 12, 4, 2 or 1) |
Definition at line 251 of file loan.lib.php.
References dol_print_date(), and dol_time_plus_duree().
Referenced by loanNextPayment(), loanPeriodDays(), and loanRecalculateSchedule().