Price List Application (Flask, SQLAlchemy, pyQT4)

My elder brother needed an application to manage price lists of his wholesalers and dealers. Products’ prices that he is following are subject to change daily because exchange rates may change daily and it may be very hard to find optimal price for a product if it can be obtained from multiple dealers. So I decided to help him with an software solution. Price lists and displays support utf-8 (as they can be seen in screenshots – Russian language price lists are used for tests).

Solution’s architecture is simple. We have one back-end application runs as server. Back-end is responsible to manage database connections, client’s requests and authentication&authorization things. Then I thought it is better for server to speak RESTful, because mobile applications and MVW web frameworks (like angular) can be implemented to use this back-end. Off course it has many points to be fixed but code is written in 5 days. License is MIT and please feel free to contact me if you have any questions.

For front-end I decided to use python for programming language and pyQT4 for GUI framework. I used requests package to make RESTful calls to backend.

Design decisions made pretty easy because price lists are in excel format. They have product description and price columns. So GUI is responsible to read these excel files, send them to backend and backend stores them in database. When a product is searched back-end queries products and returns the results RESTful answer.

So, first things first. I added models for backend to store different companies. Each company may have more than one price lists, so I added one-to-many price lists for a company. Each price list would have products, so we have one-to-many relationship here as well.

I added company add, company edit and company delete functionality to front-end and back-end. Cascaded delete operations are configured with sqlalchemy. There is a special function in main application menu called “rebuild price lists” which reads registered price lists and send them to back-end. This should only be done when price lists need to be updated.

Username, password authentication is added, and changing password is added as well.

Exchange rate, sales commission rate (percentage) and back-end RESTful API endpoint GUI are added for flexibility.

Simple bucket window is added to export bucket items to excel is supported.

Searching is done with OR clause and every keyword in search terms should be more than 2 letters, otherwise they are ignored in the query.

For pyqt4 part, I designed ui files using QT4 Designer, and used resource file editor in it. Then I issued

pyuic xyz.ui > ui_xyz.py

to generate ui class files. Then I inherited ui_xyz.py files in xyz.py files as main coding class. This way if I redesigned my ui file in designer, I would not have to change my xyz.py file, because pyuic compiler will rebuild ui_xyz.py.

I also used resources compiler similar way.

Virtual environment is highly recommended for developers!

I used docker based mariadb for database, required commands to run docker can be found in codebase (under db folder).

That’s it, here I give you some screenshots for the application and related source repos.

pricelist_backend: https://bitbucket.org/iclykofte/pricelist_backend

pricelist_frontend: https://bitbucket.org/iclykofte/pricelist_frontend

 

Leave a Reply

Your email address will not be published. Required fields are marked *