Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/order/domain/aggregate/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OrderId>{

Expand Down Expand Up @@ -208,6 +209,9 @@ export class Order extends AggregateRoot<OrderId>{
}

addOrderReport(orderReport: OrderReport): void {
if (this.orderReport)
throw new OrderAlreadyReportedException();

this.apply(
OrderReported.create(
this.getId(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SaveCardToUserApplicationService extends IApplicationService<SaveCa

const user = userResponse.getValue;

let userAccount = await this.accountRepository.findAccountById(user.getId().Value);
let userAccount = await this.accountRepository.findAccountByUserId(user.getId().Value);

if ( !userAccount.isSuccess() )
return Result.fail(new UserNotFoundApplicationException(data.userId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class GetUserCardsApplicationService extends IApplicationService<UserCard

const user = userResponse.getValue;

let userAccount = await this.accountRepository.findAccountById(user.getId().Value);
let userAccount = await this.accountRepository.findAccountByUserId(user.getId().Value);

if ( !userAccount.isSuccess() )
return Result.fail(new UserNotFoundApplicationException(data.userId));
Expand Down
Loading