import { Expose } from 'class-transformer';

/**
 * 처리 계정 — 기록 대상 행위를 보여 주는 화면이 **역할 이름 대신** 그리는 한 덩어리(계획 M7 D1·D9).
 *
 * 서버가 조립하고 프런트는 공유 포매터 하나(`shared/lib/processedBy.ts`)로 그린다. 화면마다
 * 문자열을 조립하면 '역할 대신 계정' 규칙이 다섯 벌이 되고 한 벌만 고쳐진다.
 *
 * - `loginId` — 평문·UNIQUE 인 `adm_login_id`. 삭제된 계정이면 조인이 끊겨 `null` 이다.
 * - `admId` — 업무 표가 가진 `adm_id`. 계정이 지워져도 이 값은 남는다.
 * - `deleted` — 업무 표에는 계정 번호가 있는데 계정 행이 없다(하드 삭제 뒤, D8). MySQL 이
 *   `CASE` 로 0/1 을 내므로 숫자다.
 */
export class ProcessedByEntity {
  @Expose()
  loginId!: string | null;

  @Expose()
  admId!: number | null;

  @Expose()
  deleted!: number;
}

/**
 * 기업머니 이력 Entity
 * 기업의 보유머니 변동 이력
 */
export class MoneyCorpEntity {
  @Expose()
  mcpId!: number;

  @Expose()
  agcId!: number;

  @Expose()
  mngId!: number | null;

  @Expose()
  mcpActorType!: string | null;

  @Expose()
  mcpActorMemId!: number | null;

  @Expose()
  mcpType!: string;

  @Expose()
  mcpTitle!: string;

  @Expose()
  mcpReason!: string | null;

  @Expose()
  mcpAmount!: number;

  @Expose()
  mcpBalance!: number;

  @Expose()
  mcpCreatedAt!: string;

  // 조인된 데이터
  //* `admName`(암호문)을 지우고 계정으로 바꿨다 — 화면에 가던 값이 사람 이름이 아니라
  //*  `FN_ENCRYPT` 로 저장된 칸의 원문이었다(계획 M7 D1).
  @Expose()
  processedBy?: ProcessedByEntity;

  @Expose()
  actorMemLoginId?: string | null;

  @Expose()
  actorMemName?: string | null;

  @Expose()
  mngTargetType?: string;
}

/**
 * 기업머니 요약 정보 Entity
 */
export class MoneyCorpSummaryEntity {
  @Expose()
  totalEarn!: number;

  @Expose()
  totalEarnRecovery!: number;

  @Expose()
  totalGrant!: number;

  @Expose()
  totalGrantRecovery!: number;

  @Expose()
  currentBalance!: number;
}
