attachment

This commit is contained in:
2026-02-25 09:22:18 +03:30
parent 65bd50cff7
commit e6dbe216c1
2 changed files with 16 additions and 6 deletions
+14 -5
View File
@@ -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[];
}
+2 -1
View File
@@ -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