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'; } 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()
@@ -65,4 +66,14 @@ export class CreateInvoiceDto {
@IsDateString() @IsDateString()
@ApiPropertyOptional({ description: 'Approval deadline (ISO date string)' }) @ApiPropertyOptional({ description: 'Approval deadline (ISO date string)' })
approvalDeadline?: 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({ @Property({
type: 'int', type: 'int',
columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED', // columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED',
persist: false, // persist: false,
nullable: true nullable: true
}) })
subTotal!: number; subTotal!: number;
@@ -42,17 +42,14 @@ export class InvoiceItem extends BaseEntity {
@Property({ @Property({
type: 'int', type: 'int',
nullable: true, nullable: true,
columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED', // columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED',
persist: false // persist: false
}) })
total!: number; total!: number;
@Property({ type: 'text', nullable: true }) @Property({ type: 'text', nullable: true })
description?: string; description?: string;
@Property({ type: 'string', nullable: true })
paymentMethod?: string;
@Property({ nullable: true, columnType: 'timestamptz' }) @Property({ nullable: true, columnType: 'timestamptz' })
confirmedAt?: Date; confirmedAt?: Date;
@@ -92,4 +92,8 @@ export class Invoice extends BaseEntity {
@Property({ type: 'json' }) @Property({ type: 'json' })
attachments: IAttachment[] = [] attachments: IAttachment[] = []
@Property({ type: 'string', nullable: true })
paymentMethod?: string;
} }
+2
View File
@@ -58,6 +58,8 @@ export class InvoiceService {
discount, discount,
paidAmount: 0, paidAmount: 0,
balance: 0, balance: 0,
attachments: [],
paymentMethod: dto.paymentMethod
}); });
em.persist(invoice); em.persist(invoice);
@@ -3,8 +3,10 @@ import {
IsInt, IsInt,
IsNotEmpty, IsNotEmpty,
IsOptional, IsOptional,
IsArray,
} from 'class-validator'; } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IAttachment } from '../interface/order.interface';
export class CreateOrderAsAdminDto { export class CreateOrderAsAdminDto {
@@ -36,6 +38,11 @@ export class CreateOrderAsAdminDto {
@IsOptional() @IsOptional()
@IsString() @IsString()
title?: string; title?: string;
@ApiProperty()
@IsOptional()
@IsArray()
attachments: IAttachment[];
} }
export class CreateOrderItemDtoAsAdmin { export class CreateOrderItemDtoAsAdmin {
+2 -1
View File
@@ -100,7 +100,8 @@ export class OrderService {
title: dto.title, title: dto.title,
status: OrderStatusEnum.CREATED, status: OrderStatusEnum.CREATED,
estimatedDays: dto.estimatedDays, estimatedDays: dto.estimatedDays,
invoiceItem invoiceItem,
attachments: dto.attachments
}); });
await this.em.persistAndFlush(order); await this.em.persistAndFlush(order);