Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The Cashinator 3000
- // As a cashier, I can initialize the cash register with a price list in a simple comma - delimited format.The price list contains product names,
- // SKU's (stock-keeping units, i.e., the product id), the price per unit, and whether the product is taxable. (Staple groceries are typically not taxable.)
- // As a cashier, I can initialize the register with a starting amount of money.
- // As a cashier, I can initialize the register with a sales tax percentage.
- // As a cashier, when I am not actively handling a customer transaction, I can choose to view the current balance of cash that the register contains.
- // As a cashier, I can start a new transaction.Transactions have id's and are time-stamped upon creation.
- // As a cashier, I can scan one item, whereupon that item is added to the transaction.
- // As a customer, I can see the last item scanned and a running subtotal of the current transaction cost.
- // As a cashier, I can input the money received from the customer, thus closing out the transaction.
- // Change is calculated to minimize the number of bills and coins that must be handled by the cashier.
- // As a customer, I can see the grand total and how much change I am to receive.
- // As a customer, I can see an itemized receipt of my purchases.
- // As a cashier, I can view a report of all the transactions that have occurred since register initialization.Transactions are listed by id, # of items purchased, and the transaction amount.
- // As a cashier, I can search all items purchased since register initialization.I can do a partial string match on product name.
- const cashRegister = function(startingAmt, startingTax) {
- // create priceList
- this.priceList = [];
- // define balance with given startingAmt or 0
- this.balance = startingAmt || 0;
- // define sales tax with given startingTax or 0
- this.salesTax = startingTax || 0;
- // perhaps define starting transaction here with SKU and price, and taxable field
- this.transactions = {'0': {items} }
- return;
- }
- // create viewBalance function, I can choose to view the current balance of cash that the register contains.
- cashRegister.prototype.viewBalance() {
- // return total balance
- return this.balance;
- }
- // start new transaction function
- cashRegister.prototype.newTransaction() {
- // create ids for transactions
- // create timestasmp after created
- }
- // check scanned and add item function, I can scan one item, whereupon that item is added to the transaction.
- cashRegister.prototype.scanItem(transactionId, item) {
- // takes in a transaction ID and item as parameters and search for that in cashRegister
- // add and push item into transaction according to transaction ID
- }
- // check last scanned item
- cashRegister.prototype.lastScanned(transactionId) {
- // takes a transaction ID paramter and look for it in cash register
- // return item of that ID
- }
- // create import money and close out transaction function
- cashRegister.prototype.importMoney(moneyAmt) {
- // find the matching ID and define money from customer?
- }
- // create grand total view function
- // Change is calculated to minimize the number of bills and coins that must be handled by the cashier.
- // As a customer, I can see the grand total and how much change I am to receive.
- cashRegister.prototype.grandTotal() {
- }
- // create itemized receipt function
- cashRegister.prototype.viewItemizedReceipt(transactionId) {
- // takes in transaction ID as paramter and look for the items by separating out items in the matching ID
- // iterate through items with for loop or forEach
- }
- // create report transacctions since last regiser initialization function
- // As a cashier, I can view a report of all the transactions that have occurred since register initialization.
- // Transactions are listed by id, # of items purchased, and the transaction amount
- cashRegister.prototype.reportRegisteredTransactions() {
- // for each existing transaction in cash register, return/console.log transaction Id, # of items, and trans amt
- }
- // create search purchased items function
- cashRegister.prototype.searchPurchasedItems(productName) {
- // iterate through existing transactions in cash register
- // if we find the matching product name, return true?
- }
Add Comment
Please, Sign In to add comment