create invoice
This commit is contained in:
@@ -7,9 +7,9 @@ import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class InvoiceItemDto {
|
||||
@IsInt()
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
orderItemId: bigint;
|
||||
orderItemId: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
@@ -22,9 +22,8 @@ export class CreateInvoiceDto {
|
||||
@ApiProperty({
|
||||
isArray: true, type: [InvoiceItemDto], example: [
|
||||
{
|
||||
productId: 1,
|
||||
quantity: 100,
|
||||
attributesValues: []
|
||||
orderItemId: 1,
|
||||
unitPrice: 100,
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -28,7 +28,6 @@ import { CreateInvoiceDto } from '../dto/create-invoice.dto';
|
||||
export class OrdersService {
|
||||
private readonly logger = new Logger(OrdersService.name);
|
||||
|
||||
|
||||
constructor(
|
||||
private readonly em: EntityManager,
|
||||
private readonly orderRepository: OrderRepository,
|
||||
@@ -123,10 +122,6 @@ export class OrdersService {
|
||||
|
||||
const targetOrder = await this.findOneOrFail(orderId)
|
||||
|
||||
// set price for order items
|
||||
// calculate order financials
|
||||
// change status
|
||||
|
||||
if (items.length !== targetOrder.items.length) {
|
||||
throw new BadRequestException("One or more order items price is not set")
|
||||
}
|
||||
@@ -136,9 +131,10 @@ export class OrdersService {
|
||||
|
||||
let subTotal = 0
|
||||
// Calculate order item finnicials
|
||||
for (const orderItem of targetOrder.items) {
|
||||
|
||||
const found = items.find(it => it.orderItemId === orderItem.id)
|
||||
for (let orderItem of targetOrder.items) {
|
||||
|
||||
const found = items.find(it => it.orderItemId == Number(orderItem.id))
|
||||
if (!found) {
|
||||
throw new BadRequestException(`order item ${orderItem} not found`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user