order
This commit is contained in:
@@ -31,6 +31,7 @@ import { OrderItem } from '../entities/order-item.entity';
|
||||
import { UpdateOrderAsAdminDto } from '../dto/update-order.dto';
|
||||
import { CreatePrintFormDto } from '../dto/create-print-form.dto';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { FindOrderItemsDto } from '../dto/find-order-items.dto';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@@ -285,11 +286,21 @@ export class OrderService {
|
||||
return orders
|
||||
}
|
||||
|
||||
async findOrdersAsAdmin(dto: FindOrdersDto) {
|
||||
const orders = await this.orderRepository.findAllPaginated(dto)
|
||||
async findOrderRequestsAsAdmin(dto: FindOrdersDto) {
|
||||
const orders = await this.orderRepository.findAllPaginated({ ...dto, isInvoiced: false })
|
||||
return orders
|
||||
}
|
||||
|
||||
async findInvoicedOrdersAsAdmin(dto: FindOrdersDto) {
|
||||
const orders = await this.orderRepository.findAllPaginated({ ...dto, isInvoiced: true, })
|
||||
return orders
|
||||
}
|
||||
|
||||
async findPrintOrderItemsAsAdmin(dto: FindOrderItemsDto) {
|
||||
const orderItems = await this.orderItemRepository.findAllPaginated({ ...dto, isPrintFormAdded: true, })
|
||||
return orderItems
|
||||
}
|
||||
|
||||
async findPrints(dto: FindOrdersDto) {
|
||||
const orders = await this.orderRepository.findAllPaginated({ ...dto, statuses: [] })
|
||||
return orders
|
||||
@@ -524,6 +535,10 @@ export class OrderService {
|
||||
|
||||
if (status != undefined) {
|
||||
order.status = status
|
||||
|
||||
if (status === OrderStatusEnum.INVOICED && !order.invoicedAt) {
|
||||
order.invoicedAt = new Date()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user