workarea-admin 3.4.27 → 3.4.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bb83fb982468b7096266c1fead527458334ed164aec727c6376c73348d92d66
4
- data.tar.gz: 729571edf5310fcab460513795bc64b70ecae6b6b7ca791d9e85fa53687ece81
3
+ metadata.gz: d5e5e70ec8db64536691e2c00009ec4cc3fbeafa558d063613272f4e68d9d3a8
4
+ data.tar.gz: fb41f84d15df3ec6e66e5005186916fec71e2e6d59b715a353254fb067edad67
5
5
  SHA512:
6
- metadata.gz: 2f0947f2b9ec42924c63e23fbc1eedca69aba17b80700520177f025b2320b70e9606660c1d5c7f6314de5356f9650d4478bc88c45a655faaba467b75e3c10b91
7
- data.tar.gz: 075dc9b989988f3dd34848a5bb1e6e2b95504ab0b446627a3193c0128efddfe54bacc25c4b85ee90c17544c6868bd592c453260f079dc5e4aba4561ec5c56f18
6
+ metadata.gz: a6dac33cba255d0f435cdfe82510a1bb048bab67b01a39c426441eb85edf362dd7f68be808c9eaa84594d1bb1c8eb79efff56bfce50b1ecd19d40194f66f5e22
7
+ data.tar.gz: 9155090353b2d4b80e7860c4d14892dbcfd3a60ea83b1af751fd8baacb9f96085f234e1c541a301cabded3afea9d03720248e640fec99074496a10e956c06546
@@ -38,12 +38,12 @@ module Workarea
38
38
 
39
39
  def average_price
40
40
  return nil if orders.zero?
41
- (merchandise - discounts) / orders
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) / previous_orders
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.regular')
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= number_to_currency result.regular_price
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)
@@ -43,7 +43,6 @@
43
43
  %th= t('workarea.admin.fields.name')
44
44
  %th.align-center= t('workarea.admin.fields.publishes')
45
45
  %th.align-center= t('workarea.admin.fields.undo_at')
46
- %th.align-center= t('workarea.admin.fields.changes')
47
46
  %th= t('workarea.admin.fields.last_published')
48
47
  %th= t('workarea.admin.fields.updated_at')
49
48
  %tbody
@@ -62,7 +61,6 @@
62
61
  #{local_time_ago(result.undo_at)}
63
62
  - else
64
63
  = t('workarea.admin.releases.index.unscheduled')
65
- %td.align-center= result.changesets_with_releasable.count || 0
66
64
  %td
67
65
  - if result.published_at.present?
68
66
  = local_time_ago(result.published_at)
@@ -1516,7 +1516,6 @@ en:
1516
1516
  category: Category
1517
1517
  category_id: Category
1518
1518
  category_ids: Categories
1519
- changes: Changes
1520
1519
  client_id: Client ID
1521
1520
  code: Code
1522
1521
  compatible_discount_ids: Compatible Discounts
@@ -1644,6 +1643,7 @@ en:
1644
1643
  search_id: Search ID
1645
1644
  search_terms: Search Terms
1646
1645
  searches: Searches
1646
+ sell_price: Sell Price
1647
1647
  send_account_creation_email: Notify Them by Email
1648
1648
  service: Service
1649
1649
  service_code: Service Code
@@ -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(11.6, view_model.average_price)
81
- assert_equal(10, view_model.previous_average_price)
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(11, view_model.average_price)
86
- assert_in_delta(11.666, view_model.previous_average_price)
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.4.27
4
+ version: 3.4.28
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-02-21 00:00:00.000000000 Z
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.4.27
19
+ version: 3.4.28
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.4.27
26
+ version: 3.4.28
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.4.27
33
+ version: 3.4.28
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.4.27
40
+ version: 3.4.28
41
41
  description: Provides site administration functionality for the Workarea Commerce
42
42
  Platform.
43
43
  email:
@@ -1362,6 +1362,7 @@ files:
1362
1362
  - test/view_models/workarea/admin/insights/insights_details_test.rb
1363
1363
  - test/view_models/workarea/admin/insights/product_view_model_test.rb
1364
1364
  - test/view_models/workarea/admin/order_timeline_view_model_test.rb
1365
+ - test/view_models/workarea/admin/pricing_sku_view_model_test.rb
1365
1366
  - test/view_models/workarea/admin/product_images_view_model_test.rb
1366
1367
  - test/view_models/workarea/admin/product_view_model_test.rb
1367
1368
  - test/view_models/workarea/admin/promo_code_view_model_test.rb