fallitos
This commit is contained in:
parent
35e261e80d
commit
ae6afd2c28
@ -33,12 +33,12 @@ export function mapDTOToCustomerInvoiceProps(dto: CreateCustomerInvoiceRequestDT
|
||||
const invoiceId = extractOrPushError(UniqueID.create(dto.id), "id", errors);
|
||||
|
||||
const invoiceNumber = extractOrPushError(
|
||||
CustomerInvoiceNumber.create(dto.invoice_number),
|
||||
maybeFromNullableVO(dto.invoice_number, (value) => CustomerInvoiceNumber.create(value)),
|
||||
"invoice_number",
|
||||
errors
|
||||
);
|
||||
const invoiceSeries = extractOrPushError(
|
||||
maybeFromNullableVO(dto.invoice_series, (value) => CustomerInvoiceSerie.create(value)),
|
||||
maybeFromNullableVO(dto.series, (value) => CustomerInvoiceSerie.create(value)),
|
||||
"invoice_series",
|
||||
errors
|
||||
);
|
||||
|
||||
@ -14,7 +14,7 @@ export class ListCustomerInvoicesPresenter extends Presenter {
|
||||
company_id: invoice.companyId.toString(),
|
||||
customer_id: invoice.customerId.toString(),
|
||||
|
||||
invoice_number: invoice.invoiceNumber.toString(),
|
||||
invoice_number: toEmptyString(invoice.invoiceNumber, (value) => value.toString()),
|
||||
status: invoice.status.toPrimitive(),
|
||||
series: toEmptyString(invoice.series, (value) => value.toString()),
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ export interface CustomerInvoiceProps {
|
||||
recipient: Maybe<InvoiceRecipient>;
|
||||
|
||||
reference: Maybe<string>;
|
||||
description: Maybe<string>;
|
||||
notes: Maybe<TextValue>;
|
||||
|
||||
languageCode: LanguageCode;
|
||||
@ -144,6 +145,10 @@ export class CustomerInvoice
|
||||
return this.props.reference;
|
||||
}
|
||||
|
||||
public get description(): Maybe<string> {
|
||||
return this.props.description;
|
||||
}
|
||||
|
||||
public get notes(): Maybe<TextValue> {
|
||||
return this.props.notes;
|
||||
}
|
||||
|
||||
@ -149,6 +149,12 @@ export class CustomerInvoiceDomainMapper
|
||||
errors
|
||||
);
|
||||
|
||||
const description = extractOrPushError(
|
||||
maybeFromNullableVO(source.description, (value) => Result.ok(String(value))),
|
||||
"description",
|
||||
errors
|
||||
);
|
||||
|
||||
const notes = extractOrPushError(
|
||||
maybeFromNullableVO(source.notes, (value) => TextValue.create(value)),
|
||||
"notes",
|
||||
@ -187,6 +193,7 @@ export class CustomerInvoiceDomainMapper
|
||||
invoiceDate,
|
||||
operationDate,
|
||||
reference,
|
||||
description,
|
||||
notes,
|
||||
languageCode,
|
||||
currencyCode,
|
||||
@ -267,7 +274,9 @@ export class CustomerInvoiceDomainMapper
|
||||
|
||||
// 5) Si hubo errores de mapeo, devolvemos colección de validación
|
||||
if (errors.length > 0) {
|
||||
return Result.fail(new ValidationErrorCollection("Customer mapping failed", errors));
|
||||
return Result.fail(
|
||||
new ValidationErrorCollection("Customer invoice mapping failed [mapToDomain]", errors)
|
||||
);
|
||||
}
|
||||
|
||||
// 6) Construcción del agregado (Dominio)
|
||||
@ -295,6 +304,7 @@ export class CustomerInvoiceDomainMapper
|
||||
recipient: recipient,
|
||||
|
||||
reference: attributes.reference!,
|
||||
description: attributes.description!,
|
||||
notes: attributes.notes!,
|
||||
|
||||
languageCode: attributes.languageCode!,
|
||||
@ -391,6 +401,7 @@ export class CustomerInvoiceDomainMapper
|
||||
currency_code: source.currencyCode.toPrimitive(),
|
||||
|
||||
reference: toNullable(source.reference, (reference) => reference),
|
||||
description: toNullable(source.description, (description) => description),
|
||||
notes: toNullable(source.notes, (notes) => notes.toPrimitive()),
|
||||
|
||||
subtotal_amount_value: allAmounts.subtotalAmount.value,
|
||||
|
||||
@ -31,13 +31,15 @@ export type CustomerInvoiceListDTO = {
|
||||
companyId: UniqueID;
|
||||
|
||||
isProforma: boolean;
|
||||
invoiceNumber: CustomerInvoiceNumber;
|
||||
invoiceNumber: Maybe<CustomerInvoiceNumber>;
|
||||
status: CustomerInvoiceStatus;
|
||||
series: Maybe<CustomerInvoiceSerie>;
|
||||
|
||||
invoiceDate: UtcDate;
|
||||
operationDate: Maybe<UtcDate>;
|
||||
|
||||
description: Maybe<string>;
|
||||
|
||||
customerId: UniqueID;
|
||||
recipient: InvoiceRecipient;
|
||||
|
||||
@ -97,7 +99,9 @@ export class CustomerInvoiceListMapper
|
||||
|
||||
// 5) Si hubo errores de mapeo, devolvemos colección de validación
|
||||
if (errors.length > 0) {
|
||||
return Result.fail(new ValidationErrorCollection("Customer invoice mapping failed", errors));
|
||||
return Result.fail(
|
||||
new ValidationErrorCollection("Customer invoice mapping failed [mapToDTO]", errors)
|
||||
);
|
||||
}
|
||||
|
||||
return Result.ok({
|
||||
@ -110,6 +114,8 @@ export class CustomerInvoiceListMapper
|
||||
invoiceDate: attributes.invoiceDate!,
|
||||
operationDate: attributes.operationDate!,
|
||||
|
||||
description: attributes.description!,
|
||||
|
||||
customerId: attributes.customerId!,
|
||||
recipient: recipientResult.data,
|
||||
|
||||
@ -148,7 +154,7 @@ export class CustomerInvoiceListMapper
|
||||
);
|
||||
|
||||
const invoiceNumber = extractOrPushError(
|
||||
CustomerInvoiceNumber.create(raw.invoice_number),
|
||||
maybeFromNullableVO(raw.invoice_number, (value) => CustomerInvoiceNumber.create(value)),
|
||||
"invoice_number",
|
||||
errors
|
||||
);
|
||||
@ -165,6 +171,12 @@ export class CustomerInvoiceListMapper
|
||||
errors
|
||||
);
|
||||
|
||||
const description = extractOrPushError(
|
||||
maybeFromNullableVO(raw.description, (value) => value),
|
||||
"description",
|
||||
errors
|
||||
);
|
||||
|
||||
const languageCode = extractOrPushError(
|
||||
LanguageCode.create(raw.language_code),
|
||||
"language_code",
|
||||
@ -241,6 +253,7 @@ export class CustomerInvoiceListMapper
|
||||
invoiceNumber,
|
||||
invoiceDate,
|
||||
operationDate,
|
||||
description,
|
||||
languageCode,
|
||||
currencyCode,
|
||||
discountPercentage,
|
||||
|
||||
@ -209,7 +209,9 @@ export class CustomerListMapper
|
||||
|
||||
// Si hubo errores de mapeo, devolvemos colección de validación
|
||||
if (errors.length > 0) {
|
||||
return Result.fail(new ValidationErrorCollection("Customer invoice mapping failed", errors));
|
||||
return Result.fail(
|
||||
new ValidationErrorCollection("Customer mapping failed [mapToDTO]", errors)
|
||||
);
|
||||
}
|
||||
|
||||
return Result.ok<CustomerListDTO>({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user