I am trying to calculate the tax but whenever I try to execute the if statements, it says 'BC' not defined. The if statements regrding tax are near the end.Any help is appreciated. Heres my code: import cgi form = cgi.FieldStorage()
# print HTTP/HTML header stuff
print """Content-type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title>Order Form</title>
</head><body>
"""
# print HTML body using form data
print "<h1>Profesional Painters</h1>"
print "<h2>Customer Reciept</h2>"
print "<p>Customer Name:", form["customerName"].value, "</p>"
print "<p>Customer Email Address:", form["customerEmail"].value, "</p>"
print "<h2>Customer Address:</h2>"
print "<p>Street:", form["customerAdd"].value, "</p>"
print "<p>City:", form["customerCity"].value, "</p>"
print "<p>Province:", form["customerProv"].value, "</p>"
print "<p>Postal Code:", form["customerPostal"].value, "</p>"
print "<h2>Payment Information:</h2>"
print "<p>Card Type:", form["type1"].value, "</p>"
print "<p>Card Number: XXXX-XXXX-XXXX-", form["four4"].value, "</p>"
print "<p>Expiry Date:", form["expirt"].value, "</p>"
print "<h2>Products Ordered</h2>"
q1 = int(form["quantity"].value)*2
q2 = int(form["quantity2"].value)*1
q3 = int(form["quantity3"].value)*150
q4 = int(form["quantity4"].value)*3
q5 = int(form["quantity5"].value)*10
if form.getvalue("interior"):
print "<p>Interior Painting quantity:", form["quantity"].value, "</p>"
print "<p>Cost: $" ,q1, ".00</p>"
else:
q1 = 0
print "<p>Interior Painting quantity: 0 <br /> Cost: $0</p>"
if form.getvalue("exterior"):
print "<p>Exterior Painting quantity:", form["quantity2"].value, "</p>"
print "<p>Cost: $" ,q2, ".00</p>"
else:
q2 = 0
print "<p>Exterior Painting quantity: 0 <br /> Cost: $0</p>"
if form.getvalue("pressure"):
print "<p>Pressure Washing quantity:", form["quantity3"].value, "</p>"
print "<p>Cost : $" ,q3, ".00</p>"
else:
q3 = 0
print "<p>Pressure Washing quantity: 0 <br /> Cost: $0</p>"
if form.getvalue("wood"):
print "<p>Wood Finishing quantity:", form["quantity4"].value, "</p>"
print "<p>Cost: $" ,int(form["quantity4"].value)*3, ".00</p>"
else:
q4 = 0
print "<p>Wood Finsihing quantity: 0 <br /> Cost: $0</p>"
if form.getvalue("spraycan"):
print "<p>Spray Can quantity:", form["quantity5"].value, "</p>"
print "<p>Cost: $" ,int(form["quantity5"].value)*10, ".00</p>"
else:
q5 = 0
print "<p>Spray Can quantity: 0 <br /> Cost: $0</p>"
if form.getvalue("email"):
print "<p>An email notification will be sent to ",form["customerEmail"].value, "</p>"
total = q1 + q2 + q3 + q4 + q5
print "<p>Total Cost of goods purchased is $: ", total
def discount():
return float(total*0.15)
disc = discount()
disc2=0
if total > 150:
print "<p>Discount: $" , float(disc),"</p>"
else:
total<150
print "<p>Discount:" ,disc2,"</p>"
g1 = int(form["quantity"].value)
g2 = int(form["quantity2"].value)
g3 = int(form["quantity3"].value)
g4 = int(form["quantity4"].value)
g5 = int(form["quantity5"].value)
def gift():
return g1+g2+g3+g4+g5
giftwrp = gift()
if form.getvalue("giftwrap"):
print "<p>Gift wrap cost: $ ",int(giftwrp),".00</p>"
if total > 150 and form["customerProv"].value == BC or bc or Bc or bC:
print"<p>Tax: $",float((total-disc))*0.12,"</p>"
elif total <150 and form["customerProv"].value == BC or bc or Bc or bC:
print "<p>Tax: $",float(total)*0.12,"</p>"
elif total > 150 and form["customerProv"].value == BC or bc or Bc or bC and form.getvalue("giftwrap"):
print "<p>Tax: $",float(((total-disc)+giftwrp))*0.12,"</p>"
elif total < 150 and form["customerProv"].value == BC or bc or Bc or bC and form.getvalue("giftwrap"):
print "<p>Tax: $",float((total+giftwrp))*0.12,"</p>"
elif total > 150 and form["customerProv"].value != BC or bc or Bc or bC:
print"<p>Tax: $",float((total-disc))*0.12,"</p>"
elif total <150 and form["customerProv"].value != BC or bc or Bc or bC:
print "<p>Tax: $",float(total)*0.12,"</p>"
elif total > 150 and form["customerProv"].value != BC or bc or Bc or bC and form.getvalue("giftwrap"):
print "<p>Tax: $",float(((total-disc)+giftwrp))*0.12,"</p>"
elif total < 150 and form["customerProv"].value != BC or bc or Bc or bC and form.getvalue("giftwrap"):
print "<p>Tax: $",float((total+giftwrp))*0.12,"</p>"
print "</body></html>"