import {
  BelongsTo,
  Column,
  DataType,
  ForeignKey,
  Model,
  Table,
} from 'sequelize-typescript';
import { ProductModel } from './product.entity';

@Table({ tableName: 'product_ProductWithInventory', timestamps: false })
export class ProductWithInventoryModel extends Model {
  @ForeignKey(() => ProductModel)
  @Column({
    type: DataType.STRING,
    allowNull: false,
    primaryKey: true,
  })
  ProductId: string;

  @Column({ allowNull: false, type: DataType.STRING(20) })
  UOM: string;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnits: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsAvailable: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsInCurrentOrder: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsSold: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsReserved: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsVoid: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsInTransit: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsOnConsignment: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsUnderMaintenance: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsBackOrdered: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  TotalUnitsPreOrdered: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  StockLowAlertLevel: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  StockReorderLevel: number;

  @Column({ allowNull: true, type: DataType.DECIMAL(10, 2) })
  BufferStockLevel: number;

  @BelongsTo(() => ProductModel)
  Product: ProductModel;
}
