import { api } from '$lib/api';
import type { ApiResponse } from '$lib/api';

// Interfaces
export interface DepreciationCatalog {
	id: number;
	tenant_id: number;
	company_id: number;
	fraction: string;
	description: string;
	depreciation_rate: number;
	created_at: string;
	updated_at: string;
}

export interface DepreciationCatalogListResponse {
	items: DepreciationCatalog[];
	total: number;
	page: number;
	page_size: number;
	pages: number;
}

// API Functions
export async function getDepreciationCatalog(
	page = 1,
	pageSize = 100,
	companyId: number,
	filters: Record<string, any> = {}
): Promise<ApiResponse<DepreciationCatalogListResponse>> {
	const params = new URLSearchParams({
		company_id: companyId.toString(),
		page: page.toString(),
		page_size: pageSize.toString(),
		...filters
	});

	return api.get<DepreciationCatalogListResponse>(
		`/v1/a76/depreciation-catalog/?${params.toString()}`
	);
}
