Guest User

Untitled

a guest
May 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. class Cashinator {
  2.  
  3. //initialize the cash register with a price list in a simple comma-delimited format.
  4. // The price list contains product names, SKU's (stock-keeping units, i.e., the product id),
  5. // the price per unit, and whether the product is taxable. (Staple groceries are typically not taxable.)
  6. // initialize the register with a starting amount of money, a sales tax percentage.
  7.  
  8. constructor(pricelist, startingMoney, salesTax){
  9. this.pricelist = pricelist.parseCSV; //seems like price list is a csvfile, parse csv will turn into an object with SKU as key
  10. this.balance = startingMoney || 0;
  11. this.salesTax = salesTax || 0;
  12. this.transactions = [];
  13. this.lastTransactionId = 0;
  14. this.inProgressTransaction;
  15. }
  16.  
  17.  
  18. showBalance(){
  19. //display current balance on screen
  20. }
  21.  
  22. // view a report of all the transactions that have occurred since register initialization.
  23. // Transactions are listed by id, # of items purchased, and the transaction amount.
  24. showTransactionReport(){
  25. //for each transaction in transaction array
  26. //print id, items.length, total
  27. }
  28. //search all items purchased since register initialization. I can do a partial string match on product name
  29. searchRegisterItems(searchString){
  30. //?? not sure point of this function
  31. }
  32.  
  33. startTransaction(){
  34. //increment the lastTransactionId
  35. //create a new Transaction, passing in new id
  36. //set this transaction to the inProgressTransaction
  37. }
  38.  
  39. scanItem(sku){
  40. //get the item from the pricelist used skuKey
  41. //call transaction.addItem to add to array
  42. //call display.displayCustomer(item, transaction.subtotal) to show the updated running values
  43. }
  44.  
  45. endTransaction(){
  46. //call transaction.transaction end
  47. //
  48. }
  49.  
  50. handleCustomerMoney(){
  51.  
  52. }
  53.  
  54. }
  55.  
  56. class Transaction{
  57. constructor(id){
  58. this.id = id;
  59. this.createdAt = Date.now();
  60. this.items = []
  61. this.subtotal = 0;
  62. this.nonTaxableAmount = 0; //we could do a reduce function, but it will be more efficient to just add to values as they are added
  63. }
  64. // As a cashier, I can scan one item, whereupon that item is added to the transaction.
  65. addItem(item){
  66. //push the item to the items array
  67. //add item.price to subtotal
  68. }
  69.  
  70. transactionEnd(taxRate){
  71. //calculate this.total and set it
  72. //Apply sales tax to (subtotal - nonTaxableAmount)
  73. //add subtotal+tax to nonTaxableAmount
  74. }
  75. printReciept(){
  76. //for each item in the items array, print details
  77. //print subtotal and total
  78. }
  79.  
  80. }
  81.  
  82. class Display{
  83. constructor(){
  84. this.currentDisplay = ''
  85. }
  86. displayCustomer(item, subtotal){
  87. this.currentDisplay = //formatted item and subtotal
  88. }
  89. displayFinal(total){
  90. //show the final total of the transation
  91. }
  92. displayCashier(){
  93. //if the inProgressTransaction is undefined, show the currrent Cashinator balance
  94. //else, show displayCustomer
  95. }
  96. }
Add Comment
Please, Sign In to add comment