# Dezen B2B portal — MVP specification

Wholesale ordering portal for Dezen (True Innovation DOO). Approved business customers browse a price list in an Excel-like grid, enter quantities in master cartons and submit orders. Dezen reviews each order, marks availability per line, confirms manually, and continues outside the portal (pro forma, invoicing, fiscal documents are NOT part of this system).

- URL: `b2b.dezen.rs` (domain may change later; keep it in config only)
- UI language: **Serbian Latin** everywhere (customer and admin). Code, identifiers and comments in English.
- Currency: **RSD only**. All prices are per piece, **excluding VAT**.
- Brands at launch: **La Rochère**, **Zafferano**. Dezen holds no stock; goods are ordered from the factory after an order is confirmed.
- Visual reference: `mockups/` (see `mockups/README.md`). The screen descriptions in this file are authoritative on behaviour; the mockups on layout and look.

---

## 1. Stack and hosting

- **Laravel** (current LTS-compatible major), **PHP 8.2+**, **MySQL/MariaDB**.
- **Filament 3** for the admin panel (`/admin`).
- Customer side: Blade + **Alpine.js** (or Livewire where it fits). The order grid must feel instant: quantity changes update totals client-side with no server round-trip; the cart is synced to the server debounced (≈500 ms) so it survives a reload.
- **PhpSpreadsheet** (e.g. via `maatwebsite/excel` or direct) for xlsx import/export.
- **Intervention Image** for thumbnails.
- Transactional email via an SMTP relay service (Brevo or Postmark), configured in `.env`. Do not rely on the hosting's local mail.
- Hosting: shared cPanel hosting with SSH. Requirements: document root pointed at `/public`, `composer` over SSH, cron entry `* * * * * php artisan schedule:run`. Queue driver `database`; the scheduler runs `queue:work --stop-when-empty` every minute (no long-running workers on shared hosting).
- Write a short `DEPLOY.md` covering first deploy and updates on cPanel.

## 2. Formatting conventions

- Money: `1.234,56` (dot thousands, comma decimals) + ` RSD`. Store as `DECIMAL(12,2)`.
- Dates: `20.11.2026.` ; datetimes `20.11.2026. u 18:42`. Timezone `Europe/Belgrade`.
- Percentages: integers or one decimal, `10%`.
- Rounding: round to 2 decimals at the **unit-price** step and at the **VAT** step (see §5). Never round line totals separately beyond 2 decimals.

## 3. Roles and access

- **Guest**: login, registration, password reset. Never sees prices or the catalog.
- **Customer (pending)**: registered, awaiting approval. After login sees only a "Vaš nalog čeka odobrenje" page. No prices, no catalog.
- **Customer (approved)**: catalog grid, cart, order submission, own order history, own company data (read-only except contact phone/person; changes to PIB/name go through Dezen).
- **Customer (rejected / disabled)**: cannot log in; message "Nalog nije aktivan. Kontaktirajte nas."
- **Admin**: Filament panel. Admins are created via artisan command (`php artisan b2b:make-admin`), not via registration.

One login (email) per company in MVP.

**Security rule:** prices and discounts are only ever rendered or returned for authenticated, approved customers. No price data in any guest-reachable response, JSON, or HTML.

## 4. Data model

```
companies
  id, name, pib (char 9, unique), maticni_broj (char 8), activity (enum: retail, horeca, interior_design, corporate_gifts, other),
  vat_registered (bool), address, city, postal_code,
  delivery_same_as_seat (bool), delivery_address, delivery_city, delivery_postal_code (nullable),
  contact_name, contact_phone, note (text, nullable),
  status (enum: pending, approved, rejected, disabled), approved_at, approved_by,
  general_discount (decimal 5,2, default 0), timestamps

users
  id, company_id (nullable for admins), email (unique), password, is_admin (bool), timestamps
  -- standard Laravel auth + password reset

brands
  id, name (unique), lead_time_days (int, default 30), timestamps

categories
  id, name (unique), sort_order (int), timestamps
  -- created automatically from import values; sort_order editable in admin

products
  id, sku (unique), name, ean (nullable), brand_id, category_id (nullable),
  price (decimal 12,2, RSD per piece excl. VAT), carton_qty (int ≥1),
  image_thumb_path (nullable),
  is_active (bool), last_import_id, timestamps

discount_rules
  id, company_id, scope (enum: brand, product), brand_id (nullable), product_id (nullable),
  percent (decimal 5,2, 0–100), timestamps
  unique(company_id, scope, brand_id, product_id)
  -- the general discount lives on companies.general_discount

carts
  id, company_id (unique), updated_at
cart_items
  cart_id, product_id, cartons (int ≥1)   -- rows with 0 are deleted

orders
  id, number (unique, "B2B-2026-0001", sequential per year), company_id, user_id,
  status (enum: received, confirmed, shipped, cancelled),
  customer_note (text), admin_message (text, sent in confirmation email),
  submitted_at, confirmed_at, confirmed_by, delivery_due_date (date, nullable), shipped_at, cancelled_at,
  -- snapshot of company data at submission:
  company_snapshot (json),
  -- totals (recomputed on every admin edit, stored for listing):
  net_now, vat_now, gross_now, net_backorder, net_unavailable  (decimal 12,2)
  vat_rate (decimal 5,2)  -- snapshot of settings at submission

order_lines
  id, order_id, product_id (nullable, keep line if product later deleted),
  -- snapshot at submission:
  sku, name, brand_name, carton_qty, list_price, discount_percent, discount_source (enum: product, brand, general), unit_price,
  cartons_ordered,
  -- admin-editable before confirmation:
  cartons_confirmed, availability (enum: available, backorder, unavailable, default available), backorder_expected_date (nullable),
  pieces (computed: cartons_confirmed × carton_qty), line_total (pieces × unit_price)

price_imports
  id, user_id, filename, brands_in_file (json), rows_total, rows_published, rows_skipped,
  report (json: errors, warnings), status (enum: previewed, published, cancelled), timestamps

settings  (key/value, cached)
  min_order_net (default 35000), vat_rate (default 20),
  notification_emails (json array)
```

## 5. Pricing rules

**Discount resolution** (most specific wins, never added together):

1. product rule for this company → use it (0% = net item, overrides brand rule)
2. else brand rule for this company → use it
3. else `companies.general_discount`

No category-level discounts in MVP.

**Calculation**

- `unit_price = round(list_price × (1 − percent/100), 2)`
- `pieces = cartons × carton_qty`
- `line_total = unit_price × pieces`
- `net = Σ line_total` ; `vat = round(net × vat_rate/100, 2)` ; `gross = net + vat`

All calculation lives in one PHP service (`PriceCalculator`) with unit tests. The front-end grid duplicates the arithmetic for live totals, but the server is the source of truth on submit.

## 6. Customer side

### 6.1 Registration (`/registracija`)
Fields (all required unless noted): PIB, matični broj, poslovno ime, delatnost (select), u sistemu PDV-a (da/ne), ulica i broj, mesto, poštanski broj, checkbox "Adresa isporuke je ista kao adresa sedišta" (if unchecked: delivery address fields), ime i prezime kontakt osobe, telefon, e-mail, lozinka (min 10), ponovljena lozinka, napomena (optional), checkbox prihvatanja uslova (links to terms/privacy pages, content provided later).

Validation:
- **PIB**: 9 digits + ISO 7064 MOD 11,10 check digit:
  ```
  a = 10
  for each of the first 8 digits d: a = (a + d) % 10; if a == 0: a = 10; a = (a * 2) % 11
  check = (11 − a) % 10   → must equal digit 9
  ```
  Show live "✓ PIB je ispravnog formata" under the field. PIB must be unique.
- Matični broj: exactly 8 digits.
- Rate-limit registration (e.g. 5/hour/IP) and add a honeypot field.

After submit: account `pending`, user sees "Zahtev je primljen. Javićemo vam se e-mailom kada nalog bude aktivan." Admin notification email goes to `notification_emails`.

Side panel on the page: "Kako funkcioniše" (registracija → odobrenje → poručivanje → potvrda; step 4 text: "Potvrda. Proveravamo raspoloživost kod proizvođača i šaljemo potvrdu sa XLSX listom stavki.") and a note: "Minimalna porudžbina: {min_order_net} RSD bez PDV-a. Poručuje se u celim transportnim kartonima. Rok isporuke je 30 dana od potvrde porudžbine." (values from settings / brand lead time).

### 6.2 Catalog grid (`/katalog`) — the core screen
Header: logo "dezen" + B2B badge; nav: Katalog, Moje porudžbine, Podaci firme; right: company name, PIB, short discount summary; Odjava.

Above the grid:
- Title "Cenovnik", subline "Ažurirano {last publish date} · Cene su u dinarima, po komadu, bez PDV-a · Poručuje se u celim kartonima".
- Toolbar: search (SKU, name, EAN; instant, client-side), brand select (Svi brendovi / per brand), toggle "Samo izabrano (n)".
- Info bar (green): **"Rok isporuke: 30 dana od potvrde porudžbine."** (use the brand lead time; if brands differ, show "Rok isporuke: La Rochère X dana, Zafferano Y dana od potvrde porudžbine.")
- Category chips: "Sve (n)" + one per category with product count; one active at a time.

Grid:
- **No pagination.** Whole filtered list in one scrolling table with a sticky header inside a fixed-height scroll box. Load all active products for the approved customer in one payload (prices already discount-resolved server-side). If the catalog exceeds ~1,500 rows, add row virtualization; lazy-load images (`loading="lazy"`).
- Rows grouped by category with a group header row ("Čaše · 9"), categories in `sort_order`.
- Columns: slika (40 px thumb, "bez slike" placeholder) · Šifra · Naziv · EAN · Kom/karton · Cenovnik RSD (struck through when a discount applies) · Rabat (badge, tooltip shows source: "Rabat za artikal" / "Rabat za brend X" / "Opšti rabat") · Vaša cena RSD · **Kartona** (− [input] +) · Komada · Iznos RSD bez PDV.
- Quantity is entered in **cartons** (integers ≥0). Komada = kartona × kom/karton. Rows with quantity get a light green background.
- Keyboard: Enter or ↓ in a quantity input moves focus to the next row's input; ↑ moves up; typing replaces the value. Tab works normally.

Sticky footer (always visible):
- Stavki · Kartona / komada · Osnovica · PDV 20% · Ukupno sa PDV.
- Progress bar toward the minimum: "Još X RSD do minimalne porudžbine od Y RSD (bez PDV)" or "Minimalni iznos porudžbine je dostignut".
- Button "Pregled porudžbine →" (disabled below the minimum), with small text under it: "Isporuka 30 dana od potvrde".

### 6.3 Order review (`/porudzbina/pregled`)
Read-only list of selected lines with totals, editable quantities allowed (link back to grid), optional note "Napomena", button "Pošalji porudžbinu". The server re-validates: approved company, active products, cartons ≥1, min order met. On success: create order (status `received`) with full snapshot, empty the cart, show "Porudžbina {number} je poslata. Dobićete e-mail kada je potvrdimo." No email to the customer at this point.

If a product in the cart was deactivated by a newer import, remove it from the cart with a visible notice on the grid.

### 6.4 Moje porudžbine
List: broj, datum, status (Primljena / Potvrđena / Poslata / Otkazana), iznos, rok isporuke (when confirmed). Detail: lines with availability status per line once confirmed, totals split as in the admin screen, admin message.

### 6.5 Podaci firme
Read-only company data; contact person and phone editable; password change.

## 7. Admin side (Filament, `/admin`, Serbian labels)

Navigation: Kontrolna tabla, Porudžbine (badge: count of `received`), Kupci (badge: count of `pending`), Cenovnik. Kontrolna tabla holds, in order: pending customers (when any), Podešavanja (§7.5), Brendovi (lead times editable in the table) and Slike ("Bez slike", §7.4); they have no menu items of their own.

### 7.1 Porudžbine
- List: number, company, submitted at, **waiting time** for `received` orders (e.g. "čeka 2 dana", highlighted after 1 working day), status, net, delivery due. Filters by status and company.
- Detail:
  - Header: number, status badge, submitted datetime, and for `received`: "Ako potvrdite danas, rok isporuke je {today + lead time}."
  - Status stepper: Primljena → Potvrđena → Poslata; separate Otkazana.
  - Lines table: Šifra, Naziv, Kom/kart., Rabat, Cena RSD, Poručeno kart., **Potvrđeno kart.** (editable while `received`), **Dostupnost** (select: Dostupno / Naknadna isporuka / Nije dostupno; colored), expected date input when Naknadna isporuka, Komada, Iznos. Unavailable lines are struck through and excluded.
  - Totals: "Za isporuku sada" (net, VAT, gross); "Naknadna isporuka, osnovica" (not on the first pro forma, invoiced when shipped); "Nije dostupno (ne obračunava se)".
  - Side: company card (snapshot + link to customer), customer note, textarea "Poruka uz potvrdu".
  - Actions: **Preuzmi XLSX**, **Odbij** (→ cancelled, confirm dialog, no email in MVP), **Potvrdi porudžbinu**.
  - Line amounts: **Nije dostupno** sets `cartons_confirmed = 0` (pieces 0); the "Nije dostupno" total is computed from `cartons_ordered × carton_qty × unit_price` and reported only. **Naknadna isporuka** and **Dostupno** use `cartons_confirmed`.
  - **Rok isporuke** field (date, editable while `received`): defaults to today + max(lead_time_days of brands among lines that are not unavailable); if no such line exists, max lead time across all lines in the order. Dezen checks with the factory and adjusts it before confirming.
  - On confirm: if `net_now` < min order → show a warning but allow confirming. Set `confirmed_at`, `delivery_due_date` = the Rok isporuke field, lock line editing, send the customer confirmation email.
  - "Označi kao poslato" on confirmed orders sets `shipped`.

### 7.2 Kupci
- "Na čekanju" section on top: firm, PIB, delatnost, kontakt, date; actions Odobri (→ approved, sends "nalog odobren" email) / Odbij (→ rejected, no email).
- Customer detail: company data, status (can disable), orders list, and **Rabati**:
  - Info text: "Važi najkonkretnije pravilo: rabat za artikal, zatim rabat za brend, zatim opšti rabat. Rabati se ne sabiraju. Rabat 0% za artikal znači neto cenu."
  - Opšti rabat: one % input.
  - Rabat po brendu: table brand / % / remove; add via brand select.
  - Rabat po artiklu: table SKU / naziv / cenovnik / % / resulting price / remove; add via SKU-or-name search.

### 7.3 Cenovnik (price import)
Flow: upload xlsx → **preview report** (nothing changes yet) → Objavi / Otkaži.

Expected columns (first sheet, header row 1, header names matched case-insensitively after trimming; accept these aliases):

| Field | Accepted headers |
|---|---|
| sku (required) | `SKU`, `ŠIFRA`, `SIFRA`, `ITEM CODE` |
| name (required) | `NAZIV`, `DESCRIPTION`, `DESCRTIPTION` |
| price RSD (required, >0) | `CENA`, `PRICE`, `NET PRICE` (prefix match) |
| carton_qty (required, int ≥1) | `KOM/KARTON`, `MASTER BOX` (prefix match) |
| ean (optional) | `EAN` (prefix match) |
| brand (required) | `BREND`, `BRAND` |
| category (optional) | `KATEGORIJA`, `CATEGORY` |

Unknown columns (e.g. `ORDER`) are ignored and listed as "Ne uvozi se". The picture column (`IMG`, `SLIKA`) is used for product pictures, see §7.4.

Validation report:
- **Errors (row skipped):** missing SKU, missing name, missing/zero/non-numeric price, missing/invalid carton qty, missing brand, duplicate SKU within the file (first occurrence wins, later ones skipped).
- **Warnings (row published):** carton qty identical for every row in the file ("proverite da li je tačno"); prices with more than 2 decimals (rounded); brand value that looks like a number; EAN not 8/13 digits; unknown brand (will be created).
- Summary cards: Spremno za objavu · Preskače se · Upozorenja · Bez slike.
- Show Excel row numbers (header = row 1).

Publish semantics — **scoped to brands present in the file**:
- Upsert products by SKU (name, price, carton qty, EAN, brand, category; `is_active = true`).
- Products of those brands whose SKU is **not** in the file → `is_active = false` (never deleted).
- Products of other brands are untouched. The preview states this explicitly, e.g. "Fajl sadrži brend Zafferano. Menjaju se samo Zafferano artikli … La Rochère ostaje nepromenjen."
- Existing orders are never changed (they use line snapshots). Carts: deactivated products are dropped from carts; price changes simply apply to the cart.
- Wrap publish in a DB transaction. Keep an import history list (who, when, file, counts).

### 7.4 Slike
- Pictures come from the price list: a picture placed in the picture column (`IMG`, `SLIKA`, `IMAGE`, `PICTURE`, `FOTO`) becomes the image of the product in that row. Matching is by position only:
  - a row gets a picture only when exactly one picture starts in the picture column inside that row and lies entirely within it (2 pt tolerance);
  - rows with several pictures, or a picture reaching into another row, are "unclear": listed in the preview as a warning, imported without a picture from the file. Never guessed.
- The preview shows the counts, the unclear rows, the SKUs that will stay without a picture, and a gallery of matched thumbnails next to their SKUs.
- On publish: a picture in the file replaces the product's current picture; no picture in the file keeps the current one (never deletes).
- Only a thumbnail is stored: 96×96 contain, white background, JPEG, under `storage/app/public/products/thumbs/`. No large image.
- Missing pictures are added one product at a time from Cenovnik ("Dodaj sliku" / "Zameni sliku"). There is no zip upload.
- Slike section on Kontrolna tabla: report "Bez slike" (active SKUs with no image, per brand) with a link to Cenovnik filtered to those products.

### 7.5 Podešavanja
- Minimalna porudžbina (RSD, bez PDV) — default 35.000.
- Stopa PDV-a — default 20%.
- **Rok isporuke po brendu** (calendar days from confirmation): managed in the **Brendovi** section on Kontrolna tabla (list, add, rename, lead time edited in the table, delete a brand without products). Brands also appear there when an import creates them.
- **Podrazumevani rok za nove brendove**: lead time a brand gets when an import creates it (default 30).
- **E-mail adrese za obaveštenja** — list, add/remove. Receives: new order, new registration.
- Category order (drag or sort numbers).

### 7.6 Naknadne isporuke (backorders) — agreed and built 21.11.2026.
After confirmation, every line with availability "Naknadna isporuka" has its own backorder status. Whole lines only: the customer accepts or declines a whole line, and Dezen delivers a whole line at once (if the factory splits it, Dezen adjusts and handles the rest separately).

Backorder statuses (customer label in quotes):

| Status | Customer sees | Customer can | Set by |
|---|---|---|---|
| awaiting_answer | "Čeka vaš odgovor" | Prihvatam · Ne želim | confirmation |
| accepted | "Prihvaćeno, čeka proizvođača" | Odustajem | customer (Prihvatam) |
| ordered | "Poručeno kod proizvođača" | — | Dezen ("Označi poručeno") |
| delivered | "Isporučeno {date}" | — | Dezen ("Označi isporučeno") |
| declined | "Odbili ste {date}" | — | customer (Ne želim / Odustajem) |
| cancelled | "Otkazao Dezen {date}" + reason | — | Dezen ("Otkaži") |

Rules:
- The customer may decline while the line is awaiting_answer or accepted, immediately and without approval, with an optional reason. Once Dezen marks it ordered, the decline option disappears (that is the cutoff).
- No answer: one reminder email after 2 working days (Mon–Fri) in awaiting_answer; after that the line stays awaiting_answer and is flagged in the admin list for Dezen to follow up.
- Dezen can change the expected date while the line is not final; the customer is emailed only when the date moves later.
- Marking delivered changes only the line, not the order status. The order page shows how many backorders are still open.
- The order's "Naknadna isporuka" total counts only awaiting_answer, accepted and ordered lines; declined and cancelled lines drop out of it.

Customer panel:
- Menu item **Naknadne isporuke** (only shown when the customer has any backorders), with a badge counting lines awaiting their answer.
- The catalog shows a notice while answers are pending: "N stavki na naknadnoj isporuci čeka vaš odgovor →".
- The page lists, per section: Čeka vaš odgovor · Prihvaćeno, čeka proizvođača · Poručeno kod proizvođača · Istorija (delivered, declined, cancelled). Columns: šifra, naziv, kartona, iznos bez PDV, očekuje se, porudžbina; totals per section. Decline asks for confirmation with an optional reason.
- The order page in Moje porudžbine shows each backorder line's status with the same buttons.

Admin:
- In Porudžbine, a tab **Naknadne isporuke** across all customers, with a badge for lines awaiting the customer's answer. Filters: kupac, brend, status, očekivani datum. Shows when the reminder was sent. Bulk actions on selected lines: Označi poručeno, Promeni očekivani datum, Označi isporučeno, Otkaži (with reason).
- The same list, filtered to the customer, on the customer's page in Kupci.
- The order detail shows each backorder line's status.

E-mails:

| Event | To |
|---|---|
| Order confirmed with backorders | customer: the confirmation lists them with a button "Odgovorite na naknadnu isporuku" |
| Reminder (once, after 2 working days without answer) | customer |
| Customer declines (Ne želim / Odustajem) | notification_emails |
| Customer accepts | none |
| Marked delivered | customer |
| Expected date moved later | customer |
| Cancelled by Dezen | customer, with reason |

## 8. Emails (Serbian, simple branded HTML + plain-text part, queued)

| Trigger | To | Content |
|---|---|---|
| New registration | notification_emails | company, PIB, contact, link to approve |
| Account approved | customer | account is active, login link |
| New order submitted | notification_emails | number, company, net total, link to admin; **order xlsx attached** |
| Order confirmed | customer | number, lines grouped: Za isporuku (with qty/prices), Naknadna isporuka (with expected date), Nije dostupno; totals "za isporuku sada"; **rok isporuke {delivery_due_date}**; admin message; **order xlsx attached** (with availability per line) |
| Order cancelled | customer | number, optional explanation from Dezen, contact address (decision 21.11.2026.) |
| Order shipped | customer | number, optional note (courier, tracking), reminder about backorder lines (decision 21.11.2026.) |
| Password reset | user | Laravel default, translated |

No email to the customer on submit (Dezen confirms first). Cancellation and shipping do email the customer (decisions 21.11.2026.).

## 9. Order xlsx export
Simple list, one sheet. Header block: broj porudžbine, datum, kupac, PIB, adresa isporuke, napomena. Then columns: Šifra, EAN, Naziv, Brend, Kom/karton, Kartona, Komada, Cenovnik, Rabat %, Cena, Iznos, Dostupnost. Totals at the bottom. Numbers as real numeric cells (not text). Filename `B2B-2026-0014.xlsx`.

## 10. Build phases and acceptance

**Phase 1 — Foundation & accounts**
Laravel + Filament install, Serbian locale, auth, registration with PIB validation, pending/approved flow, admin Kupci approve/reject, settings model, admin creation command, `DEPLOY.md`.
✓ A company registers, admin gets an email, approves, customer gets an email and can log in; pending users see no prices anywhere.

**Phase 2 — Catalog data**
Brands, categories, products, xlsx import with preview/validation/brand-scoped publish, import history, product pictures from the xlsx (thumbnails), single-picture upload.
✓ Importing the test file shows the expected errors/warnings; publishing a single-brand file leaves the other brand untouched.

**Phase 3 — Customer ordering**
PriceCalculator + discount rules (with unit tests covering precedence and rounding), catalog grid (grouping, chips, search, brand filter, only-selected, keyboard nav, sticky footer, min-order gate), server-synced cart, review page, order submission with snapshots, Moje porudžbine.
✓ Totals in the grid match the server to the para; an order below the minimum cannot be submitted.

**Phase 4 — Admin orders & emails**
Orders list with waiting time, order detail with availability/confirmed cartons, split totals, confirm/cancel/ship, delivery due date, xlsx export, all emails, Podešavanja screens (lead times, notification emails, category order), discount management UI on customers.
✓ Confirming an order with one unavailable and one backorder line produces the correct totals, due date and customer email.

Each phase: feature tests for the rules above; seeders with demo data (two brands, three categories, ~30 products, one pending and one approved company with brand + product discounts).

## 11. Out of scope for MVP
Pro forma / invoices / fiscalization, stock levels, multiple users per company, per-category discounts, English UI, customer-facing email on submit, payment, integration with the WooCommerce shop on dezen.rs.

## 12. Decisions log (agreed with Stevan)
- Standalone app, not a WooCommerce plugin.
- Prices hidden until the account is approved.
- One price list for all; per-customer discounts at general / brand / product level; most specific wins, no stacking; no category discounts for now.
- Ordering in master cartons; carton qty from the price list is both the minimum and the step.
- No stock shown. Delivery: 30 days from confirmation (per-brand setting).
- Minimum order configurable in admin, default 35.000 RSD excl. VAT. If marking lines unavailable drops an order below the minimum, admin is warned but may still confirm.
- Backorder lines are not on the first pro forma; invoiced when shipped.
- Customer is emailed only when the order is confirmed (plus account approval).
- Price changes = upload a new xlsx; images uploaded separately, keyed by SKU.
- Serbian Latin UI, RSD only.
- Order confirmation email to the customer carries the order XLSX (registration page says so). (20.11.2026.)
- Unavailable lines: confirmed cartons 0, value reported from ordered cartons. (20.11.2026.)
- Delivery due date: default from brand lead time (usually 30 days), admin adjusts after checking with the factory, before confirming. (20.11.2026.)
- Discount rule uniqueness enforced in application code (MySQL unique index ignores NULLs). (20.11.2026.)
- `vat_registered` is informational only; VAT is always charged. (confirmed 21.11.2026.)
- Laravel 13 (current) with Filament 3.3 as specified; production needs **PHP 8.3+** (Laravel 13 minimum), so the cPanel account must offer PHP 8.3 or 8.4. (20.11.2026., proposed in Phase 1 — Stevan to confirm)
- Registration rate limit counts successful registrations only (5/hour/IP), so a customer correcting validation errors is not locked out. (20.11.2026., proposed in Phase 1 — Stevan to confirm)
- After registering, the customer is not logged in automatically; they see the "Zahtev je primljen" page and can log in to see the pending page. (20.11.2026., proposed in Phase 1 — Stevan to confirm)
- Admin status actions: Odobri (pending/rejected → approved, email), Odbij (pending → rejected, no email), Onemogući (approved → disabled), Ponovo aktiviraj (disabled → approved, no email). (20.11.2026., proposed in Phase 1 — Stevan to confirm)
- Postal codes validated as 5 digits (Serbian format). (20.11.2026., proposed in Phase 1 — Stevan to confirm)
- SKUs are not case-sensitive: the xlsx and image filenames may use any case; SKUs are stored and shown in upper case. (21.11.2026.)
- A price list without a category column leaves existing products' categories unchanged; new products from it have no category. (21.11.2026.)
- "Brands in the file" for publish scoping = brands of the rows that pass validation. A brand value that looks like a number (e.g. "70133759") is still created, with a warning in the preview. (21.11.2026.)
- The "more than 2 decimals" warning ignores floating-point noise from Excel formulas (23.040000000000003 counts as 23.04). (21.11.2026.)
- Uploaded price list files are kept and can be downloaded from the import history. (21.11.2026.)
- Price list files are in RSD; no currency conversion on import. (21.11.2026.)
- Pictures are taken from the price list xlsx by position (rules in §7.4); unclear rows get no picture and are reported. Gaps are filled one product at a time from Cenovnik ("Dodaj sliku"). Zip upload removed. (21.11.2026.)
- Thumbnails only (96 px): no large image and no click-to-enlarge in the grid (MVP). A picture in the file replaces the current one; no picture in the file keeps it. (21.11.2026.)
- Brand names in price lists match existing brands ignoring spaces, accents, punctuation and case ("LaRochere" = "La Rochère"); the stored name is what customers see. (21.11.2026.)
- Brands and lead times are managed in admin (Brendovi), not seeded or hardcoded; new brands from imports get the default lead time set in Podešavanja. The customer-facing lead-time text only counts brands with active products. (21.11.2026.)
- Admin layout: menu is Kontrolna tabla, Porudžbine (when built), Kupci, Cenovnik. Podešavanja, Brendovi and Slike are sections on Kontrolna tabla, not menu items. (21.11.2026.)
- Phase 3 also includes: discount management on the customer page in Kupci (moved from Phase 4), the customer "Podaci firme" page (§6.5), and category order as a "Kategorije" section on Kontrolna tabla (moved from Phase 4). Products without a category are shown last in the grid under "Ostalo". (21.11.2026.)
- The catalog grid must work well on phones: below tablet width each product is a compact card with the same quantity controls and the sticky totals footer. (21.11.2026.)
- Pricing arithmetic runs in whole paras and basis points (integers) on both server and client, so grid and server agree exactly; a test runs the browser code in Node against PHP on 2,000 random carts. (21.11.2026.)
- Grid order: categories by their order, then SKU (natural order); "Ostalo" last. Search matches SKU, name and EAN, every word, ignoring accents. (21.11.2026.)
- Cart sync sends the whole quantity map (debounced 500 ms, and once more when the page is left); max 9.999 cartons per product. The review page is read-only with a link back to the grid to change quantities. (21.11.2026.)
- A 0% product rule shows no discount badge in the grid (price equals list price). (21.11.2026.)
- Order waiting time counts working days Mon–Fri (no holidays); highlighted after more than 1 working day. (21.11.2026.)
- An order can be cancelled while received or confirmed (not after shipping). The customer gets a cancellation email with an optional explanation, also shown on the order. (21.11.2026., changes §8/§11)
- Marking an order shipped emails the customer, with an optional note (e.g. courier, tracking). (21.11.2026., changes §8/§11)
- Confirmed cartons per line may be any whole number 0–9.999, also more than ordered; totals and the confirmation follow the confirmed amount. (21.11.2026.)
- `vat_registered` is information only; VAT is always charged. (21.11.2026., confirmed by Stevan)
- Backorder handling (§7.6) agreed: customer must accept or decline each backordered line; can decline immediately until Dezen marks it ordered; one reminder after 2 working days, then Dezen follows up; whole lines only; delivery changes only the line; date-change email only when later; admin list as a tab in Porudžbine plus per customer. Built 21.11.2026.
- Each brand has an optional "Link za pretragu" (Brendovi on Kontrolna tabla). Clicking a šifra in admin Cenovnik and in the customer catalog opens that link with the šifra filled in, in a new tab; the šifra is appended to the link, or replaces {sifra} if present. E.g. https://larochere.com/search?q= and https://www.zafferanoitalia.com/en-eu/search?type=product&q= . (21.11.2026.)
- Customers can repeat a past order ("Ponovi porudžbinu" on the order page and list): the products are added to the cart with the cartons originally ordered, at today's prices; inactive products are skipped with a notice; the catalog then opens on "Samo izabrano". (21.11.2026.)
- Catalog filter "Već poručivani artikli": products the company has ever ordered (all past orders, cancelled included); shown only when there are any. (21.11.2026.)
- The Rabat column is hidden for a customer without any discount (catalog grid, review page, order page); it shows as soon as any product/line has one. Admin always shows it. (21.11.2026.)
- The "Cenovnik" (list price) column is also hidden for a customer without any discount, so only "Vaša cena" shows. (21.11.2026.)
- Admin can add a customer in Kupci ("Novi kupac"), e.g. after a phone call: same fields as registration plus login e-mail; created approved. Default: the customer gets an e-mail with a 7-day link to set the password; alternatively Dezen sets a password and tells the customer. "Pošalji link za lozinku" on the customer page resends the link. (21.11.2026.)
- Installation and updates without SSH (21.11.2026.): a web installer at /instalacija (server check, database, e-mail with test, install, admin account, cron line with live check), which locks itself when finished. Only someone with the cPanel database credentials can complete it. Updates: upload the new zip in cPanel File Manager and extract it; the app clears its caches and runs pending database migrations itself on the next request. "Provera sistema" on Kontrolna tabla shows cron, e-mail queue, settings and limits, and allows a test e-mail and changing the e-mail settings.
- E-mail goes through Google Workspace SMTP (smtp.gmail.com:587, app password): login account b2b@studio.rs, sender b2b@dezen.rs (dezen.rs is a domain alias of studio.rs). The hosting's local mail is not used. Replaces the Brevo/Postmark default in §1. (21.11.2026.)
