app/controllers/swimmers_controller.rb
# Radiography for a specified swimmer id: "Presence" tab rendering.
# Show swimmer presence in the current seasons
# Show costs only to team manager (for managed team's swimemrs)
# and logged swimmers (for himselves)
#
# == Params:
# id: the swimmer id to be processed
#
Radiography for a specified swimmer id: "Presence" tab rendering.
Show swimmer presence in the current seasons
Show costs only to team manager (for managed team's swimemrs)
and logged swimmers (for himselves)

the swimmer id to be processed
Radiography for a specified swimmer id : " Presence " tab rendering . Show swimmer presence in the current seasons Show costs only to team manager ( for managed team ' s swimemrs ) and logged swimmers ( for himselves ) the swimmer id to be processed
def presence
    @tab_title = I18n.t('presences.title')
    @costs = false
    @cash = []
    @notes = {}
    hyp = HeaderYearPicker.new()
    @season_list = hyp.find(2015)
    payment_badges = []
    date_to_use = params['header_year'].present? ? Date.parse(params['header_year'].slice(5, 4) + "0101") : Date.today()
    spc = SwimmerPresenceChecker.new(@swimmer, date_to_use)
    current_badges = spc.get_swimmer_current_badges()
    current_badges.each do |badge|
      current_season = badge.season
      get_costs = ( badge.has_to_pay_badge || badge.has_to_pay_fees || badge.has_to_pay_relays )
      is_team_manager = TeamManagerValidator.can_manage_badge?( current_user, badge )
      spc.scan_season( current_season, badge.has_to_pay_fees, badge.has_to_pay_relays )
      if (( get_costs && current_user == @swimmer.associated_user ) || is_team_manager )
        @costs = true
        payment_badges << badge.id
        if badge.has_to_pay_badge
          cash_row = {}
          cash_row[:issue]   = I18n.t('presences.badge') + ' ' + current_season.season_type.federation_type.code
          cash_row[:amount] = -current_season.badge_fee
          @cash << cash_row
        end
        @notes[badge.team.editable_name] = badge.team.notes if badge.team.notes && badge.team.notes.length > 0
      end
    end
    @badge_payments = BadgePayment.where( badge_id: payment_badges ).sort_by_date('ASC')
    @spDAO = spc.swimmer_presence_dao
    @last_payment_update = BadgePayment.where( badge_id: current_badges.map{ |b| b.id }).sort_by_date('ASC').last.payment_date if @badge_payments.count > 0
  end
def presence @tab_title = I18n . t ( 'presences.title' ) @costs = false @cash = [ ] @notes = { } hyp = HeaderYearPicker . new ( ) @season_list = hyp . find ( 2015 ) payment_badges = [ ] date_to_use = params [ 'header_year' ] . present? ? Date . parse ( params [ 'header_year' ] . slice ( 5 , 4 ) + "0101" ) : Date . today ( ) spc = SwimmerPresenceChecker . new ( @swimmer , date_to_use ) current_badges = spc . get_swimmer_current_badges ( ) current_badges . each do | badge | current_season = badge . season get_costs = ( badge . has_to_pay_badge || badge . has_to_pay_fees || badge . has_to_pay_relays ) is_team_manager = TeamManagerValidator . can_manage_badge? ( current_user , badge ) spc . scan_season ( current_season , badge . has_to_pay_fees , badge . has_to_pay_relays ) if ( ( get_costs && current_user == @swimmer . associated_user ) || is_team_manager ) @costs = true payment_badges << badge . id if badge . has_to_pay_badge cash_row = { } cash_row [ :issue ] = I18n . t ( 'presences.badge' ) + ' ' + current_season . season_type . federation_type . code cash_row [ :amount ] = - current_season . badge_fee @cash << cash_row end @notes [ badge . team . editable_name ] = badge . team . notes if badge . team . notes && badge . team . notes . length > 0 end end @badge_payments = BadgePayment . where ( badge_id : payment_badges ) . sort_by_date ( 'ASC' ) @spDAO = spc . swimmer_presence_dao @last_payment_update = BadgePayment . where ( badge_id : current_badges . map { | b | b . id } ) . sort_by_date ( 'ASC' ) . last . payment_date if @badge_payments . count > 0 end
Radiography for a specified swimmer id: "Presence" tab rendering.
Radiography for a specified swimmer id : " Presence " tab rendering .
# --- "Presence" tab: --- # TODO Find out managed seasons # Find out current seasons for team # Check if cost has to be shown # TODO maybe create startegy and DAO for payments too # Check for payments # Check for fee notes # Check for last payments update