import { isApplicationRequestLike } from './documentClassification.js'

export function isArchivedExpenseClaim(claim) {
  const stage = String(claim?.approval_stage || claim?.approvalStage || '').trim()
  const status = String(claim?.status || '').trim().toLowerCase()

  if (stage === '归档入账' || stage === '已付款' || stage === 'completed' || stage.includes('归档')) {
    return true
  }

  if (!['approved', 'completed', 'paid'].includes(status)) {
    return false
  }

  if (isApplicationRequestLike(claim) && ['审批完成', '申请归档'].includes(stage)) {
    return true
  }

  return !stage || stage === '归档入账' || stage === '已付款' || stage === 'completed'
}
