Merge remote-tracking branch 'origin/24-nov' into development
This commit is contained in:
91
frontend/src/lib/api/dashboard/a76/exchange-rate.ts
Normal file
91
frontend/src/lib/api/dashboard/a76/exchange-rate.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import type { PaginatedResponse } from '$lib/types';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface ExchangeRate {
|
||||
id: number;
|
||||
date: string;
|
||||
value: number | null;
|
||||
local_currency: string | null;
|
||||
foreign_currency: string | null;
|
||||
company_id: number;
|
||||
tenant_id: number;
|
||||
}
|
||||
|
||||
export interface ExchangeRateCreate {
|
||||
date: string;
|
||||
value?: number | null;
|
||||
local_currency?: string | null;
|
||||
foreign_currency?: string | null;
|
||||
}
|
||||
|
||||
export interface ExchangeRateUpdate {
|
||||
date?: string;
|
||||
value?: number | null;
|
||||
local_currency?: string | null;
|
||||
foreign_currency?: string | null;
|
||||
}
|
||||
|
||||
export interface ExchangeRateListResponse extends PaginatedResponse {
|
||||
items: ExchangeRate[];
|
||||
}
|
||||
|
||||
export interface ExchangeRateFilters {
|
||||
date?: string;
|
||||
local_currency?: string;
|
||||
foreign_currency?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
|
||||
export async function getExchangeRates(
|
||||
companyId: number,
|
||||
filters?: ExchangeRateFilters
|
||||
): Promise<ExchangeRateListResponse> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
|
||||
if (filters) {
|
||||
if (filters.date) params.append('date', filters.date);
|
||||
if (filters.local_currency) params.append('local_currency', filters.local_currency);
|
||||
if (filters.foreign_currency) params.append('foreign_currency', filters.foreign_currency);
|
||||
if (filters.page) params.append('page', filters.page.toString());
|
||||
if (filters.page_size) params.append('page_size', filters.page_size.toString());
|
||||
}
|
||||
|
||||
return api.get<ExchangeRateListResponse>(`/v1/a76/exchange-rate/?${params.toString()}`);
|
||||
}
|
||||
|
||||
export async function getExchangeRate(
|
||||
exchangeRateId: number,
|
||||
companyId: number
|
||||
): Promise<ExchangeRate> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.get<ExchangeRate>(`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`);
|
||||
}
|
||||
|
||||
export async function createExchangeRate(
|
||||
data: ExchangeRateCreate,
|
||||
companyId: number
|
||||
): Promise<ExchangeRate> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.post<ExchangeRate>(`/v1/a76/exchange-rate/?${params.toString()}`, data);
|
||||
}
|
||||
|
||||
export async function updateExchangeRate(
|
||||
exchangeRateId: number,
|
||||
data: ExchangeRateUpdate,
|
||||
companyId: number
|
||||
): Promise<ExchangeRate> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.put<ExchangeRate>(
|
||||
`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteExchangeRate(
|
||||
exchangeRateId: number,
|
||||
companyId: number
|
||||
): Promise<void> {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
return api.delete(`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`);
|
||||
}
|
||||
@@ -2,3 +2,5 @@
|
||||
* Exportaciones de APIs para módulo A76
|
||||
*/
|
||||
export * from './classes';
|
||||
export * from './packages';
|
||||
export * from './exchange-rate';
|
||||
|
||||
122
frontend/src/lib/api/dashboard/a76/packages.ts
Normal file
122
frontend/src/lib/api/dashboard/a76/packages.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* API para gestión de Packages (Bultos/Embalajes A76)
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
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;
|
||||
}
|
||||
|
||||
export interface PackageCreate {
|
||||
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 {
|
||||
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 PackageListResponse {
|
||||
items: Package[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export interface PackageFilters {
|
||||
key?: string;
|
||||
description_es?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener lista de packages con paginación
|
||||
*/
|
||||
export async function getPackages(
|
||||
companyId: number,
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
filters?: PackageFilters
|
||||
): Promise<ApiResponse<PackageListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
company_id: companyId.toString(),
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString()
|
||||
});
|
||||
|
||||
if (filters?.key) {
|
||||
params.append('key', filters.key);
|
||||
}
|
||||
if (filters?.description_es) {
|
||||
params.append('description_es', filters.description_es);
|
||||
}
|
||||
|
||||
return api.get<PackageListResponse>(`/v1/a76/packages/?${params.toString()}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener un package por ID
|
||||
*/
|
||||
export async function getPackage(
|
||||
packageId: number,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<Package>> {
|
||||
return api.get<Package>(`/v1/a76/packages/${packageId}?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un nuevo package
|
||||
*/
|
||||
export async function createPackage(
|
||||
data: PackageCreate,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<Package>> {
|
||||
return api.post<Package>(`/v1/a76/packages/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar un package existente
|
||||
*/
|
||||
export async function updatePackage(
|
||||
packageId: number,
|
||||
data: PackageUpdate,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<Package>> {
|
||||
return api.put<Package>(`/v1/a76/packages/${packageId}?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar un package
|
||||
*/
|
||||
export async function deletePackage(
|
||||
packageId: number,
|
||||
companyId: number
|
||||
): Promise<ApiResponse<void>> {
|
||||
return api.delete<void>(`/v1/a76/packages/${packageId}?company_id=${companyId}`);
|
||||
}
|
||||
95
frontend/src/lib/api/dashboard/a76/seal.ts
Normal file
95
frontend/src/lib/api/dashboard/a76/seal.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* API client for Seal operations
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface Seal {
|
||||
id: number;
|
||||
seal: string;
|
||||
company_id: number;
|
||||
tenant_id: number;
|
||||
}
|
||||
|
||||
export interface SealListResponse {
|
||||
items: Seal[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export interface SealCreateRequest {
|
||||
seal: string;
|
||||
}
|
||||
|
||||
export interface SealUpdateRequest {
|
||||
seal?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all seals with pagination and filters
|
||||
*/
|
||||
export async function getSeals(
|
||||
companyId: number,
|
||||
filters?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
seal?: string;
|
||||
}
|
||||
): Promise<{ data: SealListResponse; status: number }> {
|
||||
const params = new URLSearchParams();
|
||||
params.append('company_id', companyId.toString());
|
||||
|
||||
if (filters?.page) params.append('page', filters.page.toString());
|
||||
if (filters?.page_size) params.append('page_size', filters.page_size.toString());
|
||||
if (filters?.seal) params.append('seal', filters.seal);
|
||||
|
||||
const response = await api.get(`/v1/a76/seals?${params.toString()}`);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single seal by ID
|
||||
*/
|
||||
export async function getSeal(
|
||||
id: number,
|
||||
companyId: number
|
||||
): Promise<{ data: Seal; status: number }> {
|
||||
const response = await api.get(`/v1/a76/seals/${id}?company_id=${companyId}`);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new seal
|
||||
*/
|
||||
export async function createSeal(
|
||||
data: SealCreateRequest,
|
||||
companyId: number
|
||||
): Promise<{ data: Seal; status: number }> {
|
||||
const response = await api.post(`/v1/a76/seals?company_id=${companyId}`, data);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing seal
|
||||
*/
|
||||
export async function updateSeal(
|
||||
id: number,
|
||||
data: SealUpdateRequest,
|
||||
companyId: number
|
||||
): Promise<{ data: Seal; status: number }> {
|
||||
const response = await api.put(`/v1/a76/seals/${id}?company_id=${companyId}`, data);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a seal
|
||||
*/
|
||||
export async function deleteSeal(
|
||||
id: number,
|
||||
companyId: number
|
||||
): Promise<{ data: any; status: number }> {
|
||||
const response = await api.delete(`/v1/a76/seals/${id}?company_id=${companyId}`);
|
||||
return response;
|
||||
}
|
||||
95
frontend/src/lib/api/dashboard/public/countries.ts
Normal file
95
frontend/src/lib/api/dashboard/public/countries.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* API client for Countries operations
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface Country {
|
||||
m3_key: string;
|
||||
mex_key: string;
|
||||
ame_key: string;
|
||||
description_es: string;
|
||||
description_en: string;
|
||||
}
|
||||
|
||||
export interface CountryListResponse {
|
||||
items: Country[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface CountryCreateRequest {
|
||||
m3_key: string;
|
||||
mex_key: string;
|
||||
ame_key: string;
|
||||
description_es: string;
|
||||
description_en: string;
|
||||
}
|
||||
|
||||
export interface CountryUpdateRequest {
|
||||
m3_key: string;
|
||||
mex_key: string;
|
||||
ame_key: string;
|
||||
description_es: string;
|
||||
description_en: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all countries with pagination
|
||||
*/
|
||||
export async function getCountries(
|
||||
filters?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
): Promise<{ data: CountryListResponse; status: number }> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (filters?.page) params.append('page', filters.page.toString());
|
||||
if (filters?.page_size) params.append('page_size', filters.page_size.toString());
|
||||
|
||||
const response = await api.get(`/v1/public/refrence_data/countries?${params.toString()}`);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single country by m3_key
|
||||
*/
|
||||
export async function getCountry(
|
||||
m3_key: string
|
||||
): Promise<{ data: Country; status: number }> {
|
||||
const response = await api.get(`/v1/public/refrence_data/countries/${m3_key}`);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new country
|
||||
*/
|
||||
export async function createCountry(
|
||||
data: CountryCreateRequest
|
||||
): Promise<{ data: Country; status: number }> {
|
||||
const response = await api.post(`/v1/public/refrence_data/countries`, data);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing country
|
||||
*/
|
||||
export async function updateCountry(
|
||||
m3_key: string,
|
||||
data: CountryUpdateRequest
|
||||
): Promise<{ data: Country; status: number }> {
|
||||
const response = await api.put(`/v1/public/refrence_data/countries/${m3_key}`, data);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a country
|
||||
*/
|
||||
export async function deleteCountry(
|
||||
m3_key: string
|
||||
): Promise<{ data: any; status: number }> {
|
||||
const response = await api.delete(`/v1/public/refrence_data/countries/${m3_key}`);
|
||||
return response;
|
||||
}
|
||||
Reference in New Issue
Block a user