after claude code
This commit is contained in:
47
src/modules/transactions/entities/transaction-item.entity.ts
Normal file
47
src/modules/transactions/entities/transaction-item.entity.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
Index,
|
||||
} from 'typeorm';
|
||||
import { Transaction } from './transaction.entity';
|
||||
import { Product } from '../../products/entities/product.entity';
|
||||
|
||||
@Entity('transaction_items')
|
||||
export class TransactionItem {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ type: 'uuid' })
|
||||
@Index('idx_transaction_items_transaction')
|
||||
transactionId: string;
|
||||
|
||||
@Column({ type: 'uuid' })
|
||||
@Index('idx_transaction_items_product')
|
||||
productId: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 255 })
|
||||
productName: string;
|
||||
|
||||
@Column({ type: 'decimal', precision: 10, scale: 2 })
|
||||
price: number;
|
||||
|
||||
@Column({ type: 'int' })
|
||||
quantity: number;
|
||||
|
||||
@Column({ type: 'decimal', precision: 10, scale: 2 })
|
||||
lineTotal: number;
|
||||
|
||||
// Relationships
|
||||
@ManyToOne(() => Transaction, (transaction) => transaction.items, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'transactionId' })
|
||||
transaction: Transaction;
|
||||
|
||||
@ManyToOne(() => Product, (product) => product.transactionItems)
|
||||
@JoinColumn({ name: 'productId' })
|
||||
product: Product;
|
||||
}
|
||||
Reference in New Issue
Block a user