Se agrego un modal provicional para el fomrulario y creacion de los registros en la base de datos. Aun faltan 3 catalogos para la integracion con la base de datos
This commit is contained in:
@@ -2,60 +2,71 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface ClassificationConcept {
|
||||
id: number;
|
||||
classification: string;
|
||||
description?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
classification: string;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface ClassificationConceptCreate {
|
||||
classification: string;
|
||||
description?: string;
|
||||
classification: string;
|
||||
}
|
||||
|
||||
export interface ClassificationConceptUpdate extends Partial<ClassificationConceptCreate> {}
|
||||
|
||||
export interface ClassificationConceptListResponse {
|
||||
items: ClassificationConcept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: ClassificationConcept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getClassificationConcepts(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<ClassificationConceptListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/classification_concepts?${params.toString()}`);
|
||||
return response.data;
|
||||
|
||||
const response = await api.get(`/v1/a76/classification-concepts/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getClassificationConcept(id: number): Promise<ClassificationConcept> {
|
||||
const response = await api.get(`/a76/classification_concepts/${id}`);
|
||||
return response.data;
|
||||
export async function getClassificationConcept(id: number, companyId: number): Promise<ClassificationConcept> {
|
||||
const response = await api.get(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createClassificationConcept(data: ClassificationConceptCreate): Promise<ClassificationConcept> {
|
||||
const response = await api.post('/a76/classification_concepts', data);
|
||||
return response.data;
|
||||
export async function createClassificationConcept(
|
||||
data: ClassificationConceptCreate,
|
||||
companyId: number
|
||||
): Promise<ClassificationConcept> {
|
||||
// 👇 AQUÍ ESTABA EL ERROR GRAVE
|
||||
const response = await api.post(`/v1/a76/classification-concepts/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateClassificationConcept(id: number, data: ClassificationConceptUpdate): Promise<ClassificationConcept> {
|
||||
const response = await api.patch(`/a76/classification_concepts/${id}`, data);
|
||||
return response.data;
|
||||
|
||||
export async function updateClassificationConcept(
|
||||
id: number,
|
||||
data: ClassificationConceptUpdate,
|
||||
companyId: number // <-- Faltaba esto
|
||||
): Promise<ClassificationConcept> {
|
||||
const response = await api.put(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteClassificationConcept(id: number): Promise<void> {
|
||||
await api.delete(`/a76/classification_concepts/${id}`);
|
||||
}
|
||||
|
||||
export async function deleteClassificationConcept(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -1,91 +1,91 @@
|
||||
import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
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 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 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 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 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 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 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 createCompany(data: CompanyCreate): Promise<ApiResponse<Company>> {
|
||||
return await api.post(`/v1/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 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}`);
|
||||
}
|
||||
export async function deleteCompany(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/company/${id}`);
|
||||
}
|
||||
|
||||
@@ -2,78 +2,88 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface Concept {
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
priority_ame?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
priority_ame?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface ConceptCreate {
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
priority_ame?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
priority_ame?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
}
|
||||
|
||||
export interface ConceptUpdate extends Partial<ConceptCreate> {}
|
||||
|
||||
export interface ConceptListResponse {
|
||||
items: Concept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: Concept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getConcepts(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {},
|
||||
): Promise<ApiResponse<ConceptListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/concepts?${params.toString()}`);
|
||||
return response.data;
|
||||
const response = await api.get(`/v1/a76/concepts/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getConcept(id: number): Promise<Concept> {
|
||||
const response = await api.get(`/a76/concepts/${id}`);
|
||||
return response.data;
|
||||
|
||||
export async function getConcept(id: number, companyId: number): Promise<Concept> {
|
||||
|
||||
const response = await api.get(`/v1/a76/concepts/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createConcept(data: ConceptCreate): Promise<Concept> {
|
||||
const response = await api.post('/a76/concepts', data);
|
||||
return response.data;
|
||||
|
||||
export async function createConcept(data: ConceptCreate, companyId: number): Promise<Concept> {
|
||||
|
||||
const response = await api.post(`/v1/a76/concepts/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateConcept(id: number, data: ConceptUpdate): Promise<Concept> {
|
||||
const response = await api.patch(`/a76/concepts/${id}`, data);
|
||||
return response.data;
|
||||
|
||||
export async function updateConcept(id: number, data: ConceptUpdate, companyId: number): Promise<Concept> {
|
||||
|
||||
const response = await api.put(`/v1/a76/concepts/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteConcept(id: number): Promise<void> {
|
||||
await api.delete(`/a76/concepts/${id}`);
|
||||
}
|
||||
|
||||
export async function deleteConcept(id: number, companyId: number): Promise<void> {
|
||||
|
||||
await api.delete(`/v1/a76/concepts/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -2,76 +2,68 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface CustomsBrokerConcept {
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
broker_key: string;
|
||||
concept: string;
|
||||
amount?: number;
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
export interface CustomsBrokerConceptCreate {
|
||||
code: string;
|
||||
description?: string;
|
||||
description_en?: string;
|
||||
detailed_description?: string;
|
||||
priority?: number;
|
||||
first_total?: boolean;
|
||||
type?: string;
|
||||
is_printed?: boolean;
|
||||
section?: number;
|
||||
classification?: string;
|
||||
broker_key: string;
|
||||
concept?: string;
|
||||
amount?: number;
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
export interface CustomsBrokerConceptUpdate extends Partial<CustomsBrokerConceptCreate> {}
|
||||
|
||||
export interface CustomsBrokerConceptListResponse {
|
||||
items: CustomsBrokerConcept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: CustomsBrokerConcept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export async function getCustomsBrokerConcepts(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number, // <-- Nuevo
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<CustomsBrokerConceptListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/customs_broker_concepts?${params.toString()}`);
|
||||
return response.data;
|
||||
|
||||
const response = await api.get(`/v1/a76/customs-broker-concepts/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getCustomsBrokerConcept(id: number): Promise<CustomsBrokerConcept> {
|
||||
const response = await api.get(`/a76/customs_broker_concepts/${id}`);
|
||||
return response.data;
|
||||
export async function createCustomsBrokerConcept(
|
||||
data: CustomsBrokerConceptCreate,
|
||||
companyId: number
|
||||
): Promise<CustomsBrokerConcept> {
|
||||
|
||||
const response = await api.post(`/v1/a76/customs-broker-concepts/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createCustomsBrokerConcept(data: CustomsBrokerConceptCreate): Promise<CustomsBrokerConcept> {
|
||||
const response = await api.post('/a76/customs_broker_concepts', data);
|
||||
return response.data;
|
||||
export async function updateCustomsBrokerConcept(
|
||||
id: number,
|
||||
data: CustomsBrokerConceptUpdate,
|
||||
companyId: number
|
||||
): Promise<CustomsBrokerConcept> {
|
||||
|
||||
const response = await api.put(`/v1/a76/customs-broker-concepts/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateCustomsBrokerConcept(id: number, data: CustomsBrokerConceptUpdate): Promise<CustomsBrokerConcept> {
|
||||
const response = await api.patch(`/a76/customs_broker_concepts/${id}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteCustomsBrokerConcept(id: number): Promise<void> {
|
||||
await api.delete(`/a76/customs_broker_concepts/${id}`);
|
||||
}
|
||||
export async function deleteCustomsBrokerConcept(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/customs-broker-concepts/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -1,61 +1,134 @@
|
||||
import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
// ==========================================
|
||||
// ERROR CLASSIFICATION
|
||||
// ==========================================
|
||||
|
||||
export interface ErrorClassification {
|
||||
id: number;
|
||||
code: string;
|
||||
level?: string;
|
||||
errors?: ErrorCatalog[];
|
||||
tenant_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface ErrorClassificationCreate {
|
||||
code: string;
|
||||
level?: string;
|
||||
}
|
||||
|
||||
export interface ErrorClassificationUpdate {
|
||||
level?: string;
|
||||
}
|
||||
|
||||
export interface ErrorClassificationListResponse {
|
||||
items: ErrorClassification[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export interface ErrorCatalog {
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
classification_id?: number;
|
||||
classification?: ErrorClassification;
|
||||
tenant_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface ErrorCatalogCreate {
|
||||
code: string;
|
||||
description?: string;
|
||||
code: string;
|
||||
description?: string;
|
||||
classification_id?: number;
|
||||
}
|
||||
|
||||
export interface ErrorCatalogUpdate extends Partial<ErrorCatalogCreate> {}
|
||||
export interface ErrorCatalogUpdate {
|
||||
description?: string;
|
||||
classification_id?: number;
|
||||
}
|
||||
|
||||
export interface ErrorCatalogListResponse {
|
||||
items: ErrorCatalog[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: ErrorCatalog[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getErrorCatalogs(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<ErrorCatalogListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
export async function getErrorClassifications(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<ErrorClassificationListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/error_catalogs?${params.toString()}`);
|
||||
return response.data;
|
||||
const response = await api.get(`/a76/error_classifications?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getErrorClassification(id: number): Promise<ErrorClassification> {
|
||||
const response = await api.get(`/a76/error_classifications/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createErrorClassification(data: ErrorClassificationCreate): Promise<ErrorClassification> {
|
||||
const response = await api.post('/a76/error_classifications', data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateErrorClassification(id: number, data: ErrorClassificationUpdate): Promise<ErrorClassification> {
|
||||
const response = await api.patch(`/a76/error_classifications/${id}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteErrorClassification(id: number): Promise<void> {
|
||||
await api.delete(`/a76/error_classifications/${id}`);
|
||||
}
|
||||
|
||||
// --- Catalogs ---
|
||||
|
||||
export async function getErrorCatalogs(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<ErrorCatalogListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/error_catalogs?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getErrorCatalog(id: number): Promise<ErrorCatalog> {
|
||||
const response = await api.get(`/a76/error_catalogs/${id}`);
|
||||
return response.data;
|
||||
const response = await api.get(`/a76/error_catalogs/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createErrorCatalog(data: ErrorCatalogCreate): Promise<ErrorCatalog> {
|
||||
const response = await api.post('/a76/error_catalogs', data);
|
||||
return response.data;
|
||||
const response = await api.post('/a76/error_catalogs', data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateErrorCatalog(id: number, data: ErrorCatalogUpdate): Promise<ErrorCatalog> {
|
||||
const response = await api.patch(`/a76/error_catalogs/${id}`, data);
|
||||
return response.data;
|
||||
const response = await api.patch(`/a76/error_catalogs/${id}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteErrorCatalog(id: number): Promise<void> {
|
||||
await api.delete(`/a76/error_catalogs/${id}`);
|
||||
}
|
||||
await api.delete(`/a76/error_catalogs/${id}`);
|
||||
}
|
||||
@@ -7,8 +7,8 @@ export interface Identifier {
|
||||
description: string | null;
|
||||
level: string | null;
|
||||
complement: string | null;
|
||||
company_id: number;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
tenant_id: number;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
}
|
||||
@@ -18,7 +18,6 @@ export interface IdentifierCreate {
|
||||
description?: string | null;
|
||||
level?: string | null;
|
||||
complement?: string | null;
|
||||
company_id: number;
|
||||
}
|
||||
|
||||
export interface IdentifierUpdate {
|
||||
@@ -39,24 +38,37 @@ export interface IdentifierListResponse {
|
||||
export async function getIdentifiers(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<IdentifierListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/a76/identifiers?${queryParams.toString()}`);
|
||||
|
||||
return await api.get(`/v1/a76/identifiers/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createIdentifier(data: IdentifierCreate): Promise<ApiResponse<Identifier>> {
|
||||
return await api.post('/a76/identifiers', data);
|
||||
export async function createIdentifier(
|
||||
data: IdentifierCreate,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<Identifier>> {
|
||||
return await api.post(`/v1/a76/identifiers/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateIdentifier(id: number, data: IdentifierUpdate): Promise<ApiResponse<Identifier>> {
|
||||
return await api.put(`/a76/identifiers/${id}`, data);
|
||||
export async function updateIdentifier(
|
||||
id: number,
|
||||
data: IdentifierUpdate,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<Identifier>> {
|
||||
return await api.put(`/v1/a76/identifiers/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteIdentifier(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/identifiers/${id}`);
|
||||
}
|
||||
export async function deleteIdentifier(
|
||||
id: number,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/identifiers/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -2,62 +2,77 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface INPC {
|
||||
id: number;
|
||||
year: string;
|
||||
month: string;
|
||||
value?: number;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
year: string;
|
||||
month: string;
|
||||
value?: number;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface INPCCreate {
|
||||
year: string;
|
||||
month: string;
|
||||
value?: number;
|
||||
year: string;
|
||||
month: string;
|
||||
value?: number;
|
||||
|
||||
}
|
||||
|
||||
export interface INPCUpdate extends Partial<INPCCreate> {}
|
||||
|
||||
export interface INPCListResponse {
|
||||
items: INPC[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: INPC[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export async function getINPCs(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<INPCListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/inpc?${params.toString()}`);
|
||||
return response.data;
|
||||
const response = await api.get(`/v1/a76/inpc/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getINPC(id: number): Promise<INPC> {
|
||||
const response = await api.get(`/a76/inpc/${id}`);
|
||||
return response.data;
|
||||
|
||||
export async function getINPC(id: number, companyId: number): Promise<INPC> {
|
||||
const response = await api.get(`/v1/a76/inpc/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createINPC(data: INPCCreate): Promise<INPC> {
|
||||
const response = await api.post('/a76/inpc', data);
|
||||
return response.data;
|
||||
|
||||
export async function createINPC(
|
||||
data: INPCCreate,
|
||||
companyId: number
|
||||
): Promise<INPC> {
|
||||
const response = await api.post(`/v1/a76/inpc/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateINPC(id: number, data: INPCUpdate): Promise<INPC> {
|
||||
const response = await api.patch(`/a76/inpc/${id}`, data);
|
||||
return response.data;
|
||||
|
||||
export async function updateINPC(
|
||||
id: number,
|
||||
data: INPCUpdate,
|
||||
companyId: number
|
||||
): Promise<INPC> {
|
||||
|
||||
const response = await api.put(`/v1/a76/inpc/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteINPC(id: number): Promise<void> {
|
||||
await api.delete(`/a76/inpc/${id}`);
|
||||
}
|
||||
export async function deleteINPC(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/inpc/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -2,60 +2,71 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface Legend {
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
code: number;
|
||||
description?: string;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface LegendCreate {
|
||||
code: string;
|
||||
description?: string;
|
||||
code: number;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface LegendUpdate extends Partial<LegendCreate> {}
|
||||
|
||||
export interface LegendListResponse {
|
||||
items: Legend[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: Legend[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getLegends(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<LegendListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/legends?${params.toString()}`);
|
||||
return response.data;
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
const response = await api.get(`/v1/a76/legends/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getLegend(id: number): Promise<Legend> {
|
||||
const response = await api.get(`/a76/legends/${id}`);
|
||||
return response.data;
|
||||
export async function getLegend(id: number, companyId: number): Promise<Legend> {
|
||||
const response = await api.get(`/v1/a76/legends/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createLegend(data: LegendCreate): Promise<Legend> {
|
||||
const response = await api.post('/a76/legends', data);
|
||||
return response.data;
|
||||
|
||||
export async function createLegend(
|
||||
data: LegendCreate,
|
||||
companyId: number
|
||||
): Promise<Legend> {
|
||||
|
||||
const response = await api.post(`/v1/a76/legends/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateLegend(id: number, data: LegendUpdate): Promise<Legend> {
|
||||
const response = await api.patch(`/a76/legends/${id}`, data);
|
||||
return response.data;
|
||||
export async function updateLegend(
|
||||
id: number,
|
||||
data: LegendUpdate,
|
||||
companyId: number
|
||||
): Promise<Legend> {
|
||||
|
||||
const response = await api.put(`/v1/a76/legends/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteLegend(id: number): Promise<void> {
|
||||
await api.delete(`/a76/legends/${id}`);
|
||||
}
|
||||
export async function deleteLegend(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/legends/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -1,52 +1,69 @@
|
||||
/**
|
||||
* API Client para Locations - Ubicaciones relacionadas con puertos
|
||||
* Basado en los campos location_code y location_description del módulo de puertos
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface Location {
|
||||
location_code: string;
|
||||
location_description: string | null;
|
||||
id: number;
|
||||
code: string;
|
||||
description?: string;
|
||||
|
||||
|
||||
tenant_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nota: Las ubicaciones están integradas en el módulo de puertos.
|
||||
* Este archivo proporciona tipos para trabajar con ubicaciones,
|
||||
* pero las operaciones se realizan a través del módulo de puertos.
|
||||
*
|
||||
* Ver: /a76/ports para operaciones relacionadas con ubicaciones
|
||||
*/
|
||||
|
||||
/**
|
||||
* Obtiene ubicaciones únicas de los puertos
|
||||
* Esta función extrae las ubicaciones únicas de la lista de puertos
|
||||
*/
|
||||
export async function getLocationsFromPorts(): Promise<ApiResponse<Location[]>> {
|
||||
const portsResponse = await api.get('/a76/ports?page_size=1000');
|
||||
|
||||
if (portsResponse.error || !portsResponse.data) {
|
||||
return {
|
||||
error: portsResponse.error || 'Error al obtener puertos',
|
||||
status: portsResponse.status
|
||||
};
|
||||
}
|
||||
export interface LocationCreate {
|
||||
code: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
// Extraer ubicaciones únicas
|
||||
const locationMap = new Map<string, Location>();
|
||||
const ports = portsResponse.data.items || [];
|
||||
|
||||
ports.forEach((port: any) => {
|
||||
if (port.location_code && !locationMap.has(port.location_code)) {
|
||||
locationMap.set(port.location_code, {
|
||||
location_code: port.location_code,
|
||||
location_description: port.location_description
|
||||
});
|
||||
}
|
||||
|
||||
export interface LocationUpdate {
|
||||
code?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface LocationListResponse {
|
||||
items: Location[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function getLocations(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<LocationListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
return {
|
||||
data: Array.from(locationMap.values()),
|
||||
status: 200
|
||||
};
|
||||
const response = await api.get(`/a24/locations?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getLocation(id: number): Promise<Location> {
|
||||
const response = await api.get(`/a24/locations/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createLocation(data: LocationCreate): Promise<Location> {
|
||||
const response = await api.post('/a24/locations', data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateLocation(id: number, data: LocationUpdate): Promise<Location> {
|
||||
const response = await api.patch(`/a24/locations/${id}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteLocation(id: number): Promise<void> {
|
||||
await api.delete(`/a24/locations/${id}`);
|
||||
}
|
||||
@@ -2,60 +2,78 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface MultiCurrencyType {
|
||||
id: number;
|
||||
key: string;
|
||||
description?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
|
||||
currency_type_code: string;
|
||||
country_key: string | null;
|
||||
conversion_factor: number | null;
|
||||
publication_date: number;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface MultiCurrencyTypeCreate {
|
||||
key: string;
|
||||
description?: string;
|
||||
currency_type_code: string;
|
||||
country_key?: string | null;
|
||||
conversion_factor?: number | null;
|
||||
publication_date: number;
|
||||
}
|
||||
|
||||
export interface MultiCurrencyTypeUpdate extends Partial<MultiCurrencyTypeCreate> {}
|
||||
|
||||
export interface MultiCurrencyTypeListResponse {
|
||||
items: MultiCurrencyType[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: MultiCurrencyType[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getMultiCurrencyTypes(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<MultiCurrencyTypeListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/multi_currency_types?${params.toString()}`);
|
||||
return response.data;
|
||||
// Agregamos /v1 y el path correcto
|
||||
const response = await api.get(`/v1/a76/multi_currency_types/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getMultiCurrencyType(id: number): Promise<MultiCurrencyType> {
|
||||
const response = await api.get(`/a76/multi_currency_types/${id}`);
|
||||
return response.data;
|
||||
|
||||
export async function getMultiCurrencyType(id: number, companyId: number): Promise<MultiCurrencyType> {
|
||||
const response = await api.get(`/v1/a76/multi_currency_types/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createMultiCurrencyType(data: MultiCurrencyTypeCreate): Promise<MultiCurrencyType> {
|
||||
const response = await api.post('/a76/multi_currency_types', data);
|
||||
return response.data;
|
||||
export async function createMultiCurrencyType(
|
||||
data: MultiCurrencyTypeCreate,
|
||||
companyId: number
|
||||
): Promise<MultiCurrencyType> {
|
||||
const response = await api.post(`/v1/a76/multi_currency_types/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateMultiCurrencyType(id: number, data: MultiCurrencyTypeUpdate): Promise<MultiCurrencyType> {
|
||||
const response = await api.patch(`/a76/multi_currency_types/${id}`, data);
|
||||
return response.data;
|
||||
|
||||
export async function updateMultiCurrencyType(
|
||||
id: number,
|
||||
data: MultiCurrencyTypeUpdate,
|
||||
companyId: number
|
||||
): Promise<MultiCurrencyType> {
|
||||
const response = await api.put(`/v1/a76/multi_currency_types/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteMultiCurrencyType(id: number): Promise<void> {
|
||||
await api.delete(`/a76/multi_currency_types/${id}`);
|
||||
}
|
||||
|
||||
export async function deleteMultiCurrencyType(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/multi_currency_types/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -4,17 +4,17 @@ import type { ApiResponse } from '$lib/api';
|
||||
export interface Package {
|
||||
id: number;
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
key: string;
|
||||
description_es: string | null;
|
||||
description_en: string | null;
|
||||
weight_unit: number | null;
|
||||
plurals: string | null;
|
||||
plural_in: string | null;
|
||||
code_ace: string | null;
|
||||
code_aamex: string | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
company_id: number;
|
||||
key: string;
|
||||
description_es: string | null;
|
||||
description_en: string | null;
|
||||
weight_unit: number | null;
|
||||
plurals: string | null;
|
||||
plural_in: string | null;
|
||||
code_ace: string | null;
|
||||
code_aamex: string | null;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface PackageCreate {
|
||||
@@ -26,19 +26,9 @@ export interface PackageCreate {
|
||||
plural_in?: string | null;
|
||||
code_ace?: string | null;
|
||||
code_aamex?: string | null;
|
||||
company_id: number;
|
||||
}
|
||||
|
||||
export interface PackageUpdate {
|
||||
key?: string;
|
||||
description_es?: string | null;
|
||||
description_en?: string | null;
|
||||
weight_unit?: number | null;
|
||||
plurals?: string | null;
|
||||
plural_in?: string | null;
|
||||
code_ace?: string | null;
|
||||
code_aamex?: string | null;
|
||||
}
|
||||
export interface PackageUpdate extends Partial<PackageCreate> {}
|
||||
|
||||
export interface PackageListResponse {
|
||||
items: Package[];
|
||||
@@ -48,31 +38,48 @@ export interface PackageListResponse {
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export async function getPackages(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number, // Obligatorio por el Mixin
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<PackageListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/a76/packages?${queryParams.toString()}`);
|
||||
|
||||
const response = await api.get(`/v1/a76/packages/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getPackage(id: number): Promise<ApiResponse<Package>> {
|
||||
return await api.get(`/a76/packages/${id}`);
|
||||
|
||||
export async function getPackage(id: number, companyId: number): Promise<Package> {
|
||||
const response = await api.get(`/v1/a76/packages/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createPackage(data: PackageCreate): Promise<ApiResponse<Package>> {
|
||||
return await api.post(`/a76/packages`, data);
|
||||
export async function createPackage(
|
||||
data: PackageCreate,
|
||||
companyId: number
|
||||
): Promise<Package> {
|
||||
const response = await api.post(`/v1/a76/packages/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updatePackage(id: number, data: PackageUpdate): Promise<ApiResponse<Package>> {
|
||||
return await api.put(`/a76/packages/${id}`, data);
|
||||
|
||||
export async function updatePackage(
|
||||
id: number,
|
||||
data: PackageUpdate,
|
||||
companyId: number
|
||||
): Promise<Package> {
|
||||
const response = await api.put(`/v1/a76/packages/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deletePackage(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/packages/${id}`);
|
||||
}
|
||||
export async function deletePackage(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/packages/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -2,62 +2,79 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface Signature {
|
||||
id: number;
|
||||
name: string;
|
||||
position?: string;
|
||||
certificate?: string;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
|
||||
code: string;
|
||||
signature: string | null;
|
||||
photo_path: string | null;
|
||||
|
||||
|
||||
tenant_id: number;
|
||||
company_id: number;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface SignatureCreate {
|
||||
name: string;
|
||||
position?: string;
|
||||
certificate?: string;
|
||||
code: string;
|
||||
signature?: string | null;
|
||||
photo_path?: string | null;
|
||||
|
||||
}
|
||||
|
||||
export interface SignatureUpdate extends Partial<SignatureCreate> {}
|
||||
|
||||
export interface SignatureListResponse {
|
||||
items: Signature[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: Signature[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export async function getSignatures(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<SignatureListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/signatures?${params.toString()}`);
|
||||
return response.data;
|
||||
|
||||
const response = await api.get(`/v1/a76/signatures/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getSignature(id: number): Promise<Signature> {
|
||||
const response = await api.get(`/a76/signatures/${id}`);
|
||||
return response.data;
|
||||
|
||||
export async function getSignature(id: number, companyId: number): Promise<Signature> {
|
||||
const response = await api.get(`/v1/a76/signatures/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createSignature(data: SignatureCreate): Promise<Signature> {
|
||||
const response = await api.post('/a76/signatures', data);
|
||||
return response.data;
|
||||
|
||||
export async function createSignature(
|
||||
data: SignatureCreate,
|
||||
companyId: number
|
||||
): Promise<Signature> {
|
||||
const response = await api.post(`/v1/a76/signatures/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateSignature(id: number, data: SignatureUpdate): Promise<Signature> {
|
||||
const response = await api.patch(`/a76/signatures/${id}`, data);
|
||||
return response.data;
|
||||
export async function updateSignature(
|
||||
id: number,
|
||||
data: SignatureUpdate,
|
||||
companyId: number
|
||||
): Promise<Signature> {
|
||||
const response = await api.put(`/v1/a76/signatures/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteSignature(id: number): Promise<void> {
|
||||
await api.delete(`/a76/signatures/${id}`);
|
||||
}
|
||||
export async function deleteSignature(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/signatures/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -2,62 +2,76 @@ import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
|
||||
export interface UnitConversion {
|
||||
id: number;
|
||||
from_unit_id: number;
|
||||
to_unit_id: number;
|
||||
conversion_factor: number;
|
||||
tenant_id: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
id: number;
|
||||
from_unit_code: string;
|
||||
to_unit_code: string;
|
||||
conversion_factor: number;
|
||||
tenant_id: number; // number
|
||||
company_id: number; // number
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface UnitConversionCreate {
|
||||
from_unit_id: number;
|
||||
to_unit_id: number;
|
||||
conversion_factor: number;
|
||||
from_unit_code: string; // Ej: "KGM"
|
||||
to_unit_code: string; // Ej: "LBR"
|
||||
conversion_factor: number;
|
||||
// company_id va en la URL
|
||||
}
|
||||
|
||||
export interface UnitConversionUpdate extends Partial<UnitConversionCreate> {}
|
||||
|
||||
export interface UnitConversionListResponse {
|
||||
items: UnitConversion[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
items: UnitConversion[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
|
||||
export async function getUnitConversions(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters: Record<string, any> = {}
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number, // 👈 Obligatorio
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitConversionListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
});
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/a76/unit_conversions?${params.toString()}`);
|
||||
return response.data;
|
||||
// Agregamos /v1 y prefijo.
|
||||
// NOTA: Revisa si en tu router definiste "unit_conversions" o "unit-conversions"
|
||||
const response = await api.get(`/v1/a76/unit-conversions/?${params.toString()}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getUnitConversion(id: number): Promise<UnitConversion> {
|
||||
const response = await api.get(`/a76/unit_conversions/${id}`);
|
||||
return response.data;
|
||||
export async function getUnitConversion(id: number, companyId: number): Promise<UnitConversion> {
|
||||
const response = await api.get(`/v1/a76/unit-conversions/${id}/?company_id=${companyId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createUnitConversion(data: UnitConversionCreate): Promise<UnitConversion> {
|
||||
const response = await api.post('/a76/unit_conversions', data);
|
||||
return response.data;
|
||||
export async function createUnitConversion(
|
||||
data: UnitConversionCreate,
|
||||
companyId: number
|
||||
): Promise<UnitConversion> {
|
||||
const response = await api.post(`/v1/a76/unit-conversions/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateUnitConversion(id: number, data: UnitConversionUpdate): Promise<UnitConversion> {
|
||||
const response = await api.patch(`/a76/unit_conversions/${id}`, data);
|
||||
return response.data;
|
||||
|
||||
export async function updateUnitConversion(
|
||||
id: number,
|
||||
data: UnitConversionUpdate,
|
||||
companyId: number
|
||||
): Promise<UnitConversion> {
|
||||
const response = await api.put(`/v1/a76/unit-conversions/${id}/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteUnitConversion(id: number): Promise<void> {
|
||||
await api.delete(`/a76/unit_conversions/${id}`);
|
||||
}
|
||||
export async function deleteUnitConversion(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/unit_conversions/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export interface InvoiceListResponse {
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface CreateInvoiceData {
|
||||
export interface InvoiceData {
|
||||
operation_type?: OperationType | null;
|
||||
invoice_type?: string | null;
|
||||
invoice_number?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user