c80_shared 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/custom/currency_helper.rb +9 -5
- data/app/helpers/custom/dimension_helper.rb +18 -0
- data/app/helpers/custom/price_helper.rb +29 -0
- data/app/serializers/boat_serializer.rb +331 -0
- data/app/serializers/configs/boats/central_agent/boat_list.rb +26 -0
- data/app/serializers/configs/lease/central_agent/inquiry_list.rb +29 -0
- data/app/serializers/lib/boats/dimensions.rb +26 -0
- data/app/serializers/lib/boats/rent_price_per_season.rb +51 -0
- data/app/serializers/lib/boats/sale_price.rb +17 -0
- data/lib/c80_shared/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb69360e62a37e82a25e04c0f1c58b758f1b08ba9ba1e61f0c37afad5d7514d
|
4
|
+
data.tar.gz: b60b0b9fe9c872a0166d69599f11c0e0820e71e091d1daebeed7a77e8f66c042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f3e67dd585908ff384bcddb985db8407f0b085a030afb19af6ba291659843ce213229d0880d97178db59cadaddb42c33b9d0f38796449e684926779145a9bf
|
7
|
+
data.tar.gz: a36075b8c1aad10b245e4cf3fd53ad435ae4c18cd0488afcabd3a592986f8bf6db9a51da5e44167a8ff11f9ac15f5d4609d3cdd4b0edc06b3d36369bbf106d0f
|
@@ -1,16 +1,20 @@
|
|
1
1
|
module Custom
|
2
2
|
module CurrencyHelper
|
3
|
-
def currency_symbol
|
4
|
-
|
3
|
+
def currency_symbol(currency = nil)
|
4
|
+
currency ||= cookies[:currency]
|
5
|
+
collection_name_by_id(I18n.t('static.currencies', default: ''), currency) || ''
|
5
6
|
end
|
6
7
|
|
7
8
|
def currency_for_label(options = {})
|
8
9
|
options[:prefix] ||= ', '
|
9
10
|
"#{options[:prefix]}#{currency_symbol}"
|
10
11
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
# @param name [Symbol, String] Например: `charter_1_day_high`
|
14
|
+
#
|
15
|
+
def currency_attribute_name name, currency = nil
|
16
|
+
currency ||= cookies[:currency]
|
17
|
+
Currency.attribute_name(currency, name)
|
14
18
|
end
|
15
19
|
|
16
20
|
# 12 USD -> $ 12.00, EUR -> €,...
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Custom
|
2
|
+
module DimensionHelper
|
3
|
+
def dimension_symbol(uom = nil)
|
4
|
+
uom ||= cookies[:dimension]
|
5
|
+
collection_name_by_id(I18n.t('static.dimensions', default: ''), uom) || ''
|
6
|
+
end
|
7
|
+
|
8
|
+
def dimension_for_label options = {}
|
9
|
+
options[:prefix] ||= ', '
|
10
|
+
"#{options[:prefix]}#{dimension_symbol}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def dimension_attribute_name(name, uom = nil)
|
14
|
+
uom ||= cookies[:dimension]
|
15
|
+
Dimension.attribute_name(uom, name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Custom
|
2
|
+
module PriceHelper
|
3
|
+
|
4
|
+
# @param [Boat] object
|
5
|
+
#
|
6
|
+
def price_discount(object, attr)
|
7
|
+
price = object.attributes[currency_attribute_name(attr)]
|
8
|
+
discount = object.attributes["#{attr}_discount"]
|
9
|
+
return '' if price.nil?
|
10
|
+
|
11
|
+
return price if discount.nil?
|
12
|
+
|
13
|
+
price - (price / 100 * discount)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param [Boat] object
|
17
|
+
#
|
18
|
+
def price_format(object, attr, options = {})
|
19
|
+
price = options[:discounted] ? price_discount(object, attr) : object.attributes[currency_attribute_name(attr, options[:currency])]
|
20
|
+
return '' if price.blank?
|
21
|
+
|
22
|
+
unit = currency_symbol options[:currency]
|
23
|
+
price = number_to_currency(price, unit: unit).to_s
|
24
|
+
price = price + options[:postfix] if options[:postfix]
|
25
|
+
price = options[:prefix] + price if options[:prefix]
|
26
|
+
price
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,331 @@
|
|
1
|
+
class BoatSerializer < AbstractSerializer
|
2
|
+
|
3
|
+
class << self
|
4
|
+
def available_attributes
|
5
|
+
%i[
|
6
|
+
charter_1_hour_low_usd
|
7
|
+
charter_1_hour_low_rub
|
8
|
+
charter_1_hour_low_eur
|
9
|
+
charter_1_day_low_usd
|
10
|
+
charter_1_day_low_rub
|
11
|
+
charter_1_day_low_eur
|
12
|
+
charter_1_week_low_usd
|
13
|
+
charter_1_week_low_rub
|
14
|
+
charter_1_week_low_eur
|
15
|
+
charter_1_month_low_usd
|
16
|
+
charter_1_month_low_rub
|
17
|
+
charter_1_month_low_eur
|
18
|
+
charter_1_hour_high_usd
|
19
|
+
charter_1_hour_high_rub
|
20
|
+
charter_1_hour_high_eur
|
21
|
+
charter_1_day_high_usd
|
22
|
+
charter_1_day_high_rub
|
23
|
+
charter_1_day_high_eur
|
24
|
+
charter_1_week_high_usd
|
25
|
+
charter_1_week_high_rub
|
26
|
+
charter_1_week_high_eur
|
27
|
+
charter_1_month_high_usd
|
28
|
+
charter_1_month_high_rub
|
29
|
+
charter_1_month_high_eur
|
30
|
+
sale_price_usd
|
31
|
+
sale_price_rub
|
32
|
+
sale_price_eur
|
33
|
+
id
|
34
|
+
picture_medium_url
|
35
|
+
name
|
36
|
+
builder
|
37
|
+
short_description
|
38
|
+
per_season
|
39
|
+
price
|
40
|
+
price_discount
|
41
|
+
guests_total
|
42
|
+
guest_cabins
|
43
|
+
crew_total
|
44
|
+
built_year
|
45
|
+
refit_year
|
46
|
+
boat_model
|
47
|
+
location_address
|
48
|
+
latitude
|
49
|
+
boat_type_id
|
50
|
+
boat_length_metrics
|
51
|
+
boat_length_metrics_meters
|
52
|
+
boat_length_metrics_ft
|
53
|
+
boat_beam_metrics
|
54
|
+
boat_beam_metrics_ft
|
55
|
+
boat_beam_metrics_meters
|
56
|
+
boat_draft_metrics
|
57
|
+
boat_draft_metrics_ft
|
58
|
+
boat_draft_metrics_meters
|
59
|
+
].freeze
|
60
|
+
end
|
61
|
+
|
62
|
+
def default_opts
|
63
|
+
{
|
64
|
+
uom: 'ft',
|
65
|
+
currency: 'USD',
|
66
|
+
locale: 'en',
|
67
|
+
is_for_rent: true
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
def serialize(model, attributes: available_attributes, opts: {})
|
72
|
+
super(model, attributes: attributes, opts: default_opts.merge(opts))
|
73
|
+
end
|
74
|
+
|
75
|
+
def id(boat)
|
76
|
+
{ id: boat.id }
|
77
|
+
end
|
78
|
+
|
79
|
+
# noinspection RubyResolve
|
80
|
+
def picture_medium_url(boat)
|
81
|
+
url = if boat.boat_photo.present?
|
82
|
+
boat.boat_photo.picture.url(:medium).gsub('\'', ''')
|
83
|
+
else
|
84
|
+
''
|
85
|
+
end
|
86
|
+
|
87
|
+
{ picture_medium_url: url }
|
88
|
+
end
|
89
|
+
|
90
|
+
def name(boat)
|
91
|
+
{ name: boat.name }
|
92
|
+
end
|
93
|
+
|
94
|
+
def builder(boat)
|
95
|
+
{ builder: boat.builder }
|
96
|
+
end
|
97
|
+
|
98
|
+
def short_description(boat)
|
99
|
+
attr = 'short_description_%s' % @opts[:locale]
|
100
|
+
value = boat.send(attr.to_sym) || ''
|
101
|
+
{ short_description: value }
|
102
|
+
end
|
103
|
+
|
104
|
+
# per day, per week; в день, в час, за месяц;
|
105
|
+
def per_season(boat)
|
106
|
+
season_key = ::Lib::Boats::RentPricePerSeason.spot_rentprice_id(boat, @opts[:currency], @opts[:rent_price_id]).gsub(/_low|_high/, '')
|
107
|
+
#=> charter_1_week_low, charter_1_day_high
|
108
|
+
translate = I18n.t("boat.rent_price.per_#{season_key}")
|
109
|
+
value = @opts[:is_for_rent] ? translate : ''
|
110
|
+
|
111
|
+
{ per_season: value }
|
112
|
+
end
|
113
|
+
|
114
|
+
# ₽ 293,885
|
115
|
+
def price(boat)
|
116
|
+
value = if @opts[:is_for_rent]
|
117
|
+
::Lib::Boats::RentPricePerSeason.price(boat, @opts[:currency], @opts[:rent_price_id])
|
118
|
+
else
|
119
|
+
::Lib::Boats::SalePrice.price(boat, @opts[:currency])
|
120
|
+
end
|
121
|
+
|
122
|
+
{ price: value }
|
123
|
+
end
|
124
|
+
|
125
|
+
# 12%
|
126
|
+
def price_discount(boat)
|
127
|
+
value = if @opts[:is_for_rent]
|
128
|
+
::Lib::Boats::RentPricePerSeason.price_discount(boat, @opts[:currency])
|
129
|
+
else
|
130
|
+
::Lib::Boats::SalePrice.price_discount(boat)
|
131
|
+
end
|
132
|
+
{ price_discount: value }
|
133
|
+
end
|
134
|
+
|
135
|
+
def guests_total(boat)
|
136
|
+
{ guests_total: boat.guests_total || '' }
|
137
|
+
end
|
138
|
+
|
139
|
+
def guest_cabins(boat)
|
140
|
+
{ guest_cabins: boat.guest_cabins || '' }
|
141
|
+
end
|
142
|
+
|
143
|
+
def crew_total(boat)
|
144
|
+
{ crew_total: boat.crew_total || '' }
|
145
|
+
end
|
146
|
+
|
147
|
+
def built_year(boat)
|
148
|
+
{ built_year: boat.built_year || '' }
|
149
|
+
end
|
150
|
+
|
151
|
+
def refit_year(boat)
|
152
|
+
value = boat.refit_year || ''
|
153
|
+
{ refit_year: value }
|
154
|
+
end
|
155
|
+
|
156
|
+
def boat_model(boat)
|
157
|
+
{ boat_model: boat.boat_model }
|
158
|
+
end
|
159
|
+
|
160
|
+
def location_address(boat)
|
161
|
+
{ location_address: boat.location_address }
|
162
|
+
end
|
163
|
+
|
164
|
+
def latitude(boat)
|
165
|
+
{ latitude: boat.latitude }
|
166
|
+
end
|
167
|
+
|
168
|
+
def longitude(boat)
|
169
|
+
{ longitude: boat.longitude }
|
170
|
+
end
|
171
|
+
|
172
|
+
def boat_type_id(boat)
|
173
|
+
{ boat_type_id: boat.boat_type_id }
|
174
|
+
end
|
175
|
+
|
176
|
+
def boat_length_metrics(boat)
|
177
|
+
value = ::Lib::Boats::Dimensions.boatlength(boat, @opts[:uom])
|
178
|
+
{ boat_length_metrics: value }
|
179
|
+
end
|
180
|
+
|
181
|
+
def boat_length_metrics_meters(boat)
|
182
|
+
{ boat_length_metrics_meters: boat.boat_length_metrics_meters }
|
183
|
+
end
|
184
|
+
|
185
|
+
def boat_length_metrics_ft(boat)
|
186
|
+
{ boat_length_metrics_ft: boat.boat_length_metrics_ft }
|
187
|
+
end
|
188
|
+
|
189
|
+
def boat_beam_metrics(boat)
|
190
|
+
value = ::Lib::Boats::Dimensions.boatbeam(boat, @opts[:uom])
|
191
|
+
{ boat_beam_metrics: value }
|
192
|
+
end
|
193
|
+
|
194
|
+
def boat_beam_metrics_ft(boat)
|
195
|
+
{ boat_beam_metrics_ft: boat.boat_beam_metrics_ft }
|
196
|
+
end
|
197
|
+
|
198
|
+
def boat_beam_metrics_meters(boat)
|
199
|
+
{ boat_beam_metrics_meters: boat.boat_beam_metrics_meters }
|
200
|
+
end
|
201
|
+
|
202
|
+
def boat_draft_metrics(boat)
|
203
|
+
value = ::Lib::Boats::Dimensions.boatdraft(boat, @opts[:uom])
|
204
|
+
{ boat_draft_metrics: value }
|
205
|
+
end
|
206
|
+
|
207
|
+
def boat_draft_metrics_ft(boat)
|
208
|
+
{ boat_draft_metrics_ft: boat.boat_draft_metrics_ft }
|
209
|
+
end
|
210
|
+
|
211
|
+
def boat_draft_metrics_meters(boat)
|
212
|
+
{ boat_draft_metrics_meters: boat.boat_draft_metrics_meters }
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
# --[low]-----------------------------------------------------------------------------------------------------------
|
217
|
+
|
218
|
+
def charter_1_hour_low_usd(boat)
|
219
|
+
{ charter_1_hour_low_usd: boat.charter_1_hour_low_usd || '' }
|
220
|
+
end
|
221
|
+
|
222
|
+
def charter_1_hour_low_rub(boat)
|
223
|
+
{ charter_1_hour_low_rub: boat.charter_1_hour_low_rub || '' }
|
224
|
+
end
|
225
|
+
|
226
|
+
def charter_1_hour_low_eur(boat)
|
227
|
+
{ charter_1_hour_low_eur: boat.charter_1_hour_low_eur || '' }
|
228
|
+
end
|
229
|
+
|
230
|
+
def charter_1_day_low_usd(boat)
|
231
|
+
{ charter_1_day_low_usd: boat.charter_1_day_low_usd || '' }
|
232
|
+
end
|
233
|
+
|
234
|
+
def charter_1_day_low_rub(boat)
|
235
|
+
{ charter_1_day_low_rub: boat.charter_1_day_low_rub || '' }
|
236
|
+
end
|
237
|
+
|
238
|
+
def charter_1_day_low_eur(boat)
|
239
|
+
{ charter_1_day_low_eur: boat.charter_1_day_low_eur || '' }
|
240
|
+
end
|
241
|
+
|
242
|
+
def charter_1_week_low_usd(boat)
|
243
|
+
{ charter_1_week_low_usd: boat.charter_1_week_low_usd || '' }
|
244
|
+
end
|
245
|
+
|
246
|
+
def charter_1_week_low_rub(boat)
|
247
|
+
{ charter_1_week_low_rub: boat.charter_1_week_low_rub || '' }
|
248
|
+
end
|
249
|
+
|
250
|
+
def charter_1_week_low_eur(boat)
|
251
|
+
{ charter_1_week_low_eur: boat.charter_1_week_low_eur || '' }
|
252
|
+
end
|
253
|
+
|
254
|
+
def charter_1_month_low_usd(boat)
|
255
|
+
{ charter_1_month_low_usd: boat.charter_1_month_low_usd || '' }
|
256
|
+
end
|
257
|
+
|
258
|
+
def charter_1_month_low_rub(boat)
|
259
|
+
{ charter_1_month_low_rub: boat.charter_1_month_low_rub || '' }
|
260
|
+
end
|
261
|
+
|
262
|
+
def charter_1_month_low_eur(boat)
|
263
|
+
{ charter_1_month_low_eur: boat.charter_1_month_low_eur || '' }
|
264
|
+
end
|
265
|
+
|
266
|
+
# --[high]-----------------------------------------------------------------------------------------------------------
|
267
|
+
|
268
|
+
def charter_1_hour_high_usd(boat)
|
269
|
+
{ charter_1_hour_high_usd: boat.charter_1_hour_high_usd || '' }
|
270
|
+
end
|
271
|
+
|
272
|
+
def charter_1_hour_high_rub(boat)
|
273
|
+
{ charter_1_hour_high_rub: boat.charter_1_hour_high_rub || '' }
|
274
|
+
end
|
275
|
+
|
276
|
+
def charter_1_hour_high_eur(boat)
|
277
|
+
{ charter_1_hour_high_eur: boat.charter_1_hour_high_eur || '' }
|
278
|
+
end
|
279
|
+
|
280
|
+
def charter_1_day_high_usd(boat)
|
281
|
+
{ charter_1_day_high_usd: boat.charter_1_day_high_usd || '' }
|
282
|
+
end
|
283
|
+
|
284
|
+
def charter_1_day_high_rub(boat)
|
285
|
+
{ charter_1_day_high_rub: boat.charter_1_day_high_rub || '' }
|
286
|
+
end
|
287
|
+
|
288
|
+
def charter_1_day_high_eur(boat)
|
289
|
+
{ charter_1_day_high_eur: boat.charter_1_day_high_eur || '' }
|
290
|
+
end
|
291
|
+
|
292
|
+
def charter_1_week_high_usd(boat)
|
293
|
+
{ charter_1_week_high_usd: boat.charter_1_week_high_usd || '' }
|
294
|
+
end
|
295
|
+
|
296
|
+
def charter_1_week_high_rub(boat)
|
297
|
+
{ charter_1_week_high_rub: boat.charter_1_week_high_rub || '' }
|
298
|
+
end
|
299
|
+
|
300
|
+
def charter_1_week_high_eur(boat)
|
301
|
+
{ charter_1_week_high_eur: boat.charter_1_week_high_eur || '' }
|
302
|
+
end
|
303
|
+
|
304
|
+
def charter_1_month_high_usd(boat)
|
305
|
+
{ charter_1_month_high_usd: boat.charter_1_month_high_usd || '' }
|
306
|
+
end
|
307
|
+
|
308
|
+
def charter_1_month_high_rub(boat)
|
309
|
+
{ charter_1_month_high_rub: boat.charter_1_month_high_rub || '' }
|
310
|
+
end
|
311
|
+
|
312
|
+
def charter_1_month_high_eur(boat)
|
313
|
+
{ charter_1_month_high_eur: boat.charter_1_month_high_eur || '' }
|
314
|
+
end
|
315
|
+
|
316
|
+
# --[sale]----------------------------------------------------------------------------------------------------------
|
317
|
+
|
318
|
+
def sale_price_usd(boat)
|
319
|
+
{ sale_price_usd: boat.sale_price_usd || '' }
|
320
|
+
end
|
321
|
+
|
322
|
+
def sale_price_rub(boat)
|
323
|
+
{ sale_price_rub: boat.sale_price_rub || '' }
|
324
|
+
end
|
325
|
+
|
326
|
+
def sale_price_eur(boat)
|
327
|
+
{ sale_price_eur: boat.sale_price_eur || '' }
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Configs
|
2
|
+
module Boats
|
3
|
+
module CentralAgent
|
4
|
+
class BoatList
|
5
|
+
# список атрибутов Лодок, которые видны Агенту в списке Лодок
|
6
|
+
def self.attributes
|
7
|
+
%i[
|
8
|
+
id
|
9
|
+
picture_medium_url
|
10
|
+
name
|
11
|
+
builder
|
12
|
+
guests_total
|
13
|
+
guest_cabins
|
14
|
+
crew_total
|
15
|
+
boat_length_metrics
|
16
|
+
built_year
|
17
|
+
boat_model
|
18
|
+
location_address
|
19
|
+
price
|
20
|
+
per_season
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Configs
|
2
|
+
module Lease
|
3
|
+
module CentralAgent
|
4
|
+
class InquiryList
|
5
|
+
# список атрибутов Заявки, которые видны Агенту в списке заявок
|
6
|
+
def self.attributes
|
7
|
+
[
|
8
|
+
:id,
|
9
|
+
:token,
|
10
|
+
:is_skippered,
|
11
|
+
:is_my_price,
|
12
|
+
:my_price,
|
13
|
+
:my_price_currency,
|
14
|
+
:address,
|
15
|
+
:period,
|
16
|
+
:duration,
|
17
|
+
:guests,
|
18
|
+
:kids,
|
19
|
+
:watersports,
|
20
|
+
:need_transfer,
|
21
|
+
:comments,
|
22
|
+
:created_at,
|
23
|
+
:boat_types
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Lib
|
2
|
+
module Boats
|
3
|
+
class Dimensions
|
4
|
+
extend ::Custom::DimensionHelper
|
5
|
+
extend ::Custom::SelectHelper
|
6
|
+
|
7
|
+
# @param [String] uom: ft, meters
|
8
|
+
# @return [String] '78.7 ft', '20 m'
|
9
|
+
#
|
10
|
+
def self.boatlength(boat, uom = nil)
|
11
|
+
attr = dimension_attribute_name(:boat_length_metrics, uom)
|
12
|
+
'%s %s' % [boat.attributes[attr], dimension_symbol(uom)]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.boatbeam(boat, uom = nil)
|
16
|
+
attr = dimension_attribute_name(:boat_beam_metrics, uom)
|
17
|
+
'%s %s' % [boat.attributes[attr], dimension_symbol(uom)]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.boatdraft(boat, uom = nil)
|
21
|
+
attr = dimension_attribute_name(:boat_draft_metrics, uom)
|
22
|
+
'%s %s' % [boat.attributes[attr], dimension_symbol(uom)]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Lib
|
2
|
+
module Boats
|
3
|
+
class RentPricePerSeason
|
4
|
+
extend ::Custom::CurrencyHelper
|
5
|
+
extend ::Custom::PriceHelper
|
6
|
+
extend ::ActionView::Helpers::NumberHelper
|
7
|
+
|
8
|
+
# Вернёт отформатированное минимальное число среди цен на аренду вместе с подписью.
|
9
|
+
# Если у лодки не заполнены цены - вернёт дефлотное значение.
|
10
|
+
# value возвращается, но не используется.
|
11
|
+
#
|
12
|
+
# @return [Hash] { value: String, perseason: String }
|
13
|
+
#
|
14
|
+
def self.min_rentprice(boat, currency)
|
15
|
+
::Dictionaries::BoatCharterAttribute::ALL.map do |attr|
|
16
|
+
{
|
17
|
+
attr: attr.to_s,
|
18
|
+
value: boat.send(currency_attribute_name(attr, currency))
|
19
|
+
}
|
20
|
+
end.delete_if { |el| !el[:value].present? }.sort_by { |el| el[:value] }.first || { attr: 'charter_1_day_high', value: 0 }
|
21
|
+
end
|
22
|
+
|
23
|
+
# Определить столбец, из которого надо взять цену аренды.
|
24
|
+
# Может зависеть от контекста - от того, какой параметр выставлен в поисковой форме.
|
25
|
+
# Если с поисковой формы приходит nil или пустая строка - вернёт дефолтное значение.
|
26
|
+
# Если у лодки не заполнено искомое поле - вернёт дефолтное значение.
|
27
|
+
# Дефолтное значение - вычисляется с помощью min_rent_price
|
28
|
+
#
|
29
|
+
# @param [Symbol, String] rent_price_id Например: charter_1_day_low
|
30
|
+
# @return [String]
|
31
|
+
#
|
32
|
+
def self.spot_rentprice_id(boat, currency = 'USD', rent_price_id = nil)
|
33
|
+
default_id = min_rentprice(boat, currency)[:attr]
|
34
|
+
return default_id unless rent_price_id
|
35
|
+
|
36
|
+
return default_id unless boat.attributes[currency_attribute_name(rent_price_id, currency)].present?
|
37
|
+
|
38
|
+
rent_price_id.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.price(boat, currency = 'USD', rent_price_id = nil)
|
42
|
+
attr = spot_rentprice_id(boat, currency, rent_price_id)
|
43
|
+
price_format(boat, attr, currency: currency)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.price_discount(boat, currency = 'USD')
|
47
|
+
boat.send('%s_discount' % min_rentprice(boat, currency)[:attr])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Lib
|
2
|
+
module Boats
|
3
|
+
class SalePrice
|
4
|
+
extend ::Custom::PriceHelper
|
5
|
+
extend ::Custom::CurrencyHelper
|
6
|
+
extend ::ActionView::Helpers::NumberHelper
|
7
|
+
|
8
|
+
def self.price(boat, currency)
|
9
|
+
price_format(boat, :sale_price, currency: currency)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.price_discount(boat)
|
13
|
+
boat.sale_price_discount
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/c80_shared/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c80_shared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C80609A
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,10 +52,18 @@ files:
|
|
52
52
|
- app/dicts/email_token_subj.rb
|
53
53
|
- app/dicts/rent_skip_type.rb
|
54
54
|
- app/helpers/custom/currency_helper.rb
|
55
|
+
- app/helpers/custom/dimension_helper.rb
|
56
|
+
- app/helpers/custom/price_helper.rb
|
55
57
|
- app/helpers/custom/select_helper.rb
|
56
58
|
- app/helpers/site/time_helper.rb
|
59
|
+
- app/serializers/boat_serializer.rb
|
60
|
+
- app/serializers/configs/boats/central_agent/boat_list.rb
|
61
|
+
- app/serializers/configs/lease/central_agent/inquiry_list.rb
|
57
62
|
- app/serializers/lease/bid_serializer.rb
|
58
63
|
- app/serializers/lease/inquiry_serializer.rb
|
64
|
+
- app/serializers/lib/boats/dimensions.rb
|
65
|
+
- app/serializers/lib/boats/rent_price_per_season.rb
|
66
|
+
- app/serializers/lib/boats/sale_price.rb
|
59
67
|
- bin/console
|
60
68
|
- bin/rails
|
61
69
|
- bin/setup
|