# Pakajo Dashboard · Development Steps for the Backend Integration

As of: 10 Oct 2026 · Basis: mockup build 2026-10-10-48 · Target system: Pakajo backend

The steps are cut small and ordered sensibly. Each step is testable on its own; the mockup stays runnable throughout because all modules access data only via `window.PakajoBackend` (see *Backend Integration*).

---

## Phase 0 · Project setup

### 0.1 Repository and build
Move the mockup into a repo, split the script blocks into separate files (adapter, modules, styles), build for `dashboard.html`/`index.html` + service worker.

### 0.2 Configuration and environments
`PakajoBackend.config` on environment variables (dev / staging / prod), API base URL, VAT rate, currency.

### 0.3 Authentication
Connect login/registration (`pakajo-login.html`) to the auth service: session token instead of `?selfreg=<base64>`; e-mail confirmation (mail 1) and welcome mail (mail 2) via the mail service.

---

## Phase 1 · Master data from the backend

### 1.1 Carriers
`carriers.all / forScreen / forCountry` → `GET /carriers` (ID, name, service class, transit time, max weight, country coverage, features).

### 1.2 Shipping products
`products.all` → `GET /products` (codes 1–7) plus pickup/drop-off/return products `products.pickup(mode)`.

### 1.3 Countries and Glocal countries
`countries.list` (ISO-2/ISO-3/name/flag) and `glocal.countries` from the Glocal product group.

### 1.4 Customers and clients
`customers.list / get / save` → existing customers from the backend; master client + locations; Enterprise customers created directly in the backend appear in the frontend.

### 1.5 Users and roles
`users.list / current` → users, roles, client assignment, sub-user login (sees only assigned clients).

---

## Phase 2 · Prices and subscriptions

### 2.1 Quote
`pricing.quote` → `POST /quote` (carrier, country, weight, dimensions, product, insurance, express → net/VAT/gross) from the customer's offer groups.

### 2.2 Offer groups and subscriptions
`subscriptions.*` → offer group per customer, active plan, discounts, feature unlocks (box presets from Silver, shipping rules from Gold, client/user limits) checked **server-side**.

### 2.3 Billing
`billing.*` → prepaid top-up, payment method (card/PayPal), request SEPA mandate and approve by Pakajo, plan switch, prepaid credit on plan start, Bronze trial.

### 2.4 Gross/net
Store the "entitled to input-tax deduction" flag from the registration on the master client; render prices from `quote()` directly as net/gross (DOM conversion removed).

---

## Phase 3 · Shipping

### 3.1 Single shipment
Create shipment → `POST /shipments` (client, destination ISO-2, dimensions, product, carrier ID, recipient, additional insurance); label/tracking number from the server.

### 3.2 Orders and collective orders
`shipments.orders` → orders, daily collective order, shipments per order; unify status enum.

### 3.3 Bulk shipping
Import (XLSX/CSV) → backend validation and calculation; rows deliver `dest`, `gewicht`, `produkt`, `carrierId`; workflow steps (calculated → shipping data → label) from the backend.

### 3.4 Shipping rules
`rules.list / save` → persist rules per customer; application in single and bulk shipping (first matching rule wins); AI suggestions `rules.aiSuggestions` from the shipping analysis.

### 3.5 Customs and commercial invoice
Import tax `importTax(iso)`, CN22/commercial invoice from customer input, customs tariff products per shipment.

### 3.6 Pickup, drop-off, return pickup
Booking → backend (slot/fixed slots, drop-off points, pickup quota per plan, fill rule); label/QR code from carrier or backend.

---

## Phase 4 · After shipping

### 4.1 Tracking
`tracking.events(nr)` → AI tracking (existing); master-detail view reads backend data only.

### 4.2 Returns
`returns.list` → returns portal from the backend (existing) rendered in the frontend.

### 4.3 Claims (Bitrix24)
`claims.tickets / webhook` → ticket created by the service, customer is participant; webhooks ONTASKADD / ONTASKUPDATE / ONTASKCOMMENTADD; messenger in the dashboard; e-mail invitation.

### 4.4 Invoices and ESN data
`billing.invoices` → invoice overview and XLSX export from the ESN shipping data; credit notes.

---

## Phase 5 · Shop, data, analytics

### 5.1 Shop and marketplace orders, articles
`orders.shopOrders / articles` → display existing backend data; order → shipment.

### 5.2 Shipping performance
`performance.query` → SQL editor queries into the frontend (charts/KPIs).

### 5.3 Pricing tool
Price overview from real offer-group prices per plan (+ AI suggestions); XLSX export.

### 5.4 Integrations and API docs
`integrations.list`, `apiDocs.url` → embed existing backend integrations and docs; API keys server-side.

---

## Phase 6 · Customer area

### 6.1 Address book
`addressbook.list` + save/edit in the backend (display stays frontend).

### 6.2 Box presets
Frontend storage per customer (optional backend sync).

### 6.3 Branding
Logo/colours/sender data for label, commercial invoice, returns portal (frontend + backend).

### 6.4 Paku Points
`points.*` → balance, credit per shipment, redeem; only Free/Bronze/Silver/Gold (not Enterprise).

### 6.5 Profile, language, currency, 2FA
Profile data per user from the backend; language/currency as preference; 2FA in the frontend.

---

## Phase 7 · Hardening and acceptance

### 7.1 Security
Proxy LLM calls (chatbot/AI suggestions) via the backend, no API keys in the browser; tracking lookups via the backend; IDs (tracking, booking, ticket, credit note) from the server.

### 7.2 Enums and i18n
Central status, plan and product enums; labels via i18n (DE/EN/ES/FR/IT …).

### 7.3 Remove demo data
Replace demo clients 2600–2607 and static table rows with seed data from the backend.

### 7.4 Mobile and PWA
Responsive check of all screens, service worker/caching, offline notes.

### 7.5 Acceptance
Test cases per phase (new registration → first shipment, plan switch, bulk shipping with rules, claim via webhook, pickup with label/QR), launch preparation.
