Se cambio la tabla de unidades de medida generales por unidades de medida
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]:
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user