fossil 0.5.41 → 0.5.42
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +1 -1
- data/lib/models/flight_log_expense.rb +15 -6
- data/lib/models/trip_leg.rb +3 -4
- data/lib/support/core_extensions.rb +10 -0
- data/spec/silly_spec.rb +19 -13
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.42
|
data/fossil.gemspec
CHANGED
@@ -156,12 +156,21 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
156
156
|
0.0
|
157
157
|
end
|
158
158
|
|
159
|
-
def
|
160
|
-
expense_type =
|
161
|
-
tl
|
159
|
+
def fuel_passdown_hash
|
160
|
+
expense_type = type_string
|
161
|
+
tl = trip_leg
|
162
|
+
p expense_type
|
163
|
+
p tl
|
164
|
+
p vendor_id
|
165
|
+
p tl.send("#{expense_type}_fuel_vendor")
|
166
|
+
p tl.dep_fuel_vendor
|
167
|
+
p tl.arr_fuel_vendor
|
162
168
|
vendor = tl.send("#{expense_type}_fuel_vendor__company_2")
|
169
|
+
p vendor
|
163
170
|
vendor = tl.send("#{expense_type}_fuel_vendor__company_1") if !vendor or vendor == ""
|
171
|
+
p vendor
|
164
172
|
vendor = tl.send("#{expense_type}_fuel_vendor__vendor_id") if !vendor or vendor == ""
|
173
|
+
p vendor
|
165
174
|
airport = tl.send("#{expense_type}_icao_val")
|
166
175
|
fbo = tl.send("#{expense_type}_fbo__name")
|
167
176
|
aircraft = (tl.aircraft ? tl.tail_number : tl.aircraft_id)
|
@@ -175,9 +184,9 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
175
184
|
:airport => airport,
|
176
185
|
:fbo => fbo,
|
177
186
|
:vendor => vendor,
|
178
|
-
:fuel_rate =>
|
179
|
-
:fuel_quantity =>
|
180
|
-
:fuel_cost =>
|
187
|
+
:fuel_rate => fuel_rate,
|
188
|
+
:fuel_quantity => quantity,
|
189
|
+
:fuel_cost => fuel_cost
|
181
190
|
}
|
182
191
|
end
|
183
192
|
end
|
data/lib/models/trip_leg.rb
CHANGED
@@ -958,11 +958,10 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
958
958
|
trip_legs.each do |leg|
|
959
959
|
leg.fuel_expenses.each do |expense|
|
960
960
|
|
961
|
-
|
962
|
-
|
963
|
-
p fbo_name
|
961
|
+
fbo_name = leg.send( "#{expense.type_string}_fbo__name" )
|
962
|
+
|
964
963
|
if fbo_keys.include?(fbo_name) then # is this an fbo we are looking for?
|
965
|
-
expense_hash =
|
964
|
+
expense_hash = expense.fuel_passdown_hash
|
966
965
|
|
967
966
|
if data.has_key?(fbo_name)
|
968
967
|
data[fbo_name].push(expense_hash)
|
@@ -22,6 +22,10 @@ class Integer
|
|
22
22
|
def in_hundredths
|
23
23
|
self.to_f.in_hundredths
|
24
24
|
end
|
25
|
+
|
26
|
+
def to_currency
|
27
|
+
self.to_f.to_currency
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
class Float
|
@@ -34,6 +38,12 @@ class Float
|
|
34
38
|
val = "#{self/60.0}.#{((100.0*(self.modulo(60.0)))/60.0).to_s.rjust(2, '0')}"
|
35
39
|
BigDecimal.new(val, 2).round(2).to_f
|
36
40
|
end
|
41
|
+
|
42
|
+
def to_currency
|
43
|
+
int, frac = self.round(2).to_s.split('.')
|
44
|
+
num = int.gsub(/(\d)(?=(\d\d\d)+(\d))/, '\\1,')
|
45
|
+
"$#{num}.#{frac}"
|
46
|
+
end
|
37
47
|
end
|
38
48
|
|
39
49
|
class Range
|
data/spec/silly_spec.rb
CHANGED
@@ -2,24 +2,30 @@ require_relative '../lib/fossil'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'pp'
|
4
4
|
|
5
|
-
class Sequel::Model::Associations::OneToManyAssociationReflection
|
6
|
-
# one_to_many associations can only have associated objects if none of
|
7
|
-
# the :keys options have a nil value.
|
8
|
-
def can_have_associated_objects?(obj)
|
9
|
-
!self[:primary_keys].any?{|k| obj.send(k).nil?}
|
10
|
-
end
|
11
|
-
end
|
5
|
+
#class Sequel::Model::Associations::OneToManyAssociationReflection
|
6
|
+
# # one_to_many associations can only have associated objects if none of
|
7
|
+
# # the :keys options have a nil value.
|
8
|
+
# def can_have_associated_objects?(obj)
|
9
|
+
# !self[:primary_keys].any?{|k| obj.send(k).nil?}
|
10
|
+
# end
|
11
|
+
#end
|
12
12
|
|
13
13
|
#DB = Sequel.fos('fosprod', :loggers=>[Logger.new($stdout)])
|
14
|
-
DB = Sequel.fos('fos', :loggers=>[Logger.new($stdout)])
|
14
|
+
#DB = Sequel.fos('fos', :loggers=>[Logger.new($stdout)])
|
15
15
|
#DB = Sequel.fos('demo_company_fos_db')#, :loggers=>[Logger.new($stdout)])
|
16
|
-
|
17
|
-
[CityPair,CityCost].each {|model| model.db = DB}
|
18
|
-
p CityPair.first.city_costs
|
16
|
+
DB = Sequel.fos('flyos', :loggers=>[Logger.new($stdout)])
|
17
|
+
#[CityPair,CityCost].each {|model| model.db = DB}
|
18
|
+
#p CityPair.first.city_costs
|
19
19
|
#p CityPair.first.send('kid - user')
|
20
|
-
#[TripLeg
|
20
|
+
#[TripLeg].each {|model| model.db = DB}
|
21
|
+
p DB.run("UPDATE \"TRIP LEGS\" SET \"NOTE\" = 'hi rob' WHERE (\"TRIP NUMBER\" = 45) AND (\"LEG NUMBER\" = 1)")
|
22
|
+
#p TripLeg.filter(:trip_number=>45,:leg_number=>1).first.note
|
23
|
+
#tl = TripLeg.filter(:trip_number=>45,:leg_number=>1).first
|
24
|
+
#tl.note = "hi tob"
|
25
|
+
#tl.save
|
21
26
|
#[Vendor].each {|model| model.db = DB}
|
22
|
-
#
|
27
|
+
#Aircraft.db = DB
|
28
|
+
#p Aircraft.first
|
23
29
|
#p [AirportFuel.min(:kid_date),AirportFuel.max(:kid_date)]
|
24
30
|
#p [TripLeg.min(:dept_date_gmt),TripLeg.max(:dept_date_gmt)]
|
25
31
|
#p [Date.from_fos_days(TripLeg.min(:dept_date_gmt)).to_s,Date.from_fos_days(TripLeg.max(:dept_date_gmt)).to_s]
|