module Gekanator
  class AiRunBudget
    MONTHLY_LIMIT_JPY = BigDecimal('450').freeze
    MAX_RUN_ESTIMATED_COST_JPY = BigDecimal('5').freeze

    def self.remaining_monthly_budget_jpy
      MONTHLY_LIMIT_JPY - monthly_cost_jpy
    end

    def self.monthly_cost_jpy
      GekanatorAiRun.this_month.sum(:estimated_cost_jpy)
    end

    def self.exceeded?
      monthly_cost_jpy >= MONTHLY_LIMIT_JPY
    end

    def self.exceeded_after_next_run?
      monthly_cost_jpy + MAX_RUN_ESTIMATED_COST_JPY >= MONTHLY_LIMIT_JPY
    end
  end
end
