def TravelClaim(ClaimNumber): while True: EmployeeNumber = BP.ValidEmployeeNumber9() EmployeeName = input("Enter employee name: ") TripLocation = input("Enter location of travel: ") # Format the dates to allow them to be subtracted**** # newdate1 = time.strptime(date1, "%d/%m/%Y") and newdate2 = time.strptime(date2, "%d/%m/%Y") StartDatestr = input("Business trip start date (yyyy-mm-dd): ") EndDatestr = input("Business trip end date (yyyy-mm-dd): ") # formats start & end dates without time, and calculates travel days StartDate, EndDate, TotalTravelDays = BP.ProcessDate( StartDatestr, EndDatestr) OwnOrRented = input("Was the vehicle owned or rented? (O/R): ") TotalKilometers = int(input("Enter the total kilometers travelled: ")) if TotalTravelDays <= 3: PerDiem = TotalTravelDays * 85.00 else: PerDiem = TotalTravelDays * 100.00 if OwnOrRented.upper() == "O": MileageAmount = TotalKilometers * 0.10 elif OwnOrRented.upper() == "R": MileageAmount = TotalTravelDays * 56.00 else: MileageAmount = 0 ClaimAmount = PerDiem + MileageAmount TaxAmount = PerDiem * HST ClaimTotal = ClaimAmount + TaxAmount # Formatting #PerDiemStr = "${:,.2f}".format(PerDiem) #MileageAmountStr = "${:,.2f}".format(MileageAmount) #ClaimAmountStr = "${:,.2f}".format(ClaimAmount) TaxAmountStr = "${:,.2f}".format(TaxAmount) ClaimTotalStr = "${:,.2f}".format(ClaimTotal) # Printing results print() print(" NL Chocolate Company - Travel Claim") print() print("*" * 60) print() print("Employee Number: {} Employee Name: {:<12}".format( EmployeeNumber, EmployeeName)) print() print("Travel location: {}".format(TripLocation)) print("Travel Start Date: {} Travel End Date: {}".format( StartDate, EndDate)) print() print("Total Days Travelled: {}".format(TotalTravelDays)) print("Car Status (Owned or Rented): {}".format(OwnOrRented)) print("Total Kilometers Travelled: {}".format(TotalKilometers)) print() print("*" * 60) print() print("Daily Cost: ${:,.2f}".format(PerDiem)) print("Mileage Cost: ${:,.2f}".format(MileageAmount)) print("Claim Amount: ${:,.2f}".format(ClaimAmount)) print("Tax Amount: {:<10}".format(TaxAmountStr)) print(" ----------") print("Claim Total: {:<10}".format(ClaimTotalStr)) print() print("") file = open('Claims.dat', 'a') file.write("{}, ".format(ClaimNumber)) file.write("{}, ".format(EmployeeNumber)) file.write("{}, ".format(EmployeeName)) file.write("{}, ".format(TripLocation)) file.write("{}, ".format(StartDate)) file.write("{}, ".format(EndDate)) file.write("{}, ".format(TotalTravelDays)) file.write("{}, ".format(OwnOrRented)) file.write("{}, ".format(TotalKilometers)) file.write("{}, ".format(PerDiem)) file.write("{}, ".format(MileageAmount)) file.write("{}, ".format(ClaimAmount)) file.write("{}, ".format(TaxAmount)) file.write("{}\n".format(ClaimTotal)) file.close() # Increase claim number ClaimNumber += 1 # Updates Deflt.dat with new claim number file = open('Deflt.dat', 'w') file.write("{}\n".format(str(ClaimNumber))) file.write("{}\n".format(str(HST))) file.write("{}\n".format(str(LowPerDiemRate))) file.write("{}\n".format(str(HighPerDiemRate))) file.write("{}\n".format(float(MileageRate))) file.write("{}\n".format(int(RentalCarRate))) file.close() print("Claim processed successfully") print() Continue = input( "Process another data claim? (Enter Y for yes or any other key to end): " ) if Continue.upper() != "Y": break Anykey = input("Press any key to continue.")