1. Purpose of the application
FAMS-CA is a web application for maintaining a Fixed Asset Register (FAR), recording additions and disposals, handling inter-unit transfers within the same company, importing bulk data from Excel, and computing depreciation under two frameworks: Companies Act 2013 (Schedule II, SLM-style with pro-rata rules) and Income Tax Act 1961 (block-of-assets WDV method). It supports master data (companies, factory/office units, categories), user authentication, dashboards, and Excel/PDF reporting. Also to verify fised asset at different location using QR code and updating verification information in data base
2. Technology stack
- Language: Python 3
- Web framework: Flask 3 (application factory pattern, blueprints)
- ORM / database: Flask-SQLAlchemy / SQLAlchemy
- Default database: SQLite (fams.db); overridable via DATABASE_URL / .env
- Authentication: Flask-Login; forms: Flask-WTF
- QR codes: qrcode + Pillow
3. High-level architecture
The system follows a classic three-tier, server-rendered monolith:
- Presentation: Browser → Flask routes render Jinja2 templates; static JS/CSS in app/static/
- Application: route handlers in app/routes/ orchestrate requests, flash messages, redirects
- Domain logic: app/engines/ (import_engine, dep_engine, reports, qr_engine) — heavy rules
- Persistence: app/models/ mapped to relational tables via SQLAlchemy
4. Architecture diagram (conceptual)
Browser (HTML/CSS/JS)
|
v
Flask app (create_app) — URL routing via Blueprints
|
+-- Routes (app/routes/*) — request/response, forms, flashes, redirects
|
+-- Engines (app/engines/*) — business rules: import, depreciation, reports, QR
|
+-- Models (app/models/*) — SQLAlchemy ORM → SQLite (or DATABASE_URL)
|
+-- Templates (app/templates) + Static (app/static)
5. Application entry & configuration
- run.py — starts Flask dev server or Waitress; parses prod argument
- config.py / ProductionConfig — database URI, uploads, QR folder, Asset Type.xlsx path
- requirements.txt — Python dependencies (Flask, SQLAlchemy, pandas, openpyxl, reportlab, qrcode, waitress, python-docx, …)
- app/engines/qr_engine.py — QR code file generation
- app/engines/verification_engine.py — verification workflows
6. Data model — core entities & relationships
Organizational hierarchy: Company (1) has many FactoryUnit (factory/office). Each Asset belongs to a Company and a FactoryUnit (and Category). Categories store Companies Act useful life and IT Act WDV rate hints.
- Company — legal entity; linked to many FactoryUnits and Assets
- FactoryUnit — plant/office under one company; foreign key company_id
- Category — asset class; links to Schedule II life and IT block rate
- Asset — central FAR row: identifiers, dates, cost, quantity, WDV fields, disposal flags, import_template (INITIAL_SETUP, SUBSEQUENT_ADDITION, DISPOSAL, TRANSFER), import_fy; optional transfer_in_date and inter_unit_transfer_source_id for receiver-side pro-rata
- PhysicalAsset — row-level physical sub-units when quantity > 1; tracks disposal per physical tag
- DepreciationLedger — posted depreciation per asset, per financial year, framework CO_ACT or IT path
- ITBlockBalance — opening WDV per company, factory unit, category, financial year (IT Act blocks)
- AssetTransfer — audit trail for inter-unit transfers (as implemented in models)
- User — credentials for Flask-Login
7. Depreciation engine — logic (dep_engine.py)
Two parallel frameworks; selection is by route/UI (Companies Act run vs IT Act run/report).
- Companies Act: primarily SLM-style depreciation from depreciable amount and useful life; pro-rata by days in FY vs ready-to-use date; small-asset rule (e.g. unit cost ≤ ₹5,000) can force 100% in year of addition unless flagged ineligible
- Special asset numbering patterns (_is_qty_split_portion_asset): rows from partial sales/splits use pro-rata opening WDV on the Asset row rather than recomputing from stale ledgers
- Inter-unit transfers: transfer_in_date on receiver asset drives pro-rata in the receiving unit
- Income Tax Act: block-wise WDV using ITBlockBalance and category rates; separate from per-asset CO ledger (exact formulas in dep_engine)
8. Routes & features (assets blueprint — summary)
- Dashboard / asset index with company–unit filters (sanitized server-side for reports)
- Asset Import UI: tabs for Opening FAR, Additions, IT Block, Disposal, Transfers; Excel upload + optional manual forms
- Data management: filter, edit (FY-guarded), delete imported rows
- Depreciation: POST to run CO Act or IT Act for selected FY / company / unit
- Reports: FAR Excel, depreciation register, IT dep report, disposal register, profit/loss on sold assets, PDF depreciation schedule
- Disposal on single asset from detail; QR generation endpoint
9. Security, configuration, and operations
- SECRET_KEY and DATABASE_URL should be set for production (.env)
- Login required on business routes via @login_required
- Upload size limit and secure filenames for imports
- Logging: rotating file handler for troubleshooting
- Dev: python run.py (port 5001 by convention); Prod: python run.py prod (Waitress, e.g. 8080)
10. Integration points & file formats
- Input: .xlsx templates for FAR, disposal, transfer, IT block
- Reference: Asset Type.xlsx for category codes / mapping
- Output: .xlsx reports, .pdf schedules; QR image files under configured folder