-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. devtracker.rb: Added Transaction and Quaterly Financial budget API…
… Call for Transaction Page for both DFID and Partners Project and set current financial start and end date globally. 2. codelists.rb: add function to identify document mime type. 3. common_helpers.rb: add common functions those can be used to get desired outputs. 4. country_helpers.rb: change variable names to camel case. 5. document_helpers.rb: add function to get document category list for a document. 6. project_helpers.rb: add function to sum budgets for a project and will provide 0 if there is no budget. 7. country.html.erb: formating change on Total Project Budget. 8. _project-list.html.erb: Project Budget added into Project Search list with proper formatting and document type filter option disabled due performance issue. 9. _projects-header.html.erb: Breadcrumb issue fixed for project (specially for Partner Projects) 10. documents.html.erb: Add human readable document type in the page. 11. transactions.html.erb: Budgets and all type of transactions (IF,C,D,E) are generated for both DFID and Partner Projects.
- Loading branch information
1 parent
e55031d
commit 646e481
Showing
11 changed files
with
243 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
module CommonHelpers | ||
|
||
#New One based on API Call | ||
def financial_year_wise_budgets(yearWiseBudgets,type) | ||
|
||
projectBudgets = [] | ||
|
||
yearWiseBudgets.each do |y| | ||
if y["quarter"]==1 | ||
p=[y["quarter"],y["budget"],y["year"],y["year"]-1] | ||
else | ||
p=[y["quarter"],y["budget"],y["year"],y["year"]] | ||
end | ||
|
||
projectBudgets << p | ||
end | ||
|
||
#project_budgets | ||
#project_budgets = year_wise_budgets.group_by{|b| b["year"]}.map{|year, budgets| | ||
#summedBudgets = budgets.reduce(0) {|memo, budget| memo + budget["budget"]} | ||
#[year, summedBudgets] | ||
#}.sort | ||
|
||
finYearWiseBudgets = projectBudgets.group_by{|b| b[3]}.map{|year, budgets| | ||
summedBudgets = budgets.reduce(0) {|memo, budget| memo + budget[1]} | ||
[year, summedBudgets] | ||
}.sort | ||
|
||
# determine what range to show | ||
#current_financial_year = first_day_of_financial_year(DateTime.now) | ||
currentFinancialYear = financial_year | ||
|
||
# if range is 6 or less just show it | ||
if (type=="C") then | ||
range = if finYearWiseBudgets.size < 7 then | ||
finYearWiseBudgets | ||
# if the last item in the list is less than or equal to | ||
# the current financial year get the last 6 | ||
elsif finYearWiseBudgets.last.first <= currentFinancialYear | ||
finYearWiseBudgets.last(6) | ||
# other wise show current FY - 3 years and cuurent FY + 3 years | ||
else | ||
index_of_now = finYearWiseBudgets.index { |i| i[0] == currentFinancialYear } | ||
|
||
if index_of_now.nil? then | ||
finYearWiseBudgets.last(6) | ||
else | ||
finYearWiseBudgets[[index_of_now-3,0].max..index_of_now+2] | ||
end | ||
end | ||
|
||
# finally convert the range into a label format | ||
range.each { |item| | ||
item[0] = financial_year_formatter(item[0]) | ||
} | ||
elsif (type=="P") then | ||
finYearWiseBudgets.each { |item| | ||
item[0] = financial_year_formatter(item[0]) | ||
} | ||
|
||
end | ||
|
||
end | ||
|
||
#New One based on API Call | ||
def financial_year_formatter(y) | ||
|
||
#date = if(d.kind_of?(String)) then | ||
#Date.parse d | ||
#else | ||
#d | ||
#end | ||
|
||
#if date.month < 4 | ||
#{}"FY#{(date.year-1).to_s[2..3]}/#{date.year.to_s[2..3]}" | ||
#else | ||
"FY#{y.to_s[2..3]}/#{(y+1).to_s[2..3]}" | ||
#end | ||
end | ||
|
||
def financial_year | ||
now = Time.new | ||
if(now.month < 4) | ||
now.year-1 | ||
else | ||
now.year | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.