import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import {
  SalesPriceFormulaEntity,
  TransactionSetting,
} from '../../domain/entities/sales-price-formula.entity';
import { Column, Entity } from 'typeorm';
import { BaseModel } from 'src/core/modules/data/model/base.model';
import { FormulaType } from '../../constants';

@Entity(TABLE_NAME.PRICE_FORMULA)
export class SalesPriceFormulaModel
  extends BaseModel<SalesPriceFormulaEntity>
  implements SalesPriceFormulaEntity
{
  @Column('enum', {
    name: 'type',
    enum: FormulaType,
    default: FormulaType.SALES_PRICE,
  })
  type: FormulaType;

  @Column('json', { name: 'formula_render', nullable: true })
  formula_render: any;

  @Column('varchar', { name: 'formula_string', nullable: true })
  formula_string: string;

  @Column('varchar', { default: 'dpp' })
  value_for: string;

  @Column('varchar', { name: 'example_formula', nullable: true })
  example_formula: string;

  @Column('numeric', { name: 'example_result', nullable: true })
  example_result: number;
}

@Entity(TABLE_NAME.TRANSACTION_SETTING)
export class TransactionSettingModel
  extends BaseModel<TransactionSetting>
  implements TransactionSetting
{
  @Column('numeric', { default: 100 })
  value: number;
}
