from datetime import datetime
firstnames=input('First name of tenant(s)')
rentincreasedate= input("DD/MM/YYYY for rent increase date")
RID=datetime.strptime(rentincreasedate,"%d/%m/%Y").date()
RID1=datetime.strftime(RID,"%d %B, %Y")
if RID1[0]=='0':
RID1=RID1[1:]
print(RID1)
periodstart=input("DD/MM/YY for start of payment period")
startperiod=datetime.strptime(periodstart,"%d/%m/%Y").date()
sp=datetime.strftime(startperiod,"%d %B, %Y")
if sp[0]=='0':
sp=sp[1:]
periodend=input("DD/MM/YY for end of payment period")
endperiod=datetime.strptime(periodend,"%d/%m/%Y").date()
ep=datetime.strftime(endperiod,"%d %B, %Y")
if ep[0]=='0':
ep=ep[1:]
deposit=float(input("Deposit held?"))
rpw=float(input("Old rent per week"))
ripw=float(input("New rent per week"))
periodlength= endperiod.toordinal()-startperiod.toordinal()+1
if periodlength==7:
var="weekly"
elif periodlength==14:
var='fortnightly'
elif periodlength<=31 or periodlength>=28:
var='monthly'
else:
print('wtf')
period1length= (RID.toordinal()-1) - startperiod.toordinal()+1
period2length= endperiod.toordinal() - RID.toordinal() + 1
period1= round(rpw/7*period1length,2)
period2= round(ripw/7*period2length,2)
tot= round(period1+period2,2)
tonobal= round(tot-deposit,2)
if var=='monthly':
np= ripw/7*365/12
if var=='fortnightly':
np= ripw*2
if var=='weekly':
np= ripw
print(period1length, period2length, "${:.2f}".format(period1), period2)
RIDminus= datetime.fromordinal((RID.toordinal()-1))
epplus= datetime.fromordinal((endperiod.toordinal()+1))
RID1_=datetime.strftime(RIDminus,"%d %B, %Y")
if RID1_[0]=='0':
RID1_=RID1_[1:]
ep_=datetime.strftime(epplus,"%d %B, %Y")
if ep_[0]=='0':
ep_=ep_[1:]
print('Hello', firstnames+", \n \nI hope this email finds you well. \n ")
print("As the rent increase has taken effect from", RID1+", please see below for the rent adjustment calculation for the", var, "payment for the period", sp, "-", ep+":")
print()
print("$" + str(rpw) + "/PW:", sp, "-", RID1_, "=", str(period1length), "days")
print("$"+str(rpw), "/ 7 days x", str(period1length), "days =", "$"+str(period1))
print()
print("$"+str(ripw)+"/PW:", RID1, "-", ep, "=", str(period2length), "days")
print("$"+str(ripw), "/ 7 days x", str(period2length), "days =", "$"+str(period2))
print()
print("Total balance to be paid for the following period:")
print("${:.2f}".format(period1), "+", "${:.2f}".format(period2), "=", "${:.2f}".format(tot))
if deposit>0:
print("Balance paid:", "${:.2f}".format(deposit))
print("Remaining balance to be paid:", "${:.2f}".format(np), "-", "${:.2f}".format(deposit), "=", "${:.2f}".format(tonobal))
print()
print("From", (ep_)+", the new", var, "payment is", "${:.2f}.".format(np))
print("\nPlease let us know if there are any questions about the calculation. Thank you sincerely.")