feat: Add dialog for creating and editing historical tariff fractions and implement deterministic sorting for fraction listings.
This commit is contained in:
@@ -19,6 +19,40 @@ export interface HistoricalFraction {
|
||||
end_date: string | null;
|
||||
}
|
||||
|
||||
export interface HistoricalFractionCreate {
|
||||
historical_fraction: string;
|
||||
unit_of_measure_code?: string | null;
|
||||
country?: string | null;
|
||||
fraction_type?: string | null;
|
||||
sector?: string | null;
|
||||
import_tax_rate?: number | null;
|
||||
export_tax_rate?: number | null;
|
||||
publication_date?: string | null;
|
||||
is_immex?: boolean | null;
|
||||
normal_temporality?: boolean | null;
|
||||
services_temporality?: boolean | null;
|
||||
certified_temporality?: boolean | null;
|
||||
by_log?: boolean | null;
|
||||
end_date?: string | null;
|
||||
}
|
||||
|
||||
export interface HistoricalFractionUpdate {
|
||||
historical_fraction?: string;
|
||||
unit_of_measure_code?: string | null;
|
||||
country?: string | null;
|
||||
fraction_type?: string | null;
|
||||
sector?: string | null;
|
||||
import_tax_rate?: number | null;
|
||||
export_tax_rate?: number | null;
|
||||
publication_date?: string | null;
|
||||
is_immex?: boolean | null;
|
||||
normal_temporality?: boolean | null;
|
||||
services_temporality?: boolean | null;
|
||||
certified_temporality?: boolean | null;
|
||||
by_log?: boolean | null;
|
||||
end_date?: string | null;
|
||||
}
|
||||
|
||||
export interface HistoricalFractionList {
|
||||
items: HistoricalFraction[];
|
||||
total: number;
|
||||
@@ -41,15 +75,29 @@ export async function getHistoricalFractions(
|
||||
|
||||
if (historicalFraction) params.append('historical_fraction', historicalFraction);
|
||||
|
||||
const response = await api.get<{ message?: string, items?: HistoricalFraction[], total?: number }>(`/v1/a76/fractions/historical-tariff-fractions/?${params.toString()}`);
|
||||
|
||||
// Handle potential wrapper response
|
||||
if (response.data && 'items' in response.data) {
|
||||
return response.data as unknown as HistoricalFractionList;
|
||||
}
|
||||
|
||||
const response = await api.get<HistoricalFractionList>(`/v1/a76/fractions/historical-tariff-fractions/?${params.toString()}`);
|
||||
if (!response.data) throw new Error('Error fetching historical fractions');
|
||||
|
||||
// Fallback
|
||||
return response.data as unknown as HistoricalFractionList;
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function createHistoricalFraction(
|
||||
companyId: number,
|
||||
data: HistoricalFractionCreate
|
||||
): Promise<ApiResponse<HistoricalFraction>> {
|
||||
return await api.post(`/v1/a76/fractions/historical-tariff-fractions/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function updateHistoricalFraction(
|
||||
companyId: number,
|
||||
id: number,
|
||||
data: HistoricalFractionUpdate
|
||||
): Promise<ApiResponse<HistoricalFraction>> {
|
||||
return await api.put(`/v1/a76/fractions/historical-tariff-fractions/${id}/?company_id=${companyId}`, data);
|
||||
}
|
||||
|
||||
export async function deleteHistoricalFraction(
|
||||
companyId: number,
|
||||
id: number
|
||||
): Promise<ApiResponse<void>> {
|
||||
return await api.delete(`/v1/a76/fractions/historical-tariff-fractions/${id}/?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user