has_accounts 2.1.0 → 3.0.0.beta0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/booking.rb +55 -0
- data/lib/has_accounts/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7536557b72ba28c4867b5e4397b03f8a06d5dfb3
|
4
|
+
data.tar.gz: b73be36ba1905821003318b7a836700c5343538a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d71c0b21006327dcbf25351c3c7ae7d11fba23afaa254138ef45f0a3b064c4d07b9bd33772bb7fc7054e273175afbc013e24e3a69a9dac1baffbf27fd82a9b
|
7
|
+
data.tar.gz: 3379c6d6c3f491728d922247d999f8576366b0295d45cef037db6ff6a6d06c42257e979e95178bda3ef9180e081068c477871d4a1a89b314342b2b03a6713361
|
data/app/models/booking.rb
CHANGED
@@ -75,6 +75,61 @@ class Booking < ActiveRecord::Base
|
|
75
75
|
end
|
76
76
|
}
|
77
77
|
|
78
|
+
# Scope filter for date range
|
79
|
+
scope :by_date_period, lambda {|date_from, date_to|
|
80
|
+
if date_from.present? && date_to.present?
|
81
|
+
where(:value_date => date_from..date_to)
|
82
|
+
elsif date_from.present?
|
83
|
+
where('value_date >= ?', date_from)
|
84
|
+
elsif date_to.present?
|
85
|
+
where('value_date <= ?', date_to)
|
86
|
+
end
|
87
|
+
}
|
88
|
+
|
89
|
+
# Scope for date filter
|
90
|
+
#
|
91
|
+
# @param from [Date]
|
92
|
+
# @param to [Date]
|
93
|
+
scope :by_date, lambda {|*args|
|
94
|
+
dates = args.map do |date|
|
95
|
+
begin
|
96
|
+
date.to_date
|
97
|
+
rescue
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
if dates.count == 0
|
103
|
+
scoped
|
104
|
+
elsif dates.count == 1
|
105
|
+
where(:value_date => dates[0])
|
106
|
+
elsif dates.count == 2
|
107
|
+
by_date_period(dates[0], dates[1])
|
108
|
+
end
|
109
|
+
}
|
110
|
+
|
111
|
+
# Scope for amount range filter
|
112
|
+
scope :by_amount_range, lambda {|amount_from, amount_to|
|
113
|
+
if amount_from.present? && amount_to.present?
|
114
|
+
where(:amount => amount_from..amount_to)
|
115
|
+
elsif amount_from.present?
|
116
|
+
where('amount >= ?', amount_from)
|
117
|
+
elsif amount_to.present?
|
118
|
+
where('amount <= ?', amount_to)
|
119
|
+
end
|
120
|
+
}
|
121
|
+
|
122
|
+
# Scope for amount filter
|
123
|
+
scope :by_amount, lambda {|*args|
|
124
|
+
if args.count == 0
|
125
|
+
scoped
|
126
|
+
elsif args.count == 1
|
127
|
+
where(:amount => args[0])
|
128
|
+
elsif args.count == 2
|
129
|
+
by_amount_range(args[0], args[1])
|
130
|
+
end
|
131
|
+
}
|
132
|
+
|
78
133
|
# Scope for all accounts assigned to account
|
79
134
|
#
|
80
135
|
# @param account_id [Integer]
|
data/lib/has_accounts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_accounts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.beta0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Hürlimann (CyT)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -84,9 +84,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.3.1
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
92
|
rubygems_version: 2.2.2
|
@@ -94,3 +94,4 @@ signing_key:
|
|
94
94
|
specification_version: 4
|
95
95
|
summary: HasAccounts provides models for financial accounting.
|
96
96
|
test_files: []
|
97
|
+
has_rdoc:
|