Sha256: 0e6cbf2f9a0516acfdb8abfa1771f509b70b17e72278b83cabe58c336622b007

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

class TenantsController < AuthorizedController
  # Actions
  def current
    redirect_to current_user.tenant
  end

  def profit_sheet
    @company = current_tenant.company

    # use current date if not specified otherwise
    params[:profit] ||= {}

    # use current date if not specified otherwise
    if params[:by_value_period]
      @end_date = Date.parse(params[:by_value_period][:to])
      @start_date = Date.parse(params[:by_value_period][:from])
      @dates = [@start_date..@end_date]
    elsif params[:years]
      @dates = params[:years].map{|year| current_tenant.fiscal_period(year.to_i)[:from]..current_tenant.fiscal_period(year.to_i)[:to]}
    else
      @end_date = Date.today
      @start_date = @end_date.to_time.advance(:years => -1, :days => 1).to_date
      @dates = [@start_date..@end_date]
    end
  end

  def balance_sheet
    @company = current_tenant.company

    # use current date if not specified otherwise
    if params[:by_value_period]
      @dates = [Date.parse(params[:by_value_period][:to])]
    elsif params[:years]
      @dates = params[:years].map{|year| current_tenant.fiscal_period(year.to_i)[:to]}
    else
      @dates = [Date.today]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookyt-0.0.1 app/controllers/tenants_controller.rb