Error al duplicar las proformas
This commit is contained in:
parent
e0ba5ef229
commit
38eaa10cb4
@ -47,9 +47,11 @@ export const AuditPage = () => {
|
||||
<RdxPageContainer width="full">
|
||||
<RdxPageStack spacing="default">
|
||||
<RdxPageHeader description={t("audit.description")} title={t("audit.title")} />
|
||||
|
||||
{controller.isError && controller.hasUsableData ? (
|
||||
<ErrorAlert message={t("audit.error.refresh")} title={t("audit.error.load")} />
|
||||
) : null}
|
||||
|
||||
<div className="flex flex-col gap-4 lg:flex-row">
|
||||
<AuditFiltersPanel filters={controller.filters} onChange={controller.setFilters} />
|
||||
<div className="min-w-0 flex-1 space-y-4">
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { PaymentTermPublicModelMapper } from "./payment-term-public-model.mapper";
|
||||
|
||||
test("serializa los porcentajes de las reglas de vencimiento como DTO", () => {
|
||||
const mapper = new PaymentTermPublicModelMapper();
|
||||
|
||||
const result = mapper.toPublicModel({
|
||||
id: { toString: () => "payment-term-id" },
|
||||
companyId: { toString: () => "company-id" },
|
||||
name: { toPrimitive: () => "Al contado" },
|
||||
description: { map: () => null },
|
||||
isActive: true,
|
||||
dueRules: {
|
||||
getAll: () => [
|
||||
{
|
||||
dueDays: { toPrimitive: () => 0 },
|
||||
percentage: {
|
||||
toPrimitive: () => ({ value: 10000, scale: 2 }),
|
||||
toObjectString: () => ({ value: "10000", scale: "2" }),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
} as never);
|
||||
|
||||
assert.deepEqual(result.dueRules[0]?.percentage, {
|
||||
value: "10000",
|
||||
scale: "2",
|
||||
});
|
||||
});
|
||||
@ -11,7 +11,7 @@ export class PaymentTermPublicModelMapper {
|
||||
isActive: paymentTerm.isActive,
|
||||
dueRules: paymentTerm.dueRules.getAll().map((rule) => ({
|
||||
dueDays: String(rule.dueDays.toPrimitive()),
|
||||
percentage: rule.percentage.toPrimitive(),
|
||||
percentage: rule.percentage.toObjectString(),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import type { PercentageDTO } from "@erp/core";
|
||||
import type { UniqueID } from "@repo/rdx-ddd";
|
||||
import type { Maybe } from "@repo/rdx-utils";
|
||||
|
||||
@ -11,9 +12,6 @@ export interface PaymentTermPublicModel {
|
||||
isActive: boolean;
|
||||
dueRules: Array<{
|
||||
dueDays: string;
|
||||
percentage: {
|
||||
value: string;
|
||||
scale: number;
|
||||
};
|
||||
percentage: PercentageDTO;
|
||||
}>;
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import type { PercentageDTO } from "@erp/core";
|
||||
|
||||
/**
|
||||
* Datos del plazo de pago que completan a la proforma.
|
||||
*/
|
||||
@ -8,9 +10,6 @@ export interface InvoicePaymentTermReadModel {
|
||||
isActive: boolean;
|
||||
dueRules: Array<{
|
||||
dueDays: string;
|
||||
percentage: {
|
||||
value: string;
|
||||
scale: number;
|
||||
};
|
||||
percentage: PercentageDTO;
|
||||
}>;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ test("detail devuelve payment_term enriquecido cuando existe", () => {
|
||||
dueRules: [
|
||||
{
|
||||
dueDays: "0",
|
||||
percentage: { value: "5000", scale: 2 },
|
||||
percentage: { value: "5000", scale: "2" },
|
||||
},
|
||||
],
|
||||
}),
|
||||
@ -87,4 +87,8 @@ test("detail devuelve payment_term enriquecido cuando existe", () => {
|
||||
assert.equal(snapshot.payment_term?.name, "50/50");
|
||||
assert.equal(snapshot.payment_term?.is_active, false);
|
||||
assert.equal(snapshot.payment_term?.due_rules.length, 1);
|
||||
assert.deepEqual(snapshot.payment_term?.due_rules[0]?.percentage, {
|
||||
value: "5000",
|
||||
scale: "2",
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user