Se integro el sistema de extraer el tipo de cambio
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user