fossil 0.4.17 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/fossil.gemspec +2 -2
- data/lib/models/flight_log_expense.rb +48 -0
- data/lib/models/trip_leg.rb +47 -52
- data/lib/sequel/model_patch.rb +17 -4
- data/spec/models/trip_leg_spec.rb +183 -158
- data/spec/sequel/model_patch_spec.rb +6 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.18
|
data/fossil.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fossil}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.18"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Patrick Lardin, Daniel Sudol"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-13}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{plardin@xojet.com}
|
15
15
|
s.files = [
|
@@ -2,6 +2,9 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
2
2
|
|
3
3
|
code_association :expense_type_value, :'type', :flight_log_expense_type
|
4
4
|
|
5
|
+
#Many to one association with composite keys
|
6
|
+
n_to_o :trip_leg, :class=>:TripLeg, :prefix=>'trip leg'
|
7
|
+
|
5
8
|
#### BEGIN GENERATED SECTION ####
|
6
9
|
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
7
10
|
|
@@ -89,4 +92,49 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
89
92
|
column_alias :key2, :'key2'
|
90
93
|
#### END GENERATED SECTION ####
|
91
94
|
|
95
|
+
def fuel_rate # Takes a FlightLogExpense for fuel
|
96
|
+
return 0 if type != 1
|
97
|
+
my_type = (arrival_airport == 1 ? "ARRIVAL" : "DEPART")
|
98
|
+
airport_fuel = airport_fuel_lookup vendor_id, my_type
|
99
|
+
(airport_fuel ? fuel_rate_by_quantity(quantity, airport_fuel) : 0)
|
100
|
+
end
|
101
|
+
|
102
|
+
def airport_fuel_lookup vendor_id, type #ARRIVAL or DEPART
|
103
|
+
str = (type == "DEPART" ? "DEPT" : "ARR")
|
104
|
+
prefix = (type == "DEPART" ? "FUELER" : "FBO")
|
105
|
+
sql = <<-SQL
|
106
|
+
SELECT TOP 1 TL."TRIP NUMBER",TL."LEG NUMBER", TL."#{type} AIRPORT ID",
|
107
|
+
AF."COST 1", AF."QTY 1", AF."COST 2", AF."QTY 2", AF."COST 3", AF."QTY 3", AF."COST 4", AF."QTY 4",
|
108
|
+
AF."COST 5", AF."QTY 5", AF."COST 6", AF."QTY 6", AF."COST 7", AF."QTY 7", AF."COST 8", AF."QTY 8",
|
109
|
+
AF."COST 9", AF."QTY 9", AF."COST 10", AF."QTY 10", AF."EFFECTIVE DATE"
|
110
|
+
FROM "TRIP LEGS" AS TL, "AIRPORT FUEL" AS AF
|
111
|
+
WHERE (AF."FBO KID - DATE" = TL."#{prefix} KID - DATE"
|
112
|
+
AND AF."FBO KID - TIME" = TL."#{prefix} KID - TIME"
|
113
|
+
AND AF."FBO KID - MULT" = TL."#{prefix} KID - MULT"
|
114
|
+
AND AF."FBO KID - COMM" = TL."#{prefix} KID - COMM"
|
115
|
+
AND AF."FBO KID - USER" = TL."#{prefix} KID - USER"
|
116
|
+
AND AF."VENDOR ID" = '#{vendor_id}'
|
117
|
+
AND (AF."EFFECTIVE DATE" <= TL."#{str} DATE ACT LOCAL" OR AF."EFFECTIVE DATE" <= TL."#{type} DATE - LOCAL"))
|
118
|
+
AND (TL."TRIP NUMBER" = ? AND TL."LEG NUMBER" = ?)
|
119
|
+
ORDER BY AF."EFFECTIVE DATE" DESC
|
120
|
+
SQL
|
121
|
+
return db.fetch(sql, trip_leg.trip_number, trip_leg.leg_number).first
|
122
|
+
end
|
123
|
+
|
124
|
+
def build_fuel_tier_hash airport_fuel # creates a hash table of the qty and fuel prices for each tier
|
125
|
+
h = Hash.new
|
126
|
+
(1..10).each do |n|
|
127
|
+
h[airport_fuel[:"qty #{n}"]] = airport_fuel[:"cost #{n}"]
|
128
|
+
end
|
129
|
+
h
|
130
|
+
end
|
131
|
+
|
132
|
+
def fuel_rate_by_quantity qty, airport_fuel # gives the cost associated with the qty of fuel purchased
|
133
|
+
return 0 if qty == nil or qty == 0 or airport_fuel == nil
|
134
|
+
h = build_fuel_tier_hash airport_fuel
|
135
|
+
h.keys.sort.reverse.each do |key|
|
136
|
+
return (h[key] / 100.0) if (qty and key) and qty >= key
|
137
|
+
end
|
138
|
+
0
|
139
|
+
end
|
92
140
|
end
|
data/lib/models/trip_leg.rb
CHANGED
@@ -8,6 +8,8 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
8
8
|
many_to_one :locked_by, :class=>:User, :key=>:'locked by - user id', :primary_key=>:'users initials'
|
9
9
|
many_to_one :leg_rate_aircraft, :class=>:Aircraft, :key=>:'leg rate ac id', :primary_key=>:'aircraft id'
|
10
10
|
many_to_one :authorizer_name, :class=>:Personnel, :key=>:authorization, :primary_key=>:employee_id
|
11
|
+
many_to_one :departure_fuel_vendor, :class=>:Vendor, :key=>:dep_fuel_vendor, :primary_key=>:vendor_id
|
12
|
+
many_to_one :arrival_fuel_vendor, :class=>:Vendor, :key=>:arr_fuel_vendor, :primary_key=>:vendor_id
|
11
13
|
|
12
14
|
# Many to one associations with composite primary keys
|
13
15
|
n_to_o :trip, :class=>:Trip, :prefix=>'trips'
|
@@ -702,6 +704,7 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
702
704
|
column_view :land_time_act_gmt, :time, :actual_land_time_gmt
|
703
705
|
column_view :delay_1_time, :time, :delay_1_duration
|
704
706
|
column_view :delay_2_time, :time, :delay_2_duration
|
707
|
+
column_view :ron, :boolean
|
705
708
|
|
706
709
|
|
707
710
|
# get pic or sic or purser for this trip leg. type should be :pic or :sic or :pur
|
@@ -814,70 +817,62 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
814
817
|
((nautical_miles*1.150777*10).to_i)/10.0
|
815
818
|
end
|
816
819
|
|
817
|
-
|
818
|
-
def
|
819
|
-
|
820
|
-
arr = method.to_s.split('_')
|
821
|
-
send(:get_fuel_value, arr[0], arr[2])
|
822
|
-
else
|
823
|
-
super(method, *args, &block)
|
824
|
-
end
|
820
|
+
# Datamart Methods
|
821
|
+
def arrival_ap_id
|
822
|
+
arrival_airport_id ? "#{arrival_ap_prefix}#{arrival_airport_id}" : ""
|
825
823
|
end
|
826
824
|
|
827
|
-
def
|
828
|
-
|
829
|
-
pow = instance_variable_get "@#{type}_fuel"
|
830
|
-
pow[item.to_sym]
|
825
|
+
def depart_ap_id
|
826
|
+
depart_airport_id ? "#{depart_ap_prefix}#{depart_airport_id}" : ""
|
831
827
|
end
|
832
828
|
|
833
|
-
|
834
|
-
|
835
|
-
my_type = (type == "arr" ? "ARRIVAL" : "DEPART")
|
836
|
-
pow = instance_variable_set "@#{type}_fuel", {}
|
837
|
-
pow[:quantity], pow[:rate] = airport_fuel_quantity_and_rate(my_type)
|
838
|
-
pow[:cost] = pow[:rate] * pow[:quantity]
|
829
|
+
def arrival_fbo_is_primary
|
830
|
+
arrival_fbo__primary == 1 ? 'Yes' : 'No'
|
839
831
|
end
|
840
832
|
|
841
|
-
def
|
842
|
-
|
843
|
-
(airport_fuel ? [airport_fuel[:quantity], fuel_cost_by_quantity(airport_fuel[:quantity], airport_fuel)]: [0,0])
|
833
|
+
def departure_fbo_is_primary
|
834
|
+
departure_fbo__primary == 1 ? 'Yes' : 'No'
|
844
835
|
end
|
845
836
|
|
846
|
-
def
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
FLE."VENDOR ID", FLE."QUANTITY",
|
851
|
-
AF."COST 1", AF."QTY 1", AF."COST 2", AF."QTY 2", AF."COST 3", AF."QTY 3", AF."COST 4", AF."QTY 4",
|
852
|
-
AF."COST 5", AF."QTY 5", AF."COST 6", AF."QTY 6", AF."COST 7", AF."QTY 7", AF."COST 8", AF."QTY 8",
|
853
|
-
AF."COST 9", AF."QTY 9", AF."COST 10", AF."QTY 10", AF."EFFECTIVE DATE"
|
854
|
-
FROM "TRIP LEGS" AS TL inner join "FLIGHT LOG EXPENSES" AS FLE
|
855
|
-
ON
|
856
|
-
(FLE."TRIP LEG KID - DATE" = TL."KID - DATE" AND FLE."TRIP LEG KID - TIME" = TL."KID - TIME"
|
857
|
-
AND FLE."TRIP LEG KID - USER" = TL."KID - USER" AND FLE."TRIP LEG KID - MULT"=TL."KID - MULT"
|
858
|
-
AND FLE."TRIP LEG KID - COMM" = TL."KID - COMM" AND FLE."TYPE" = 1)
|
859
|
-
LEFT OUTER JOIN "AIRPORT FUEL" AS AF
|
860
|
-
ON (AF."VENDOR ID" = FLE."VENDOR ID" AND AF."AIRPORT ID" = TL."DEPART AIRPORT ID" AND AF."EFFECTIVE DATE" <= TL."#{str} DATE GMT")
|
861
|
-
AND (TL."TRIP NUMBER" = ? AND TL."LEG NUMBER" = ?)
|
862
|
-
ORDER BY AF."EFFECTIVE DATE" DESC
|
863
|
-
SQL
|
864
|
-
return db.fetch(sql, trip_number, leg_number).first
|
837
|
+
def departure_airport_zipcode
|
838
|
+
departure_airport__city_state_zip and
|
839
|
+
departure_airport__city_state_zip.match(/(\d{5}-\d{4}$|\d{5})$/) and
|
840
|
+
$1
|
865
841
|
end
|
866
842
|
|
867
|
-
def
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
843
|
+
def arrival_airport_zipcode
|
844
|
+
arrival_airport__city_state_zip and
|
845
|
+
arrival_airport__city_state_zip.match(/(\d{5}-\d{4}$|\d{5})$/) and
|
846
|
+
$1
|
847
|
+
end
|
848
|
+
|
849
|
+
def fuel_expense
|
850
|
+
flight_log_expenses.find{|expense| expense.type == 1}
|
851
|
+
end
|
852
|
+
|
853
|
+
def departure_diff_in_minutes
|
854
|
+
(leg_status == "VERI" or leg_status == "FLOG") ? ((actual_departure_date_time_local - planned_departure_date_time_local)*1440).to_i : nil
|
873
855
|
end
|
874
856
|
|
875
|
-
def
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
857
|
+
def arrival_diff_in_minutes
|
858
|
+
(leg_status == "VERI" or leg_status == "FLOG") ? ((actual_arrival_date_time_local - planned_arrival_date_time_local)*1440).to_i : nil
|
859
|
+
end
|
860
|
+
|
861
|
+
def leg_class
|
862
|
+
my_class = case aircraft_type_id
|
863
|
+
when 'C750' then 'C750'
|
864
|
+
when 'CL30' then 'CL30'
|
865
|
+
# when 'Managed' then 'Managed' #TODO There is no way to know if the plane is managed other than being given specific tail numbers
|
866
|
+
when 'PRM1' then 'Premier'
|
867
|
+
when 'BE35' then 'King Air'
|
868
|
+
else 'NA'
|
880
869
|
end
|
881
|
-
|
870
|
+
|
871
|
+
my_class = 'NA' if (aircraft__owner_name =~ /xojet/i) == nil
|
872
|
+
my_class
|
873
|
+
end
|
874
|
+
|
875
|
+
def fuel_expenses
|
876
|
+
flight_log_expenses.find_all {|expense| expense.type == 1}
|
882
877
|
end
|
883
878
|
end
|
data/lib/sequel/model_patch.rb
CHANGED
@@ -8,11 +8,24 @@ class Sequel::Model
|
|
8
8
|
# Passing in an array of attribute / method names, fills a hash with values from
|
9
9
|
# the model. Can pass in attributes with __ like :passenger__name and the 'name'
|
10
10
|
# value will be delegated to 'passenger' with the delegator being created on the fly.
|
11
|
+
# Can also pass in a hash of attributes, with the key being the key you want
|
12
|
+
# for the hash and the value being the value you want from the model. So you could
|
13
|
+
# pass in {:pax_name=>:passenger__name} and the hash returned will be {:pax_name=>'Bob'}
|
11
14
|
def fill_hash(attributes)
|
12
|
-
attributes.
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
if attributes.is_a? Array
|
16
|
+
attributes.inject({}) do |hash, attribute|
|
17
|
+
attribute_name = attribute.to_s.gsub('__', '_').to_sym
|
18
|
+
generate_delegator(attribute) unless respond_to? attribute_name
|
19
|
+
hash[attribute_name] = send(attribute_name) if respond_to? attribute_name
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
elsif attributes.is_a? Hash
|
23
|
+
hash = {}
|
24
|
+
attributes.each do |key, attribute|
|
25
|
+
attribute_name = attribute.to_s.gsub('__', '_').to_sym
|
26
|
+
generate_delegator(attribute) unless respond_to? attribute_name
|
27
|
+
hash[key] = send(attribute_name) if respond_to? attribute_name
|
28
|
+
end
|
16
29
|
hash
|
17
30
|
end
|
18
31
|
end
|
@@ -37,7 +37,7 @@ describe TripLeg do
|
|
37
37
|
arr_date_act_gmt = Date.new(1900, 1, 2)
|
38
38
|
arriv_time_act_gmt = 1420
|
39
39
|
home_tz_gmt_offset = -70
|
40
|
-
tl = TripLeg.new(:
|
40
|
+
tl = TripLeg.new(:arrival_date_gmt => arr_date_act_gmt.to_fos_days, :arriv_time_act_gmt => arriv_time_act_gmt,
|
41
41
|
:home_tz_gmt_offset => home_tz_gmt_offset)
|
42
42
|
tl.actual_arrival_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
|
43
43
|
end
|
@@ -139,162 +139,187 @@ describe TripLeg do
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
#
|
147
|
-
trip_leg = TripLeg.
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
:"qty
|
167
|
-
:"qty
|
168
|
-
:"qty
|
169
|
-
:"qty
|
170
|
-
:"qty
|
171
|
-
:"qty
|
172
|
-
:"qty
|
173
|
-
:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
@tl.
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
@tl.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
@tl.
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
@tl.
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
@tl.
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
@tl.
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
@tl
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
it "
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
:"qty
|
255
|
-
:
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
:"qty
|
283
|
-
:"qty
|
284
|
-
:"qty
|
285
|
-
:"qty
|
286
|
-
:
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
tl
|
293
|
-
|
294
|
-
|
295
|
-
tl.
|
296
|
-
|
297
|
-
|
298
|
-
|
142
|
+
## NEED TO REMOVE, TESTS SHOULD BE IN FlightLogExpense spec
|
143
|
+
# describe "fuel passdown data columns" do
|
144
|
+
#
|
145
|
+
# it "query fuel info from real trip leg actually works" do
|
146
|
+
# set_fos_db([TripLeg,AirportFuel,AirportFbo,FlightLogExpense])
|
147
|
+
## trip_leg = TripLeg.first(:trip_number=>67579,:leg_number=>3)
|
148
|
+
# trip_leg = TripLeg.first(:trip_number=>79203,:leg_number=>1)
|
149
|
+
## trip_leg = TripLeg.select(:'trip legs__trip_number').
|
150
|
+
## filter(:trip_number=>67579,:leg_number=>3).
|
151
|
+
## inner_join(:flight_log_expense,)
|
152
|
+
## first
|
153
|
+
## p trip_leg.trip_number
|
154
|
+
# trip_leg.dept_fuel_quantity.should == 433
|
155
|
+
# trip_leg.dept_fuel_cost.should == 1437.56
|
156
|
+
# trip_leg.dept_fuel_rate.should == 3.32
|
157
|
+
# trip_leg.arr_fuel_quantity.should == 0
|
158
|
+
# trip_leg.arr_fuel_cost.should == 0
|
159
|
+
# trip_leg.arr_fuel_rate.should == 0
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# describe "with airport fuel data" do
|
163
|
+
# before :each do
|
164
|
+
# #expect the method airport_fuel_lookup to be called and return a prepopulated hash
|
165
|
+
# hash_with_airport_fuel = {:"qty 1"=>1, :"cost 1"=>393,
|
166
|
+
# :"qty 2"=>1000, :"cost 2"=>373,
|
167
|
+
# :"qty 3"=>2000, :"cost 3"=>362,
|
168
|
+
# :"qty 4"=>0, :"cost 4"=>0,
|
169
|
+
# :"qty 5"=>0, :"cost 5"=>0,
|
170
|
+
# :"qty 6"=>0, :"cost 6"=>0,
|
171
|
+
# :"qty 7"=>0, :"cost 7"=>0,
|
172
|
+
# :"qty 8"=>0, :"cost 8"=>0,
|
173
|
+
# :"qty 9"=>0, :"cost 9"=>0,
|
174
|
+
# :"qty 10"=>0, :"cost 10"=>0,
|
175
|
+
# :quantity=>970}
|
176
|
+
# fe = FlightLogExpense.new(:type => 1,:arrival_airport => 0, :quantity => 970)
|
177
|
+
# @tl = TripLeg.new
|
178
|
+
# mock(@tl).airport_fuel_lookup(is_a(String)) {hash_with_airport_fuel}
|
179
|
+
# stub(@tl).fuel_expense {fe}
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# it "fuel quantity for leg with airport fuel" do
|
183
|
+
# @tl.dept_fuel_quantity.should == 970
|
184
|
+
# @tl.arr_fuel_quantity.should == 0
|
185
|
+
# end
|
186
|
+
#
|
187
|
+
# it "fuel rate for leg with airport fuel" do
|
188
|
+
# @tl.dept_fuel_rate.should == 3.93
|
189
|
+
# @tl.arr_fuel_rate.should == 0
|
190
|
+
# end
|
191
|
+
#
|
192
|
+
# it "fuel cost for leg with airport fuel" do
|
193
|
+
# @tl.dept_fuel_cost.to_s.should == "3812.1"
|
194
|
+
# @tl.arr_fuel_cost.to_s.should == "0"
|
195
|
+
# end
|
196
|
+
# end
|
197
|
+
#
|
198
|
+
# describe "without airport fuel data" do
|
199
|
+
# before :each do
|
200
|
+
# #expect the method airport_fuel_lookup to be called and return a prepopulated hash
|
201
|
+
# hash_without_airport_fuel = {:quantity=>970}
|
202
|
+
# @tl = TripLeg.new
|
203
|
+
# fe = FlightLogExpense.new(:type => 1,:arrival_airport => 0, :quantity => 970)
|
204
|
+
# mock(@tl).airport_fuel_lookup(is_a(String)) {hash_without_airport_fuel}
|
205
|
+
# stub(@tl).fuel_expense {fe}
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
# it "fuel quantity for leg without airport fuel" do
|
209
|
+
# @tl.dept_fuel_quantity.should == 970
|
210
|
+
# @tl.arr_fuel_quantity.should == 0
|
211
|
+
# end
|
212
|
+
#
|
213
|
+
# it "fuel rate for leg without airport fuel" do
|
214
|
+
# @tl.dept_fuel_rate.should == 0
|
215
|
+
# @tl.arr_fuel_rate.should == 0
|
216
|
+
# end
|
217
|
+
#
|
218
|
+
# it "fuel cost for leg without airport fuel" do
|
219
|
+
# @tl.dept_fuel_cost.should == 0
|
220
|
+
# @tl.arr_fuel_cost.should == 0
|
221
|
+
# end
|
222
|
+
# end
|
223
|
+
# end
|
224
|
+
#
|
225
|
+
# describe "without any data at all" do
|
226
|
+
# before :each do
|
227
|
+
## hash_without_any_data = nil
|
228
|
+
# @tl = TripLeg.new
|
229
|
+
# fe = nil
|
230
|
+
## mock(@tl).airport_fuel_lookup(is_a(String)) {hash_without_any_data}
|
231
|
+
# stub(@tl).fuel_expense {fe}
|
232
|
+
# end
|
233
|
+
#
|
234
|
+
# it "fuel quantity for leg without any data" do
|
235
|
+
# @tl.dept_fuel_quantity.should == 0
|
236
|
+
# @tl.arr_fuel_quantity.should == 0
|
237
|
+
# end
|
238
|
+
#
|
239
|
+
# it "fuel rate for leg without any data" do
|
240
|
+
# @tl.dept_fuel_rate.should == 0
|
241
|
+
# @tl.arr_fuel_rate.should == 0
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# it "fuel cost for leg without any data" do
|
245
|
+
# @tl.dept_fuel_cost.should == 0
|
246
|
+
# @tl.arr_fuel_cost.should == 0
|
247
|
+
# end
|
248
|
+
# end
|
249
|
+
#
|
250
|
+
# # FUEL PASSDOWN SPECS
|
251
|
+
# describe "different tier pricing selection" do
|
252
|
+
# it "has fuel qty <= second lowest tier" do
|
253
|
+
# fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
|
254
|
+
# :"qty 2"=>1000, :"cost 2"=>373,
|
255
|
+
# :"qty 3"=>2000, :"cost 3"=>362,
|
256
|
+
# :"qty 4"=>0, :"cost 4"=>0,
|
257
|
+
# :"qty 5"=>0, :"cost 5"=>0,
|
258
|
+
# :"qty 6"=>0, :"cost 6"=>0,
|
259
|
+
# :"qty 7"=>0, :"cost 7"=>0,
|
260
|
+
# :"qty 8"=>0, :"cost 8"=>0,
|
261
|
+
# :"qty 9"=>0, :"cost 9"=>0,
|
262
|
+
# :"qty 10"=>0, :"cost 10"=>0,
|
263
|
+
# :quantity=>970}
|
264
|
+
# tl = TripLeg.new
|
265
|
+
# fe = FlightLogExpense.new(:type => 1,:arrival_airport => 0, :quantity => 970)
|
266
|
+
# mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
|
267
|
+
# stub(tl).fuel_expense {fe}
|
268
|
+
# tl.dept_fuel_cost.to_s.should == "3812.1"
|
269
|
+
#
|
270
|
+
# fe.arrival_airport = 1
|
271
|
+
# stub(tl).fuel_expense {fe}
|
272
|
+
# tl.arr_fuel_cost.to_s.should == "3812.1"
|
273
|
+
# end
|
274
|
+
#
|
275
|
+
# it "has fuel qty >= highest tier" do
|
276
|
+
# fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
|
277
|
+
# :"qty 2"=>1000, :"cost 2"=>373,
|
278
|
+
# :"qty 3"=>2000, :"cost 3"=>362,
|
279
|
+
# :"qty 4"=>3000, :"cost 4"=>352,
|
280
|
+
# :"qty 5"=>4000, :"cost 5"=>342,
|
281
|
+
# :"qty 6"=>5000, :"cost 6"=>332,
|
282
|
+
# :"qty 7"=>6000, :"cost 7"=>322,
|
283
|
+
# :"qty 8"=>7000, :"cost 8"=>312,
|
284
|
+
# :"qty 9"=>8000, :"cost 9"=>302,
|
285
|
+
# :"qty 10"=>9000, :"cost 10"=>292,
|
286
|
+
# :quantity=>10000}
|
287
|
+
# tl = TripLeg.new
|
288
|
+
# fe = FlightLogExpense.new(:type => 1,:arrival_airport => 0, :quantity=>10000)
|
289
|
+
# mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
|
290
|
+
# stub(tl).fuel_expense {fe}
|
291
|
+
#
|
292
|
+
# tl.dept_fuel_cost.should == 29200
|
293
|
+
#
|
294
|
+
# fe.arrival_airport = 1
|
295
|
+
# stub(tl).fuel_expense {fe}
|
296
|
+
# tl.arr_fuel_cost.should == 29200
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
# it "has fuel qty in the middle of fuel tiers" do
|
300
|
+
# fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
|
301
|
+
# :"qty 2"=>1000, :"cost 2"=>373,
|
302
|
+
# :"qty 3"=>2000, :"cost 3"=>362,
|
303
|
+
# :"qty 4"=>0, :"cost 4"=>0,
|
304
|
+
# :"qty 5"=>0, :"cost 5"=>0,
|
305
|
+
# :"qty 6"=>0, :"cost 6"=>0,
|
306
|
+
# :"qty 7"=>0, :"cost 7"=>0,
|
307
|
+
# :"qty 8"=>0, :"cost 8"=>0,
|
308
|
+
# :"qty 9"=>0, :"cost 9"=>0,
|
309
|
+
# :"qty 10"=>0, :"cost 10"=>0,
|
310
|
+
# :quantity=>1100}
|
311
|
+
# tl = TripLeg.new
|
312
|
+
# fe = FlightLogExpense.new(:type => 1,:arrival_airport => 0, :quantity=>1100)
|
313
|
+
# mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
|
314
|
+
# stub(tl).fuel_expense {fe}
|
315
|
+
#
|
316
|
+
# tl.dept_fuel_cost.should == 4103
|
317
|
+
#
|
318
|
+
# fe.arrival_airport = 1
|
319
|
+
# stub(tl).fuel_expense {fe}
|
320
|
+
# tl.arr_fuel_cost.should == 4103
|
321
|
+
# end
|
322
|
+
# end
|
323
|
+
# END FUEL PASSDOWN RELATED TESTS ####
|
299
324
|
end
|
300
325
|
|
@@ -5,11 +5,16 @@ describe "Sequel::Model extentions" do
|
|
5
5
|
|
6
6
|
describe "fill_hash method" do
|
7
7
|
|
8
|
-
it "works with attributes" do
|
8
|
+
it "works with attributes as array" do
|
9
9
|
Dude.first.should respond_to(:fill_hash)
|
10
10
|
Dude.first.fill_hash([:'kid - date']).should == {:'kid - date'=>1}
|
11
11
|
end
|
12
12
|
|
13
|
+
it "works with attributes as hash" do
|
14
|
+
Dude.first.should respond_to(:fill_hash)
|
15
|
+
Dude.first.fill_hash({:date=>:'kid - date'}).should == {:date=>1}
|
16
|
+
end
|
17
|
+
|
13
18
|
it "works with methods" do
|
14
19
|
Dude.column_alias :doo, :'kid - date'
|
15
20
|
Dude.first.fill_hash([:doo]).should == {:doo=>1}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 18
|
9
|
+
version: 0.4.18
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Patrick Lardin, Daniel Sudol
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|