munuhee/sales-and-inventory-management
Sobre
Open-source sales and inventory management system in Python/Django: point of sale (POS), stock control, purchase orders, PDF invoices and receipts, billing, loyalty points and role-based staff access. Docker ready.
Negócios e finançasO que você pode fazer
- Point of sale. Search items and customers, see stock while you sell, redeem loyalty points, and get the change worked out. The server prices every sale from the database inside a locked transaction, so totals can't be tampered with and two tills can't oversell the same stock.
- Receipts and invoices as PDF. Professional A4 documents rendered with WeasyPrint. Print opens the PDF in the browser's viewer; Download saves it. A voided sale's receipt carries a VOID watermark.
- Stock that stays correct. Purchase orders add stock only when they are received. Editing or deleting an order adjusts stock by the difference. Stock can never go negative.
- Voids, not deletes. Voiding a sale returns the items to stock and reverses loyalty points. The sale stays on record.
Crescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- +1
- em 15 dias
- Coletando histórico
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalDjango Sales and Inventory Management System (POS)
An open-source sales and inventory management system built with Python and Django. It gives a retail shop a web-based point of sale (POS), stock control, purchase orders, PDF receipts and invoices, billing and customer loyalty points, with role-based access for admins and staff.
Free to use under the MIT license. Runs with Docker or a plain Python virtualenv, and includes demo data so you can try it in minutes.
Table of Contents
- Features
- Roles
- Screenshots
- Installation
- Configuration
- Upgrading an existing database
- Running the tests
- CI and deployment
- Authors
Features
- Point of sale. Search items and customers, see stock while you sell, redeem loyalty points, and get the change worked out. The server prices every sale from the database inside a locked transaction, so totals can't be tampered with and two tills can't oversell the same stock.
- Receipts and invoices as PDF. Professional A4 documents rendered with WeasyPrint. Print opens the PDF in the browser's viewer; Download saves it. A voided sale's receipt carries a VOID watermark.
- Stock that stays correct. Purchase orders add stock only when they are received. Editing or deleting an order adjusts stock by the difference. Stock can never go negative.
- Voids, not deletes. Voiding a sale returns the items to stock and reverses loyalty points. The sale stays on record.
- Loyalty points. Customers earn points on every sale (1 point per Ksh 100 by default) and redeem them as a discount before tax. Every change is logged in a ledger; managers can make recorded corrections.
- Dashboard. Revenue today and this month, stock value, low stock alerts, a 30-day sales chart and recent sales.
- Accounts and security. Capability-based access by role, separately controlled sign-in access, approval workflow for self sign-ups, staff change history, login throttling, immediate sign-out of deactivated staff, and secure production settings: a Content Security Policy with no inline scripts, SRI hashes on every CDN asset, HttpOnly cookies, HSTS and cross-origin isolation headers.
- Exports. Sales, purchases, products and deliveries to Excel (managers only).
Roles
| Role | Can do |
|---|---|
| Operative | Sell, print receipts, view stock and invoices, manage customers and deliveries |
| Executive | Everything above, plus products, categories, purchase orders, vendors, invoices, bills, exports, voiding sales and point adjustments |
| Admin | Everything in Executive, plus staff accounts, account approvals, and staff access management |
Staff sign-in status is separate from employment status. An account can be Active, Inactive, or On leave while sign-in can also be disabled directly. New self sign-ups remain Pending until approved on the Staff page. Admins can create Operative and Executive accounts; only a Django superuser can grant the Admin role or modify/delete an Admin account. Role, status, approval, and sign-in changes are recorded in the Staff access activity log. Django superusers are always Admin; the first one is created from the terminal (see Create the first admin).
Screenshots
Taken from the demo data (seed_demo).
| Dashboard | Point of sale |
|---|---|
![]() |
![]() |
| Receipt (PDF) | Invoice (PDF) |
|---|---|
![]() |
![]() |
Sales and customers
Sales, with voided sales flagged

Sale detail. A summary for staff, with Print, Download and Void actions. The receipt itself only appears as the PDF.

Customers

Customer loyalty history, with the points ledger and manager adjustments

Deliveries

Inventory and purchasing
Products, with low stock and out-of-stock flags

Product detail

New product

Categories

Purchase orders. Stock is added only when an order is received.

New purchase order

Vendors

Finance
Invoices

Invoice detail, with Print and Download PDF

Bills

Staff, roles and sign-in
Staff management, with a pending sign-up waiting for approval

Editing a staff member's role and access

My profile

The cashier's view. Operatives only see the pages their role allows.

Sign in

Request an account. New accounts wait for an Admin to approve them.

Mobile

Installation
git clone https://github.com/munuhee/sales-and-inventory-management.git
cd sales-and-inventory-management
cp .env.example .env # then edit it
With Docker
The image includes the system libraries WeasyPrint needs.
docker build -t sales-and-inventory-management .
docker run -d -p 8000:8000 \
-e SECRET_KEY="change-me" \
-e ALLOWED_HOSTS="localhost,127.0.0.1" \
sales-and-inventory-management
The container runs migrations, then serves the app with Gunicorn. Add -e DEBUG=True for a local trial.
Without Docker
Create a virtual environment and install the dependencies:
python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txtInstall the system libraries WeasyPrint needs to render PDFs:
- Debian/Ubuntu:
sudo apt install libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0 - macOS:
brew install pango - Windows: install the GTK3 runtime, see the WeasyPrint guide.
Everything except PDF generation works without them.
- Debian/Ubuntu:
Set up the database and run the server:
python manage.py migrate python manage.py seed_demo # optional demo data, empty database only python manage.py createsuperuser # or use the demo accounts python manage.py runserver
seed_demo creates the sign-ins admin, manager and cashier, all with the password demo-pass-123. It refuses to run when DEBUG is off.
Create the first admin
A new database has no users, and sign-ups made on the "Request an account" page stay pending until an Admin approves them. So before anyone else can get in, create the first Admin from the terminal:
python manage.py createsuperuser
A superuser is always Active with the Admin role, so it can sign in straight away. Open Staff to approve requests and set each person's role.
The same command works wherever the app runs:
# Docker (use the name or ID shown by "docker ps")
docker exec -it <container> python manage.py createsuperuser
# Azure App Service: open SSH from the portal (Development Tools > SSH).
# The session starts in the app folder, so run
python manage.py createsuperuser
# Terraform VM: SSH in from your admin_cidr range, then
sudo docker exec -it inventory python manage.py createsuperuser
For scripted setups, pass the details as environment variables instead of answering prompts:
DJANGO_SUPERUSER_USERNAME=admin \
[email protected] \
DJANGO_SUPERUSER_PASSWORD='a-long-unique-password' \
python manage.py createsuperuser --noinput
Locked out? python manage.py changepassword <username> resets a password. To make an existing account the Admin, run:
python manage.py shell -c "from django.contrib.auth.models import User; u = User.objects.get(username='<username>'); u.is_superuser = u.is_staff = True; u.save()"
Saving the user as a superuser also activates their profile and gives them the Admin role.
To stop public sign-ups entirely, set ALLOW_REGISTRATION=False. Admins then add staff themselves from the Staff page.
Configuration
All settings come from environment variables (or a .env file). See .env.example for the full list.
| Variable | Purpose |
|---|---|
DEBUG |
True for development. Defaults to False. |
SECRET_KEY |
Required when DEBUG is off. |
ALLOWED_HOSTS, CSRF_TRUSTED_ORIGINS |
Comma separated. On Azure App Service the site host is added automatically. |
DB_HOST, DB_NAME, DB_USER, DB_PASSWORD |
PostgreSQL. SQLite is used when DB_HOST is empty. The AZURE_POSTGRESQL_* names also work. |
ALLOW_REGISTRATION |
Show the "Request an account" page. Defaults to True. |
BUSINESS_NAME, BUSINESS_ADDRESS, BUSINESS_PHONE, BUSINESS_TAX_PIN, BUSINESS_CURRENCY |
Printed on receipts and invoices. |
LOYALTY_EARN_PER, LOYALTY_POINT_VALUE, LOYALTY_MIN_REDEEM, LOYALTY_ENABLED |
Loyalty programme rules. |
Upgrading an existing database
Run python manage.py migrate. The migrations:
- convert money fields from floats to exact decimals, and phone numbers to text;
- mark existing staff accounts Active so nobody is locked out (only new sign-ups need approval), and make superusers Admin;
- clamp any negative stock or loyalty balance to zero;
- record each customer's existing points as an opening balance in the loyalty ledger;
- repair invoice and bill links that had empty slugs.
Running the tests
python manage.py test
PDF tests are skipped if WeasyPrint's system libraries are missing. They run in CI and in the Docker image:
docker run --rm -e DEBUG=True sales-and-inventory-management python manage.py test
CI and deployment
CI runs on every push and pull request to main, with two jobs:
- Lint:
flake8with the settings in .flake8. - Tests:
manage.py check, a check for missing migrations, and the full test suite (PDF tests included).
Deployment is separate from CI. Use the Docker image above, or the Terraform modules:
- terraform/azure: an Ubuntu VM that builds the app image, keeps the database on a Docker volume and serves it through Caddy with automatic HTTPS. SSH is open only to
admin_cidr, and only ports 80 and 443 are public. Pointdomain_nameat thepublic_ipoutput. - terraform/docker: the same image on the local Docker host, published on
127.0.0.1:8080with the database on a named volume.
Wherever it runs, set SECRET_KEY and the database settings, then create the first admin.
Authors
-
Happy coding! 🚀
Explore projetos relacionados
Carregando…



