components/financial_assistance/app/models/financial_assistance/application.rb
def compute_yearwise(incomes_or_deductions) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity TODO: Remove this
      income_deduction_per_year = Hash.new(0)

      incomes_or_deductions.each do |income_deduction|
        working_days_in_year = Float(52 * 5)
        daily_income = 0

        case income_deduction.frequency
        when "daily"
          daily_income = income_deduction.amount_in_cents
        when "weekly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 52)
        when "biweekly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 26)
        when "monthly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 12)
        when "quarterly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 4)
        when "half_yearly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 2)
        when "yearly"
          daily_income = income_deduction.amount_in_cents / working_days_in_year
        end

        income_deduction.start_date = TimeKeeper.date_of_record.beginning_of_year if income_deduction.start_date.to_s.eql?("01-01-0001" || income_deduction.start_date.blank?)
        income_deduction.end_date   = TimeKeeper.date_of_record.end_of_year if income_deduction.end_date.to_s.eql?("01-01-0001" || income_deduction.end_date.blank?)
        years = (income_deduction.start_date.year..income_deduction.end_date.year)

        years.to_a.each do |year|
          actual_days_worked = compute_actual_days_worked(year, income_deduction.start_date, income_deduction.end_date)
          income_deduction_per_year[year] += actual_days_worked * daily_income
        end
      end

      income_deduction_per_year.merge(income_deduction_per_year) do |_k, v|

        Integer(v)
      rescue StandardError
        v

      end
    end
##### Methods below were transferred from EDI DB system
##### TODO: verify utility and improve names
Methods below were transferred from EDI DB system
TODO: verify utility and improve names
Methods below were transferred from EDI DB system TODO : verify utility and improve names
def compute_yearwise(incomes_or_deductions) 
      income_deduction_per_year = Hash.new(0)
      incomes_or_deductions.each do |income_deduction|
        working_days_in_year = Float(52 * 5)
        daily_income = 0
        case income_deduction.frequency
        when "daily"
          daily_income = income_deduction.amount_in_cents
        when "weekly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 52)
        when "biweekly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 26)
        when "monthly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 12)
        when "quarterly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 4)
        when "half_yearly"
          daily_income = income_deduction.amount_in_cents / (working_days_in_year / 2)
        when "yearly"
          daily_income = income_deduction.amount_in_cents / working_days_in_year
        end
        income_deduction.start_date = TimeKeeper.date_of_record.beginning_of_year if income_deduction.start_date.to_s.eql?("01-01-0001" || income_deduction.start_date.blank?)
        income_deduction.end_date   = TimeKeeper.date_of_record.end_of_year if income_deduction.end_date.to_s.eql?("01-01-0001" || income_deduction.end_date.blank?)
        years = (income_deduction.start_date.year..income_deduction.end_date.year)
        years.to_a.each do |year|
          actual_days_worked = compute_actual_days_worked(year, income_deduction.start_date, income_deduction.end_date)
          income_deduction_per_year[year] += actual_days_worked * daily_income
        end
      end
      income_deduction_per_year.merge(income_deduction_per_year) do |_k, v|
        Integer(v)
      rescue StandardError
        v
      end
    end
def compute_yearwise ( incomes_or_deductions ) income_deduction_per_year = Hash . new ( 0 ) incomes_or_deductions . each do | income_deduction | working_days_in_year = Float ( 52 * 5 ) daily_income = 0 case income_deduction . frequency when "daily" daily_income = income_deduction . amount_in_cents when "weekly" daily_income = income_deduction . amount_in_cents / ( working_days_in_year / 52 ) when "biweekly" daily_income = income_deduction . amount_in_cents / ( working_days_in_year / 26 ) when "monthly" daily_income = income_deduction . amount_in_cents / ( working_days_in_year / 12 ) when "quarterly" daily_income = income_deduction . amount_in_cents / ( working_days_in_year / 4 ) when "half_yearly" daily_income = income_deduction . amount_in_cents / ( working_days_in_year / 2 ) when "yearly" daily_income = income_deduction . amount_in_cents / working_days_in_year end income_deduction . start_date = TimeKeeper . date_of_record . beginning_of_year if income_deduction . start_date . to_s . eql? ( "01-01-0001" || income_deduction . start_date . blank? ) income_deduction . end_date = TimeKeeper . date_of_record . end_of_year if income_deduction . end_date . to_s . eql? ( "01-01-0001" || income_deduction . end_date . blank? ) years = ( income_deduction . start_date . year .. income_deduction . end_date . year ) years . to_a . each do | year | actual_days_worked = compute_actual_days_worked ( year , income_deduction . start_date , income_deduction . end_date ) income_deduction_per_year [ year ] += actual_days_worked * daily_income end end income_deduction_per_year . merge ( income_deduction_per_year ) do | _k , v | Integer ( v ) rescue StandardError v end end
Methods below were transferred from EDI DB system
TODO: verify utility and improve names
Methods below were transferred from EDI DB system TODO : verify utility and improve names
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity TODO: Remove this
incomes_or_deductions