Gigafibre Field Service Management - ERPNext doctypes, dispatch app, architecture docs
Go to file
louispaulb 218f6fc7b1 feat(ops): Service Contract detail view + sub-delete redirects there
Contract termination is a fee-bearing, auditable workflow — it belongs
on the contract, not buried in a sub's delete dialog. Standard SaaS /
telecom practice: subs are an immutable event stream, contracts
orchestrate their lifecycle.

ServiceContractDetail.vue (new)
  • Status banner: contract type, dates, status — "Résilier" button
    when actionable, termination invoice link when already résilié.
  • Term progress bar: months_elapsed / duration_months with color
    ramp (primary → amber near end → positive when done).
  • Financial summary grid: mensualité, abonnement (clickable), devis,
    lieu, total avantages, résiduel, signature method & date.
  • Benefits detail table: per-row description, regular_price vs
    granted_price, économie, reconnu à date, et "À rembourser"
    (valeur résiduelle) — this is what the rep needs to see before
    deciding to break a contract.
  • Termination recap (only when status=Résilié): date, raison,
    penalty breakdown, link to the termination invoice.
  • "Résilier" action runs a 2-step dialog: first calls
    /contract/calculate-termination for the preview, then prompts for
    a reason (textarea, min 3 chars) before firing /contract/terminate.
    On success: cascade-cancels the linked sub (status=Annulé +
    end_date + cancellation_date — no hard delete), mutates the
    local doc so the modal refreshes in place, and emits
    contract-terminated so the parent page updates its sub + contract
    rows + drops an audit comment on the customer.

DetailModal
  • SECTION_MAP now routes Service Contract → ServiceContractDetail.
    Also added 'Service Subscription' → SubscriptionDetail (same
    template fits; was falling through to the generic grid).
  • Re-emits contract-terminated so the parent can listen.

ClientDetailPage
  • confirmDeleteSub: when a live contract references the sub, the
    dialog now simply redirects the rep to the contract modal
    ("Voir le contrat") instead of trying to do termination from
    the sub row. Terminal-state contracts (Résilié/Complété/Expiré)
    still get the inline link-scrub path so stale refs don't block
    a legit delete.
  • onContractTerminated: reflects the cascade locally — contract
    row → Résilié, sub row → Cancelled + end_date, audit Comment
    posted to the customer's notes feed.
2026-04-23 14:46:34 -04:00
apps feat(ops): Service Contract detail view + sub-delete redirects there 2026-04-23 14:46:34 -04:00
docs fix(tech): restore Gemini-native scanner + port equipment UX into ops 2026-04-22 15:56:38 -04:00
erpnext feat: flow editor, Gemini QR scanner with offline queue, dispatch planning v2 2026-04-22 10:44:17 -04:00
patches refactor: reduce token count, DRY code, consolidate docs 2026-04-13 08:39:58 -04:00
scripts feat: flow editor, Gemini QR scanner with offline queue, dispatch planning v2 2026-04-22 10:44:17 -04:00
services fix(chain+subs): safe job-delete, plan_name from Quotation, bi-dir sub link 2026-04-23 10:19:56 -04:00
.gitignore feat: flow editor, Gemini QR scanner with offline queue, dispatch planning v2 2026-04-22 10:44:17 -04:00
README.md docs: reorganize into architecture/features/reference/archive folders 2026-04-22 11:51:33 -04:00

Gigafibre FSM

Gigafibre FSM is the operations platform for Gigafibre (consumer brand of TARGO Internet), a fiber ISP in Quebec. It replaces a legacy PHP/MariaDB billing system with ERPNext v16 + Vue 3/Quasar apps for ops, dispatch, field service, and customer self-service.

Repository Structure

gigafibre-fsm/
  apps/
    ops/           Targo Ops -- main operations PWA (Vue 3 / Quasar v2)
    field/         Targo Field -- mobile app for technicians
    client/        Gigafibre Portal -- customer self-service
    website/       www.gigafibre.ca -- marketing site (React / Vite / Tailwind)
    portal/        Customer portal deploy configs
  services/
    targo-hub/     Node.js API gateway (ERPNext, GenieACS, Twilio, Traccar)
    modem-bridge/  SNMP/TR-069 bridge for CPE diagnostics
    legacy-db/     Legacy MariaDB read-only access
    docuseal/      Document signing service
  erpnext/         Custom doctype setup scripts (setup_fsm_doctypes.py)
  scripts/
    migration/     51 Python scripts for legacy-to-ERPNext data migration
    bulk_submit.py, fix_ple_*.py/sh -- PostgreSQL patches, bulk ops
  docs/            Architecture, infrastructure, migration, strategy docs
  docker/          Docker compose fragments
  patches/         ERPNext patches

Architecture

           Internet
              |
    96.125.196.67 (Proxmox VM, Ubuntu 24.04, Docker)
              |
        Traefik v2.11 (TLS via Let's Encrypt)
              |
   +----------+----------+----------+----------+----------+
   |          |          |          |          |          |
ERPNext    Ops PWA   Authentik    n8n     Website    Oktopus
erp.       erp.      auth.       n8n.    www.       oss.
gigafibre  gigafibre  targo.ca    giga    giga       giga
.ca        .ca/ops/              fibre   fibre      fibre
                                 .ca     .ca        .ca
              |
         targo-hub (API gateway)
              |
   +----------+----------+----------+
   |          |          |          |
GenieACS   Twilio    Traccar   modem-bridge
(TR-069)   (SMS)     (GPS)     (SNMP/TR-069)

Services & Dependencies

Service URL Port Stack Purpose
ERPNext erp.gigafibre.ca 8080 Frappe v16, PostgreSQL ERP backend, API
Ops PWA erp.gigafibre.ca/ops/ 80 Vue 3, Quasar, Pinia Staff operations app
targo-hub internal 3100 Node.js, Express API gateway to external services
modem-bridge internal 3200 Node.js SNMP/TR-069 CPE diagnostics
Authentik auth.targo.ca / id.gigafibre.ca 9000 Python, PostgreSQL SSO (staff + customers)
n8n n8n.gigafibre.ca 5678 Node.js Workflow automation (SMS, email)
Traefik -- 80/443 Go Reverse proxy, TLS, forwardAuth
Oktopus oss.gigafibre.ca 8428 Go TR-069 CPE management
Website www.gigafibre.ca 80 React, Vite, Tailwind Marketing site + address API
Traccar tracker.targointernet.com 8082 Java GPS tracking for techs

ERPNext Custom Doctypes

Doctype ID Pattern Purpose
Service Location LOC-##### Customer premises (address, GPS, OLT port, network config)
Service Equipment EQP-##### Deployed hardware (ONT, router, TV box -- serial, MAC, IP)
Service Subscription SUB-##### Active service plans (speed, price, billing, RADIUS)
Dispatch Job DJ-##### Work orders with equipment, materials, checklist, photos, signature
Dispatch Technician DT-##### Tech profiles with GPS (Traccar), skills, color coding
Dispatch Tag -- Skill/service/region tags with levels (Fibre, TV, Telephonie, etc.)

Key Custom Fields

Doctype Custom Fields
Customer legacy_account_id, legacy_customer_id, ppa_enabled, stripe_id
Item legacy_product_id, download_speed, upload_speed, olt_profile
Subscription radius_user, radius_pwd, legacy_service_id
Issue legacy_ticket_id, assigned_staff, issue_type, is_important, service_location

Tech Stack

Frontend: Vue 3, Quasar v2, Pinia, Vite, Mapbox GL JS Backend: ERPNext v16 / Frappe (Python), PostgreSQL, Node.js (targo-hub) Infra: Docker, Traefik v2.11, Authentik SSO, Proxmox Integrations: Twilio (SMS), Mailjet (email), Stripe (payments), Traccar (GPS), GenieACS (TR-069), Gemini 2.5 Flash via targo-hub (vision/OCR — see docs/features/vision-ocr.md)

Data Volumes (migrated from legacy)

Entity Volume
Customers 6,667 (active + terminated)
Subscriptions 21,876 (with RADIUS credentials)
Sales Invoices 115,000+
Payments 99,000+ (with invoice references)
Tickets (Issues) 242,000+ (parent/child hierarchy)
Ticket Messages 784,000+
Devices 7,600+ (ONT, router, TV box)
Service Locations ~17,000

Development

# Ops app
cd apps/ops && npm install && npx quasar dev

# Website
cd apps/website && npm install && npm run dev

# targo-hub
cd services/targo-hub && npm install && npm run dev

# Deploy ops to production
cd apps/ops && bash deploy.sh

Auth Pattern

Authentik SSO protects staff apps via Traefik forwardAuth. The ops app reads X-Authentik-Email from the proxied request header. All ERPNext API calls from targo-hub and the ops nginx proxy use Authorization: token <ERP_SERVICE_TOKEN> (Bearer token from server .env). Customer-facing SSO is at id.gigafibre.ca, federated from auth.targo.ca.

Documentation

Start at docs/README.md — it indexes every doc with a "I want to…" intent table. Quick map:

Area Entry point
Plan & live module URLs docs/roadmap.md
System architecture (services, Docker, SSO) docs/architecture/overview.md
ERPNext data model + customer flows docs/architecture/data-model.md
Frontend patterns (Vue/Quasar/Pinia) docs/architecture/app-design.md
Billing, Stripe, invoices docs/features/billing-payments.md
CPE / modems / ONTs / TR-069 docs/features/cpe-management.md
Scanner / OCR / Gemini pipeline docs/features/vision-ocr.md
Agent flows (Flow Template) docs/features/flow-editor.md
Wizard SKU vs legacy audit docs/reference/erpnext-item-diff.md
Historical snapshots & migration logs docs/archive/