This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,734 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class Admin::AuctionReportsController < ApplicationController | ||
before_filter :require_admin | ||
|
||
def show | ||
@auction = Auction.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.csv do | ||
begin | ||
response.headers['Content-Type'] = 'text/csv' | ||
response.headers['Content-Disposition'] = "attachment" | ||
send_data WinningBidderExport.new(@auction).export_csv, | ||
filename: "winning_bidder_info_for_auction_#{@auction.id}.csv" | ||
rescue WinningBidderExport::Error | ||
redirect_to :back | ||
flash[:error] = I18n.t('controllers.admin.auction_reports.show.error') | ||
end | ||
end | ||
end | ||
end | ||
|
||
def csv_string | ||
CSV.generate do |csv| | ||
csv << [ | ||
"User ID", | ||
"Test", | ||
] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class WinningBid | ||
def initialize(auction) | ||
@auction = auction | ||
end | ||
|
||
def find | ||
auction_rules.winning_bid | ||
end | ||
|
||
private | ||
|
||
attr_reader :auction | ||
|
||
def auction_rules | ||
RulesFactory.new(auction).create | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
require 'csv' | ||
|
||
class WinningBidderExport | ||
class Error < StandardError; end | ||
|
||
def initialize(auction) | ||
@auction = auction | ||
end | ||
|
||
def export_csv | ||
CSV.generate do |csv| | ||
csv << [ | ||
"13GG Vendor Name", | ||
"13JJ Vendor Address Line 1", | ||
'13KK Vendor Address Line 2', | ||
'13LL Vendor Address Line 3', | ||
'13MM Vendor Address City', | ||
'13NN Vendor Address State', | ||
'13PP Vendor Zip Code', | ||
'13QQ Vendor Country Code', | ||
'13RR Vendor Phone Number', | ||
'13SS Vendor Fax Number', | ||
] | ||
csv << [ | ||
legal_business_name, | ||
address_line_1, | ||
address_line_2, | ||
address_line_3, | ||
address_city, | ||
address_state, | ||
address_zip, | ||
address_country, | ||
phone, | ||
fax, | ||
] | ||
end | ||
end | ||
|
||
private | ||
|
||
attr_reader :auction | ||
|
||
def legal_business_name | ||
sam_data[:legalBusinessName] | ||
end | ||
|
||
def address_line_1 | ||
sam_address[:line1] | ||
end | ||
|
||
def address_line_2 | ||
sam_address[:line2] || nil | ||
end | ||
|
||
def address_line_3 | ||
sam_address[:line3] || nil | ||
end | ||
|
||
def address_city | ||
sam_address[:city] | ||
end | ||
|
||
def address_state | ||
sam_address[:stateorProvince] | ||
end | ||
|
||
def address_zip | ||
sam_address[:zip] + zip_plus_4 | ||
end | ||
|
||
def zip_plus_4 | ||
sam_address[:zipPlus4] || '' | ||
end | ||
|
||
def address_country | ||
sam_address[:countryCode] | ||
end | ||
|
||
def phone | ||
sam_data[:govtBusinessPoc][:usPhone] | ||
end | ||
|
||
def fax | ||
sam_data[:govtBusinessPoc][:fax] | ||
end | ||
|
||
def sam_address | ||
sam_data[:samAddress] | ||
end | ||
|
||
def sam_data | ||
if get_duns_data['Code'] && get_duns_data['Code'] == 404 | ||
fail WinningBidderExport::Error | ||
else | ||
get_duns_data.deep_symbolize_keys[:sam_data][:registration] | ||
end | ||
end | ||
|
||
def get_duns_data | ||
@_get_duns_data ||= client.get_duns_info(duns: winning_bidder.duns_number) | ||
end | ||
|
||
def winning_bidder | ||
WinningBid.new(auction).find.bidder | ||
end | ||
|
||
def client | ||
@client ||= Samwise::Client.new(api_key: DataDotGovCredentials.api_key) | ||
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
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.