This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on("init", () => { | |
var state = { | |
Status: "New" | |
}; | |
return state; | |
}); | |
on("loan-submission", (state, req) => { | |
state.Amount = req.Amount; | |
if(req.CreditScore < 500) { | |
state.Status = "Denied"; | |
return "Credit score too low"; | |
} | |
if(req.Amount < 1000) { | |
state.Status = "Approved"; | |
return "Credit score is good and loan amount is small"; | |
} | |
if(req.LifeInsurance == null) { | |
state.Status = next("life-insurance-setup"); | |
return; | |
} | |
state.Status = next("compute-apr"); | |
return; | |
}); | |
on("life-insurance-setup", (state, req) => { | |
if(req.Denied){ | |
state.Status = "Denied"; | |
return "Cannot get a loan for this ammount without life insurance"; | |
} | |
state.Status = next("compute-apr"); | |
}); | |
on("compute-apr", (state, req) => { | |
if(req.APR > 25) { | |
state.Status = "Denied"; | |
return "Better to refuse the loan than handle usury charges"; | |
} | |
state.Status = next("offer-to-user"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment