Files
psp_api/src/modules/sales-invoices/dto/create-sales-invoice.dto.ts
T
ahasani b949500482 feat(customers): add DTOs for individual and legal customer creation
- Created CreateCustomerIndividualDto for individual customer data with fields: first_name, last_name, national_code, postal_code, is_favorite, and economic_code.
- Created CreateCustomerLegalDto for legal customer data with fields: company_name, economic_code, registration_number, and postal_code.
2026-02-24 12:42:10 +03:30

63 lines
1.5 KiB
TypeScript

import { ApiProperty, PartialType } from '@nestjs/swagger'
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'
import { CreateSalesInvoiceItemDto } from '../../sales-invoice-items/dto/create-sales-invoice-item.dto'
export class CreateSalesInvoiceDto {
@IsNumber()
@ApiProperty({ required: true, default: 0 })
total_amount: number
@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
@IsOptional()
@IsString()
@ApiProperty({ required: false })
customer_id?: string
@ApiProperty({ required: false })
@IsOptional()
@IsObject()
customer?:
| {
first_name: string
last_name: string
}
| CustomerIndividual
| CustomerLegal
}
export class UpdateSalesInvoiceDto extends PartialType(CreateSalesInvoiceDto) {}