INDEX
SR PAGE NO.
NO. TOPIC
1 Acknowledgement 1
2 PREFACE 2
3 Working description: 3
MINIMUM HARDWARE AND 4
4 SOFTWARE REQUIREMENTS
5 INTRODUCTION OF PYTHON 5
6 CLASSES 6
&
FUNCTIONS
&
BINARY FILE
7 SOURCE CODE 7-19
9 OUTPUT 20-26
Acknowledgement
I would like to express my special thanks of gratitude to my
teacher (Mr. Subhabrata Sarkar and Mr. Krishna Bag) as well
as our Principal (Mr. Palash Kumar Saha), who gave us the
golden opportunity to do this wonderful project on the topic
(Telephone Billing Payment System), which also helped us in
doing a lot of Research and we came to know about so many
new things we are really thankful to them. Secondly, we would
also like to thank our parents and friends who helped us a lot
in finalizing this project within the limited time frame.
1|Page
PREFACE
The TELEPHONE BILLING SOFTWARE helps to minimize the
use of paper and it is better to use software instead of paper
because by using software we can get instant result, we can
save a lot of papers. Managing paper is more difficult than to
store things on computer.
The purpose of the project is to present the requirement of the
computerization of TELEPHONE BILLING MANAGEMENT. The
project thus manage the telephone details automatically it
does almost every work which is related to automatic
management of telephone billing via - new telephone detail,
updating of detail, modification of detail, viewing customer
record. TELEPHONE BILLING MANAGEMENT is developed as
per seeing the increasing culture. Thus a new software has
been proposed to reduce manually work, improving work
efficiency, saving time and to provide greater flexibility and
user friendliness.
2|Page
Working description:
This program is designed to keep the telephone bill records.
This program consist of SIX options as follows:
1 To add new telephone record
2 To see all records
3 For enquiry
4 To modify record
5. To delete record
6. To exit
3|Page
MINIMUM HARDWARE AND
SOFTWARE REQUIREMENTS
Operating System: - Windows XP, Vista, 7.
Processor: - Pentium III/1.4GHz Processor.
RAM: 512MB.
Hard Disk Space: - 10.2 GB space required.
Software required: - Python
4|Page
INTRODUCTION OF PYTHON
Python was created by Guido Van Rossum when he was working at CWI
(Centrum Wiskunde & Informatica) which is a National Research
Institute for Mathematics and Computer Science in Netherlands. The
language was released in I991. Python got its name from a BBC comedy
series from seventies- “Monty Python‟s Flying Circus”. Python can be
used to follow both Procedural approach and Object Oriented approach
of programming. It is free to use. Some of the features which make
Python so popular are as follows:-
• It is a general purpose programming language which can be used
for both scientific and non scientific programming.
• It is a platform independent programming language.
• It is a very simple high level language with vast library of add-on
modules.
• It is excellent for beginners as the language is interpreted, hence
gives immediate results.
• The programs written in Python are easily readable and
understandable.
• It is suitable as an extension language for customizable
applications.
• It is easy to learn and use
5|Page
CLASSES
Classes are the group of objects with same attributes
and common behaviour. A class is basically a blueprint
for creating an object in abject oriented programming
language like python. Classes allow data encapsulation
as it combines the objects and the associated functions
into a single unit itself. Syntax to define a class in
python is as follows:- class : statement 1 statement 2
FUNCTIONS
Functions is a set of instructions enclosed in a single
unit which can be executed as and when required by
calling the function. Syntax:- def : statement1
statement2
BINARY FILE
The binary file contains arbitrary binary data.the
numbers in a binary file can be used for numerical
operations. Therefore while working on an arbitrary file
we have to convert the binary pattern into the desired
data type as required by our program.Special methods
like LOAD and DUMP help to accomplish this task
6|Page
SOURCE CODE
#=======================================================
# TELEPHONE BILLING SYSTEM
#=======================================================
class customer:
cno=''
ph=''
name=''
addr=''
city=''
def getdata(self):
import os
os.system('cls')
print("\n"*4)
self.ph=int(input("\n\t\t\tEnter The 8 Digit Telephone No. :"))
self.cno=int(input("\n\t\t\tEnter The Consumer No:"))
self.name=input("\n\t\t\tEnter Name:")
self.city=input("\n\t\t\tEnter City:")
self.addr=input("\n\t\t\tEnter Address:")
self.type=input('''\n\t\t\tEnter 'O' for Office Or
'Enter' for residential:''')
if self.type.upper()=='O':
self.type='Office'
else:
self.type='Home '
def showdata(self):
7|Page
import os
os.system('cls')
print("\n"*4)
print("\t\t\tPhone No:",self.ph)
print("\t\t\tConsumer No:",self.cno)
print("\t\t\tName:",self.name)
print("\t\t\tCity:",self.city)
print("\t\t\tAddress:",self.addr)
print("\t\t\tType:",self.type)
def showcust(self):
print("\t\t",self.ph,"\t",self.cno,"\t",self.type," ",self.name)
#======================================================
#CLASS TO CALCULATE AND DISPLAY THE BILL
#=======================================================
class bill:
def _init_(self):
customer._init_(self)
self.ffcalls=100
self.oprd=''
self.clrd=''
self.mcalls=0
self.fcalls=100
self.credit=''
self.debits=''
self.chargec=0
self.chargem=0
self.tax=0
8|Page
self.grossamt=0
self.surcharge=20
self.netamtbef=0
self.netamtaft=0
self.c=0
self.found=False
#=======================================================
# FUNCTION TO CALCULATE THE BILL
#=======================================================
def calbill(self):
import pickle
self.c=customer()
self.file=open("bill.dat","rb")
self.phone=''
import os
os.system('cls')
print("\n"*4)
while self.phone=='':
self.phone=input("\n\t\t\tEnter Telephone No. :")
self.phone=int(self.phone)
self.found=False
try:
while True:
self.c=pickle.load(self.file)
if self.c.ph==self.phone:
self.found =True
break
9|Page
except EOFError:
pass
if self.found==False:
print("\n\t\t\tTelephone Number Not Found In The Records")
input("\n\t\t\tPress Any Key To Continue")
return
self.file.close()
self.ffcalls=100
while self.oprd=='':
self.oprd=input("\n\t\t\tEnter The Open Meter Reading:")
while self.clrd=='':
self.clrd=input("\n\t\t\tEnter The Close Meter Readng:")
self.oprd=int(self.oprd)
self.clrd=int(self.clrd)
self.mcalls=self.clrd-self.oprd
if self.mcalls<self.fcalls:
self.chargec=0
self.chargem=0
else:
self.chargec=self.mcalls-self.fcalls
self.chargem=self.chargec*0.80
while self.debits=='':
self.debits=input("\n\t\t\tEnter Debits If Any:")
self.debits=int(self.debits)
self.tax=int((self.chargem+self.debits)/20)
self.grossamt=self.chargem+self.tax+self.debits
while self.credit=='':
10 | P a g e
self.credit=input("\n\t\t\tEnter Credits If Any:")
self.credit=int(self.credit)
if self.credit>self.grossamt:
self.netamtbef=0
self.surcharge=0
else:
self.netamtbef=self.grossamt-self.credit
self.netamtaft=self.netamtbef+self.surcharge
#=======================================================
# FUNCTION TO CALCULATE THE BILL
#=======================================================
def dispbill(self):
import os
os.system('cls')
print("\n"*4)
if self.found:
print("\n")
print("="*31,"Telephone Bill","="*32)
print("Name:",self.c.name)
print("-"*79)
print("Address:",self.c.addr)
print("="*79)
print("Telephone Number",end=' '*3)
print("Consumer Number",end=' '*3)
print("Previous reading",end=' '*3)
print("Current reading:")
print("="*79)
11 | P a g e
print(self.c.ph,end=' '*11)
print(self.c.cno,end=' '*12)
print(self.oprd,end=' '*18)
print(self.clrd)
print("-"*79)
print("Metered Calls"," "*30,":"," "*9,self.mcalls)
print("Free Calls"," "*33,":"," "*9,self.fcalls)
print("Chargable calls"," "*28,":"," "*9,self.chargec)
print("Debits"," "*37,":"," "*9,self.debits)
print("Taxes"," "*38,":"," "*9,self.tax)
print("Gross Amount"," "*31,":"," "*9,int(self.grossamt))
print("Credits"," "*36,":"," "*9,self.credit)
print("-"*79)
print("Amount payable before"," "*22,":"," "*9,int(self.netamtbef))
print("-"*79)
print("Surcharge"," "*34,":"," "*9,self.surcharge)
print("-"*79)
print("Amount payable after"," "*23,":"," "*9,int(self.netamtaft))
print("="*79)
input("\n\t\t\tPress any key to continue")
#=======================================================
# FUNCTION TO ADD A NEW CUSTOMER
#=======================================================
def addrec():
import pickle
file=open("bill.dat",'ab')
c=customer()
12 | P a g e
import os
while True:
os.system('cls')
print("\n"*4)
c.getdata()
pickle.dump(c,file)
ch=input("\n\t\t\tDo You Want To Enter More Records:")
if ch.upper()=='N':
break
file.close()
#=======================================================
# FUNCTION TO SHOW ALL THE CUSTOMERS FROM THE FILE
#=======================================================
def showrec():
import pickle
file=open('bill.dat','rb')
c=customer()
import os
os.system('cls')
print("\n"*4)
print("\t\tPhone No.\t Consumer No.\t Type\t Name")
try:
while True:
c=pickle.load(file)
print('\n')
c.showcust()
except EOFError:
13 | P a g e
pass
file.close()
input("\n\t\t\tPress Any Key To Continue")
def searchrec():
import pickle
file=open("bill.dat","rb")
c=customer()
import os
os.system('cls')
print("\n"*4)
phn=int(input("\n\t\t\tEnter The Telephone No. :"))
found=False
try:
while True:
c=pickle.load(file)
if phn==c.ph:
found=True
break
except EOFError:
pass
if found:
c.showdata()
input("\n\t\t\tPress Enter To Continue")
else:
print("\n\t\t\tRecord not found:")
input("\n\t\t\tPress Enter To Continue")
file.close()
14 | P a g e
#=======================================================
# FUNCTION TO DELETE RECORD OF A CUSTOMER FROM THE FILE
#=======================================================
def delrec():
import pickle
import os
file=open("bill.dat","rb")
temp=open('temp.dat','ab')
import os
os.system('cls')
print("\n"*4)
phone=int(input("\n\t\t\tEnter The Phone Number:"))
c=customer()
try:
while True:
c=pickle.load(file)
if c.ph==phone:
print("\n\t\t\tRecord Successfully Deleted")
c.showdata()
input("\n\t\t\tPress any key to continue")
pass
elif c.ph!=phone:
pickle.dump(c,temp)
except EOFError:
pass
file.close()
temp.close()
15 | P a g e
os.remove('bill.dat')
os.rename('temp.dat','bill.dat')
#=======================================================
# FUNCTION TO MODIFY DETAILS OF A CUSTOMER
#=======================================================
def modrec():
import pickle
file = open("bill.dat", 'rb')
clist = list()
i=0
c = customer()
import os
os.system('cls')
print("\n"*4)
phn = int(input("\n\t\t\tEnter The Telephone Number : "))
try:
while True :
c = pickle.load(file)
clist.append(c);
except EOFError :
pass
file.close()
found = False
i=0
for c in clist :
if ( c.ph==phn ) :
found = True
16 | P a g e
break
else :
i = i+1
if ( not found ) :
print("\n\t\t\tInvalid Phone Number ")
return
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\tEnter The New Details About The Customer:")
clist[i].getdata()
file = open("bill.dat", 'wb')
for c in clist :
pickle.dump(c,file)
file.close()
#=======================================================
# MAIN MENU
#=======================================================
def menu():
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\t\tMAIN MENU")
print("\n\t\t\tPress 1 : To Generate a Bill")
print("\n\t\t\tPress 2 : To List all Customers")
print("\n\t\t\tPress 3 : To Manage Customers")
print("\n\t\t\tPress 4 : To Exit")
17 | P a g e
#=======================================================
# CUSTOMER MENU
#=======================================================
def menurec():
import os
os.system('cls')
print("\n"*4)
print("\n\t\t\t\tCUSTOMER MENU")
print("\n\t\t\tPress 1 : To List All Customer")
print("\n\t\t\tPress 2 : To Add a Customer")
print("\n\t\t\tPress 3 : To Show Details About A Customer")
print("\n\t\t\tpress 4 : To Delete a Customer")
print("\n\t\t\tPress 5 : To Modify a Existing Customer")
print("\n\t\t\tPress 6 : To Go Back To Previous Menu")
#=======================================================
# MAIN
#=======================================================
opt=0
while opt!=4:
menu()
opt=int(input("\n\t\t\tEnter Your Choice:"))
if opt==1:
b=bill()
b.calbill()
b.dispbill()
elif opt==2:
showrec()
18 | P a g e
elif opt==3:
ropt=0
while ropt!=4:
menurec()
ropt=int(input("\n\t\t\tEnter Your Choice:"))
if ropt==1:
showrec()
elif ropt==2:
addrec()
elif ropt==3:
searchrec()
elif ropt==4:
delrec()
elif ropt==5:
modrec()
elif ropt==6:
break
else:
print("\n\t\t\tInvalid Choice")
input("\n\t\t\tPress Any Key To Continue")
elif opt==4:
print("\n\t\t\tGood Bye")
input("\n\t\t\tPress Any Key To Continue")
break
else:
print("\n\t\t\tInvalid Choice") input(“\n\t\t\tPress Any Key To Continue”)
19 | P a g e
OUTPUT
20 | P a g e
21 | P a g e
22 | P a g e
23 | P a g e
24 | P a g e
25 | P a g e
26 | P a g e