Merge pull request 'fix/tabla_unidades_medida' (#66) from fix/tabla_unidades_medida into development
Reviewed-on: ADUANASOFT/anexo76#66
This commit is contained in:
@@ -36,14 +36,8 @@ class UnitOfMeasureBase(BaseModel):
|
||||
oma_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralBase(BaseModel):
|
||||
code: str = Field(..., max_length=20, description="Unit Code")
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
conversion_factor: Optional[Decimal] = None
|
||||
mexico_unit: Optional[str] = Field(None, max_length=20)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=20)
|
||||
customs_code: Optional[int] = Field(None)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
class UnitOfMeasureGeneralBase(UnitOfMeasureBase):
|
||||
pass
|
||||
|
||||
# --- Create DTOs ---
|
||||
|
||||
@@ -105,14 +99,8 @@ class UnitOfMeasureUpdate(BaseModel):
|
||||
oma_code: Optional[str] = Field(None, max_length=20)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralUpdate(BaseModel):
|
||||
code: Optional[str] = Field(None, max_length=20)
|
||||
description: Optional[str] = Field(None, max_length=100)
|
||||
conversion_factor: Optional[Decimal] = None
|
||||
mexico_unit: Optional[str] = Field(None, max_length=20)
|
||||
american_unit_code: Optional[str] = Field(None, max_length=20)
|
||||
customs_code: Optional[int] = Field(None)
|
||||
ace_code: Optional[str] = Field(None, max_length=20)
|
||||
class UnitOfMeasureGeneralUpdate(UnitOfMeasureUpdate):
|
||||
pass
|
||||
|
||||
# --- Response DTOs ---
|
||||
|
||||
@@ -142,6 +130,5 @@ class UnitOfMeasureResponse(UnitOfMeasureBase):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralResponse(UnitOfMeasureGeneralBase):
|
||||
id: int
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
class UnitOfMeasureGeneralResponse(UnitOfMeasureResponse):
|
||||
pass
|
||||
|
||||
@@ -154,7 +154,7 @@ class UnitOfMeasureService(BaseService):
|
||||
|
||||
|
||||
class UnitOfMeasureGeneralService(BaseService):
|
||||
model = UnitOfMeasureGeneral
|
||||
model = UnitOfMeasure
|
||||
|
||||
|
||||
def get_all_uom_general(session: Session, skip: int = 0, limit: int = 100) -> Sequence[UnitOfMeasureGeneral]:
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"valuation_methods": "Valuation Methods",
|
||||
"countries": "Countries",
|
||||
"ports": "Ports",
|
||||
"unit_measures": "Units of Measure - General",
|
||||
"unit_measures": "Units of Measure",
|
||||
"um_customs_mex": "Units of Measure - Mexican Customs",
|
||||
"um_customs_ame": "Units of Measure - American Customs",
|
||||
"um_ace": "Units of Measure - ACE",
|
||||
@@ -65,7 +65,7 @@
|
||||
},
|
||||
"goods": {
|
||||
"title": "Goods",
|
||||
"classes": "Classes",
|
||||
"classes": "Classes",
|
||||
"parts": "Parts"
|
||||
},
|
||||
"pedimentos": {
|
||||
@@ -77,16 +77,16 @@
|
||||
"customs_sections": "Customs Sections",
|
||||
"anexo_22_app_31": "Anexo 22 App 3"
|
||||
},
|
||||
"import_invoices":{
|
||||
"import_invoices": {
|
||||
"title": "Import Invoices",
|
||||
"temporary": "Temporary",
|
||||
"definitive": "Definitive",
|
||||
"mexican_purchases": "Mexican Purchases",
|
||||
"regime_change": "Regime Change"
|
||||
"regime_change": "Regime Change"
|
||||
},
|
||||
"export_invoices": {
|
||||
"title": "Export Invoices",
|
||||
"exportation": "Exportation",
|
||||
"exportation": "Exportation",
|
||||
"repair": "Repair"
|
||||
},
|
||||
"clients_and_providers": "Clients and Providers",
|
||||
@@ -97,4 +97,4 @@
|
||||
"logout": "Logout"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"hello_world": "Hello, {name} from es!",
|
||||
"sidebar": {
|
||||
"reference_data": {
|
||||
"title": "Catálogos Fijos",
|
||||
"codes_pedimento_regimen": "Códigos de Pedimento y Régimen",
|
||||
"containers": "Contenedores",
|
||||
"countries": "Países",
|
||||
"currency_types": "Tipos de moneda",
|
||||
"customs_sections": "Secciones de aduanas",
|
||||
"customs_warehouses": "Recintos",
|
||||
"incoterms": "Incoterms",
|
||||
"invoice_types": "Tipos de factura",
|
||||
"material_types": "Tipos de material",
|
||||
"payment_methods": "Métodos de pago",
|
||||
"pedimento_codes": "Códigos de pedimento",
|
||||
"pedimento_regimes": "Regímenes de pedimentos",
|
||||
"sectors": "Sectores",
|
||||
"states": "Estados",
|
||||
"transportation_modes": "Métodos de transporte",
|
||||
"transportation_types": "Tipos de transporte",
|
||||
"valuation_methods": "Métodos de valoración",
|
||||
"configuracion": "Configuración",
|
||||
"general": "General",
|
||||
"licencia": "Licencia",
|
||||
"usuarios": "Usuarios",
|
||||
"ayuda": "Ayuda"
|
||||
},
|
||||
"general_catalogs": {
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"hello_world": "Hello, {name} from es!",
|
||||
"sidebar": {
|
||||
"reference_data": {
|
||||
"title": "Catálogos Fijos",
|
||||
"codes_pedimento_regimen": "Códigos de Pedimento y Régimen",
|
||||
"containers": "Contenedores",
|
||||
"countries": "Países",
|
||||
"currency_types": "Tipos de moneda",
|
||||
"customs_sections": "Secciones de aduanas",
|
||||
"customs_warehouses": "Recintos",
|
||||
"incoterms": "Incoterms",
|
||||
"invoice_types": "Tipos de factura",
|
||||
"material_types": "Tipos de material",
|
||||
"payment_methods": "Métodos de pago",
|
||||
"pedimento_codes": "Códigos de pedimento",
|
||||
"pedimento_regimes": "Regímenes de pedimentos",
|
||||
"sectors": "Sectores",
|
||||
"states": "Estados",
|
||||
"transportation_modes": "Métodos de transporte",
|
||||
"transportation_types": "Tipos de transporte",
|
||||
"valuation_methods": "Métodos de valoración",
|
||||
"configuracion": "Configuración",
|
||||
"general": "General",
|
||||
"licencia": "Licencia",
|
||||
"usuarios": "Usuarios",
|
||||
"ayuda": "Ayuda"
|
||||
},
|
||||
"general_catalogs": {
|
||||
"title": "Catalogos Generales",
|
||||
"company_information": "Información de la empresa",
|
||||
"packages": "Bultos",
|
||||
@@ -41,7 +41,7 @@
|
||||
"valuation_methods": "Metódos de valoración",
|
||||
"countries": "Países",
|
||||
"ports": "Puertos",
|
||||
"unit_measures": "UM general",
|
||||
"unit_measures": "Unidades de medida",
|
||||
"um_customs_mex": "UM Aduanas MX",
|
||||
"um_customs_ame": "UM Aduanas USA",
|
||||
"um_ace": "UM ACE",
|
||||
@@ -65,10 +65,10 @@
|
||||
},
|
||||
"goods": {
|
||||
"title": "Mercancías",
|
||||
"classes": "Clases",
|
||||
"classes": "Clases",
|
||||
"parts": "Partes"
|
||||
},
|
||||
"pedimentos": {
|
||||
"pedimentos": {
|
||||
"title": "Pedimentos",
|
||||
"pedimento_management": "Gestión de Pedimentos",
|
||||
"pedimento_codes": "Claves de Pedimento",
|
||||
@@ -77,16 +77,16 @@
|
||||
"customs_sections": "Secciones Aduaneras",
|
||||
"anexo_22_app_31": "Anexo 22 App 3"
|
||||
},
|
||||
"import_invoices":{
|
||||
"import_invoices": {
|
||||
"title": "Facturas de importación",
|
||||
"temporary": "Temporal",
|
||||
"definitive": "Definitiva",
|
||||
"mexican_purchases": "Compras mexicanas",
|
||||
"regime_change": "Cambio de régimen"
|
||||
"regime_change": "Cambio de régimen"
|
||||
},
|
||||
"export_invoices": {
|
||||
"title": "Facturas de exportación",
|
||||
"exportation": "Exportación",
|
||||
"exportation": "Exportación",
|
||||
"repair": "Reparación"
|
||||
},
|
||||
"clients_and_providers": "Clientes y Proveedores",
|
||||
@@ -95,5 +95,5 @@
|
||||
"profile": "Perfil",
|
||||
"settings": "Configuración"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ export interface UnitOfMeasureGeneralUpdate {
|
||||
}
|
||||
|
||||
export interface UnitOfMeasureGeneralListResponse {
|
||||
items: UnitOfMeasureGeneral[];
|
||||
items: UnitOfMeasureGeneral[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
@@ -214,7 +214,7 @@ export async function updateUnitOfMeasureGeneral(id: number, data: UnitOfMeasure
|
||||
}
|
||||
|
||||
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}`);
|
||||
return await api.delete(`/v1/a76/units-of-measure/general/${id}?company_id=${companyId}`);
|
||||
}
|
||||
|
||||
// --- Customs ---
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
||||
import { MoreHorizontal, Pencil, Trash2 } from 'lucide-svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import CreateEditDialog from './create-edit-dialog.svelte';
|
||||
import type { UnitOfMeasureGeneral } from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { deleteUnitOfMeasureGeneral } from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
const response = await deleteUnitOfMeasureGeneral(unit.id, activeCompanyId);
|
||||
if (response.error) {
|
||||
toast.error(response.error);
|
||||
} else if (response.status === 204 || response.status === 200) {
|
||||
onSuccess?.();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<script lang="ts" generics="TData, TValue">
|
||||
import {
|
||||
type ColumnDef,
|
||||
getCoreRowModel,
|
||||
} from "@tanstack/table-core";
|
||||
import { createSvelteTable, FlexRender } from "$lib/components/ui/data-table/index.js";
|
||||
import * as Table from "$lib/components/ui/table/index.js";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/stores";
|
||||
|
||||
type DataTableProps<TData, TValue> = {
|
||||
columns: ColumnDef<TData, TValue>[];
|
||||
data: TData[];
|
||||
pageCount: number;
|
||||
totalItems: number;
|
||||
};
|
||||
|
||||
let {
|
||||
data,
|
||||
columns,
|
||||
pageCount,
|
||||
totalItems
|
||||
}: DataTableProps<TData, TValue> = $props();
|
||||
|
||||
const table = createSvelteTable({
|
||||
get data() { return data; },
|
||||
get columns() { return columns; },
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
manualPagination: true,
|
||||
get pageCount() { return pageCount; },
|
||||
});
|
||||
|
||||
function handlePageChange(newPage: number) {
|
||||
const url = new URL($page.url);
|
||||
url.searchParams.set('page', newPage.toString());
|
||||
goto(url, { keepFocus: true, noScroll: true });
|
||||
}
|
||||
|
||||
const currentPage = $derived(Number($page.url.searchParams.get('page') || 1));
|
||||
</script>
|
||||
|
||||
<div class="rounded-md border">
|
||||
<Table.Root>
|
||||
<Table.Header>
|
||||
{#each table.getHeaderGroups() as headerGroup (headerGroup.id)}
|
||||
<Table.Row>
|
||||
{#each headerGroup.headers as header (header.id)}
|
||||
<Table.Head>
|
||||
{#if !header.isPlaceholder}
|
||||
<FlexRender
|
||||
content={header.column.columnDef.header}
|
||||
context={header.getContext()}
|
||||
/>
|
||||
{/if}
|
||||
</Table.Head>
|
||||
{/each}
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each table.getRowModel().rows as row (row.id)}
|
||||
<Table.Row data-state={row.getIsSelected() && "selected"}>
|
||||
{#each row.getVisibleCells() as cell (cell.id)}
|
||||
<Table.Cell>
|
||||
<FlexRender
|
||||
content={cell.column.columnDef.cell}
|
||||
context={cell.getContext()}
|
||||
/>
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row>
|
||||
{:else}
|
||||
<Table.Row>
|
||||
<Table.Cell colspan={columns.length} class="h-24 text-center">
|
||||
No hay resultados.
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex items-center justify-end space-x-2 py-4 px-2">
|
||||
<div class="flex-1 text-sm text-muted-foreground">
|
||||
Total: {totalItems} registros
|
||||
</div>
|
||||
<div class="space-x-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onclick={() => handlePageChange(currentPage - 1)}
|
||||
disabled={currentPage <= 1}
|
||||
>
|
||||
Anterior
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onclick={() => handlePageChange(currentPage + 1)}
|
||||
disabled={currentPage >= pageCount}
|
||||
>
|
||||
Siguiente
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,18 +1,18 @@
|
||||
import {
|
||||
Archive,
|
||||
ArrowDownToLine,
|
||||
ArrowUpFromLine,
|
||||
BadgeCheck,
|
||||
ChartPie,
|
||||
Database,
|
||||
FileText,
|
||||
Frame,
|
||||
GalleryVerticalEnd,
|
||||
LayoutDashboard,
|
||||
Package,
|
||||
Settings2,
|
||||
Shield,
|
||||
Users,
|
||||
import {
|
||||
Archive,
|
||||
ArrowDownToLine,
|
||||
ArrowUpFromLine,
|
||||
BadgeCheck,
|
||||
ChartPie,
|
||||
Database,
|
||||
FileText,
|
||||
Frame,
|
||||
GalleryVerticalEnd,
|
||||
LayoutDashboard,
|
||||
Package,
|
||||
Settings2,
|
||||
Shield,
|
||||
Users,
|
||||
} from 'lucide-svelte';
|
||||
import * as m from "$lib/paraglide/messages.js";
|
||||
import { Title } from '../ui/alert';
|
||||
@@ -296,7 +296,7 @@ export function getSidebarData(): SidebarData {
|
||||
{
|
||||
title: m["sidebar.goods.classes"](),
|
||||
url: "/dashboard/goods/fixed-asset-classes",
|
||||
},
|
||||
},
|
||||
{
|
||||
title: m["sidebar.goods.parts"](),
|
||||
url: "/dashboard/goods/parts",
|
||||
@@ -369,7 +369,7 @@ export function getSidebarData(): SidebarData {
|
||||
{
|
||||
title: m["sidebar.export_invoices.repair"](),
|
||||
url: "/dashboard/invoices?operation_type=exp&invoice_type=REPAR",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="flex flex-col gap-4 p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold tracking-tight">Unidades de Medida Generales</h1>
|
||||
<h1 class="text-2xl font-bold tracking-tight">Unidades de Medida</h1>
|
||||
<p class="text-muted-foreground">
|
||||
Catálogo general de unidades de medida
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user