This page describes the operations sub-module in src/cluster_erp/modules/fleet/operations/. It records who holds an asset and when, which tractor pulls which trailer, driver inspections and the defects they find, reservations of pool assets, and incidents such as accidents. The module overview is on fleet module.
Scope and source¶
- Defined in:
src/cluster_erp/modules/fleet/models.py(FleetAssignment,FleetCoupling,FleetInspection,FleetDefect,FleetReservation,FleetIncident),operations/services.py,operations/routes.py,operations/schemas.py, andoperations/metadata.py. - Count: 6 tables, 27 routes in
operations/routes.py, 14ActionMetaentries inoperations/metadata.py. - Every service refuses a new document on a disposed asset (
src/cluster_erp/modules/fleet/operations/services.py:80-98).
Entities¶
| Entity | Key fields | Statuses | Source |
|---|---|---|---|
FleetAssignment |
asset_id, party_id, kind (driver or custodian), starts_at, ends_at, note |
open while ends_at is empty |
src/cluster_erp/modules/fleet/models.py:83, src/cluster_erp/modules/fleet/models.py:455-479 |
FleetCoupling |
tractor_asset_id, trailer_asset_id, starts_at, ends_at, note |
open while ends_at is empty |
src/cluster_erp/modules/fleet/models.py:482-510 |
FleetInspection |
asset_id, kind (pre_trip, post_trip, periodic), inspected_at, inspector_party_id, odometer_km, author_signed_at, is_clean |
unsigned or signed | src/cluster_erp/modules/fleet/models.py:84, src/cluster_erp/modules/fleet/models.py:513-529 |
FleetDefect |
asset_id, inspection_id, title, severity, first_observed_at, last_observed_at, resolved_at, resolved_by_party_id, verified_by_inspection_id, work_order_id |
open, resolved, verified |
src/cluster_erp/modules/fleet/models.py:85-86, src/cluster_erp/modules/fleet/models.py:532-556 |
FleetReservation |
asset_id, party_id, reserved_from, reserved_to, purpose, checkout_odometer, return_odometer, damage_note |
reserved, retrieved, returned, settled, cancelled |
src/cluster_erp/modules/fleet/models.py:87-93, src/cluster_erp/modules/fleet/models.py:559-574 |
FleetIncident |
asset_id, kind (accident, damage), occurred_at, location, driver_party_id, police_report_no, insurance_file_no, work_order_id |
reported, in_claim, closed |
src/cluster_erp/modules/fleet/models.py:94-95, src/cluster_erp/modules/fleet/models.py:577-593 |
Assignments and couplings¶
- An assignment names a party, checked through
GetPartyByIdon the EventBus (src/cluster_erp/modules/fleet/operations/services.py:64-79,src/cluster_erp/modules/fleet/operations/services.py:138). - An assignment starts now or in the past, at most five minutes ahead (
src/cluster_erp/modules/fleet/operations/services.py:139-145). - A new assignment closes the open one of the same asset and kind at its own start. It must start after the open one and must not overlap closed history (
src/cluster_erp/modules/fleet/operations/services.py:146-187). - A partial unique index allows one open assignment per asset and kind (
src/cluster_erp/modules/fleet/models.py:463-472). GET /assignments/as-ofanswers who held the asset at a moment, per kind. A time without an offset is read as UTC (src/cluster_erp/modules/fleet/operations/routes.py:83-100,src/cluster_erp/modules/fleet/operations/services.py:225-249).- A coupling joins a powered tractor and an unpowered trailer, read from the asset class. An asset whose class is gone is refused (
src/cluster_erp/modules/fleet/operations/services.py:284-294,src/cluster_erp/modules/fleet/operations/services.py:352-375). - A new coupling closes the open couplings of both sides; partial unique indexes allow one open coupling per tractor and per trailer (
src/cluster_erp/modules/fleet/operations/services.py:295-320,src/cluster_erp/modules/fleet/models.py:486-501).
Inspections and defects¶
The code describes a three-signature chain: the author signs the inspection, resolving a defect is the second signature, and the next signed clean inspection verifies resolved defects (src/cluster_erp/modules/fleet/operations/services.py:12-16).
stateDiagram-v2 [*] --> open: defect recorded open --> resolved: resolve resolved --> open: reopen or observe resolved --> verified: later signed clean inspection open --> open: observe
In prose: a defect starts open. Resolve moves it to resolved; Reopen or a new observation moves it back to open. When a later inspection of the same asset is signed clean, every defect resolved before that inspection becomes verified (src/cluster_erp/modules/fleet/operations/services.py:423-459, src/cluster_erp/modules/fleet/operations/services.py:569-656).
- An unsigned inspection can be edited; a signed one is sealed (
src/cluster_erp/modules/fleet/operations/services.py:410-422,src/cluster_erp/modules/fleet/operations/services.py:461-467). - Signing sets
is_cleanwhen the inspection has no defects of its own, and records the odometer as a reading with sourceform. A refused reading does not block the signature (src/cluster_erp/modules/fleet/operations/services.py:434-440,src/cluster_erp/modules/fleet/operations/services.py:478-503). - A defect on an inspection must belong to the same asset, and a signed inspection takes no new defects (
src/cluster_erp/modules/fleet/operations/services.py:538-567). - Create Work Order on a defect opens one order with an item of source
inspection_defectorfault; a defect gets at most one order (src/cluster_erp/modules/fleet/operations/services.py:612-645).
Reservations and incidents¶
- A reservation names a party, must end after it starts, and must not overlap a
reservedorretrievedreservation of the same asset (src/cluster_erp/modules/fleet/operations/services.py:693-725). - Check Out and Return can record odometer readings with source
form. The return value cannot be below the checkout value. A damage note at return creates an open defect (src/cluster_erp/modules/fleet/operations/services.py:727-786). - An incident can be edited until it is closed. Open Insurance Claim needs
reported; Create Repair Order opens one work order; Close seals it (src/cluster_erp/modules/fleet/operations/services.py:855-934).
Actions¶
| Entity | Action | Label | Condition | Source |
|---|---|---|---|---|
| Assignment | end |
End Assignment | none | src/cluster_erp/modules/fleet/operations/metadata.py:92-107 |
| Coupling | uncouple |
Uncouple | none | src/cluster_erp/modules/fleet/operations/metadata.py:259-274 |
| Inspection | sign |
Sign | none | src/cluster_erp/modules/fleet/operations/metadata.py:403-410 |
| Defect | resolve |
Resolve | status is open |
src/cluster_erp/modules/fleet/operations/metadata.py:552-566 |
| Defect | observe |
Observed Again | status is open or resolved |
src/cluster_erp/modules/fleet/operations/metadata.py:567-573 |
| Defect | reopen |
Reopen | status is resolved |
src/cluster_erp/modules/fleet/operations/metadata.py:574-580 |
| Defect | create_work_order |
Create Work Order | status is open |
src/cluster_erp/modules/fleet/operations/metadata.py:581-589 |
| Reservation | retrieve |
Check Out | status is reserved |
src/cluster_erp/modules/fleet/operations/metadata.py:728-743 |
| Reservation | return_asset |
Return | status is retrieved |
src/cluster_erp/modules/fleet/operations/metadata.py:744-767 |
| Reservation | settle |
Settle | status is returned |
src/cluster_erp/modules/fleet/operations/metadata.py:768-776 |
| Reservation | cancel |
Cancel | status is reserved |
src/cluster_erp/modules/fleet/operations/metadata.py:777-785 |
| Incident | open_claim |
Open Insurance Claim | status is reported |
src/cluster_erp/modules/fleet/operations/metadata.py:952-960 |
| Incident | create_work_order |
Create Repair Order | status is reported or in_claim |
src/cluster_erp/modules/fleet/operations/metadata.py:961-969 |
| Incident | close |
Close | status is reported or in_claim |
src/cluster_erp/modules/fleet/operations/metadata.py:970-976 |
Routes¶
Each of the six routers has list, create, read, and action routes; inspections and incidents also have an update route (src/cluster_erp/modules/fleet/operations/routes.py:45-458). The router prefixes are /assignments, /couplings, /inspections, /defects, /reservations, and /incidents (src/cluster_erp/modules/fleet/operations/routes.py:45-50). There is no delete route in operations/routes.py.
Terms introduced¶
| Term | Code identifier | Definition | Turkish term | Source |
|---|---|---|---|---|
| assignment segment | FleetAssignment |
A time-boxed record of which party held an asset as driver or custodian. | Atama dönemi | src/cluster_erp/modules/fleet/models.py:455 |
| coupling | FleetCoupling |
A time-boxed link between a powered tractor and an unpowered trailer. | Çekici-dorse bağlantısı | src/cluster_erp/modules/fleet/models.py:482 |
| defect | FleetDefect |
A fault seen on an asset, with its first and last observation, that can feed a work order. | Kusur | src/cluster_erp/modules/fleet/models.py:532 |
Related pages¶
Verified against commit 92f8051 on 2026-11-13.