workarea-admin 3.5.5 → 3.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/workarea/admin/create_segments_controller.rb +1 -0
- data/app/view_models/workarea/admin/insights/product_view_model.rb +2 -2
- data/app/view_models/workarea/admin/pricing_sku_view_model.rb +49 -0
- data/app/views/workarea/admin/pricing_skus/index.html.haml +2 -4
- data/app/views/workarea/admin/releases/list.html.haml +0 -2
- data/app/views/workarea/admin/reports/timeline.html.haml +1 -1
- data/config/locales/en.yml +1 -0
- data/test/view_models/workarea/admin/insights/product_view_model_test.rb +4 -4
- data/test/view_models/workarea/admin/pricing_sku_view_model_test.rb +72 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8fa975ea8aaf2ec8c71f21118f5a6672be8af2a16221654ee8caef70edf542
|
4
|
+
data.tar.gz: 7aecf7b4a34ccf6f640940302d8c1f66441786457d1cba7d628e37dd2c9d305a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 596fb4fccb2975532e5f7cd53a4b9855cb403a39abf885760f05e99fa86adf900ff1868285d0dc63e48a11b0dba603955727f65b0bfb184ee9d5b936b82ef15b
|
7
|
+
data.tar.gz: 135d270f27bb7fa8cd61b803f5c568278a477e16dfb8dcd0669a4bd334a79937c2269b3e16f7ac7118a9f176f125b95d5c305dd3417d0850a52e057b9462c1dd
|
@@ -38,12 +38,12 @@ module Workarea
|
|
38
38
|
|
39
39
|
def average_price
|
40
40
|
return nil if orders.zero?
|
41
|
-
(merchandise - discounts) /
|
41
|
+
(merchandise - discounts) / units_sold
|
42
42
|
end
|
43
43
|
|
44
44
|
def previous_average_price
|
45
45
|
return nil if previous_orders.zero?
|
46
|
-
(previous_merchandise - previous_discounts) /
|
46
|
+
(previous_merchandise - previous_discounts) / previous_units_sold
|
47
47
|
end
|
48
48
|
|
49
49
|
def average_price_percent_change
|
@@ -16,6 +16,55 @@ module Workarea
|
|
16
16
|
def inventory
|
17
17
|
@inventory ||= Inventory::Sku.where(id: model.id).first
|
18
18
|
end
|
19
|
+
|
20
|
+
# All prices that this SKU will be sold at. Makes a determination
|
21
|
+
# based on whether the price is on sale.
|
22
|
+
#
|
23
|
+
# @return [Array<Workarea::Pricing::Price>]
|
24
|
+
def sell_prices
|
25
|
+
prices.sort_by(&:sell)
|
26
|
+
end
|
27
|
+
|
28
|
+
# The lowest price that this SKU can be purchased for. Dependent
|
29
|
+
# on the current sale state of the SKU.
|
30
|
+
#
|
31
|
+
# @return [Money]
|
32
|
+
def min_price
|
33
|
+
sell_prices.first.sell
|
34
|
+
end
|
35
|
+
|
36
|
+
# The highest regular price set on this SKU.
|
37
|
+
#
|
38
|
+
# @return [Money]
|
39
|
+
def max_price
|
40
|
+
sell_prices.last.sell
|
41
|
+
end
|
42
|
+
|
43
|
+
# Show a price range if the `min_price` and `max_price` are not
|
44
|
+
# the same value.
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
47
|
+
def show_range?
|
48
|
+
min_price != max_price
|
49
|
+
end
|
50
|
+
|
51
|
+
# This SKU is considered "on sale" if it is marked as such, or if
|
52
|
+
# any prices that it contains are marked as such.
|
53
|
+
#
|
54
|
+
# @return [Boolean]
|
55
|
+
def on_sale?
|
56
|
+
model.on_sale? || prices.any?(&:on_sale?)
|
57
|
+
end
|
58
|
+
|
59
|
+
# The price of this SKU as rendered on the index page. Shows a
|
60
|
+
# price range when multiple prices are contained within the SKU,
|
61
|
+
# otherwise it just shows the only sell price available.
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
def sell_price
|
65
|
+
return min_price.format unless show_range?
|
66
|
+
"#{max_price.format} – #{min_price.format}"
|
67
|
+
end
|
19
68
|
end
|
20
69
|
end
|
21
70
|
end
|
@@ -47,8 +47,7 @@
|
|
47
47
|
= label_tag 'select_all', t('workarea.admin.bulk_actions.select_all'), class: 'checkbox__label'
|
48
48
|
%th= t('workarea.admin.fields.sku')
|
49
49
|
%th.align-right= t('workarea.admin.fields.msrp')
|
50
|
-
%th.align-right= t('workarea.admin.fields.
|
51
|
-
%th.align-right= t('workarea.admin.fields.sale_price')
|
50
|
+
%th.align-right= t('workarea.admin.fields.sell_price')
|
52
51
|
%th.align-center= t('workarea.admin.fields.on_sale')
|
53
52
|
%th.align-center= t('workarea.admin.fields.allow_discounting')
|
54
53
|
%th= t('workarea.admin.fields.updated_at')
|
@@ -63,8 +62,7 @@
|
|
63
62
|
= link_to result.id, pricing_sku_path(result)
|
64
63
|
= upcoming_changesets_icon_for(result)
|
65
64
|
%td.align-right= number_to_currency result.msrp
|
66
|
-
%td.align-right=
|
67
|
-
%td.align-right= number_to_currency result.sale_price
|
65
|
+
%td.align-right= result.sell_price
|
68
66
|
%td.align-center= t("workarea.admin.#{result.on_sale?}")
|
69
67
|
%td.align-center= t("workarea.admin.#{result.discountable?}")
|
70
68
|
%td= local_time_ago(result.updated_at)
|
@@ -47,7 +47,6 @@
|
|
47
47
|
= label_tag 'select_all', t('workarea.admin.bulk_actions.select_all'), class: 'checkbox__label'
|
48
48
|
%th= t('workarea.admin.fields.name')
|
49
49
|
%th.align-center= t('workarea.admin.fields.publishes')
|
50
|
-
%th.align-center= t('workarea.admin.fields.changes')
|
51
50
|
%th= t('workarea.admin.fields.last_published')
|
52
51
|
%th= t('workarea.admin.fields.updated_at')
|
53
52
|
%tbody
|
@@ -65,7 +64,6 @@
|
|
65
64
|
#{local_time_ago(result.publish_at)}
|
66
65
|
- else
|
67
66
|
= t('workarea.admin.releases.index.unscheduled')
|
68
|
-
%td.align-center= result.changesets_with_releasable.count || 0
|
69
67
|
%td
|
70
68
|
- if result.published_at.present?
|
71
69
|
= local_time_ago(result.published_at)
|
@@ -42,7 +42,7 @@
|
|
42
42
|
= form_tag report_custom_events_path, method: 'post' do
|
43
43
|
.property
|
44
44
|
= label_tag 'custom_event_name', t('workarea.admin.fields.name'), class: 'property__name'
|
45
|
-
= text_field_tag 'custom_event[name]', nil, class: 'text-box'
|
45
|
+
= text_field_tag 'custom_event[name]', nil, class: 'text-box', required: true
|
46
46
|
.property
|
47
47
|
.box.box--rounded.box--padded
|
48
48
|
= hidden_field_tag 'custom_event[occurred_at]', nil, data: { datetimepicker_field: { inline: true } }
|
data/config/locales/en.yml
CHANGED
@@ -77,13 +77,13 @@ module Workarea
|
|
77
77
|
|
78
78
|
product = create_product(id: 'foo')
|
79
79
|
view_model = ProductViewModel.wrap(product, starts_at: '2018-10-28', ends_at: '2018-10-29')
|
80
|
-
assert_equal(
|
81
|
-
assert_equal(
|
80
|
+
assert_equal(5.8, view_model.average_price)
|
81
|
+
assert_equal(5.0, view_model.previous_average_price)
|
82
82
|
assert_in_delta(15.999, view_model.average_price_percent_change)
|
83
83
|
|
84
84
|
view_model = ProductViewModel.wrap(product, starts_at: '2018-10-29', ends_at: '2018-10-30')
|
85
|
-
assert_equal(
|
86
|
-
assert_in_delta(
|
85
|
+
assert_equal(5.5, view_model.average_price)
|
86
|
+
assert_in_delta(5.833, view_model.previous_average_price)
|
87
87
|
assert_in_delta(-5.714, view_model.average_price_percent_change)
|
88
88
|
end
|
89
89
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Admin
|
5
|
+
class PricingSkuViewModelTest < Workarea::TestCase
|
6
|
+
setup :setup_pricing_sku_and_prices
|
7
|
+
|
8
|
+
def setup_pricing_sku_and_prices
|
9
|
+
@sku = PricingSkuViewModel.wrap(
|
10
|
+
create_pricing_sku(on_sale: true).tap do |sku|
|
11
|
+
sku.prices.create!(
|
12
|
+
regular: 4.to_m,
|
13
|
+
sale: 1.to_m
|
14
|
+
)
|
15
|
+
sku.prices.create!(
|
16
|
+
regular: 3.to_m,
|
17
|
+
sale: 2.to_m
|
18
|
+
)
|
19
|
+
end
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_sell_prices
|
24
|
+
assert_equal(@sku.prices.count, @sku.sell_prices.count)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_min_price
|
28
|
+
assert_equal(1.to_m, @sku.min_price)
|
29
|
+
|
30
|
+
@sku.update!(on_sale: false)
|
31
|
+
|
32
|
+
assert_equal(3.to_m, @sku.min_price)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_max_price
|
36
|
+
assert_equal(2.to_m, @sku.max_price)
|
37
|
+
|
38
|
+
@sku.update!(on_sale: false)
|
39
|
+
|
40
|
+
assert_equal(4.to_m, @sku.max_price)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_show_range?
|
44
|
+
assert(@sku.show_range?)
|
45
|
+
|
46
|
+
@sku.prices.last.destroy!
|
47
|
+
|
48
|
+
refute(@sku.show_range?)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_on_sale?
|
52
|
+
assert(@sku.on_sale?)
|
53
|
+
|
54
|
+
@sku.update!(on_sale: false)
|
55
|
+
|
56
|
+
refute(@sku.on_sale?)
|
57
|
+
|
58
|
+
@sku.prices.first.update!(on_sale: true)
|
59
|
+
|
60
|
+
assert(@sku.on_sale?)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_price
|
64
|
+
assert_match(/.2\.00 – .1\.00/, @sku.sell_price)
|
65
|
+
|
66
|
+
@sku.update!(on_sale: false)
|
67
|
+
|
68
|
+
assert_match(/.4\.00 – .3\.00/, @sku.sell_price)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Crouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea-core
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.5.
|
19
|
+
version: 3.5.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.5.
|
26
|
+
version: 3.5.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: workarea-storefront
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.5.
|
33
|
+
version: 3.5.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.5.
|
40
|
+
version: 3.5.6
|
41
41
|
description: Provides site administration functionality for the Workarea Commerce
|
42
42
|
Platform.
|
43
43
|
email:
|
@@ -1484,6 +1484,7 @@ files:
|
|
1484
1484
|
- test/view_models/workarea/admin/insights/product_view_model_test.rb
|
1485
1485
|
- test/view_models/workarea/admin/insights/segment_view_model_test.rb
|
1486
1486
|
- test/view_models/workarea/admin/order_timeline_view_model_test.rb
|
1487
|
+
- test/view_models/workarea/admin/pricing_sku_view_model_test.rb
|
1487
1488
|
- test/view_models/workarea/admin/product_images_view_model_test.rb
|
1488
1489
|
- test/view_models/workarea/admin/product_rules_preview_view_model_test.rb
|
1489
1490
|
- test/view_models/workarea/admin/product_view_model_test.rb
|