class RequestContract
  include Mongoid::Document
  include Mongoid::Timestamps
  include Slug

  field :new_site_cost, type: Integer, :default => 0
  field :hosting_with_rulingdigital_cost, type: Integer, :default => 0
  field :service_cost, type: Integer, :default => 0
  field :option_module_cost, type: Integer, :default => 0
  field :customized_module_cost, type: Integer, :default => 0
  field :template_cost, type: Integer, :default => 0
  field :customized_template_cost, type: Integer, :default => 0
  field :rwd_cost, type: Integer, :default => 0
  field :other
  field :other_cost, type: Integer, :default => 0
  field :confirmed, type: Boolean, :default => false

  mount_uploader :contract_file, AssetUploader
  mount_uploader :signed_contract_file, AssetUploader

  has_one :site_request
  has_one :contract_purchase

  def total_amount
    self.new_site_cost + self.hosting_with_rulingdigital_cost + self.service_cost + self.option_module_cost + self.customized_module_cost + self.template_cost + self.customized_template_cost + self.rwd_cost + self.other_cost
  end

  def is_confirmed?
    self.confirmed
  end

  def contract_user
    self.site_request.c_panel_user
  end

  def get_site
    self.site_request.get_site 
  end
end