diff --git a/modules/customer-invoices/src/web/proformas/change-status/helpers/index.ts b/modules/customer-invoices/src/web/proformas/change-status/helpers/index.ts new file mode 100644 index 00000000..7af5c72d --- /dev/null +++ b/modules/customer-invoices/src/web/proformas/change-status/helpers/index.ts @@ -0,0 +1 @@ +export * from "./proforma-status-ui"; diff --git a/modules/customer-invoices/src/web/proformas/types/proforma-status.ts b/modules/customer-invoices/src/web/proformas/change-status/helpers/proforma-status-ui.ts similarity index 96% rename from modules/customer-invoices/src/web/proformas/types/proforma-status.ts rename to modules/customer-invoices/src/web/proformas/change-status/helpers/proforma-status-ui.ts index 6a84e831..7b5b9f54 100644 --- a/modules/customer-invoices/src/web/proformas/types/proforma-status.ts +++ b/modules/customer-invoices/src/web/proformas/change-status/helpers/proforma-status-ui.ts @@ -7,6 +7,8 @@ import { XCircleIcon, } from "lucide-react"; +import type { ProformaStatus } from "../../shared"; + export const getProformaStatusButtonVariant = ( status: ProformaStatus ): "default" | "secondary" | "outline" | "destructive" => { diff --git a/modules/customer-invoices/src/web/proformas/change-status/ui/change-status-dialog.tsx b/modules/customer-invoices/src/web/proformas/change-status/ui/change-status-dialog.tsx index dce99f59..604284e8 100644 --- a/modules/customer-invoices/src/web/proformas/change-status/ui/change-status-dialog.tsx +++ b/modules/customer-invoices/src/web/proformas/change-status/ui/change-status-dialog.tsx @@ -11,19 +11,15 @@ import { import { useState } from "react"; import { useTranslation } from "../../../i18n"; -import { - PROFORMA_STATUS, - PROFORMA_STATUS_TRANSITIONS, - type ProformaSummaryData, - getProformaStatusIcon, -} from "../../types"; +import { PROFORMA_STATUS, PROFORMA_STATUS_TRANSITIONS, type ProformaListRow } from "../../shared"; +import { getProformaStatusIcon } from "../helpers"; import { StatusNode, TimelineConnector } from "./components"; interface ChangeStatusDialogProps { open: boolean; onOpenChange: (open: boolean) => void; - proformas: ProformaSummaryData[]; + proformas: ProformaListRow[]; targetStatus?: string; isSubmitting: boolean; onConfirm: (status: PROFORMA_STATUS) => void; diff --git a/modules/customer-invoices/src/web/proformas/change-status/ui/components/status-node.tsx b/modules/customer-invoices/src/web/proformas/change-status/ui/components/status-node.tsx index 0f8f4451..477ddc8d 100644 --- a/modules/customer-invoices/src/web/proformas/change-status/ui/components/status-node.tsx +++ b/modules/customer-invoices/src/web/proformas/change-status/ui/components/status-node.tsx @@ -4,7 +4,7 @@ import { cn } from "@repo/shadcn-ui/lib/utils"; import { CheckCircle2, type LucideIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; -import type { PROFORMA_STATUS } from "../../../types"; +import type { PROFORMA_STATUS } from "../../../shared"; interface StatusNodeProps { status: PROFORMA_STATUS; diff --git a/modules/customer-invoices/src/web/proformas/types/index.ts b/modules/customer-invoices/src/web/proformas/types/index.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/customer-invoices/src/web/proformas/types/proforma-summary.web.schema.ts b/modules/customer-invoices/src/web/proformas/types/proforma-summary.web.schema.ts deleted file mode 100644 index ef1ff213..00000000 --- a/modules/customer-invoices/src/web/proformas/types/proforma-summary.web.schema.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ProformaSummary, ProformaSummaryPage } from "./proforma.api.schema"; - -export type ProformaSummaryData = ProformaSummary & { - subtotal_amount_fmt: string; - subtotal_amount: number; - - discount_percentage_fmt: string; - discount_percentage: number; - - discount_amount_fmt: string; - discount_amount: number; - - taxable_amount_fmt: string; - taxable_amount: number; - - taxes_amount_fmt: string; - taxes_amount: number; - - total_amount_fmt: string; - total_amount: number; -}; - -export type ProformaSummaryPageData = ProformaSummaryPage & { - items: ProformaSummaryData[]; -}; diff --git a/modules/factuges/src/common/dto/request/create-proforma-from-factuges.request.dto.ts b/modules/factuges/src/common/dto/request/create-proforma-from-factuges.request.dto.ts index 8dd9d75c..032b6bc7 100644 --- a/modules/factuges/src/common/dto/request/create-proforma-from-factuges.request.dto.ts +++ b/modules/factuges/src/common/dto/request/create-proforma-from-factuges.request.dto.ts @@ -28,7 +28,7 @@ export const CreateProformaFromFactugesRequestSchema = z.object({ //id: z.uuid(), - series: z.string().default(""), + series: z.string(), //invoice_number: z.string(), reference: z.string().default(""), @@ -63,11 +63,11 @@ export const CreateProformaFromFactugesRequestSchema = z.object({ website: z.string(), }), - global_discount_percentage_value: NumericStringSchema.default(""), + global_discount_percentage_value: NumericStringSchema, payment_method: z.string().default(""), - items: z.array(CreateProformaItemFromFactugesRequestSchema).default([]), + items: z.array(CreateProformaItemFromFactugesRequestSchema), }); export type CreateProformaFromFactugesRequestDTO = z.infer< typeof CreateProformaFromFactugesRequestSchema diff --git a/packages/rdx-ddd/src/helpers/normalizers.ts b/packages/rdx-ddd/src/helpers/normalizers.ts index d091a874..11ae68fe 100644 --- a/packages/rdx-ddd/src/helpers/normalizers.ts +++ b/packages/rdx-ddd/src/helpers/normalizers.ts @@ -7,10 +7,13 @@ import { MoneyValue, Percentage, Quantity } from "../value-objects"; /** any | null | undefined -> Maybe usando validación */ export function maybeFromNullableResult( input: S, - validate: (raw: S) => Result + validate: (raw: NonNullable) => Result ): Result> { - if (isNullishOrEmpty(input)) return Result.ok(Maybe.none()); - const value = validate(input); + if (isNullishOrEmpty(input)) { + return Result.ok(Maybe.none()); + } + + const value = validate(input as NonNullable); return value.isSuccess ? Result.ok(Maybe.some(value.data)) : Result.fail(value.error); }