Desarrollo de rutina de CRUD para los catalogos generales
This commit is contained in:
@@ -37,36 +37,28 @@ export async function getClassificationConcepts(
|
||||
...filters
|
||||
});
|
||||
|
||||
|
||||
const response = await api.get(`/v1/a76/classification-concepts/?${params.toString()}`);
|
||||
return response.data;
|
||||
return await api.get(`/v1/a76/classification-concepts/?${params.toString()}`);
|
||||
}
|
||||
|
||||
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 getClassificationConcept(id: number, companyId: number): Promise<ApiResponse<ClassificationConcept>> {
|
||||
return await api.get(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
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;
|
||||
): Promise<ApiResponse<ClassificationConcept>> {
|
||||
return await api.post(`/v1/a76/classification-concepts/?company_id=${companyId}`, 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;
|
||||
companyId: number
|
||||
): Promise<ApiResponse<ClassificationConcept>> {
|
||||
return await api.put(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
|
||||
export async function deleteClassificationConcept(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`);
|
||||
export async function deleteClassificationConcept(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/classification-concepts/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -1,91 +1,115 @@
|
||||
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;
|
||||
curp?: 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;
|
||||
responsible_rfc?: string | null;
|
||||
position?: string | null;
|
||||
has_express_line?: boolean;
|
||||
is_service_company?: boolean;
|
||||
order_format_type?: string | null;
|
||||
ctpat_svi?: string | null;
|
||||
trusted_exporter_number?: 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;
|
||||
curp?: 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;
|
||||
responsible_rfc?: string | null;
|
||||
position?: string | null;
|
||||
has_express_line?: boolean;
|
||||
is_service_company?: boolean;
|
||||
order_format_type?: string | null;
|
||||
ctpat_svi?: string | null;
|
||||
trusted_exporter_number?: 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;
|
||||
curp?: 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;
|
||||
responsible_rfc?: string | null;
|
||||
position?: string | null;
|
||||
has_express_line?: boolean;
|
||||
is_service_company?: boolean;
|
||||
order_format_type?: string | null;
|
||||
ctpat_svi?: string | null;
|
||||
trusted_exporter_number?: 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(`/v1/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(`/v1/a76/company/${id}`);
|
||||
}
|
||||
|
||||
export async function createCompany(data: CompanyCreate): Promise<ApiResponse<Company>> {
|
||||
return await api.post(`/v1/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(`/v1/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(`/v1/a76/company/${id}`);
|
||||
}
|
||||
|
||||
@@ -57,33 +57,25 @@ export async function getConcepts(
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/v1/a76/concepts/?${params.toString()}`);
|
||||
return response.data;
|
||||
return await api.get(`/v1/a76/concepts?${params.toString()}`);
|
||||
}
|
||||
|
||||
|
||||
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 getConcept(id: number, companyId: number): Promise<ApiResponse<Concept>> {
|
||||
return await api.get(`/v1/a76/concepts/${id}?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
|
||||
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 createConcept(data: ConceptCreate, companyId: number): Promise<ApiResponse<Concept>> {
|
||||
return await api.post(`/v1/a76/concepts?company_id=${companyId}`, 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 updateConcept(id: number, data: ConceptUpdate, companyId: number): Promise<ApiResponse<Concept>> {
|
||||
return await api.put(`/v1/a76/concepts/${id}?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
|
||||
export async function deleteConcept(id: number, companyId: number): Promise<void> {
|
||||
|
||||
await api.delete(`/v1/a76/concepts/${id}/?company_id=${companyId}`);
|
||||
export async function deleteConcept(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/concepts/${id}?company_id=${companyId}`);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface CustomsBrokerConceptUpdate extends Partial<CustomsBrokerConceptCreate> {}
|
||||
|
||||
export interface CustomsBrokerConceptListResponse {
|
||||
items: CustomsBrokerConcept[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getCustomsBrokerConcepts(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {},
|
||||
): Promise<ApiResponse<CustomsBrokerConceptListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
|
||||
return await api.get(`/v1/a76/customs-broker-concepts?${params.toString()}`);
|
||||
}
|
||||
|
||||
export async function getCustomsBrokerConcept(id: number, companyId: number): Promise<ApiResponse<CustomsBrokerConcept>> {
|
||||
return await api.get(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
export async function createCustomsBrokerConcept(data: CustomsBrokerConceptCreate, companyId: number): Promise<ApiResponse<CustomsBrokerConcept>> {
|
||||
return await api.post(`/v1/a76/customs-broker-concepts?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateCustomsBrokerConcept(id: number, data: CustomsBrokerConceptUpdate, companyId: number): Promise<ApiResponse<CustomsBrokerConcept>> {
|
||||
return await api.put(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteCustomsBrokerConcept(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`);
|
||||
}
|
||||
@@ -38,35 +38,28 @@ export async function getLegends(
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
const response = await api.get(`/v1/a76/legends/?${params.toString()}`);
|
||||
return response.data;
|
||||
return await api.get(`/v1/a76/legends/?${params.toString()}`);
|
||||
}
|
||||
|
||||
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 getLegend(id: number, companyId: number): Promise<ApiResponse<Legend>> {
|
||||
return await api.get(`/v1/a76/legends/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
): Promise<ApiResponse<Legend>> {
|
||||
return await api.post(`/v1/a76/legends/?company_id=${companyId}`, 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;
|
||||
): Promise<ApiResponse<Legend>> {
|
||||
return await api.put(`/v1/a76/legends/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteLegend(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/legends/${id}/?company_id=${companyId}`);
|
||||
export async function deleteLegend(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/legends/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -1,79 +1,78 @@
|
||||
import { api } from '$lib/api';
|
||||
import type { ApiResponse } from '$lib/api';
|
||||
import type { PaginatedResponse } from '$lib/types';
|
||||
|
||||
export interface MultiCurrencyType {
|
||||
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;
|
||||
id: number;
|
||||
currency_type_code: string;
|
||||
country_key: string | null;
|
||||
conversion_factor: number | null;
|
||||
publication_date: number;
|
||||
company_id: number;
|
||||
tenant_id: number;
|
||||
}
|
||||
|
||||
export interface MultiCurrencyTypeCreate {
|
||||
currency_type_code: string;
|
||||
country_key?: string | null;
|
||||
conversion_factor?: number | null;
|
||||
publication_date: number;
|
||||
currency_type_code: string;
|
||||
country_key?: string | null;
|
||||
conversion_factor?: number | null;
|
||||
publication_date: number;
|
||||
}
|
||||
|
||||
export interface MultiCurrencyTypeUpdate extends Partial<MultiCurrencyTypeCreate> {}
|
||||
export interface MultiCurrencyTypeUpdate {
|
||||
currency_type_code?: string;
|
||||
country_key?: string | null;
|
||||
conversion_factor?: number | null;
|
||||
publication_date?: number;
|
||||
}
|
||||
|
||||
export interface MultiCurrencyTypeListResponse {
|
||||
items: MultiCurrencyType[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
export interface MultiCurrencyTypeListResponse extends PaginatedResponse {
|
||||
items: MultiCurrencyType[];
|
||||
}
|
||||
|
||||
export async function getMultiCurrencyTypes(
|
||||
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(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
companyId: number,
|
||||
page?: number,
|
||||
pageSize?: number
|
||||
): Promise<MultiCurrencyTypeListResponse> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
if (page) params.append('page', page.toString());
|
||||
if (pageSize) params.append('page_size', pageSize.toString());
|
||||
|
||||
// Agregamos /v1 y el path correcto
|
||||
const response = await api.get(`/v1/a76/multi_currency_types/?${params.toString()}`);
|
||||
return response.data;
|
||||
return api.get<MultiCurrencyTypeListResponse>(`/v1/a76/multi-currency-types/?${params.toString()}`);
|
||||
}
|
||||
|
||||
|
||||
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 getMultiCurrencyType(
|
||||
multiCurrencyTypeId: number,
|
||||
companyId: number
|
||||
): Promise<MultiCurrencyType> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.get<MultiCurrencyType>(`/v1/a76/multi-currency-types/${multiCurrencyTypeId}?${params.toString()}`);
|
||||
}
|
||||
|
||||
export async function createMultiCurrencyType(
|
||||
data: MultiCurrencyTypeCreate,
|
||||
companyId: number
|
||||
data: MultiCurrencyTypeCreate,
|
||||
companyId: number
|
||||
): Promise<MultiCurrencyType> {
|
||||
const response = await api.post(`/v1/a76/multi_currency_types/?company_id=${companyId}`, data);
|
||||
return response.data;
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.post<MultiCurrencyType>(`/v1/a76/multi-currency-types/?${params.toString()}`, data);
|
||||
}
|
||||
|
||||
|
||||
export async function updateMultiCurrencyType(
|
||||
id: number,
|
||||
data: MultiCurrencyTypeUpdate,
|
||||
companyId: number
|
||||
multiCurrencyTypeId: 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;
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.put<MultiCurrencyType>(
|
||||
`/v1/a76/multi-currency-types/${multiCurrencyTypeId}?${params.toString()}`,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export async function deleteMultiCurrencyType(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/multi_currency_types/${id}/?company_id=${companyId}`);
|
||||
export async function deleteMultiCurrencyType(
|
||||
multiCurrencyTypeId: number,
|
||||
companyId: number
|
||||
): Promise<void> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.delete(`/v1/a76/multi-currency-types/${multiCurrencyTypeId}?${params.toString()}`);
|
||||
}
|
||||
@@ -52,22 +52,19 @@ export async function getPackages(
|
||||
...filters
|
||||
});
|
||||
|
||||
const response = await api.get(`/v1/a76/packages/?${params.toString()}`);
|
||||
return response.data;
|
||||
return await api.get(`/v1/a76/packages?${params.toString()}`);
|
||||
}
|
||||
|
||||
|
||||
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 getPackage(id: number, companyId: number): Promise<ApiResponse<Package>> {
|
||||
return await api.get(`/v1/a76/packages/${id}?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
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;
|
||||
): Promise<ApiResponse<Package>> {
|
||||
return await api.post(`/v1/a76/packages?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,11 +72,10 @@ 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;
|
||||
): Promise<ApiResponse<Package>> {
|
||||
return await api.put(`/v1/a76/packages/${id}?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deletePackage(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/packages/${id}/?company_id=${companyId}`);
|
||||
export async function deletePackage(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/packages/${id}?company_id=${companyId}`);
|
||||
}
|
||||
@@ -73,5 +73,5 @@ export async function updateUnitConversion(
|
||||
}
|
||||
|
||||
export async function deleteUnitConversion(id: number, companyId: number): Promise<void> {
|
||||
await api.delete(`/v1/a76/unit_conversions/${id}/?company_id=${companyId}`);
|
||||
await api.delete(`/v1/a76/unit-conversions/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
@@ -31,26 +31,28 @@ export interface UnitOfMeasureACEListResponse {
|
||||
export async function getUnitsOfMeasureACE(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitOfMeasureACEListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/a76/units-of-measure/ace?${queryParams.toString()}`);
|
||||
return await api.get(`/v1/a76/units-of-measure/ace/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createUnitOfMeasureACE(data: UnitOfMeasureACECreate): Promise<ApiResponse<UnitOfMeasureACE>> {
|
||||
return await api.post('/a76/units-of-measure/ace', data);
|
||||
export async function createUnitOfMeasureACE(data: UnitOfMeasureACECreate, companyId: number): Promise<ApiResponse<UnitOfMeasureACE>> {
|
||||
return await api.post(`/v1/a76/units-of-measure/ace/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateUnitOfMeasureACE(id: number, data: UnitOfMeasureACEUpdate): Promise<ApiResponse<UnitOfMeasureACE>> {
|
||||
return await api.put(`/a76/units-of-measure/ace/${id}`, data);
|
||||
export async function updateUnitOfMeasureACE(id: number, data: UnitOfMeasureACEUpdate, companyId: number): Promise<ApiResponse<UnitOfMeasureACE>> {
|
||||
return await api.put(`/v1/a76/units-of-measure/ace/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteUnitOfMeasureACE(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/units-of-measure/ace/${id}`);
|
||||
export async function deleteUnitOfMeasureACE(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/units-of-measure/ace/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
// --- OMA ---
|
||||
@@ -81,28 +83,30 @@ export interface UnitOfMeasureOMAListResponse {
|
||||
}
|
||||
|
||||
export async function getUnitsOfMeasureOMA(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitOfMeasureOMAListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/a76/units-of-measure/oma?${queryParams.toString()}`);
|
||||
return await api.get(`/v1/a76/units-of-measure/oma/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createUnitOfMeasureOMA(data: UnitOfMeasureOMACreate): Promise<ApiResponse<UnitOfMeasureOMA>> {
|
||||
return await api.post('/a76/units-of-measure/oma', data);
|
||||
export async function createUnitOfMeasureOMA(data: UnitOfMeasureOMACreate, companyId: number): Promise<ApiResponse<UnitOfMeasureOMA>> {
|
||||
return await api.post(`/v1/a76/units-of-measure/oma/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateUnitOfMeasureOMA(id: number, data: UnitOfMeasureOMAUpdate): Promise<ApiResponse<UnitOfMeasureOMA>> {
|
||||
return await api.put(`/a76/units-of-measure/oma/${id}`, data);
|
||||
export async function updateUnitOfMeasureOMA(id: number, data: UnitOfMeasureOMAUpdate, companyId: number): Promise<ApiResponse<UnitOfMeasureOMA>> {
|
||||
return await api.put(`/v1/a76/units-of-measure/oma/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteUnitOfMeasureOMA(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/units-of-measure/oma/${id}`);
|
||||
export async function deleteUnitOfMeasureOMA(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/units-of-measure/oma/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
// --- American ---
|
||||
@@ -133,26 +137,139 @@ export interface UnitOfMeasureAmericanListResponse {
|
||||
}
|
||||
|
||||
export async function getUnitsOfMeasureAmerican(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitOfMeasureAmericanListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/a76/units-of-measure/american?${queryParams.toString()}`);
|
||||
return await api.get(`/v1/a76/units-of-measure/american/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createUnitOfMeasureAmerican(data: UnitOfMeasureAmericanCreate): Promise<ApiResponse<UnitOfMeasureAmerican>> {
|
||||
return await api.post('/a76/units-of-measure/american', data);
|
||||
export async function createUnitOfMeasureAmerican(data: UnitOfMeasureAmericanCreate, companyId: number): Promise<ApiResponse<UnitOfMeasureAmerican>> {
|
||||
return await api.post(`/v1/a76/units-of-measure/american/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateUnitOfMeasureAmerican(id: number, data: UnitOfMeasureAmericanUpdate): Promise<ApiResponse<UnitOfMeasureAmerican>> {
|
||||
return await api.put(`/a76/units-of-measure/american/${id}`, data);
|
||||
export async function updateUnitOfMeasureAmerican(id: number, data: UnitOfMeasureAmericanUpdate, companyId: number): Promise<ApiResponse<UnitOfMeasureAmerican>> {
|
||||
return await api.put(`/v1/a76/units-of-measure/american/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteUnitOfMeasureAmerican(id: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/a76/units-of-measure/american/${id}`);
|
||||
export async function deleteUnitOfMeasureAmerican(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/units-of-measure/american/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
// --- General ---
|
||||
export interface UnitOfMeasureGeneral {
|
||||
id: number;
|
||||
code: string;
|
||||
description: string | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureGeneralCreate {
|
||||
code: string;
|
||||
description?: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureGeneralUpdate {
|
||||
code?: string;
|
||||
description?: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureGeneralListResponse {
|
||||
items: UnitOfMeasureGeneral[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getUnitsOfMeasureGeneral(
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitOfMeasureGeneralListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/v1/a76/units-of-measure/general/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createUnitOfMeasureGeneral(data: UnitOfMeasureGeneralCreate, companyId: number): Promise<ApiResponse<UnitOfMeasureGeneral>> {
|
||||
return await api.post(`/v1/a76/units-of-measure/general/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateUnitOfMeasureGeneral(id: number, data: UnitOfMeasureGeneralUpdate, companyId: number): Promise<ApiResponse<UnitOfMeasureGeneral>> {
|
||||
return await api.put(`/v1/a76/units-of-measure/general/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteUnitOfMeasureGeneral(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/units-of-measure/general/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
// --- Customs ---
|
||||
export interface UnitOfMeasureCustoms {
|
||||
id: number;
|
||||
code: string;
|
||||
description: string | null;
|
||||
scaii_unit_code: string | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureCustomsCreate {
|
||||
code: string;
|
||||
description?: string | null;
|
||||
scaii_unit_code?: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureCustomsUpdate {
|
||||
code?: string;
|
||||
description?: string | null;
|
||||
scaii_unit_code?: string | null;
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureCustomsListResponse {
|
||||
items: UnitOfMeasureCustoms[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export async function getUnitsOfMeasureCustoms(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<UnitOfMeasureCustomsListResponse>> {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
});
|
||||
return await api.get(`/v1/a76/units-of-measure/customs/?${queryParams.toString()}`);
|
||||
}
|
||||
|
||||
export async function createUnitOfMeasureCustoms(data: UnitOfMeasureCustomsCreate, companyId: number): Promise<ApiResponse<UnitOfMeasureCustoms>> {
|
||||
return await api.post(`/v1/a76/units-of-measure/customs/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateUnitOfMeasureCustoms(id: number, data: UnitOfMeasureCustomsUpdate, companyId: number): Promise<ApiResponse<UnitOfMeasureCustoms>> {
|
||||
return await api.put(`/v1/a76/units-of-measure/customs/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteUnitOfMeasureCustoms(id: number, companyId: number): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/units-of-measure/customs/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user