F0rtis5

Untitled

Oct 30th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import datetime
  2.  
  3.  
  4. oDate = ''
  5. cPctr = 0
  6. dataFile = ''
  7.  
  8.  
  9. def main():
  10. iRec = init()
  11. while iRec != "":
  12. cStoreCost, iQty, iPrice = calcs(iRec)
  13. output(cStoreCost, iQty, iPrice, iRec)
  14. iRec = read()
  15. closing()
  16.  
  17.  
  18. def closing():
  19. print("\n")
  20. dataFile.close()
  21.  
  22.  
  23. def output(cStoreCost, iQty, iPrice, iRec):
  24. iStoreName = iRec[0:10]
  25. iPatch = iRec[11:12]
  26. if iPatch == 'N':
  27. oPatch = "North"
  28. elif iPatch == 'S':
  29. oPatch = "SkunkCreek"
  30. else:
  31. oPatch = "Back 40"
  32.  
  33. print(iStoreName, format(" ", "7s"), oPatch, format(" ", "9s"), iQty,
  34. format(" ", "15s"), iPrice, format(" ", "6s"), cStoreCost)
  35.  
  36.  
  37.  
  38. def calcs(iRec):
  39. iQty = int(iRec[12:15])
  40. iPrice = float(iRec[15:20])
  41. cStoreCost = (iQty * iPrice)
  42. return cStoreCost, iQty, iPrice
  43.  
  44.  
  45.  
  46. def init():
  47. global oDate
  48. global dataFile
  49. dataFile = open(r'data/pumpkin.dat', 'r')
  50. oDate = datetime.datetime.today().strftime('%m/%d/%Y')
  51. headings()
  52. iRec = read()
  53. return iRec
  54.  
  55.  
  56.  
  57. def read():
  58. iRec = dataFile.readline()
  59. return iRec
  60.  
  61.  
  62. def headings():
  63. global cPctr
  64. cPctr = cPctr + 1
  65. print("Date: ", oDate, format(" ", "15s"), "Pumpkin Patch Ranch", format(" ", "16s"), "Page: ", format(cPctr, "2d"))
  66. print(format(" ", "36s"), "Sales Report\n")
  67. print("Store Name", " ", "Patch Name", " ", "Quantity", " ",
  68. "Price", " ", "Store Cost\n")
  69.  
  70. main()
Advertisement
Add Comment
Please, Sign In to add comment