Bug fix
- Fixed: netTotal is undefined in getUserDetails() - Fixed: bug causes acc map to be undefined when processing loans
This commit is contained in:
parent
2e73e0e4c5
commit
22fdac08b8
20
index.html
20
index.html
@ -11929,10 +11929,10 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
//Might need to add net interest calculations
|
//Might need to add net interest calculations
|
||||||
result.netTotal = result.depositTotal - result.loanTotal;
|
result.netTotal = result.depositTotal - result.loanTotal;
|
||||||
}
|
return result;
|
||||||
return result
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getAccount: function(floID, index) {
|
getAccount: function(floID, index) {
|
||||||
@ -12211,7 +12211,7 @@
|
|||||||
let index = this.accMap[myFloID] ? this.accMap[myFloID].length : 0;
|
let index = this.accMap[myFloID] ? this.accMap[myFloID].length : 0;
|
||||||
//check for validity of loan (ie, check if enough deposit is present)
|
//check for validity of loan (ie, check if enough deposit is present)
|
||||||
let user = this.getUserDetails(myFloID)
|
let user = this.getUserDetails(myFloID)
|
||||||
if (user.depositTotal <= amount) {
|
if (user.netTotal <= amount) {
|
||||||
if (user.depositTotal) {
|
if (user.depositTotal) {
|
||||||
reject(`Deposit insufficient! Max eligible loan amount: ${user.depositTotal.toLocaleString(`en-IN`, { style: 'currency', currency: 'INR' })}`);
|
reject(`Deposit insufficient! Max eligible loan amount: ${user.depositTotal.toLocaleString(`en-IN`, { style: 'currency', currency: 'INR' })}`);
|
||||||
} else {
|
} else {
|
||||||
@ -12242,15 +12242,21 @@
|
|||||||
throw ('Invalid request: Request-type is not openLoan');
|
throw ('Invalid request: Request-type is not openLoan');
|
||||||
if (req.status !== "pending")
|
if (req.status !== "pending")
|
||||||
throw ("Request already processed");
|
throw ("Request already processed");
|
||||||
|
//check for validity of loan (ie, check if enough deposit is present)
|
||||||
|
let user = this.getUserDetails(req.floID);
|
||||||
|
if (user.netTotal <= req.amount) {
|
||||||
|
if (user.depositTotal > 0)
|
||||||
|
throw ("R>Deposit insufficient");
|
||||||
|
else
|
||||||
|
throw ("R>No Active deposit available");
|
||||||
|
}
|
||||||
//verify the signature
|
//verify the signature
|
||||||
|
if (!this.accMap[req.floID])
|
||||||
|
this.accMap[req.floID] = [];
|
||||||
if (req.index != this.accMap[req.floID].length)
|
if (req.index != this.accMap[req.floID].length)
|
||||||
throw (`R>Invalid index (correct index is ${this.accMap[req.floID].length})`);
|
throw (`R>Invalid index (correct index is ${this.accMap[req.floID].length})`);
|
||||||
if (!floCrypto.verifySign(this.util.istr + `open#${req.index}:loan|${req.amount}`, req.sign, req.pubKey))
|
if (!floCrypto.verifySign(this.util.istr + `open#${req.index}:loan|${req.amount}`, req.sign, req.pubKey))
|
||||||
throw ("R>Invalid signature: Re-signing required");
|
throw ("R>Invalid signature: Re-signing required");
|
||||||
//check for validity of loan (ie, check if enough deposit is present)
|
|
||||||
let user = this.getUserDetails(req.floID)
|
|
||||||
if (user.netTotal <= req.amount)
|
|
||||||
return reject("R>Deposit insufficient");
|
|
||||||
let data = this.dataConstruct(timestamp, req.floID, "open-loan", req.index, req.sign, req.pubKey, req.amount);
|
let data = this.dataConstruct(timestamp, req.floID, "open-loan", req.index, req.sign, req.pubKey, req.amount);
|
||||||
let txid = await this.writeBankTxData(myPrivKey, data, req.floID, req.amount)
|
let txid = await this.writeBankTxData(myPrivKey, data, req.floID, req.amount)
|
||||||
let response = {
|
let response = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user