Error al guardar cotizaciones con bloques
This commit is contained in:
parent
e70706389a
commit
0a67c6a0e9
@ -225,6 +225,7 @@ export const QuoteDetailsCardEditor = ({
|
||||
const handleAppendBlock = useCallback(
|
||||
(block: any) => {
|
||||
fieldActions.append({
|
||||
id_article: "",
|
||||
description: `${block.title}\n${block.body}`,
|
||||
quantity: {
|
||||
amount: null,
|
||||
|
||||
@ -6,6 +6,15 @@ describe("ArticleIdentifier", () => {
|
||||
expect(ArticleIdentifier.create(Number.MAX_SAFE_INTEGER).isSuccess).toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes missing identifiers to null for free quote lines", () => {
|
||||
for (const value of ["", undefined]) {
|
||||
const result = ArticleIdentifier.create(value);
|
||||
|
||||
expect(result.isSuccess).toBe(true);
|
||||
expect(result.object?.isNull()).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects zero, decimals, non-numeric, negative and unsafe identifiers", () => {
|
||||
expect(ArticleIdentifier.create(0).isFailure).toBe(true);
|
||||
expect(ArticleIdentifier.create(1.5).isFailure).toBe(true);
|
||||
|
||||
@ -16,7 +16,7 @@ export class ArticleIdentifier extends NullableValueObject<number> {
|
||||
) {
|
||||
const ruleNull = RuleValidator.RULE_ALLOW_NULL_OR_UNDEFINED.default(null);
|
||||
|
||||
const ruleEmpty = RuleValidator.RULE_ALLOW_EMPTY.default(null);
|
||||
const ruleEmpty = RuleValidator.RULE_ALLOW_EMPTY.empty("").default(null);
|
||||
|
||||
const ruleNumber = RuleValidator.RULE_IS_TYPE_NUMBER.label(
|
||||
options.label ? options.label : "ArticleIdentifier"
|
||||
@ -35,7 +35,7 @@ export class ArticleIdentifier extends NullableValueObject<number> {
|
||||
return value ? Number(value) : null;
|
||||
}
|
||||
|
||||
public static create(value: NullOr<number | string>, options: IArticleIdentifierOptions = {}) {
|
||||
public static create(value: NullOr<number | string> = null, options: IArticleIdentifierOptions = {}) {
|
||||
const _options = {
|
||||
label: "ArticleIdentifier",
|
||||
...options,
|
||||
@ -52,7 +52,7 @@ export class ArticleIdentifier extends NullableValueObject<number> {
|
||||
if (typeof validationResult.object === "string") {
|
||||
_value = parseInt(validationResult.object, 10);
|
||||
} else {
|
||||
_value = validationResult.object;
|
||||
_value = validationResult.object ?? null;
|
||||
}
|
||||
|
||||
if (_value !== null && (!Number.isSafeInteger(_value) || _value <= 0)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user