This commit is contained in:
2026-02-21 12:18:29 +03:30
parent f682465d4c
commit 1acae30b75
6 changed files with 31 additions and 9 deletions
@@ -11,6 +11,7 @@ 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()
@@ -65,4 +66,14 @@ export class CreateInvoiceDto {
@IsDateString()
@ApiPropertyOptional({ description: 'Approval deadline (ISO date string)' })
approvalDeadline?: string;
@ApiPropertyOptional()
@IsString()
paymentMethod?: string
// @IsArray()
// @Type(() => IAttachment)
// @ApiProperty({ type: [IAttachment] })
// attachments: IAttachment[];
}
@@ -27,8 +27,8 @@ export class InvoiceItem extends BaseEntity {
@Property({
type: 'int',
columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED',
persist: false,
// columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED',
// persist: false,
nullable: true
})
subTotal!: number;
@@ -42,17 +42,14 @@ export class InvoiceItem extends BaseEntity {
@Property({
type: 'int',
nullable: true,
columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED',
persist: false
// columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED',
// persist: false
})
total!: number;
@Property({ type: 'text', nullable: true })
description?: string;
@Property({ type: 'string', nullable: true })
paymentMethod?: string;
@Property({ nullable: true, columnType: 'timestamptz' })
confirmedAt?: Date;
@@ -92,4 +92,8 @@ export class Invoice extends BaseEntity {
@Property({ type: 'json' })
attachments: IAttachment[] = []
@Property({ type: 'string', nullable: true })
paymentMethod?: string;
}
+3 -1
View File
@@ -58,6 +58,8 @@ export class InvoiceService {
discount,
paidAmount: 0,
balance: 0,
attachments: [],
paymentMethod: dto.paymentMethod
});
em.persist(invoice);
@@ -125,7 +127,7 @@ export class InvoiceService {
if (!item) {
throw new NotFoundException('Invoice item not found');
}
if(item.confirmedAt){
if (item.confirmedAt) {
throw new BadRequestException('Invoice item already confirmed');
}
item.confirmedAt = new Date();
@@ -3,8 +3,10 @@ import {
IsInt,
IsNotEmpty,
IsOptional,
IsArray,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IAttachment } from '../interface/order.interface';
export class CreateOrderAsAdminDto {
@@ -36,6 +38,11 @@ export class CreateOrderAsAdminDto {
@IsOptional()
@IsString()
title?: string;
@ApiProperty()
@IsOptional()
@IsArray()
attachments: IAttachment[];
}
export class CreateOrderItemDtoAsAdmin {
+2 -1
View File
@@ -100,7 +100,8 @@ export class OrderService {
title: dto.title,
status: OrderStatusEnum.CREATED,
estimatedDays: dto.estimatedDays,
invoiceItem
invoiceItem,
attachments: dto.attachments
});
await this.em.persistAndFlush(order);