58a7c359d8
- Created SendBulkSaleInvoicesDto for handling bulk sale invoice requests. - Implemented TaxSwitchSendPayloadDto and related DTOs for tax switch item payloads and results. - Developed SalesInvoiceTaxSwitchService to manage tax switch operations, including sending and retrieving tax information. - Added SalesInvoiceTaxService for handling sales invoice tax logic, including bulk sending and persistence of results. - Introduced NamaTaxSwitchAdapter to interact with the tax switch service, simulating external API responses. - Created SendBulkSalesInvoicesDto for POS module to handle bulk sales invoice requests.
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
|
import {
|
|
ArrayMinSize,
|
|
IsBoolean,
|
|
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 {
|
|
// @TODO: totalAmount must calculated instead of get from api
|
|
@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: false, default: false })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
send_to_tax?: boolean
|
|
|
|
@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?: {
|
|
customer_individual?: Omit<CustomerIndividual, 'business_activity_id' | 'customer_id'>
|
|
customer_legal?: Omit<CustomerLegal, 'business_activity_id' | 'customer_id'>
|
|
customer_unknown?: {
|
|
first_name: string
|
|
last_name: string
|
|
}
|
|
}
|
|
}
|
|
|
|
export class UpdateSalesInvoiceDto extends PartialType(CreateSalesInvoiceDto) {}
|