39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from 'typeorm';
|
|
import { RefundItemEntity } from '../../domain/entities/refund-item.entity';
|
|
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
|
import { RefundModel } from './refund.model';
|
|
|
|
@Entity(TABLE_NAME.REFUND_ITEM)
|
|
export class RefundItemModel
|
|
extends BaseCoreModel<RefundItemEntity>
|
|
implements RefundItemEntity
|
|
{
|
|
@Column('decimal', { name: 'qty_refund', nullable: true })
|
|
qty_refund: number;
|
|
|
|
@Column('decimal', { name: 'refund_total', nullable: true })
|
|
refund_total: number;
|
|
|
|
// transaction to refund
|
|
@Column('decimal', { name: 'refund_item_id', nullable: true })
|
|
refund_item_id: number;
|
|
@ManyToOne(() => RefundModel, (model) => model.refund_items, {
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'refund_item_id' })
|
|
refund: RefundModel;
|
|
|
|
// transaction to transaction item
|
|
@Column('varchar', { name: 'transaction_item_id', nullable: true })
|
|
transaction_item_id: string;
|
|
@ManyToOne(() => TransactionItemModel, (model) => model.refunds, {
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'transaction_item_id' })
|
|
transaction_item: TransactionItemModel;
|
|
}
|