diff --git a/src/modules/invoice/dto/create-invoice.dto.ts b/src/modules/invoice/dto/create-invoice.dto.ts index b80934f..f3bbf9c 100644 --- a/src/modules/invoice/dto/create-invoice.dto.ts +++ b/src/modules/invoice/dto/create-invoice.dto.ts @@ -11,7 +11,6 @@ import { } from 'class-validator'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; -import { IAttachment } from 'src/modules/order/interface/order.interface'; export class CreateInvoiceItemDto { @IsString() @@ -40,6 +39,16 @@ export class CreateInvoiceItemDto { description?: string; } +export class IAttachmentDto { + @IsString() + @ApiProperty({ description: 'Attachment type' }) + type: string; + + @IsString() + @ApiProperty({ description: 'Attachment URL' }) + url: string; +} + export class CreateInvoiceDto { @IsOptional() @IsString() @@ -78,8 +87,8 @@ export class CreateInvoiceDto { @ApiPropertyOptional() description?: string; - // @IsArray() - // @Type(() => IAttachment) - // @ApiProperty({ type: [IAttachment] }) - // attachments: IAttachment[]; + @IsArray() + @Type(() => IAttachmentDto) + @ApiProperty({ type: [IAttachmentDto] }) + attachments: IAttachmentDto[]; } diff --git a/src/modules/invoice/invoice.service.ts b/src/modules/invoice/invoice.service.ts index c1e19b1..305be23 100644 --- a/src/modules/invoice/invoice.service.ts +++ b/src/modules/invoice/invoice.service.ts @@ -95,6 +95,7 @@ export class InvoiceService { const total = Math.max(0, subTotal - discount + taxAmount); invoice.subTotal = subTotal; + invoice.attachments = dto.attachments; invoice.taxAmount = taxAmount; invoice.total = total; invoice.balance = total - invoice.paidAmount; @@ -185,7 +186,7 @@ export class InvoiceService { } if(dto.paymentMethod !== undefined) invoice.paymentMethod = dto.paymentMethod; if(dto.description !== undefined) invoice.description = dto.description; - // if(updateInvoiceDto.attachments !== undefined) invoice.attachments = updateInvoiceDto.attachments; + if(dto.attachments !== undefined) invoice.attachments = dto.attachments; if (dto.items !== undefined) { // Items in dto.items represent the full list: delete any existing items not in the list