up
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ export class InvoiceService {
|
|||||||
if (!item) {
|
if (!item) {
|
||||||
throw new NotFoundException('Invoice item not found');
|
throw new NotFoundException('Invoice item not found');
|
||||||
}
|
}
|
||||||
if(item.confirmedAt){
|
if (item.confirmedAt) {
|
||||||
throw new BadRequestException('Invoice item already confirmed');
|
throw new BadRequestException('Invoice item already confirmed');
|
||||||
}
|
}
|
||||||
item.confirmedAt = new Date();
|
item.confirmedAt = new Date();
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user