Dependencies
Relevant source files
The following files were used as context for generating this wiki page:
The pos-tioadan project is composed of two main components: the core Point of Sale (POS) desktop application and an optional, standalone Telegram notification service. Each component has its own set of dependencies, which are managed through a central requirements.txt file and installed using a batch script. The project relies on a mix of Python standard libraries for core functionality and third-party packages for features like PDF generation, Excel file handling, and API communication.
This document outlines the dependency structure, installation process, and build requirements for both the core application and the notification service.
Sources: CLAUDE.md, requirements.txt, README_Notifications.txt
Dependency Overview
The project's dependencies are split between the core pos_app.py and the notification_service.py. The requirements.txt file lists all third-party packages for both.
This diagram illustrates the relationship between the project components and their primary dependencies.
Third-Party Dependencies
The external Python packages required by the project are defined in requirements.txt.
# POS Application dependencies
fpdf2>=2.7.0
openpyxl>=3.1.0
# Notification Service dependencies (optional)
requests>=2.31.0
pytz>=2023.3
Sources: requirements.txt
The following table summarizes these dependencies and their roles within the project.
| Library | Version | Component | Purpose | Source Files |
|---|---|---|---|---|
fpdf2 | >=2.7.0 | Core App | Generates PDF receipts and daily sales reports. | requirements.txt:2, pos_app.py:6, 1726 |
openpyxl | >=3.1.0 | Core App | Imports product data from .xlsx Excel files. | requirements.txt:3, pos_app.py:7, 2191 |
requests | >=2.31.0 | Notification Service | Communicates with the Telegram Bot API to send messages. | requirements.txt:6, notification_service.py:14, 401 |
pytz | >=2023.3 | Notification Service | Handles timezones for scheduling daily reports. | requirements.txt:7, notification_service.py:15, 545 |
Core Application Dependencies
The main POS application (pos_app.py) is a monolithic Tkinter application. Its dependencies enable the GUI, database interaction, and feature-specific functionalities like reporting and data import.
Sources: pos_app.py, CLAUDE.md
Standard Libraries
The application relies heavily on libraries included with standard Python installations.
tkinter: The primary library for the graphical user interface (GUI), includingttkfor themed widgets.
Sources: pos_app.py:2sqlite3: Used for all database operations, managing thepos_inventory.dbfile which containsproductsandsalestables.
Sources: pos_app.py:4, 25datetime: Handles timestamps for sales records and report generation dates.
Sources: pos_app.py:5, 319os: Manages file paths, primarily for creating and accessing thereceipts,reports, anderror_logsdirectories.
Sources: pos_app.py:8, 626decimal: Ensures precise rounding of monetary values to one decimal place, avoiding floating-point inaccuracies.
Sources: pos_app.py:9, 12
Third-Party Libraries
fpdf2: This library is used to generate PDF documents. Inpos_app.py, it creates compact, thermal-style receipts for individual sales and standard A4-sized daily sales summary reports.
Sources: pos_app.py:6, 1726, 1785openpyxl: Enables the "Importar XLSX" feature, which reads product data from an Excel spreadsheet. It is configured to read calculated values from formulas (data_only=True).
Sources: pos_app.py:7, 2191, 2200
Notification Service Dependencies
The notification_service.py is a standalone script that monitors the POS database and sends alerts via Telegram. It runs in a separate process and has its own dependencies for networking and scheduling.
Sources: notification_service.py, README_Notifications.txt
Standard Libraries
sqlite3: Connects to the mainpos_inventory.dbin read-only mode and manages its own state database (notification_state.db).
Sources: notification_service.py:9, 41json: Loads configuration settings (bot token, chat ID) fromconfig.json.
Sources: notification_service.py:7, 342threading: Manages concurrent operations for monitoring zero-stock products, scheduling daily reports, and performing health checks.
Sources: notification_service.py:11, 600logging: Provides robust logging to both the console and rotating log files (logs/service.log,logs/error.log).
Sources: notification_service.py:8, 355
Third-Party Libraries
requests: The key dependency for sending notifications. It makes HTTP POST requests to the Telegram Bot API'ssendMessageendpoint.
Sources: notification_service.py:14, test_telegram.py:8pytz: Used to handle timezones correctly when scheduling the daily report, ensuring it runs at the configured time regardless of the server's local timezone.
Sources: notification_service.py:15, 545
Installation and Build
The project includes batch scripts to simplify dependency installation and the creation of a distributable executable.
Dependency Installation
The install_dependencies.bat script automates the setup process for the notification service.
This diagram shows the installation flow initiated by the user.
The script first verifies that Python is available in the system's PATH and then uses pip to install all packages listed in requirements.txt.
Sources: install_dependencies.bat:15, 21
Executable Build Process
The build_exe.bat script uses PyInstaller to package the core POS application (pos_app.py) into a single .exe file for easy distribution on Windows.
The build process is as follows:
- Clean: Removes previous build artifacts (
build/,dist/,*.spec). - Build: Runs
PyInstallerwith specific flags. - Result: The final
POS_TioAdan.exeis placed in thedist/folder.
pyinstaller --onefile --windowed --name="POS_TioAdan" ^
--hidden-import=openpyxl ^
--hidden-import=fpdf ^
pos_app.py
Key PyInstaller flags used:
--onefile: Creates a single executable file.--windowed: Prevents a console window from appearing when the GUI application is run.--name: Sets the name of the output executable.--hidden-import: Explicitly includesopenpyxlandfpdfto ensure they are bundled into the executable, as they might be missed by PyInstaller's static analysis. Note that the source file usesfpdfas the hidden import name, which corresponds to thefpdf2library.
Sources: build_exe.bat:16, 21-24