parent
7da8f22cb2
commit
98139f75bf
5 changed files with 62 additions and 139 deletions
@ -1,71 +1,33 @@ |
||||
import { Table, Column, ForeignKey, BelongsTo, DataType, Model } from "sequelize-typescript"; |
||||
import { |
||||
Table, |
||||
Column, |
||||
ForeignKey, |
||||
BelongsTo, |
||||
DataType, |
||||
Model, |
||||
} from "sequelize-typescript"; |
||||
import { User } from "../../users/entities/user.entity"; |
||||
import { Cart } from "src/cart/entities/cart.entity"; |
||||
|
||||
@Table |
||||
export class Invoice extends Model<Invoice> { |
||||
|
||||
|
||||
@ForeignKey(() => User) |
||||
@Column |
||||
userId: number; |
||||
|
||||
@BelongsTo(() => User, { onDelete: "CASCADE" })
|
||||
user: User; |
||||
@Column({ |
||||
type: DataType.STRING, |
||||
allowNull: false, |
||||
}) |
||||
firstName: string; |
||||
|
||||
@Column({ |
||||
type: DataType.STRING, |
||||
allowNull: false, |
||||
}) |
||||
lastName: string; |
||||
|
||||
@Column({ |
||||
type: DataType.STRING, |
||||
allowNull: false, |
||||
}) |
||||
phoneNumber: string; |
||||
|
||||
@Column({ |
||||
type: DataType.STRING, |
||||
allowNull: false, |
||||
unique: false, |
||||
}) |
||||
email: string; |
||||
|
||||
@ForeignKey(() => Cart) |
||||
@Column |
||||
totalPaymentAmount: number; |
||||
cartId: number; |
||||
|
||||
@Column({ |
||||
type: DataType.INTEGER, |
||||
allowNull: false, |
||||
}) |
||||
productId: number; |
||||
@BelongsTo(() => Cart, { onDelete: "CASCADE" })
|
||||
cart: Cart; |
||||
|
||||
@Column({ |
||||
type: DataType.INTEGER, |
||||
type: DataType.FLOAT, |
||||
allowNull: false, |
||||
}) |
||||
quantity: number; |
||||
|
||||
@Column({ |
||||
type: DataType.DECIMAL(10, 2), |
||||
allowNull: false, |
||||
}) |
||||
price: number; |
||||
|
||||
@Column({ |
||||
type: DataType.DECIMAL(10, 2), |
||||
allowNull: false, |
||||
}) |
||||
totalPrice: number; |
||||
|
||||
@Column({ |
||||
type: DataType.STRING, |
||||
allowNull: false, |
||||
}) |
||||
productName: string; |
||||
totalPaymentAmount: number; |
||||
} |
||||
|
Loading…
Reference in new issue