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
16 changes: 16 additions & 0 deletions src/order/dto/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ResponseOrderProductPresentationDetailDTO } from 'src/products/dto/prod
import { ResponseBranchDTO } from 'src/branch/dto/branch.dto';
import { OrderDeliveryEmployeeDTO } from './order-delivery.dto';
import { PaymentMethod } from 'src/payments/entities/payment-information.entity';
import { ResponsePaymentConfirmationDTO } from 'src/payments/dto/payment-confirmation.dto';

export class CreateOrderDetailDTO {
@ApiProperty({ description: 'ID of the product presentation' })
Expand Down Expand Up @@ -115,9 +116,24 @@ export class ResponseOrderDetailDTO {
@IsPositive()
quantity: number;

@Expose()
@ApiProperty({ description: 'Product price' })
@IsInt()
@IsPositive()
price: number;

@Expose()
@ApiProperty({ description: 'Subtotal price of the order detail' })
subtotal: number;

@Expose()
@ApiProperty({
description: 'Payment confirmation data (if any)',
type: ResponsePaymentConfirmationDTO,
required: false,
})
@Type(() => ResponsePaymentConfirmationDTO)
paymentConfirmation?: ResponsePaymentConfirmationDTO;
}

export class ResponseOrderDTO extends BaseDTO {
Expand Down
8 changes: 8 additions & 0 deletions src/order/entities/order.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ export class OrderDetail extends UUIDModel {
(orderDeliveryDetail) => orderDeliveryDetail.orderDetail,
)
orderDetailDeliveries: OrderDetailDelivery[];

@ManyToOne(() => PaymentConfirmation, {
nullable: true,
eager: true,
onDelete: 'SET NULL',
})
@JoinColumn({ name: 'payment_confirmation_id' })
paymentConfirmation: PaymentConfirmation;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddPaymentConfirmationInOrderDetailMigration1747426506331
implements MigrationInterface
{
name = 'AddPaymentConfirmationInOrderDetailMigration1747426506331';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "order_detail" ADD "payment_confirmation_id" uuid`,
);
await queryRunner.query(
`ALTER TABLE "order_detail" ADD CONSTRAINT "FK_2cb24b410baacf4bd387b22757e" FOREIGN KEY ("payment_confirmation_id") REFERENCES "payment_confirmation"("id") ON DELETE SET NULL ON UPDATE NO ACTION`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "order_detail" DROP CONSTRAINT "FK_2cb24b410baacf4bd387b22757e"`,
);
await queryRunner.query(
`ALTER TABLE "order_detail" DROP COLUMN "payment_confirmation_id"`,
);
}
}
Loading