Files
plantillas-proyectos/frontend/src/lib/api/dashboard/a76/company.ts
acazares 6acbd48e9e feat: Implement general catalogs for INPC, Legends, Multi-Currency Types, Packages, Ports, Prevalidators, Signatures, Unit Conversions, and Units of Measure
- Added INPC management page with search functionality.
- Created Legends management page with filters for code and description.
- Implemented Multi-Currency Types management with search capabilities.
- Developed Packages management page with filtering options.
- Introduced Ports management page with authentication and data fetching.
- Added Prevalidators management page with search filters.
- Implemented Signatures management page with search by name and position.
- Created Unit Conversions management page for conversion factors.
- Developed Units of Measure management pages for ACE, American, and OMA with data tables and create/edit dialogs.
2025-12-08 14:17:47 -06:00

92 lines
2.7 KiB
TypeScript

import { api } from '$lib/api';
import type { ApiResponse } from '$lib/api';
export interface Company {
id: number;
tenant_id: number;
name: string | null;
rfc: string | null;
main_activity: string | null;
program: string | null;
program_number: string | null;
prosec: number | null;
prosec_authorization: string | null;
manufacturer_id: string | null;
broker_company: string | null;
responsible: string | null;
responsible_name: string | null;
responsible_last_name: string | null;
responsible_mother_last_name: string | null;
created_at: string | null;
updated_at: string | null;
}
export interface CompanyCreate {
name?: string | null;
rfc?: string | null;
main_activity?: string | null;
program?: string | null;
program_number?: string | null;
prosec?: number | null;
prosec_authorization?: string | null;
manufacturer_id?: string | null;
broker_company?: string | null;
responsible?: string | null;
responsible_name?: string | null;
responsible_last_name?: string | null;
responsible_mother_last_name?: string | null;
}
export interface CompanyUpdate {
name?: string | null;
rfc?: string | null;
main_activity?: string | null;
program?: string | null;
program_number?: string | null;
prosec?: number | null;
prosec_authorization?: string | null;
manufacturer_id?: string | null;
broker_company?: string | null;
responsible?: string | null;
responsible_name?: string | null;
responsible_last_name?: string | null;
responsible_mother_last_name?: string | null;
}
export interface CompanyListResponse {
items: Company[];
total: number;
page: number;
page_size: number;
pages: number;
}
export async function getCompanies(
page = 1,
pageSize = 50,
filters: Record<string, any> = {}
): Promise<ApiResponse<CompanyListResponse>> {
const queryParams = new URLSearchParams({
page: page.toString(),
page_size: pageSize.toString(),
...filters
});
return await api.get(`/a76/company?${queryParams.toString()}`);
}
export async function getCompany(id: number): Promise<ApiResponse<Company>> {
return await api.get(`/a76/company/${id}`);
}
export async function createCompany(data: CompanyCreate): Promise<ApiResponse<Company>> {
return await api.post(`/a76/company`, data);
}
export async function updateCompany(id: number, data: CompanyUpdate): Promise<ApiResponse<Company>> {
return await api.put(`/a76/company/${id}`, data);
}
export async function deleteCompany(id: number): Promise<ApiResponse<void>> {
return await api.delete(`/a76/company/${id}`);
}