I am going to write a simple credit system that user can "add", "deduct" credits in the system. Currently I am thinking of two approaches.
Simple one: Store the user' credit as balance
field in the database, and all actions ("add", "deduct") are logged but not used to compute the latest balance.
History based: Don't store the balance in database. The balance is computed by looking at the history of transactions, e.g. ("add", "deduct")
Both case would works I think, but I am looking to see if any caveat when designing such a system, particularly I am favoring the History based
system.
Or, are there any reference implementation or open source module I am use?
Update: Or are there any Ruby/Rail based module like AuthLogic
so I can plug and play into my existing code without reinventing the wheel (e.g. transaction, rollback, security etc)?
This information is reported to Equifax by your lenders and creditors and includes the types of accounts (for example, a credit card, mortgage, student loan, or vehicle loan), the date those accounts were opened, your credit limit or loan amount, account balances, and your payment history.
Credit scoring models generally look at how late your payments were, how much was owed, and how recently and how often you missed a payment. Your credit history will also detail how many of your credit accounts have been delinquent in relation to all of your accounts on file.
You can get your free credit report from Annual Credit Report. That is the only free place to get your report. You can get it online: AnnualCreditReport.com, or by phone: 1-877-322-8228. You get one free report from each credit reporting company every year.
Generally speaking, scores between 690 and 719 are considered good credit on the commonly used 300-850 credit score range. Scores above 720 are considered excellent, while scores between 630 and 689 are considered fair.
Absolutely use both.
The balance-based way gives you fast access to the current amount.
The history-based way gives you auditing. The history table should store the transaction (as you describe), a timestamp, the balance before the transaction happened, and ideally a way to track the funds' source/destination.
See the Ruby Toolbox for bookkeeping and Plutus double-entry bookkeeping gem.
In addition, if your credit system may affect users, then I recommend also using logging, and ideally read about secure log verification and provable timestamp chaining.
For logging details see: techniques for ensuring verifiability of event log files.
For open source code that does credit, you may want to look into: http://www.gnucash.org/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With