ifixkart-admin/New admin panel/ikixkart-dashboard/services/api/inventoryPosService.ts
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

114 lines
3.3 KiB
TypeScript

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;
session_duration_minutes?: number;
expires_at?: string;
}
export const inventoryPosService = {
getWarehouses: async () => {
return apiFetch<Warehouse[]>('/api/v1/inventory-pos/warehouses');
},
createWarehouse: async (data: Partial<Warehouse>) => {
return apiFetch<Warehouse>('/api/v1/inventory-pos/warehouses', {
method: 'POST',
body: JSON.stringify(data),
});
},
getTerminals: async (locationId?: string) => {
const query = locationId ? `?location_id=${encodeURIComponent(locationId)}` : '';
return apiFetch<PosTerminal[]>(`/api/v1/inventory-pos/terminals${query}`);
},
createTerminal: async (data: { location_id: string; code: string; name: string }) => {
return apiFetch<PosTerminal>('/api/v1/inventory-pos/terminals', {
method: 'POST',
body: JSON.stringify(data),
});
},
getPosSessions: async (status?: string, locationId?: string, userId?: string) => {
const params = new URLSearchParams();
if (status) params.append('status', status);
if (locationId) params.append('location_id', locationId);
if (userId) params.append('user_id', userId);
const query = params.toString() ? `?${params.toString()}` : '';
return apiFetch<PosSession[]>(`/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<PosSession>('/api/v1/inventory-pos/pos-sessions/open', {
method: 'POST',
body: JSON.stringify(data),
});
},
closePosSession: async (sessionId: string, closingCash: number, notes?: string) => {
return apiFetch<PosSession>(`/api/v1/inventory-pos/pos-sessions/${sessionId}/close`, {
method: 'POST',
body: JSON.stringify({ closing_cash: closingCash, notes }),
});
},
extendPosSession: async (sessionId: string, data: { extension_minutes: number; reason: string }) => {
return apiFetch<PosSession>(`/api/v1/inventory-pos/pos-sessions/${sessionId}/extend`, {
method: 'POST',
body: JSON.stringify(data),
});
}
};