How I developed a fully functional Purchasing Application using Python
source link: https://towardsdatascience.com/how-i-developed-a-fully-functional-purchasing-application-using-python-282e4b18114a
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How I developed a fully functional Purchasing Application using Python
Purchase Order entry, send it to your supplier, and receive the product in your warehouse
Python is the most famous language when it comes to data: right from data integration to analysis to prediction. Considering it is open source, there are developers developing new libraries, bringing in new capabilities. One such capability is developing new applications.
In this article, I will explain how I developed a fully functional purchasing application using Python.
Before we delve into application development components, let’s understand the overall flow of purchasing process.
- Your company enters the purchase order
- It sends the purchase order to the company’s supplier. A copy of the same purchase order is sent to your company’s warehouse.
- The supplier ships the goods to the company’s warehouse. The warehouse receives the goods against the purchase order they got in the above step.
At the minimum, the purchasing application needs the below components:
- Purchasing application for entering new purchase orders and inquiring about existing purchase orders.
- Purchase order report that is sent to supplier and warehouse
Application Development
When it comes to developing python applications, there are numerous libraries and frameworks available. The below image shows the list of python frameworks available based on the kind of applications.
If you are new to Python, I suggest using the Tkinter framework. It’s easy to use and just what you need to develop a desktop application. I have used it for developing the purchasing application.
My purchasing application has a screen with three tabs
- PO Enquiry: Enquire existing purchase orders in this tab. Enter any of these below field values and get matching PO details on the same screen.
- Purchase Order Number (PO#)
- Supplier Number (Supplier#)
- PO Date
- Supplier Name
2. PO Header: Enter purchase order header details in this tab. Purchase order header details contain the below fields.
- Purchase order number (PO#)
- Purchase order date (PO Date)
- Supplier Number (Supplier#)
- Supplier Name
- Delivery address details
- Supplier address details
3. PO Line: Enter purchase order line details. The purchase order line contains the below details.
- Quantity
- Unit Price
- Amount
and other details.
Let’s go through the code for developing this screen with the tabs.
The below code snippet contains Python code for developing the PO inquiry screen.
Let’s understand the code.
The below lines are importing required libraries from the Tkinter framework.
I am developing this application on the Oracle database. The below line of codes connects the application with the Oracle database.
Refer to the below article if you want to know more about connecting the python applications with the Oracle database.
The below line of code creates a window with Title “PO Application” and creates three tabs on this window: PO Enquiry, PO Header, PO Line
The below line of code adds PO#, PO Date, Supplier#, Supplier Name fields to the PO Enquiry tab.
Add window.mainloop() to show your window.
Get the complete code from the Github location mentioned in the reference list.
Report Development
Python provides reportlab for developing picture-perfect professional reports. Below is an image of the purchase order report developed using the reportlab library.
The below code snippet shows the code behind this report.
Let’s understand the code for developing the report.
The first few lines of code are importing the reportlab libraries and cx_Oracle for connection with the database.
Here, connect to the Oracle database and open two cursors: one with purchase order header information and the other with purchase order line details.
Next, create a variable logo and assign the path where the logo image is stored on your computer.
Now open a loop with purchase order header information. SimpleDocTemplate is called with the report file name (podocname+.pdf ) and the size of the report with margin details. In my case, the report file name is made of supplier number — purchase order number- the date when the report was created.
The last line in the below code snippet opens an empty array Story.
Report data will be added to this empty array and this empty array will be added to the report as a paragraph.
Below lines of code add the log to the top right side of the report.
The below lines of code creates an array with the delivery address details and then add that array data to the Story array.
Likewise, the below line of codes adds PO line details to polintab array.
The below lines of code create a table on the report with polintab array data.
Note: Unlike python NumPy array, reportlab tab starts with columns and then rows. So, ‘ALIGN’,(3,0),(5,-1), ‘RIGHT’ indicates right align data from columns 3rd to 5th.
Finally, the below line of codes adds the polintab table to the Story array and shows that table on the report. doc.build(Story) builds the report with Story array data.
Conclusion
It’s been fun developing applications and the report on the Oracle database using Python. Python is a language with limitless possibilities and we are on a journey to explore these potentials.
Although this article shows how to develop purchasing applications, the steps can be used to develop any kind of application on a database using Python.
Looking forward to your feedback!
Reference
https://www.reportlab.com/docs/reportlab-userguide.pdf
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK