update entity
This commit is contained in:
@@ -2,7 +2,7 @@ import { Entity, Enum, Index, ManyToOne, OneToMany, PrimaryKey, Property } from
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Order } from './order.entity';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { OrderItemStatus } from '../interface/order.interface';
|
||||
// import { OrderItemStatus } from '../interface/order.interface';
|
||||
|
||||
@Entity({ tableName: 'order_items' })
|
||||
@Index({ properties: ['order'] })
|
||||
@@ -38,6 +38,8 @@ export class OrderItem extends BaseEntity {
|
||||
@Property({ nullable: true })
|
||||
description?: string;
|
||||
|
||||
@Enum(() => OrderItemStatus)
|
||||
status!: OrderItemStatus;
|
||||
// @Enum(() => OrderItemStatus)
|
||||
// status!: OrderItemStatus;
|
||||
@Property({ nullable: true, columnType: 'timestamptz' })
|
||||
confirmedAt?: Date;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ export class Order extends BaseEntity {
|
||||
@PrimaryKey({ type: 'string', columnType: 'char(26)' })
|
||||
id: string = ulid()
|
||||
|
||||
//TODO : need a new field for confirmation .confirmedAt
|
||||
// also need another for
|
||||
|
||||
@ManyToOne(() => User)
|
||||
user!: User;
|
||||
|
||||
@@ -80,7 +83,7 @@ export class Order extends BaseEntity {
|
||||
balance!: number;
|
||||
|
||||
@Property({ type: 'decimal', precision: 10, scale: 0, nullable: true })
|
||||
dueDate?: number;
|
||||
dueDate?: number; // number of days to be done
|
||||
// get balance(): number {
|
||||
// return this._balance
|
||||
// }
|
||||
@@ -94,14 +97,14 @@ export class Order extends BaseEntity {
|
||||
@Enum(() => OrderStatusEnum)
|
||||
status!: OrderStatusEnum;
|
||||
|
||||
@Property({ nullable: true, columnType: 'timestamptz' })
|
||||
confirmedAt?: Date;
|
||||
// @Property({ nullable: true, columnType: 'timestamptz' })
|
||||
// confirmedAt?: Date;
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
attachments?: string[]
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
printIds?: string[]
|
||||
printIds?: string[] // id of field options
|
||||
|
||||
@Property({ type: 'string', nullable: true })
|
||||
paymentMethod?: string;
|
||||
|
||||
@@ -13,7 +13,7 @@ export enum OrderStatusEnum {
|
||||
}
|
||||
|
||||
|
||||
export enum OrderItemStatus {
|
||||
PENDING = 'pending',
|
||||
CONFIRMED = 'confirmed',
|
||||
}
|
||||
// export enum OrderItemStatus {
|
||||
// PENDING = 'pending',
|
||||
// CONFIRMED = 'confirmed',
|
||||
// }
|
||||
|
||||
@@ -6,7 +6,7 @@ import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { CreateOrderDto } from '../dto/create-order.dto';
|
||||
import { UserService } from 'src/modules/user/providers/user.service';
|
||||
import { OrderItemStatus, OrderStatusEnum } from '../interface/order.interface';
|
||||
import { OrderStatusEnum } from '../interface/order.interface';
|
||||
import { OrderItemRepository } from '../repositories/order-item.repository';
|
||||
import { ProductService } from 'src/modules/product/providers/product.service';
|
||||
import { ProductRepository } from 'src/modules/product/repositories/product.repository';
|
||||
@@ -15,8 +15,7 @@ import { TicketRepository } from 'src/modules/ticket/repositories/tickets.reposi
|
||||
import { CreateInvoiceDto } from '../dto/create-invoice.dto';
|
||||
import { AdminRepository } from 'src/modules/admin/repositories/admin.repository';
|
||||
import { CreateOrderAsAdminDto } from '../dto/create-order-as-admin.dto';
|
||||
import { AddOrderItemDto } from '../dto/add-order-item.dto';
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class OrderService {
|
||||
@@ -76,7 +75,6 @@ export class OrderService {
|
||||
attributesValues: item.attributesValues,
|
||||
product,
|
||||
quantity: item.quantity,
|
||||
status: OrderItemStatus.PENDING,
|
||||
unitPrice: 0,
|
||||
total: 0,
|
||||
subTotal: 0,
|
||||
@@ -157,7 +155,6 @@ export class OrderService {
|
||||
attributesValues: item.attributesValues,
|
||||
product,
|
||||
quantity: item.quantity,
|
||||
status: OrderItemStatus.CONFIRMED,
|
||||
unitPrice: item.unitPrice,
|
||||
total: item.unitPrice * item.quantity,
|
||||
discount: 0,
|
||||
@@ -251,7 +248,7 @@ export class OrderService {
|
||||
total: (item.unitPrice - item.discount) * item.quantity,
|
||||
subTotal: item.unitPrice * item.quantity,
|
||||
quantity: item.quantity,
|
||||
status: OrderItemStatus.CONFIRMED,
|
||||
confirmedAt: new Date(),
|
||||
attributesValues: item.attributesValues,
|
||||
order
|
||||
})
|
||||
@@ -305,7 +302,7 @@ export class OrderService {
|
||||
throw new BadRequestException("Order Item does not belong to you")
|
||||
}
|
||||
|
||||
orderItem.status = OrderItemStatus.CONFIRMED
|
||||
orderItem.confirmedAt = new Date()
|
||||
|
||||
await this.em.persistAndFlush(OrderItem)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IsString, IsOptional, IsBoolean, IsInt, Min, IsEnum, IsNotEmpty } from 'class-validator';
|
||||
import { ApiPropertyOptional, ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { AttributeType } from '../interface/product.interface';
|
||||
import { FieldType } from 'src/modules/print/interface/print';
|
||||
|
||||
export class CreateAttributeDto {
|
||||
@IsString()
|
||||
@@ -20,9 +20,9 @@ export class CreateAttributeDto {
|
||||
isRequired: boolean;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsEnum(AttributeType)
|
||||
@ApiProperty({ enum: AttributeType, example: AttributeType.SELECT })
|
||||
type: AttributeType;
|
||||
@IsEnum(FieldType)
|
||||
@ApiProperty({ enum: FieldType, example: FieldType.select })
|
||||
type: FieldType;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { AttributeType } from '../interface/product.interface';
|
||||
import { Product } from './product.entity';
|
||||
import { Product } from './product.entity';
|
||||
import { AttributeValue } from './attribute-value.entity';
|
||||
import { FieldType } from 'src/modules/print/interface/print';
|
||||
|
||||
@Entity({ tableName: 'attributes' })
|
||||
export class Attribute extends BaseEntity {
|
||||
@@ -24,8 +24,8 @@ export class Attribute extends BaseEntity {
|
||||
@Property()
|
||||
name: string;
|
||||
|
||||
@Enum(() => AttributeType)
|
||||
type: AttributeType;
|
||||
@Enum(() => FieldType)
|
||||
type: FieldType;
|
||||
|
||||
@Property({ type: 'boolean', default: false })
|
||||
isRequired: boolean = false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export enum AttributeType{
|
||||
SELECT='select',
|
||||
TEXT='text',
|
||||
NUMBER='number',
|
||||
CHECKBOX='checkbox',
|
||||
BOOLEAN='boolean',
|
||||
}
|
||||
// export enum AttributeType{
|
||||
// SELECT='select',
|
||||
// TEXT='text',
|
||||
// NUMBER='number',
|
||||
// CHECKBOX='checkbox',
|
||||
// BOOLEAN='boolean',
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user