Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ group :development, :test do
gem "rspec-rails", "~> 3.4"
gem "rubocop"
gem "sdoc", "~> 0.4.0", group: :doc
gem "shoulda-matchers", "~> 3.1"
end

group :test do
gem "climate_control", "~> 0.2"
gem "fakefs", "~> 0.11", require: "fakefs/safe"
gem "shoulda-matchers", "~> 3.1"
end

group :development do
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.9)
connection_pool (2.2.3)
crass (1.0.6)
declarative (0.0.10)
Expand Down Expand Up @@ -147,7 +147,7 @@ GEM
httpi (2.4.4)
rack
socksify
i18n (1.8.3)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -189,7 +189,7 @@ GEM
mime-types-data (3.2020.0512)
mini_mime (1.0.2)
mini_portile2 (2.6.1)
minitest (5.14.1)
minitest (5.15.0)
multi_json (1.14.1)
multipart-post (2.1.1)
netrc (0.11.0)
Expand Down Expand Up @@ -373,7 +373,7 @@ GEM
turbolinks (2.5.4)
coffee-rails
twitter-bootstrap-rails-confirm (2.0.1)
tzinfo (1.2.7)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uber (0.1.0)
uglifier (4.2.0)
Expand Down
14 changes: 14 additions & 0 deletions app/assets/javascripts/years.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
expose "initializeYears", ->
defaultMatcher = $.fn.select2.defaults.defaults.matcher

$ ->
$("#year-selector, .year-selector").select2
theme: "bootstrap"
width: "100%"
matcher: (params, data) ->
textToMatch = data.element.getAttribute("data-search-text") || ""

if defaultMatcher(params, { text: textToMatch })
data
else
null
4 changes: 4 additions & 0 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def price_point_variance
@report = Reports::PricePointVariance.new(params, session)
end

def annual_inventory_ppv
@report = Reports::AnnualInventoryPpv.new()
end

private

def report_exporter
Expand Down
3 changes: 3 additions & 0 deletions app/models/annual_inventory_ppv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AnnualInventoryPpv < ApplicationRecord
validates_format_of :year, :with => /[0-9]{4}/
end
37 changes: 37 additions & 0 deletions app/models/reports/annual_inventory_ppv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Reports
module AnnualInventoryPpv
def self.new()
Reports::AnnualInventoryPpv::AllYears.new()
end

def self.years
AnnualInventoryPpv.all.pluck(:year).uniq.sort
end

module Base
def each
data.each { |x| yield(*x) }
end
end

class AllYears
include Reports::AnnualInventoryPpv::Base
attr_reader :annual_inventory_ppvs

def initialize()
@annual_inventory_ppvs = ::AnnualInventoryPpv.order(:year).to_a
end

def description_label
"Vendor"
end

def data
@data ||= annual_inventory_ppvs.map do |annual_inventory_ppv|
[annual_inventory_ppv.year, annual_inventory_ppv.total_inventory_value,
annual_inventory_ppv.annual_ppv,annual_inventory_ppv.real_inventory_value]
end
end
end
end
end
1 change: 1 addition & 0 deletions app/views/common/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<li><%= link_to "Total Inventory Value", total_inventory_value_reports_path %></li>
<li><%= link_to "Inventory Adjustments", inventory_adjustments_reports_path %></li>
<li><%= link_to "Price Point Variace Report", price_point_variance_reports_path %></li>
<li><%= link_to "Annual Inventory PPV Report", annual_inventory_ppv_reports_path %></li>
<li><%= link_to "Graphs", graphs_reports_path %></li>
<% if current_user.can_export? %>
<li role="separator" class="divider"></li>
Expand Down
33 changes: 33 additions & 0 deletions app/views/reports/annual_inventory_ppv.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<% content_for :title, "Annual Inventory PPV Report" %>

<% content_for :content_size, "col-sm-9 col-md-10" %>

<% content_for :content do %>
<div class="tab-content">
<div class="row">
<div class="col-xs-12">
<table class="table table-striped table-responsive data-table">
<thead>
<tr>
<th class="sort-asc">Year</th>
<th class="text-center">Total Inventory Value</th>
<th class="text-center">annual PPV</th>
<th class="text-center">Real Inventory Value</th>
</tr>
</thead>

<tbody>
<% @report.each do |year, total_inventory_value, annual_ppv, real_inventory_value| %>
<%= content_tag "tr" do %>
<td><%= year %></td>
<td class="text-center"><%= number_to_currency total_inventory_value, precision: 2 %></td>
<td class="text-center"><%= number_to_currency annual_ppv, precision: 2 %></td>
<td class="text-center"><%= number_to_currency real_inventory_value, precision: 2 %></td>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
get :value_by_county
get :value_by_donor
get :price_point_variance
get :annual_inventory_ppv
end
end

Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20220103203303_add_annual_inventory_ppvs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class AddAnnualInventoryPpvs < ActiveRecord::Migration[5.1]
def change
create_table :annual_inventory_ppvs do |t|
t.integer :year
t.decimal :total_inventory_value
t.decimal :annual_ppv
t.decimal :real_inventory_value

t.timestamps null: false
end

add_index :annual_inventory_ppvs, :year
end
end
12 changes: 11 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20211207074040) do
ActiveRecord::Schema.define(version: 20220103203303) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -25,6 +25,16 @@
t.string "zip", limit: 16
end

create_table "annual_inventory_ppvs", force: :cascade do |t|
t.integer "year"
t.decimal "total_inventory_value"
t.decimal "annual_ppv"
t.decimal "real_inventory_value"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["year"], name: "index_annual_inventory_ppvs_on_year"
end

create_table "bin_items", id: :serial, force: :cascade do |t|
t.integer "bin_id", null: false
t.integer "item_id", null: false
Expand Down