Factorizer/Cluster ERP WikiCluster ERP Türkçe
Home / Business modules

Module

Fleet module (fleet)

Module page for fleet, the asset master for vehicles and machines with meters, maintenance, work orders, operations, fuel, compliance, and cost analysis.

The fleet module in src/cluster_erp/modules/fleet/ manages the vehicles and machines a company operates. One asset master covers cars, vans, trucks, tractor units, trailers, buses, forklifts, and construction machines. Around it the module keeps meters and readings, maintenance plans and reminders, work orders with spare parts, driver assignments, inspections and defects, reservations, incidents, fuel, compliance obligations, penalties, tires, and campaigns. This page is the overview; the sub-topics have their own pages.

At a glance

Item Value Source
Package src/cluster_erp/modules/fleet/ folder
Module class Module src/cluster_erp/modules/fleet/module.py:136
name / version fleet / 0.1.0 src/cluster_erp/modules/fleet/module.py:140-146
API prefix /api/v1/fleet src/cluster_erp/modules/fleet/module.py:310
Sub-modules 7: assets, meters, maintenance, workorders, operations, fuel, tco; plus telematics.py, validation.py, and analytics_facts.py folder listing
Tables 23, all in one models.py __tablename__ in src/cluster_erp/modules/fleet/models.py
Entities in metadata 24 keys in entities src/cluster_erp/modules/fleet/module.py:552-577
Routes 116 route decorators in the package grep for @...router.get/post/put/patch/delete
Actions 43 ActionMeta entries grep "ActionMeta(" in the package
Migrations 12 files files in migrations/versions/ whose text contains one of the 23 table names
Contracts consumes 1, produces 6 see the section "Events and queries"
Web app presence Catalogue app fleet (screen module) src/cluster_erp/modules/app_store/catalog.json (entry fleet)
Desktop presence generic widgets only src/cluster_erp/desktop/modules/ has no fleet folder

What the module does

  • Keeps one asset master with first-class identities (plate, VIN, chassis number, engine number) and a lifecycle that starts as a draft (src/cluster_erp/modules/fleet/models.py:159-237).
  • Lets the organisation add its own asset fields at runtime through tenant fields; the module seeds a heavy-vehicle starter set (src/cluster_erp/modules/fleet/module.py:197-265). See tenant fields.
  • Records counters as an immutable reading ledger with life-to-date values (src/cluster_erp/modules/fleet/meters/services.py:1-18).
  • Computes maintenance due dates from calendar, meter, and threshold rules (src/cluster_erp/modules/fleet/maintenance/services.py:1-20).
  • Collects every maintenance need on one work order and issues spare parts from inventory through the EventBus (src/cluster_erp/modules/fleet/workorders/services.py:1-18).
  • Tracks who holds an asset, tractor and trailer couplings, inspections, defects, reservations, and incidents (src/cluster_erp/modules/fleet/operations/services.py:1-20).
  • Keeps a fuel ledger with consumption alerts, compliance obligations with renewal, and penalties (src/cluster_erp/modules/fleet/fuel/services.py:1-20).
  • Reports total cost of ownership, a renewal ranking, tires, campaigns, and emission factors (src/cluster_erp/modules/fleet/tco/services.py:1-12).
  • Accepts counter batches from telematics adapters (src/cluster_erp/modules/fleet/telematics.py:1-16).

Sub-modules

Sub-module Purpose Main entities Router Page
assets Asset master and asset classes FleetAsset, FleetAssetClass /assets, /classes Assets
meters Meters and the reading ledger FleetMeter, FleetMeterReading /meters, /readings Meters and fuel
fuel Fuel entries, compliance items, penalties, inspection periods FleetFuelEntry, FleetComplianceItem, FleetPenalty, FleetInspectionPeriod /fuel, /compliance, /penalties, /inspection-periods Meters and fuel
maintenance Plans and computed reminders FleetMaintenancePlan, FleetMaintenanceReminder /maintenance/plans, /maintenance/reminders Maintenance and work orders
workorders Work orders, items, parts FleetWorkOrder, FleetWorkOrderItem, FleetWorkOrderPart /work-orders, /work-order-items, /work-order-parts Maintenance and work orders
operations Assignments, couplings, inspections, defects, reservations, incidents FleetAssignment, FleetCoupling, FleetInspection, FleetDefect, FleetReservation, FleetIncident /assignments, /couplings, /inspections, /defects, /reservations, /incidents Operations
tco Cost of ownership, renewal, tires, campaigns, emission factors FleetTire, FleetCampaign, FleetCampaignAsset, FleetEmissionFactor /tco, /tires, /campaigns, /campaign-assets, /emission-factors TCO, telematics, and analytics

All routers are included in one module router with the prefix /api/v1/fleet (src/cluster_erp/modules/fleet/module.py:267-336). Each routes.py declares its own paths, for example src/cluster_erp/modules/fleet/fuel/routes.py:35-41.

Data model

All 23 tables are declared in src/cluster_erp/modules/fleet/models.py. Each sub-module page lists its fields. Common traits:

  • Every model inherits the audit and soft-delete columns of BaseModel (src/cluster_erp/modules/fleet/models.py:42). See base model and IDs.
  • Uniqueness holds on live rows only, through partial unique indexes such as uq_fleet_assets_plate_live (src/cluster_erp/modules/fleet/models.py:168-186).
  • Money columns are Numeric(18, 2) with a separate three-letter currency column, for example FleetWorkOrder.labor_cost and FleetFuelEntry.total_cost (src/cluster_erp/modules/fleet/models.py:409-413, src/cluster_erp/modules/fleet/models.py:621-622).
  • Counter values are Numeric with one decimal place (src/cluster_erp/modules/fleet/models.py:298-301).
  • Status vocabularies are tuples at the top of the file, for example FLEET_ASSET_STATUSES and FLEET_WO_STATUSES (src/cluster_erp/modules/fleet/models.py:46-127).

Screens and metadata

get_metadata declares a sidebar group Fleet (Turkish Filo) with 16 sections (src/cluster_erp/modules/fleet/module.py:403-547). Six sections show on the bar: Assets, Maintenance, Work Orders, Reservations, Fuel, and Compliance. Nine list sections carry hidden_from_bar=True: Penalties, Tires, Campaigns, Renewal Analysis, Assignments, Couplings, Inspections, Defects, and Incidents. The code comment states that these lists stay searchable and that the asset card is their contextual door (src/cluster_erp/modules/fleet/module.py:490-492). Settings is a settings view with four tabs: asset classes, maintenance plans, inspection periods, and emission factors (src/cluster_erp/modules/fleet/module.py:536-547).

The asset card has 14 detail tabs, from Overview to Tires (src/cluster_erp/modules/fleet/assets/metadata.py:358-450). The web app and the desktop render all of this generically; see generic list and generic detail.

Status and actions

Each sub-module page lists its actions. Every status change runs through an action route POST .../{id}/actions/{action}; the asset update path does not change the status (src/cluster_erp/modules/fleet/assets/services.py:1-11). The diagram shows the maintenance flow across the sub-modules.

flowchart TD
 RD["FleetMeterReading created"] --> RC["FleetReminderService.recompute_for_asset_id"]
 PL["FleetMaintenancePlan"] --> RC
 RC --> RM["FleetMaintenanceReminder: ok, due_soon, overdue"]
 RM -->|create_work_order| WO["FleetWorkOrder draft"]
 AS["FleetAsset send_to_maintenance"] --> WO2["FleetWorkOrder released"]
 DF["FleetDefect create_work_order"] --> WO
 WO -->|release, start| WOP["open, in_progress"]
 WOP -->|issue part| GI["PostGoodsIssue to inventory"]
 WOP -->|complete| DONE["completed"]
 DONE --> RCOMP["linked reminders completed"]
 DONE --> ODO["odometer reading, source work_order"]
 DONE --> BACK["asset back to active"]

In prose:

  1. A new reading recomputes the reminders of its asset (src/cluster_erp/modules/fleet/meters/services.py:308-311, src/cluster_erp/modules/fleet/meters/services.py:363-371).
  2. The reminder engine sets each reminder to ok, due_soon, overdue, or snoozed (src/cluster_erp/modules/fleet/maintenance/services.py:588-597).
  3. A reminder, a defect, an incident, or a campaign item can open a work order. Sending an asset to maintenance opens a released one (src/cluster_erp/modules/fleet/maintenance/services.py:351-366, src/cluster_erp/modules/fleet/assets/services.py:307-338).
  4. Issuing a part line posts PostGoodsIssue to inventory (src/cluster_erp/modules/fleet/workorders/services.py:464-514).
  5. Completing the order completes the linked reminders, can record a closing odometer, and returns the asset to active when no other order is open (src/cluster_erp/modules/fleet/workorders/services.py:191-265).

Business rules

The rules of each sub-module are on its page. Rules that apply across the module:

  • Every datetime the API accepts must carry a UTC offset; a naive value is refused with a validation error (src/cluster_erp/modules/fleet/validation.py:1-21).
  • A blank string in a form payload counts as no value (src/cluster_erp/modules/fleet/validation.py:24-37).
  • A disposed asset takes no new operational documents (src/cluster_erp/modules/fleet/operations/services.py:80-98).
  • Asset codes come from the sequence fleet_asset and work order codes from fleet_work_order (src/cluster_erp/modules/fleet/assets/services.py:229, src/cluster_erp/modules/fleet/workorders/services.py:108).
  • Sub-modules call each other's services inside the package. The code comments mark these as sibling imports, not cross-module calls (src/cluster_erp/modules/fleet/assets/services.py:240-241).

Events and queries

The module consumes 1 contract and produces 6. Consumed means passed as the first argument of subscribe( or register_query_handler( in the package; produced means a contract class name followed by ( in the package. The full list is on the contracts reference.

Direction Contract class Handler or emitter Source
subscribes DescribeAnalyticsFacts describe_analytics_facts src/cluster_erp/modules/fleet/module.py:338-346
queries PostGoodsIssue FleetWorkOrderService.issue_part src/cluster_erp/modules/fleet/workorders/services.py:494-507
queries GetPurchaseRequestById FleetWorkOrderService._check_pr_link src/cluster_erp/modules/fleet/workorders/services.py:565-578
queries GetPartyById _require_party src/cluster_erp/modules/fleet/operations/services.py:64-79
builds AnalyticsFactSet, AnalyticsDimension, AnalyticsMeasure analytics_facts.py src/cluster_erp/modules/fleet/analytics_facts.py:18-310

The product breakdown of a part line is checked with ensure_product_breakdown before the line is stored (src/cluster_erp/modules/fleet/workorders/services.py:412-424).

Permissions

Every route checks a permission with require_permission. The keys follow the pattern <entity>.read, .create, .update, and .delete.

Permission key Used by Source
fleet_asset.read, .create, .update, .delete assets, TCO and renewal reads, telematics feed (update) src/cluster_erp/modules/fleet/assets/routes.py:62-137, src/cluster_erp/modules/fleet/tco/routes.py:52-62, src/cluster_erp/modules/fleet/telematics.py:55
fleet_asset_class.read, .update asset classes src/cluster_erp/modules/fleet/assets/routes.py:149-187
fleet_meter.*, fleet_meter_reading.* meters and readings src/cluster_erp/modules/fleet/meters/routes.py:36-161
fleet_maintenance_plan.*, fleet_maintenance_reminder.* plans and reminders src/cluster_erp/modules/fleet/maintenance/routes.py:33-144
fleet_work_order.*, fleet_work_order_item.*, fleet_work_order_part.* work orders src/cluster_erp/modules/fleet/workorders/routes.py:39-214
fleet_assignment.*, fleet_coupling.*, fleet_inspection.*, fleet_defect.*, fleet_reservation.*, fleet_incident.* operations src/cluster_erp/modules/fleet/operations/routes.py:63-453
fleet_fuel_entry.*, fleet_compliance_item.*, fleet_penalty.*, fleet_inspection_period.* fuel, compliance, penalties, periods src/cluster_erp/modules/fleet/fuel/routes.py:52-356
fleet_tire.*, fleet_campaign.*, fleet_campaign_asset.*, fleet_emission_factor.* tires, campaigns, factors src/cluster_erp/modules/fleet/tco/routes.py:78-344

The mechanism is described on roles and permissions.

Privacy, retention, and history

The module has no privacy_handlers.py and no retention_handlers.py (folder listing). Deleting a record sets deleted_at. For an asset this also retires its live reminders, while readings, orders, and segments stay (src/cluster_erp/modules/fleet/assets/services.py:340-363). Readings are never edited or deleted; a wrong reading is marked incorrect (src/cluster_erp/modules/fleet/meters/services.py:9-12). Changes are captured by change history; deactivation is described on soft delete and deactivation.

Analytics facts

analytics_facts.py contributes four fact sets: fleet_fuel, fleet_work_order, fleet_penalty, and fleet_compliance, all read with fleet_asset.read (src/cluster_erp/modules/fleet/analytics_facts.py:35-310). Details are on TCO, telematics, and analytics; the collection path is on analytics facts.

Settings and reference data

  • Asset classes are reference data. On start the module seeds nine classes when they are missing: car, van, truck, tractor_unit, trailer, bus, forklift, construction, and other, each with its default meters (src/cluster_erp/modules/fleet/module.py:27-47, src/cluster_erp/modules/fleet/module.py:159-195).
  • The module seeds nine asset field definitions as tenant fields in the bucket fleet_asset, for example fuel_tank_l and gvwr_kg. A key that already exists is left alone (src/cluster_erp/modules/fleet/module.py:49-133, src/cluster_erp/modules/fleet/module.py:197-265).
  • Inspection periods and emission factors start empty; the organisation fills them (src/cluster_erp/modules/fleet/models.py:673-789).

Tests

Found by a grep for /fleet/ in web-client/_e2e_*.mjs and for fleet in tests/*.py.

Kind File Covers
e2e web-client/_e2e_fleet_assets.mjs asset master, classes, runtime fields
e2e web-client/_e2e_fleet_meters.mjs meters and the reading ledger
e2e web-client/_e2e_fleet_maintenance.mjs the maintenance plan engine
e2e web-client/_e2e_fleet_workorders.mjs the work order funnel
e2e web-client/_e2e_fleet_operations.mjs assignments, couplings, inspections, reservations, incidents
e2e web-client/_e2e_fleet_fuel.mjs fuel ledger and compliance
e2e web-client/_e2e_fleet_analytics.mjs fact sets, TCO, renewal, tires, campaigns
e2e web-client/_e2e_fleet_telematics.mjs the telematics feed
e2e web-client/_e2e_fleet_paranoid.mjs regression guards across sub-modules
e2e web-client/_e2e_tenant_fields_phase4b.mjs, web-client/_e2e_tenant_fields_phase4c.mjs tenant fields on fleet assets
pytest tests/test_data_map_package2.py, tests/test_backup_retention.py, tests/test_demo_data_live.py, tests/test_desktop_app_scope.py files that mention fleet

Discrepancies

Terms introduced

Term Code identifier Definition Turkish term Source
fleet asset FleetAsset One vehicle, trailer, or machine the company operates. Araç src/cluster_erp/modules/fleet/models.py:159
asset class FleetAssetClass Reference row that groups assets and declares whether they are powered and which meters they get. Araç sınıfı src/cluster_erp/modules/fleet/models.py:130
work order funnel FleetWorkOrderService The single work order on which every maintenance need of an asset lands as an item. İş emri hunisi src/cluster_erp/modules/fleet/workorders/services.py:1-10

Verified against commit 92f8051 on 2026-11-13.

Verified against commit 92f8051 · 2026-11-13