feat(web): copiar de / a entre movimientos de inventario (solicitud de traslado → transferencia de stock)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GeorgeandClaude Sonnet 5.5 committed 2026-10-16 12:20:26 -05:00
1 parent fdc042ddcd
commit a5592fac76
10 files changed
+282 -18

No files matched your search

@@ -34,9 +34,29 @@ const PATH_OF_OBJECT: ReadonlyMap<number, string> = new Map(
.map(([path, type]) => [type, path]),
);
/**
* En las líneas de una transferencia de stock, `BaseType` no es el número del objeto sino un enumerado de
* texto de SAP (`InvBaseDocTypeEnum`; sin origen vale `Default`). Objeto → nombre del enumerado.
*/
export const STOCK_BASE_TYPES: Readonly<Record<number, string>> = {
1250000001: 'InventoryTransferRequest',
67: 'WarehouseTransfers',
59: 'InventoryGeneralEntry',
20: 'PurchaseDeliveryNotes',
};
const OBJECT_OF_ENUM: ReadonlyMap<string, number> = new Map(Object.entries(STOCK_BASE_TYPES).map(([obj, name]) => [name, Number(obj)]));
/** La línea referencia a un documento origen: `BaseType` útil (número > 0 o nombre del enumerado) y `BaseEntry`. */
export function hasBaseRef(baseType: unknown, baseEntry: unknown): boolean {
if (baseEntry === null || baseEntry === undefined || baseEntry === '') return false;
if (typeof baseType === 'string') return OBJECT_OF_ENUM.has(baseType) || Number(baseType) > 0;
return Number(baseType) > 0;
}
/** Nombre del documento de un tipo de objeto (`17` → «Órdenes de venta»), o el número si no se conoce. */
export function objectLabel(type: unknown): string {
const code = Number(type);
const code = typeof type === 'string' && OBJECT_OF_ENUM.has(type) ? OBJECT_OF_ENUM.get(type)! : Number(type);
const path = PATH_OF_OBJECT.get(code);
return (path && MENU.flatMap((m) => m.items).find((i) => i.path === path)?.label) || (code > 0 ? String(code) : '');
}