project.py

 #Making recipt for school

#Here we are importing the modules which are required
from reportlab.platypus import SimpleDocTemplate,Table,Paragraph,TableStyle
from reportlab.lib import colors
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet
#here we are adding the data in the recipt
data=[['Name of the student','Roll Number','Age ','class','paid fee',' payment date','Balance']]
#taking input and addind into data
while True:
          try:
             name=input('Enter name of the student: ')
             roll=int(input('Enter roll number:'))
             age=int(input('Enter age of the student: '))
             cla=input('Enter the class of the student:class ')
             if int(cla)>7 or int(cla)<=0:
                  print('No class exist after 7 th do not enter o class or less than that one')
             reaminig_fee=0
             if  cla.isdigit and 1<=int(cla)<=7:
                  reaminig_fee=9000
             elif cla.islower() in ['nursery','lkg','ukg']:
                    reaminig_fee=3000  
             else:
                  print('Invalid class entered')
                  continue
             paid_fee=int(input('Enter the fee payment of the student:'))
             old=int(input('Enter old balance:'))
             reaminig_fee=old+reaminig_fee
             balance=reaminig_fee-paid_fee            
             day=int(input('(enter numbers only in date) Enter day:'))
             month=int(input('(enter numbers only in date) Enter month:'))
             year=int(input('(enter numbers only in date) Enter year:'))
             date=(f'{day}/{month}/{year}')
             data.append([name,roll,age,cla,paid_fee,date,balance])
             entry=input('Do you want to ener data of another student( Type (yes or no)): ')
             if entry.lower() !='yes':
                  break    
           
          except ValueError:
             print('Enter number only')
   #creating A4 size template          
pdf =SimpleDocTemplate('schoolrecipt.pdf',pagesize=A4)
#adding styles by reportlsb
styles=getSampleStyleSheet()
#style of top level heading
title_style=styles['Heading1']
# 0: left, 1: center, 2: right
title_style.alignment = 1
# creating the paragraph with  
# the heading text and passing the styles of it
title = Paragraph( "Receipt Of Shantiniketan School" , title_style )
# creates a Table Style object and in it,
# defines the styles row wise
# the tuples which look like coordinates  
# are nothing but rows and columns
style = TableStyle(
    [
        ( "BOX" , ( 0, 0 ), ( -1, -1 ), 1 , colors.black ),
        ( "GRID" , ( 0, 0 ), ( -1, -1 ), 1 , colors.black ),
        ( "BACKGROUND" , ( 0, 0 ), ( -1, 0 ), colors.gray ),
        ( "TEXTCOLOR" , ( 0, 0 ), ( -1, 0 ), colors.whitesmoke ),
        ( "ALIGN" , ( 0, 0 ), ( -1, -1 ), "CENTER" ),
        ( "BACKGROUND" , ( 0 , 1 ) , ( -1 , -1 ), colors.beige ),
    ]
)
# creates a table object and passes the style to it
table = Table( data , style = style )
 
# final step which builds the
# actual pdf putting together all the elements
pdf.build([ title , table ])
#o/p is:
'''
Enter name of the student: Faizan Enter roll number:21 Enter age of the student: 19 Enter the class of the student:class 7 Enter old balance:0 (enter numbers only in date) Enter day:2 (enter numbers only in date) Enter month:10 (enter numbers only in date) Enter year:2024 Do you want to ener data of another student( Type (yes or no)): no PS C:\project.py>
#new format:
#Making recipt for school
#Here we are importing the modules which are required
from reportlab.platypus import SimpleDocTemplate,Table,Paragraph,TableStyle
from reportlab.lib import colors
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet
#here we are adding the data in the recipt
data=[['Name of the student','Roll Number','Age ','Class','Paid fee',' Payment date','Old Balance',' New Balance']]
#taking input and addind into data
while True:
          try:
             name=input('Enter name of the student: ').strip().capitalize()
             roll=int(input('Enter roll number:').strip())
             age=int(input('Enter age of the student: ').strip())
             cla=input('Enter the class of the student: ').strip().lower()
             remaining_fee = 0
             if cla in ['nursery', 'lkg', 'ukg']:
               remaining_fee=3000

             elif cla.isdigit() and 1 <= int(cla) <= 7:
               remaining_fee=9000

             elif cla.isdigit() and int(cla) > 7:
              print('No class exist after 7th do not enter o class or less than that one')
             else:
               print('Invalid class entered')
               continue
             paid_fee=int(input('Enter the fee payment of the student:').strip())
             old=int(input('Enter old balance:').strip())
             reaminig_fee=old+remaining_fee
             balance=reaminig_fee-paid_fee            
             day=int(input('(Enter numbers only in date) Enter day:').strip())
             month=int(input('(Enter numbers only in date) Enter month:').strip())
             year=int(input('(Enter numbers only in date) Enter year:').strip())
             date=(f'{day}/{month}/{year}')
             data.append([name,roll,age,cla,paid_fee,date,old,balance])
             entry=input('Do you want to ener data of another student( Type (yes for y or no for n (in lowercase only))): ').strip().lower()
             if entry.lower() =='n':
                  break
             elif entry.lower()=='y':
                  continue
             else:
                  print('Invalid  value Entered')    
          except ValueError :
             print('Enter numbers only')
   #creating A4 size template          
pdf =SimpleDocTemplate('schoolrecipt.pdf',pagesize=A4)
#adding styles by reportlsb
styles=getSampleStyleSheet()
#style of top level heading
title_style=styles['Heading1']
# 0: left, 1: center, 2: right
title_style.alignment = 1
# creating the paragraph with  
# the heading text and passing the styles of it
title = Paragraph( "Bill Receipt Of Shantiniketan School" , title_style )
# creates a Table Style object and in it,
# defines the styles row wise
# the tuples which look like coordinates  
# are nothing but rows and columns
style = TableStyle(
    [
        ( "BOX" , ( 0, 0 ), ( -1, -1 ), 1 , colors.black ),
        ( "GRID" , ( 0, 0 ), ( -1, -1 ), 1 , colors.black ),
        ( "BACKGROUND" , ( 0, 0 ), ( -1, 0 ), colors.gray ),
        ( "TEXTCOLOR" , ( 0, 0 ), ( -1, 0 ), colors.whitesmoke ),
        ( "ALIGN" , ( 0, 0 ), ( -1, -1 ), "CENTER" ),
        ( "BACKGROUND" , ( 0 , 1 ) , ( -1 , -1 ), colors.beige ),
    ]
)
# creates a table object and passes the style to it
table = Table( data , style = style )
 
# final step which builds the
# actual pdf putting together all the elements
pdf.build([ title , table ])
 

'''





Comments

Popular posts from this blog

py2