import type { ProfitShareSchemeRecord } from "@/types/master-data";

type SerializableProfitShareScheme = {
  id: bigint;
  code: string;
  name: string;
  shareAgent: { toNumber(): number };
  shareCompany: { toNumber(): number };
  status: string;
  createdAt: Date;
  updatedAt: Date;
};

export function serializeProfitShareScheme(
  scheme: SerializableProfitShareScheme
): ProfitShareSchemeRecord {
  return {
    id: scheme.id.toString(),
    code: scheme.code,
    name: scheme.name,
    share_agent: scheme.shareAgent.toNumber(),
    share_company: scheme.shareCompany.toNumber(),
    status: scheme.status,
    created_at: scheme.createdAt.toISOString(),
    updated_at: scheme.updatedAt.toISOString()
  };
}
