import { apiFetch } from './client'; export interface Warehouse { warehouse_id: string; tenant_id: string; name: string; code: string; location_address?: string; is_active: boolean; created_at: string; } export interface PosTerminal { terminal_id: string; tenant_id: string; location_id: string; code: string; name: string; is_active: boolean; created_at?: string; } export interface PosSession { pos_session_id?: string; session_id?: string; tenant_id: string; location_id?: string; terminal_id?: string; warehouse_id?: string; user_id?: string; opened_by_user_id?: string; cashier_user_id?: string; opening_cash: number; opening_balance?: number; closing_cash?: number; closing_balance?: number; expected_cash?: number; cash_variance?: number; // Domain Sales Breakdown ecom_sales_count?: number; ecom_sales_amount?: number; service_sales_count?: number; service_sales_amount?: number; courier_charges?: number; // Payment Breakdown cash_sales?: number; upi_sales?: number; card_sales?: number; other_sales?: number; status: 'OPEN' | 'CLOSED' | string; opened_at?: string; closed_at?: string; notes?: string; } export const inventoryPosService = { getWarehouses: async () => { return apiFetch('/api/v1/inventory-pos/warehouses'); }, createWarehouse: async (data: Partial) => { return apiFetch('/api/v1/inventory-pos/warehouses', { method: 'POST', body: JSON.stringify(data), }); }, getTerminals: async (locationId?: string) => { const query = locationId ? `?location_id=${encodeURIComponent(locationId)}` : ''; return apiFetch(`/api/v1/inventory-pos/terminals${query}`); }, createTerminal: async (data: { location_id: string; code: string; name: string }) => { return apiFetch('/api/v1/inventory-pos/terminals', { method: 'POST', body: JSON.stringify(data), }); }, getPosSessions: async (status?: string, locationId?: string) => { const params = new URLSearchParams(); if (status) params.append('status', status); if (locationId) params.append('location_id', locationId); const query = params.toString() ? `?${params.toString()}` : ''; return apiFetch(`/api/v1/inventory-pos/pos-sessions${query}`); }, openPosSession: async (data: { location_id?: string; terminal_id?: string; warehouse_id?: string; opening_cash?: number; notes?: string }) => { return apiFetch('/api/v1/inventory-pos/pos-sessions/open', { method: 'POST', body: JSON.stringify(data), }); }, closePosSession: async (sessionId: string, closingCash: number, notes?: string) => { return apiFetch(`/api/v1/inventory-pos/pos-sessions/${sessionId}/close`, { method: 'POST', body: JSON.stringify({ closing_cash: closingCash, notes }), }); } };