Skip to content
Snippets Groups Projects
Commit 614d2902 authored by Ariel Madeam's avatar Ariel Madeam
Browse files

Delete receipt.py

parent 107637a2
Branches
No related tags found
No related merge requests found
# Arielle Madeam
# am4952
# 7/5/23
# receipt.py
import datetime
class Receipt:
def __init__(self, tax_rate):
self.__tax_rate = tax_rate
self.__purchases = []
def addItem(self, item):
self.__purchases.append(item)
def receiptToString(self):
subtotal = 0
tax = 0
reciept = ("----- Receipt time -----\n")
for item in self.__purchases:
price = "{:.2f}".format(item.getPrice())
reciept+=("{:_<35}{:_>5}".format(str(item.getName()),price))
subtotal += item.getPrice()
tax = item.getTax(self.__tax_rate) + tax
reciept+=("\n")
reciept+=("\n{0:_<35}{1:_>5}".format("Sub Total",f'{subtotal:.2f}'))
reciept+=("\n{0:_<35}{1:_>5}".format("Tax",f'{tax:.2f}'))
reciept+=("\n{0:_<35}{1:_>5}".format("Total",f'{subtotal+tax:.2f}'))
return reciept
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment