Se integro el sistema de extraer el tipo de cambio

This commit is contained in:
2026-01-23 10:42:21 -06:00
parent bf26268f23
commit b8045d73e6
9 changed files with 228 additions and 18 deletions

View File

@@ -37,10 +37,12 @@ export interface ExchangeRateFilters {
page_size?: number;
}
import type { ApiResponse } from '$lib/api';
export async function getExchangeRates(
companyId: number,
filters?: ExchangeRateFilters
): Promise<ExchangeRateListResponse> {
): Promise<ApiResponse<ExchangeRateListResponse>> {
const params = new URLSearchParams({ company_id: companyId.toString() });
if (filters) {
@@ -57,7 +59,7 @@ export async function getExchangeRates(
export async function getExchangeRate(
exchangeRateId: number,
companyId: number
): Promise<ExchangeRate> {
): Promise<ApiResponse<ExchangeRate>> {
const params = new URLSearchParams({ company_id: companyId.toString() });
return api.get<ExchangeRate>(`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`);
}
@@ -65,7 +67,7 @@ export async function getExchangeRate(
export async function createExchangeRate(
data: ExchangeRateCreate,
companyId: number
): Promise<ExchangeRate> {
): Promise<ApiResponse<ExchangeRate>> {
const params = new URLSearchParams({ company_id: companyId.toString() });
return api.post<ExchangeRate>(`/v1/a76/exchange-rate/?${params.toString()}`, data);
}
@@ -74,7 +76,7 @@ export async function updateExchangeRate(
exchangeRateId: number,
data: ExchangeRateUpdate,
companyId: number
): Promise<ExchangeRate> {
): Promise<ApiResponse<ExchangeRate>> {
const params = new URLSearchParams({ company_id: companyId.toString() });
return api.put<ExchangeRate>(
`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`,
@@ -85,7 +87,17 @@ export async function updateExchangeRate(
export async function deleteExchangeRate(
exchangeRateId: number,
companyId: number
): Promise<void> {
): Promise<ApiResponse<void>> {
const params = new URLSearchParams({ company_id: companyId.toString() });
return api.delete(`/v1/a76/exchange-rate/${exchangeRateId}?${params.toString()}`);
}
export interface DofResponse {
success: boolean;
message?: string;
value?: number | null;
}
export async function getDofExchangeRate(date: string): Promise<ApiResponse<DofResponse>> {
return api.get<DofResponse>(`/v1/a76/exchange-rate/dof-search?date=${date}`);
}