Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/lucavallini/aibar-frontend/llms.txt

Use this file to discover all available pages before exploring further.

The Multas module lets operators record traffic and administrative fines against fleet vehicles. In practice, transport companies rarely receive fine notifications in real time — infraction notices typically arrive days or even weeks later by post or municipal communication. The module therefore treats fecha (the date of the infraction) as fully independent from creado_en (the timestamp the record was entered into the system), allowing dispatchers to log a fine with the accurate infraction date regardless of when the paperwork landed. Each record can optionally be linked to the driver at the wheel and the active trip, giving management a complete picture of where and when penalties occurred.

Data Models

Multa

The read model returned by the API for every registered fine.
export interface Multa {
  id: string;
  camion_id: string;
  chofer_id: string | null;
  viaje_id: string | null;
  motivo: string;
  monto: number | null;
  fecha: string;
  registrado_por: string | null;
  creado_en: string;
}
id
string
required
Unique identifier for the fine record.
camion_id
string
required
ID of the truck to which the fine was issued.
chofer_id
string | null
ID of the driver who was operating the vehicle at the time. null when the driver is not recorded or not known.
viaje_id
string | null
ID of the trip the truck was running when the infraction occurred. null when not linked to a specific trip.
motivo
string
required
Free-text description of the infraction (e.g. “Exceso de velocidad”, “Estacionamiento indebido”).
monto
number | null
Monetary value of the fine. null when the amount has not yet been confirmed at the time of logging.
fecha
string
required
Date of the infraction in ISO 8601 format (YYYY-MM-DD). This is the official date on the notice, not the date the record was created.
registrado_por
string | null
ID of the user who created the record. Set by the backend.
creado_en
string
required
UTC timestamp of when the record was inserted into the database.

MultaCreate

The write model sent to the API when registering a new fine.
export interface MultaCreate {
  camion_id: string;
  chofer_id?: string;
  viaje_id?: string;
  motivo: string;
  monto?: number;
  fecha?: string;
}
camion_id
string
required
ID of the truck the fine was issued against. Must match an existing truck in the fleet.
motivo
string
required
Description of the infraction. Cannot be blank — the component trims and validates this field before submitting.
chofer_id
string
Optional. ID of the driver at the wheel. When the driver is unknown or not relevant, omit this field.
viaje_id
string
Optional. Links the fine to a specific trip. Useful for attributing the penalty to a particular route or customer job.
monto
number
Optional. Fine amount in local currency. Can be added later once the official notice confirms the value. See the note below.
fecha
string
Optional. ISO 8601 date string (YYYY-MM-DD) representing the actual infraction date. When omitted, the backend defaults to the current date. Supply the date from the official notice to keep records accurate.
monto is intentionally optional. Municipal fine notices often arrive before the payment amount is officially set or before the company has reviewed the infraction. Log the fine immediately with motivo and fecha to preserve the accurate infraction date, then update the amount once it is confirmed.

MultasService

MultasService is a root-level Angular injectable that wraps all fines-related API calls.
@Injectable({ providedIn: 'root' })
export class MultasService {
  private apiUrl = `${environment.apiUrl}/multas`;

  constructor(private http: HttpClient) {}
}

listar()

Fetches a paginated list of all fines, ordered by the backend default (most recent first).
listar(
  pagina: number = 1,
  tamanoPagina: number = 20
): Observable<RespuestaPaginada<Multa>>
HTTP request:
GET /multas/?pagina=1&tamano_pagina=20
The response follows the standard RespuestaPaginada<T> envelope:
export interface RespuestaPaginada<T> {
  items: T[];
  total: number;
  pagina: number;
  tamano_pagina: number;
  total_paginas: number;
}
Unlike the fuel module, the fines list has no date-range filter — all recorded fines are returned, paginated 20 per page.

crear()

Posts a new fine record to the API.
crear(datos: MultaCreate): Observable<Multa>
HTTP request:
POST /multas/
Content-Type: application/json

{
  "camion_id": "abc-123",
  "chofer_id": "chofer-456",
  "motivo": "Exceso de velocidad",
  "monto": 15000,
  "fecha": "2025-07-03"
}

TypeScript example — creating a fine

import { MultasService } from '../../../core/services/multas.service';
import { MultaCreate } from '../../../core/models/multa.model';

// Minimal fine — amount not yet confirmed
const multa: MultaCreate = {
  camion_id: 'abc-123',
  motivo: 'Estacionamiento indebido',
  fecha: '2025-07-03',          // actual infraction date from the notice
};

this.multasService.crear(multa).subscribe({
  next: (registro) => {
    console.log('Fine registered with id:', registro.id);
    console.log('Infraction date:', registro.fecha);
    console.log('Logged at:', registro.creado_en);  // different from fecha
  },
  error: () => console.error('Could not register fine'),
});

// Full fine — driver and trip known, amount confirmed
const multaCompleta: MultaCreate = {
  camion_id: 'abc-123',
  chofer_id: 'chofer-456',
  viaje_id: 'viaje-789',
  motivo: 'Exceso de velocidad en zona urbana',
  monto: 15000,
  fecha: '2025-07-03',
};

this.multasService.crear(multaCompleta).subscribe({
  next: (registro) => console.log('Fine registered:', registro),
});
The component validates that both camion_id and motivo are present before calling crear():
confirmarAlta(): void {
  if (!this.nuevaMulta.camion_id || !this.nuevaMulta.motivo.trim()) {
    this.error.set('Camión y motivo son obligatorios');
    return;
  }
  this.multasService.crear(this.nuevaMulta).subscribe({
    next: () => {
      this.cerrarModal();
      this.pagina.set(1);
      this.cargarMultas();
    },
    error: () => this.error.set('No se pudo registrar la multa')
  });
}

The fecha Field and Retroactive Entry

fecha and creado_en represent two distinct moments in time:
FieldMeaningSet by
fechaDate the infraction occurred (from the official notice)Operator, at registration
creado_enUTC timestamp the record was inserted into the databaseBackend, automatically
Because municipal fine notices can take days or weeks to reach the transport company, fecha must be entered manually from the document. If omitted, it defaults to today — which is almost never the correct infraction date. Always enter the date printed on the official notice.
Leaving fecha blank causes the fine to be logged with today’s date as the infraction date. This creates inaccurate records if the notice arrived after the fact. Always transcribe the date from the official fine notice.

How the List Component Works

1

Load reference data on init

ngOnInit triggers cargarDatosRelacionados(), which first fetches all trucks via CamionesService (up to 1 000 records), building a camion_id → patente lookup map.
2

Load drivers

Once trucks are loaded, cargarChoferesYMultas() fetches all drivers via ChoferesService, building a chofer_id → nombre_completo map. Both lookups complete before the fines list is fetched.
3

Fetch fines

cargarMultas() calls listar() with the current page and page size. The paginated result is stored in the multas signal.
4

Resolve labels

The template uses nombrePatente() and nombreChofer() helpers to display human-readable labels instead of raw UUIDs. If a chofer ID is null, the cell renders '-'.
5

Paginate

The <app-paginacion> component handles page navigation. Changing pages re-calls cargarMultas() with the updated page number.
6

Register a new fine

Clicking + Nueva multa opens a modal with fields for truck, driver (optional), motivo, monto (optional), and fecha (optional). On confirm, crear() is called, the modal closes, and the list resets to page 1 and reloads.
The driver (chofer) dropdown in the registration modal defaults to Sin especificar. You only need to select a driver when the infraction notice explicitly names them — for example, a speeding ticket captured by a fixed camera that identifies the vehicle but not the driver can be logged with just camion_id and motivo.

Build docs developers (and LLMs) love