Code to setup credit limit


I am currently working on an application to keep track of customer credit (Loan) for a small grocery store. Each customer has a limit (say $300). If their credit remaining is $10 and they are trying to take a grocery worth $15 the application will stop the transaction to go through and will show a message " Customer exceeded credit limit". 

Any help will be appreciated. I am also willing to have someone reach out to me to discuss this further and we can work out things. I can be reached at