Merge pull request 'feat: Convertir módulo de clases para usar TenantCRUDRoutes' (#20) from classes into development
Reviewed-on: ADUANASOFT/anexo76#20
This commit is contained in:
107
frontend/src/lib/api/dashboard/a76/classes.ts
Normal file
107
frontend/src/lib/api/dashboard/a76/classes.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* API para gestión de Classes (Clases A76)
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface A76Class {
|
||||
id: number;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
client_id: number;
|
||||
class_code: string;
|
||||
description_es: string | null;
|
||||
description_en: string | null;
|
||||
material_key: string | null;
|
||||
unit_of_measure: string;
|
||||
fraction: string;
|
||||
us_fraction: string;
|
||||
sub_key: string;
|
||||
physical_review: number;
|
||||
iva_exempt_fraction: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface A76ClassCreate {
|
||||
company_id: number;
|
||||
client_id: number;
|
||||
class_code: string;
|
||||
description_es?: string | null;
|
||||
description_en?: string | null;
|
||||
material_key?: string | null;
|
||||
unit_of_measure: string;
|
||||
fraction: string;
|
||||
us_fraction: string;
|
||||
sub_key: string;
|
||||
physical_review?: number;
|
||||
iva_exempt_fraction: string;
|
||||
}
|
||||
|
||||
export interface A76ClassUpdate {
|
||||
client_id?: number;
|
||||
class_code?: string;
|
||||
description_es?: string | null;
|
||||
description_en?: string | null;
|
||||
material_key?: string | null;
|
||||
unit_of_measure?: string;
|
||||
fraction?: string;
|
||||
us_fraction?: string;
|
||||
sub_key?: string;
|
||||
physical_review?: number;
|
||||
iva_exempt_fraction?: string;
|
||||
}
|
||||
|
||||
export interface A76ClassListResponse {
|
||||
items: A76Class[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface A76ClassListParams {
|
||||
company_id: number;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* API de Classes
|
||||
*/
|
||||
export const classesApi = {
|
||||
/**
|
||||
* Obtener lista de classes con paginación
|
||||
*/
|
||||
list: (params: A76ClassListParams): Promise<ApiResponse<A76ClassListResponse>> => {
|
||||
const { company_id, page = 1, page_size = 50 } = params;
|
||||
return api.get(`/v1/a76/classes/?company_id=${company_id}&page=${page}&page_size=${page_size}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtener un class por ID
|
||||
*/
|
||||
get: (id: number, company_id: number): Promise<ApiResponse<A76Class>> => {
|
||||
return api.get(`/v1/a76/classes/${id}?company_id=${company_id}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Crear un nuevo class
|
||||
*/
|
||||
create: (data: A76ClassCreate, company_id: number): Promise<ApiResponse<A76Class>> => {
|
||||
return api.post(`/v1/a76/classes/?company_id=${company_id}`, data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Actualizar un class existente
|
||||
*/
|
||||
update: (id: number, data: A76ClassUpdate, company_id: number): Promise<ApiResponse<A76Class>> => {
|
||||
return api.put(`/v1/a76/classes/${id}?company_id=${company_id}`, data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Eliminar un class
|
||||
*/
|
||||
delete: (id: number, company_id: number): Promise<ApiResponse<void>> => {
|
||||
return api.delete(`/v1/a76/classes/${id}?company_id=${company_id}`);
|
||||
}
|
||||
};
|
||||
4
frontend/src/lib/api/dashboard/a76/index.ts
Normal file
4
frontend/src/lib/api/dashboard/a76/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Exportaciones de APIs para módulo A76
|
||||
*/
|
||||
export * from './classes';
|
||||
Reference in New Issue
Block a user