attachment
This commit is contained in:
@@ -11,7 +11,6 @@ import {
|
|||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import { Type } from 'class-transformer';
|
import { Type } from 'class-transformer';
|
||||||
import { IAttachment } from 'src/modules/order/interface/order.interface';
|
|
||||||
|
|
||||||
export class CreateInvoiceItemDto {
|
export class CreateInvoiceItemDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
@@ -40,6 +39,16 @@ export class CreateInvoiceItemDto {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class IAttachmentDto {
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty({ description: 'Attachment type' })
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty({ description: 'Attachment URL' })
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class CreateInvoiceDto {
|
export class CreateInvoiceDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@@ -78,8 +87,8 @@ export class CreateInvoiceDto {
|
|||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
// @IsArray()
|
@IsArray()
|
||||||
// @Type(() => IAttachment)
|
@Type(() => IAttachmentDto)
|
||||||
// @ApiProperty({ type: [IAttachment] })
|
@ApiProperty({ type: [IAttachmentDto] })
|
||||||
// attachments: IAttachment[];
|
attachments: IAttachmentDto[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export class InvoiceService {
|
|||||||
const total = Math.max(0, subTotal - discount + taxAmount);
|
const total = Math.max(0, subTotal - discount + taxAmount);
|
||||||
|
|
||||||
invoice.subTotal = subTotal;
|
invoice.subTotal = subTotal;
|
||||||
|
invoice.attachments = dto.attachments;
|
||||||
invoice.taxAmount = taxAmount;
|
invoice.taxAmount = taxAmount;
|
||||||
invoice.total = total;
|
invoice.total = total;
|
||||||
invoice.balance = total - invoice.paidAmount;
|
invoice.balance = total - invoice.paidAmount;
|
||||||
@@ -185,7 +186,7 @@ export class InvoiceService {
|
|||||||
}
|
}
|
||||||
if(dto.paymentMethod !== undefined) invoice.paymentMethod = dto.paymentMethod;
|
if(dto.paymentMethod !== undefined) invoice.paymentMethod = dto.paymentMethod;
|
||||||
if(dto.description !== undefined) invoice.description = dto.description;
|
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) {
|
if (dto.items !== undefined) {
|
||||||
// Items in dto.items represent the full list: delete any existing items not in the list
|
// Items in dto.items represent the full list: delete any existing items not in the list
|
||||||
|
|||||||
Reference in New Issue
Block a user