2026-02-12 20:31:04 +03:30
|
|
|
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
2026-02-24 12:42:10 +03:30
|
|
|
import {
|
|
|
|
|
ArrayMinSize,
|
|
|
|
|
IsDateString,
|
|
|
|
|
IsEnum,
|
|
|
|
|
IsNumber,
|
|
|
|
|
IsObject,
|
|
|
|
|
IsOptional,
|
|
|
|
|
IsString,
|
|
|
|
|
} from 'class-validator'
|
|
|
|
|
import type { CustomerIndividual, CustomerLegal } from '../../../generated/prisma/client'
|
|
|
|
|
import { CustomerType } from '../../../generated/prisma/enums'
|
2026-02-16 20:51:34 +03:30
|
|
|
import { CreateSalesInvoiceItemDto } from '../../sales-invoice-items/dto/create-sales-invoice-item.dto'
|
2025-12-09 13:59:07 +03:30
|
|
|
|
|
|
|
|
export class CreateSalesInvoiceDto {
|
|
|
|
|
@IsNumber()
|
2026-02-16 20:51:34 +03:30
|
|
|
@ApiProperty({ required: true, default: 0 })
|
2026-02-12 20:31:04 +03:30
|
|
|
total_amount: number
|
2025-12-09 13:59:07 +03:30
|
|
|
|
2026-02-24 12:42:10 +03:30
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsDateString({ strict: true }, { message: 'invoice_date must be a valid ISO-8601 string' })
|
|
|
|
|
invoice_date: Date
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsObject()
|
|
|
|
|
payments: {
|
|
|
|
|
terminal: number
|
|
|
|
|
cash: number
|
|
|
|
|
set_off: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@ArrayMinSize(1)
|
|
|
|
|
items: CreateSalesInvoiceItemDto[]
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
notes?: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, default: CustomerType.UNKNOWN })
|
|
|
|
|
@IsEnum(CustomerType)
|
|
|
|
|
customer_type: CustomerType
|
|
|
|
|
|
2025-12-09 13:59:07 +03:30
|
|
|
@IsOptional()
|
2026-02-12 20:31:04 +03:30
|
|
|
@IsString()
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
customer_id?: string
|
2026-02-16 20:51:34 +03:30
|
|
|
|
2026-02-24 12:42:10 +03:30
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
customer?:
|
|
|
|
|
| {
|
|
|
|
|
first_name: string
|
|
|
|
|
last_name: string
|
|
|
|
|
}
|
|
|
|
|
| CustomerIndividual
|
|
|
|
|
| CustomerLegal
|
2025-12-09 13:59:07 +03:30
|
|
|
}
|
2026-02-12 20:31:04 +03:30
|
|
|
|
|
|
|
|
export class UpdateSalesInvoiceDto extends PartialType(CreateSalesInvoiceDto) {}
|