I was developing an application for a liquor store. It has to calculate the total business done in that day by taking the OB(opening balance) SB(stock Balance) and SL(Sold bottles) as input and calculate the TL(total bottles) RS(Rupees/ Price) and CB(Closing Balance).
I successfully did it and storing the each days entry using HTML5 local storage.
Here is the code.
Javascript:
function calTotal(idopeningBal, idStockBal, idTotal){ var openingBal = parseFloat(idopeningBal.value, 10); //if(isNaN(openingBal)) openingBal = parseFloat(0, 10); var stockBal = parseFloat(idStockBal.value, 10); //if(isNan(stockBal)) stockBal = parseFloat(0,10); var total = openingBal + stockBal idTotal.value = parseFloat(total, 10); } function calRate(idTotal, idSold, idRupees, idClosingBal, idTotalAmount, price){ /* Calculate overall price */ var priceOfCurrent = parseFloat(price, 10); var numOfSold = parseFloat(idSold.value, 10); if(isNaN(numOfSold)) numOfSold = parseFloat(0, 10); var totalPrice = priceOfCurrent * numOfSold; /* End calculating total */ idRupees.value = parseFloat(totalPrice, 10); idClosingBal.value = parseFloat(idTotal.value - idSold.value, 10); idTotalAmount.innerHTML = parseFloat(totalPrice, 10) + " Rs."; } </script>
HTMLHere:
<tr> <td class = "data">FOSTERS BEER 750</td> <td class="data"><input type="text" class="numHolder" id="ocb750ob"></td> <td class="data"><input type="text" class="numHolder" id="ocb750sb"></td> <td class="data"><input type="text" class="numHolder" id="ocb750tl" onclick="calTotal(ocb750ob, ocb750sb, ocb750tl)"></td> <td class="data"><input type="text" class="numHolder" id="ocb750sl"></td> <td class="data"><input type="text" class="numHolder" id="ocb750rs"></td> <td class="data"><input type="text" class="numHolder" id="ocb750cb"
onclick="calRate(ocb750tl, ocb750sl, ocb750rs, ocb750cb, total1, 180)">
Similarly there are about 500 table rows.
Right now the whole application works fine. Is there anything I have to worry about or look for before handing it over. I am worried mostly with money related calculation