Skip to content
eddierXdevPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Resale Manager

Offline-first desktop application for independent resellers.

Business Flow

Capital → Purchases → Orders → Inventory → Sales → Profit → Reinvestment

V1 Highlights

  • Products and flexible variants
  • FIFO inventory costing
  • Inventory lots and movement history
  • Purchase/order tracking
  • Partial order receipt
  • Optional acquisition costs
  • Full-payment sales and purchases
  • Customer returns/refunds
  • Supplier returns/refunds
  • Accounts, capital and operating expenses
  • Multi-currency
  • Manual and automatic exchange rates
  • Offline-first operation
  • Analytics
  • Backup and restore

Documentation

Read in this order:

  1. docs/REQUIREMENTS.md
  2. docs/ARCHITECTURE.md
  3. docs/DATABASE.md
  4. docs/ERD.md
  5. docs/TECH_STACK.md
  6. docs/ROADMAP.md
  7. docs/ANALYTICS.md

Current State

Phases 0-14 are complete (bootstrap through hardening). Phase 12 (Desktop UI), Phase 13 (Backup / Restore / Export) and Phase 14 (Hardening) include a fully navigable desktop application, portable Windows executable and the following capabilities:

  • Python virtual environment support
  • pyproject.toml with SQLAlchemy, Alembic, pydantic-settings, httpx and PySide6
  • SQLite engine/session with foreign-key enforcement
  • Exact Decimal storage on SQLite (no binary float)
  • Currency, Money and ExchangeRate domain objects
  • Manual rate storage with append-only history
  • Account/operation currency compatibility rules
  • Categories, products and product variants
  • Flexible attributes and variant attribute values
  • Unique SKUs and non-destructive product/variant deactivation
  • CreateProduct use case with automatic default variant
  • Accounts with one native currency and non-destructive deactivation
  • Signed financial ledger with fixed inflow/outflow rules
  • Capital contributions and withdrawals linked to their ledger entries
  • Exact balance derivation from signed ledger amounts
  • Same-currency transfers and explicit cross-currency exchange
  • Historical exchange rates preserved by every currency exchange
  • Suppliers with non-destructive deactivation
  • Purchases, purchase items, additional costs and cost allocations
  • Full-payment purchases linked to PURCHASE ledger entries
  • Purchase status transitions with protected receipt states
  • Exact allocation by quantity, value, weight or manual amounts
  • Foreign-currency cost normalization using historical exchange rates
  • Inventory lots with FIFO ordering and immutable acquisition data
  • Traceable inventory movements with fixed inflow/outflow signs
  • Partial and multiple purchase receipts with over-receipt rejection
  • Received quantity and purchase status derived from inventory lots
  • Lot unit cost including allocated purchase costs
  • Current stock queries per product variant
  • Fully collected sales with account/sale currency compatibility
  • FIFO lot selection across multiple lots with exact exhaustion
  • Immutable SaleItemLotAllocation cost snapshots for historical COGS
  • Atomic inventory reduction, SALE movements and SALE ledger entries
  • Revenue, COGS and gross-profit calculation without implicit FX
  • Customer returns against an original sale with partial-return support
  • SELLABLE returns restore the historical lot with CUSTOMER_RETURN movements
  • DAMAGED returns are recorded without increasing sellable stock
  • Partial FIFO reversal from the most recently consumed sale allocation
  • Customer refunds with CUSTOMER_REFUND ledger entries and sale status updates
  • Supplier returns against the original purchase item and exact inventory lot
  • Partial supplier returns with negative SUPPLIER_RETURN inventory movements
  • Historical lot unit cost snapshotted without rewriting the original purchase
  • Supplier refunds with positive SUPPLIER_REFUND ledger entries and purchase currency checks
  • Operating expenses with documented categories, optional descriptions and notes
  • Expenses paid from an active account in its native currency
  • Negative EXPENSE ledger entries linked to their originating expense
  • Expenses kept separate from purchase acquisition costs
  • Capital contributions and withdrawals kept separate from operating expenses
  • Replaceable ExchangeRateProvider port for exchange-rate observations
  • ManualRateProvider backed by locally stored manual rates
  • ElToqueProvider isolated in Infrastructure and configured by token, URL and timeout
  • SetManualExchangeRate use case for first-class manual rate records
  • UpdateExchangeRates persists successful automatic observations locally
  • ResolveExchangeRate provides offline lookup with source, timestamp and age
  • Stale rates are explicitly identified and can be rejected by callers
  • Provider failures fall back to stored rates instead of blocking the app
  • Manual-only operation remains the default; online FX is optional
  • Historical exchange-rate lookup at or before a reporting cutoff
  • Period analytics with product, category, supplier, customer, currency and account filters
  • Revenue net of item/sale discounts and customer-return value
  • FIFO historical COGS net of returned FIFO cost
  • Gross profit, operating expenses, net profit and margins in native currencies
  • Cross-currency sales excluded from native profit instead of using implicit FX
  • Customer refunds and supplier refunds reported separately without double counting
  • Current inventory value, best sellers, most profitable products and slow-moving stock
  • Supplier profitability with revenue/COGS attribution, volume and refunds
  • Native account balances at a reporting cutoff
  • Base-currency consolidated reporting with direct stored rates, explicit missing-rate reporting and cash-capital ROI
  • BASE_CURRENCY and ANALYTICS_SLOW_MOVING_DAYS configuration
  • PySide6 desktop shell with sidebar navigation and one screen per section
  • Use-case-driven screens that never read the database, select FIFO lots or calculate balances, COGS or profit in the presentation layer
  • Products screen with catalog search, inactive-product toggle and refresh
  • Create/edit product dialogs with category, brand, default price, currency and an optional initial variant
  • Product activation/deactivation without deleting catalog history
  • Variant management with SKU, barcode, activation and attribute values
  • Attribute management with reusable attributes and values
  • Create-category dialog from the product catalog screen
  • Read-only product and variant table models; the UI formats values but never calculates prices, stock or profit
  • Accounts screen with native-currency balances, search and inactive filter
  • Create-account dialog with native currency, type and notes
  • Account activation/deactivation without deleting ledger history
  • Purchases screen with supplier, order, item count, total, payment state and logistics status, plus search and status filtering
  • Create-purchase dialog with supplier creation, optional immediate full payment, multiple items and automatic additional-cost allocation
  • Read-only purchase detail with item lines, normalized costs and totals
  • Full-payment and logistics-status dialogs driven by the existing purchase use cases, without duplicating financial rules in the UI
  • Receiving screen for purchases in transit with partial or complete receipts and per-line remaining quantities
  • Inventory screen with stock, traceable lots and signed movement history
  • Sales screen with FIFO allocation, historical COGS and read-only sale detail
  • Returns screen for customer and supplier returns, including exact sale lines, purchase lots and optional refunds
  • Expenses & Capital screen for expenses, contributions, withdrawals, same-currency transfers and explicit currency exchanges
  • Currency Rates screen with latest-rate freshness, append-only history and manual observation entry
  • Dashboard with base-currency KPIs, missing-rate warnings, account balances, best sellers and slow-moving stock
  • Analytics screen with optional period filters, profitability, slow-moving and supplier reports
  • Settings screen showing the effective environment configuration
  • Local SQLite backups created through SQLite's consistent online backup API
  • Restore validation for SQLite integrity, foreign keys, schema revision and required tables
  • Automatic pre-restore safety backup and in-place atomic restore
  • Backup folder persisted with the application data; default configured through BACKUP_DIRECTORY
  • ZIP export of selected accounts, inventory, purchases, sales and returns as UTF-8 CSV files
  • Settings actions for changing the backup folder, creating/restoring backups and exporting selected business information
  • Reusable read-only table model and form helpers for consistent screens
  • Application-level UnitOfWork boundary with a SQLAlchemy implementation, so screens never open sessions or commit transactions
  • Alembic migrations with the initial currencies seeded
  • Pending migrations applied automatically before the UI or diagnostics start
  • Compound indexes for ordered purchase-item, variant and lot history queries
  • Corrupt databases, invalid backup folders and unsafe restores fail with a clear error instead of partially opening the application
  • Portable PyInstaller desktop build with migrations bundled inside the executable distribution
  • pytest test suite (domain, application, integration and presentation)

V1 status:

Phase 14 — Hardening (complete)
✔ Full suite and clean-database migration checks
✔ Corrupted/invalid input and offline-mode checks
✔ Stale FX and backup/restore checks
✔ Query indexes and SQLite query-plan review
✔ Desktop executable packaging

Completed:

Phase 13 — Backup / Restore / Export
✔ Local SQLite backup
✔ Restore validation
✔ Basic ZIP/CSV export
✔ Backup location setting
✔ Automatic pre-restore safety backup

Phase 12 — Desktop UI
✔ App shell and navigation
✔ Products screen (list, search, create/edit/deactivate, variants, attributes)
✔ Accounts screen (native balances, create and deactivate)
✔ Purchases screen (list, search, create, costs, payments, status, suppliers)
✔ Receiving screen (partial and complete receipts)
✔ Inventory screen (stock, lots, movements)
✔ Sales screen (FIFO sales, COGS and detail)
✔ Returns screen (customer and supplier returns)
✔ Expenses & Capital screen (expenses, capital, transfers, exchanges)
✔ Currency Rates screen (latest, history and manual rates)
✔ Dashboard (base-currency KPIs and product highlights)
✔ Analytics (period filters, profitability and supplier reports)
✔ Settings (effective configuration, backup/restore and export actions)

FIFO allocations are immutable and remain the source of truth for historical sale COGS. Supplier return items reference their exact inventory lot and snapshot its historical unit cost; the original purchase is never rewritten. Expenses never modify historical purchase costs. Exchange-rate providers never invent missing rates or overwrite historical observations.

Backup restore is intentionally schema-strict: a backup must match the current schema revision. After an application upgrade, create a fresh backup; older backups are rejected instead of risking an inconsistent restore.

Getting Started

python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev]"

copy .env.example .env

python -m app.main              # applies migrations and opens the UI
python -m app.main --check      # applies/verifies the schema and exits
pytest

On POSIX systems, replace the activation and copy commands with:

source .venv/bin/activate
cp .env.example .env

Desktop Executable (Windows)

Build a portable, one-folder executable with PyInstaller:

.\scripts\build_desktop.ps1 -Clean

The build script installs PyInstaller when missing, bundles the Alembic migrations and copies .env.example and this README beside the executable. The result is:

dist\ResaleManager\ResaleManager.exe
dist\ResaleManager\data\resale_manager.db   # created on first launch

Builder note: build_desktop.ps1 recreates dist\ResaleManager, so do not rebuild over a folder that contains live business data. Copy the built folder to a separate location for daily use.

The executable is portable as a folder: copy or move the complete dist\ResaleManager directory together, not only the .exe. It uses its own directory as the working directory, so data/ and backups live beside the executable. Place an optional .env in the same folder to override settings. Database migrations run automatically on first launch and after upgrades.

For diagnostics without opening the UI, run --check. Because release builds are windowed, the report is also written beside the executable:

dist\ResaleManager\ResaleManager.exe --check
dist\ResaleManager\diagnostics.txt

Startup failures are written to dist\ResaleManager\startup-error.log (or the equivalent folder) and shown in a dialog for normal GUI launches.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages