2026-05-24 19:51:29 +00:00
|
|
|
export interface Supplier {
|
|
|
|
|
id: string;
|
|
|
|
|
suppliername: string;
|
2026-05-24 22:47:47 +00:00
|
|
|
email: string;
|
|
|
|
|
suppliernumber: string;
|
2026-05-24 20:31:35 +00:00
|
|
|
supplieraddress: string;
|
2026-05-24 22:47:47 +00:00
|
|
|
supply_tags: string;
|
|
|
|
|
coordinates: string; // Raw coordinates text (e.g. "-33.9249, 18.4241")
|
|
|
|
|
closingtime: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Order {
|
|
|
|
|
id: string;
|
|
|
|
|
order_number: string;
|
|
|
|
|
status: string;
|
|
|
|
|
notes: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PurchaseOrder {
|
|
|
|
|
id: string;
|
|
|
|
|
po_number: string;
|
|
|
|
|
status: string;
|
2026-05-24 19:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface OrderItem {
|
|
|
|
|
id: string;
|
2026-05-24 22:47:47 +00:00
|
|
|
order: string;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Customer-facing line. Use this for label / list / customer view.
|
2026-05-24 19:51:29 +00:00
|
|
|
description: string;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Supplier-facing line. Use this on the PO pickup screen — supplier
|
|
|
|
|
// paperwork references this exact wording. Falls back to description.
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
po_description?: string;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Customer-side quantity. Nullable on legacy rows.
|
2026-05-24 19:51:29 +00:00
|
|
|
quantity: number;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Supplier-side quantity. Per the brief, falls back to quantity when
|
|
|
|
|
// blank (zero is treated as blank in getItemDisplayQty).
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
order_qty?: number;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Pricing — operator-side (cost), customer-side (selling), and audit
|
|
|
|
|
// source ('quote' | 'catalogue' | 'manual').
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
cost_price?: number;
|
2026-07-07 15:15:42 +00:00
|
|
|
selling_price?: number | null;
|
|
|
|
|
pricing_source?: 'quote' | 'catalogue' | 'manual' | string;
|
|
|
|
|
matched_quote_item?: string;
|
|
|
|
|
// Supplier part number. Use this on PO paperwork over description.
|
|
|
|
|
sku?: string;
|
|
|
|
|
// Workflow states. item_status is the operator-side state, drv_status
|
|
|
|
|
// is the driver-side state. They're independent enums — an item can
|
|
|
|
|
// be item_status='collected' (operator marked it received) while
|
|
|
|
|
// drv_status is still 'en_route' (driver hasn't checked in), etc.
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
item_status:
|
|
|
|
|
| 'pending'
|
|
|
|
|
| 'processed'
|
|
|
|
|
| 'po_generated'
|
2026-07-07 15:15:42 +00:00
|
|
|
| 'collection_pool'
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
| 'assigned'
|
|
|
|
|
| 'collected'
|
|
|
|
|
| 'stock_verified'
|
|
|
|
|
| 'picking'
|
|
|
|
|
| 'ready_delivery'
|
|
|
|
|
| 'delivered'
|
|
|
|
|
| 'cancelled';
|
2026-07-07 15:15:42 +00:00
|
|
|
drv_status?: 'unassigned' | 'assigned' | 'en_route' | 'collected' | 'failed' | string;
|
|
|
|
|
driver_status?: string;
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
delivery_status?: 'pending' | 'ready' | 'in_transit' | 'delivered' | 'failed';
|
|
|
|
|
invoice_status?: 'pending' | 'invoiced' | 'paid' | 'cancelled';
|
2026-07-07 15:15:42 +00:00
|
|
|
// Driver assignment. The canonical driver field per the brief is
|
|
|
|
|
// `drv_id` (relation -> users); the older `driver` field is a legacy
|
|
|
|
|
// shadow that only a handful of rows set. Use drv_id in every filter.
|
|
|
|
|
drv_id?: string;
|
|
|
|
|
driver?: string;
|
|
|
|
|
// Server-side ISO timestamp of when drv_id was set. Surface in detail.
|
|
|
|
|
assigned_at?: string;
|
|
|
|
|
// Audit trail of failed-collection attempts. The driver writes here.
|
|
|
|
|
// Distinct from notes (operator-side).
|
|
|
|
|
notes?: string;
|
|
|
|
|
problem_notes?: string;
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
problem_flag?: boolean;
|
2026-07-07 15:15:42 +00:00
|
|
|
problem_type?: 'stock' | 'supplier' | 'driver' | 'delivery' | 'pricing' | 'other' | string;
|
2026-07-07 23:35:26 +00:00
|
|
|
// Legacy: optional proof-of-pickup photo stamped directly on the
|
|
|
|
|
// order_item row. Kept for backwards compat with old data. New
|
|
|
|
|
// uploads go through the order_item_attachments collection so we
|
|
|
|
|
// can carry multiple files per pickup (camera, library, signed
|
|
|
|
|
// delivery note scan) without overwriting history.
|
2026-07-07 18:43:17 +00:00
|
|
|
collection_photo?: string;
|
2026-07-07 15:15:42 +00:00
|
|
|
// Per-row quantities used for proving/dashboard math.
|
|
|
|
|
qty_processed?: number;
|
|
|
|
|
qty_assigned?: number;
|
|
|
|
|
qty_collected?: number;
|
|
|
|
|
qty_delivered?: number;
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
drv_assigned_at?: string;
|
|
|
|
|
drv_collected_at?: string;
|
|
|
|
|
delivered_at?: string;
|
2026-07-07 15:15:42 +00:00
|
|
|
markup?: number;
|
|
|
|
|
markup_percent?: number;
|
refactor(ui): rebrand app, fix supplier naming
- rename `supplier` field to `suppliers` in OrderItem interface and PocketBase expand queries
- complete visual rebrand to warm cream (#f2f1ed) and dark brown (#26251e) color palette with custom CSS variables
- add accessibility improvements: skip-to-main content link, focus-visible styles, reduced motion support, and proper ARIA labels
- update all component styling to match new theme, including offline indicator, install prompt, login page, modals, map, bottom nav and global CSS
- standardize status colors: use green for success, red for errors, retain orange (#f54e00) as primary accent CTAs
2026-07-05 20:32:20 +00:00
|
|
|
legacy_order_item_id?: string;
|
|
|
|
|
// Backwards-compat shim the app uses in some spots
|
|
|
|
|
is_stock_item?: boolean;
|
|
|
|
|
collected_date?: string;
|
|
|
|
|
collection_date?: string;
|
2026-05-24 22:47:47 +00:00
|
|
|
// Expanded fields
|
2026-05-24 19:51:29 +00:00
|
|
|
expand?: {
|
2026-07-07 15:15:42 +00:00
|
|
|
supplier?: Supplier; // PB expand key matches relation field name
|
2026-05-24 22:47:47 +00:00
|
|
|
order?: Order;
|
|
|
|
|
purchase_order?: PurchaseOrder;
|
2026-05-24 19:51:29 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface DriverLocation {
|
|
|
|
|
id: string;
|
2026-07-07 23:35:26 +00:00
|
|
|
// PB schema note (verified live 2026-07-08): the relation field on
|
|
|
|
|
// `driver_locations` is named `relation`, NOT `driver`. Earlier docs
|
|
|
|
|
// and the type had this as `driver` — every save silently 400'd inside
|
|
|
|
|
// a try{}catch{} and the map polyline was always empty.
|
|
|
|
|
relation: string;
|
2026-05-24 19:51:29 +00:00
|
|
|
latitude: number;
|
|
|
|
|
longitude: number;
|
|
|
|
|
accuracy?: number;
|
|
|
|
|
altitude?: number;
|
|
|
|
|
speed?: number;
|
|
|
|
|
heading?: number;
|
|
|
|
|
timestamp: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-07 23:35:26 +00:00
|
|
|
// Attached files for a single order_item — photos taken at pickup,
|
|
|
|
|
// delivery note scans, supplier-side signed slips, etc. Created
|
|
|
|
|
// alongside the order_item row when a driver collects the item and
|
|
|
|
|
// optionally attaches a photo. Mirrors the `quote_item_attachments`
|
|
|
|
|
// schema (one row per file, parent via relation).
|
|
|
|
|
//
|
|
|
|
|
// PB collection verified 2026-07-07: order_item_attachments
|
|
|
|
|
// - order_item : relation -> order_items (cascadeDelete, required)
|
|
|
|
|
// - filename : text (required, max 500)
|
|
|
|
|
// - file : file (image/* + application/pdf, 20MB max)
|
|
|
|
|
// - content_type : text (optional, e.g. "image/jpeg")
|
|
|
|
|
// - size_bytes : number (optional)
|
|
|
|
|
// - source : select (driver_proof | operator_proof | manual)
|
|
|
|
|
// - notes : text (optional)
|
|
|
|
|
// - uploaded_at : autodate (server-side)
|
|
|
|
|
export type AttachmentSource = 'driver_proof' | 'operator_proof' | 'manual';
|
|
|
|
|
|
|
|
|
|
export interface OrderItemAttachment {
|
|
|
|
|
id: string;
|
|
|
|
|
order_item: string;
|
|
|
|
|
filename: string;
|
|
|
|
|
file: string;
|
|
|
|
|
content_type?: string;
|
|
|
|
|
size_bytes?: number;
|
|
|
|
|
source: AttachmentSource;
|
|
|
|
|
notes?: string;
|
|
|
|
|
uploaded_at: string;
|
|
|
|
|
expand?: {
|
|
|
|
|
order_item?: OrderItem;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-24 19:51:29 +00:00
|
|
|
export interface AppSettings {
|
2026-05-24 22:47:47 +00:00
|
|
|
locationInterval: number;
|
|
|
|
|
minimumAccuracy: number;
|
2026-05-24 19:51:29 +00:00
|
|
|
enableHighAccuracy: boolean;
|
|
|
|
|
darkMode: boolean;
|
|
|
|
|
fontSize: 'small' | 'normal' | 'large';
|
|
|
|
|
offlineMode: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DEFAULT_SETTINGS: AppSettings = {
|
|
|
|
|
locationInterval: 60,
|
|
|
|
|
minimumAccuracy: 50,
|
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
|
darkMode: false,
|
|
|
|
|
fontSize: 'normal',
|
|
|
|
|
offlineMode: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const PROBLEM_TYPES = [
|
|
|
|
|
{ value: 'out_of_stock', label: 'Out of Stock' },
|
|
|
|
|
{ value: 'partial_stock', label: 'Partial Stock' },
|
|
|
|
|
{ value: 'quality_issue', label: 'Quality Issue' },
|
|
|
|
|
{ value: 'wrong_item', label: 'Wrong Item' },
|
|
|
|
|
{ value: 'other', label: 'Other' },
|
|
|
|
|
] as const;
|