diff --git a/src/order/domain/aggregate/order.ts b/src/order/domain/aggregate/order.ts index 119dc185..b266a02d 100644 --- a/src/order/domain/aggregate/order.ts +++ b/src/order/domain/aggregate/order.ts @@ -19,6 +19,7 @@ import { BundleDetail } from "../entities/bundle-detail/bundle-detail-entity"; import { OrderCourierId } from "../value_objects/order-courier-id"; import { OrderCuponId } from "../value_objects/order-cupon-id"; import { OrderReported } from "../domain-events/order-reported"; +import { OrderAlreadyReportedException } from "../exception/order-already-reported.exception"; export class Order extends AggregateRoot{ @@ -208,6 +209,9 @@ export class Order extends AggregateRoot{ } addOrderReport(orderReport: OrderReport): void { + if (this.orderReport) + throw new OrderAlreadyReportedException(); + this.apply( OrderReported.create( this.getId(), diff --git a/src/order/domain/exception/order-already-reported.exception.ts b/src/order/domain/exception/order-already-reported.exception.ts new file mode 100644 index 00000000..18eb32a3 --- /dev/null +++ b/src/order/domain/exception/order-already-reported.exception.ts @@ -0,0 +1,7 @@ +import { DomainException } from "src/common/domain/domain-exception/domain-exception"; + +export class OrderAlreadyReportedException extends DomainException { + constructor() { + super('The order already has already been reported'); + } +} \ No newline at end of file diff --git a/src/user/application/services/command/wallet/save-card-to-user-application.service.ts b/src/user/application/services/command/wallet/save-card-to-user-application.service.ts index c85578c1..65085819 100644 --- a/src/user/application/services/command/wallet/save-card-to-user-application.service.ts +++ b/src/user/application/services/command/wallet/save-card-to-user-application.service.ts @@ -28,7 +28,7 @@ export class SaveCardToUserApplicationService extends IApplicationService