(coll, fina, repa, shark, disloan): Fix calculation of regular and
extended (beyond due date) loan time. At the due date, or after a last payment made at the due date, durations were zero in fina() and unpredictable elsewhere. With luck, debtors could abuse this to repay loans cheap (they couldn't gain cash, though), sharks to purchase loans cheap, and creditors to collect excessively.
This commit is contained in:
parent
ef0060ec57
commit
fcbe36e76c
5 changed files with 54 additions and 72 deletions
|
@ -57,8 +57,6 @@ coll(void)
|
|||
struct lonstr loan;
|
||||
struct sctstr sect;
|
||||
coord x, y;
|
||||
long due;
|
||||
long last;
|
||||
long rdur;
|
||||
long xdur;
|
||||
double rate;
|
||||
|
@ -82,19 +80,21 @@ coll(void)
|
|||
/* If we got here, we check to see if it's been defaulted on. We
|
||||
already know it's owed to this player. */
|
||||
(void)time(&now);
|
||||
due = loan.l_duedate;
|
||||
if (now <= due) {
|
||||
/*
|
||||
* split duration now - l_lastpay into regular (up to l_duedate)
|
||||
* and extended (beyond l_duedate)
|
||||
*/
|
||||
rdur = loan.l_duedate - loan.l_lastpay;
|
||||
xdur = now - loan.l_duedate;
|
||||
if (rdur < 0) {
|
||||
xdur += rdur;
|
||||
rdur = 0;
|
||||
}
|
||||
if (xdur <= 0) {
|
||||
pr("There has been no default on loan %d\n", arg);
|
||||
return RET_FAIL;
|
||||
}
|
||||
last = loan.l_lastpay;
|
||||
if (last < due && due < now) {
|
||||
rdur = due - last;
|
||||
xdur = now - due;
|
||||
} else if (due < last) {
|
||||
rdur = 0;
|
||||
xdur = now - last;
|
||||
}
|
||||
|
||||
rate = loan.l_irate / (loan.l_ldur * 8.64e6);
|
||||
|
||||
/* changed following to avoid overflow 3/27/89 bailey@math-cs.kent.edu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue