effective_orders 6.1.4 → 6.2.0

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: 4c1bf14140fc511842bc5dfbfd7f5ef1ad41ef96f027a44ecd6386822cee4978
4
- data.tar.gz: 390d84968bf785bf8690b027812f9c8233cbf6393880b88114310f32a48718f4
3
+ metadata.gz: 2407ab44a43970dfb04a4f9d4c9b8bf089200b3d5db3ce06299cd009f1812507
4
+ data.tar.gz: 3f8d77b5e27af60e1ef37ab48edf2e8b49a82ebdc7df0232292f0d69ea2ec44b
5
5
  SHA512:
6
- metadata.gz: f95f8037a92ece1208a9637676d2eec45e5a4ba15d593a1b22d6a9befc1323a30e96c96d70eed847a207583abfc6488cee444f74085ef3911aea4cbf8260b37a
7
- data.tar.gz: 78f2caf56e27d306b7a242e6e3a84172a5fcaa01105a6d6516c4da1c8589cd74e7a0513ad4f45f3204461dba8dea39af92691332b2d021eb26821995722dd0d7
6
+ metadata.gz: e754e64033aca9541fd069244492ccb66f366c9b66c27d782171a92a23093dbf3e28568ea5acc87e7e02693bb26d5ce6f1f70a2b9809c6f0fe7114c4cca55d68
7
+ data.tar.gz: b562aac96357bfa2549bb828410cf6775a491e08adbe5ef94f983b1da58641ab9ae9eddb6a9c0c69c740fa7cc8816ef28b76d962588cd9b368cbcff2af557e49
data/README.md CHANGED
@@ -364,11 +364,13 @@ In addition to the above, the following permissions allow access to the `/admin`
364
364
  can :admin, :effective_orders # Can access the admin screens
365
365
 
366
366
  can :index, :report_transactions
367
- can :index, :report_grouped_transactions
367
+ can :index, :report_transactions_grouped_by_name
368
+ can :index, :report_transactions_grouped_by_qb_name
368
369
  can :index, :report_payment_providers
369
370
 
370
371
  can :index, Admin::ReportTransactionsDatatable
371
- can :index, Admin::ReportGroupedTransactionsDatatable
372
+ can :index, Admin::ReportTransactionsGroupedByNameDatatable
373
+ can :index, Admin::ReportTransactionsGroupedByQbNameDatatable
372
374
  can :index, Admin::ReportPaymentProvidersDatatable
373
375
  ```
374
376
 
@@ -14,11 +14,20 @@ module Admin
14
14
  render 'index'
15
15
  end
16
16
 
17
- def grouped_transactions
18
- @page_title = 'Revenue: Grouped Transactions'
19
- @datatable = Admin::ReportGroupedTransactionsDatatable.new
17
+ def transactions_grouped_by_name
18
+ @page_title = 'Revenue: Transactions Grouped By Name'
19
+ @datatable = Admin::ReportTransactionsGroupedByNameDatatable.new
20
20
 
21
- authorize! :index, :report_grouped_transactions
21
+ authorize! :index, :report_transactions_grouped_by_name
22
+
23
+ render 'index'
24
+ end
25
+
26
+ def transactions_grouped_by_qb_name
27
+ @page_title = 'Revenue: Transactions Grouped By Quickbooks Name'
28
+ @datatable = Admin::ReportTransactionsGroupedByQbNameDatatable.new
29
+
30
+ authorize! :index, :report_transactions_grouped_by_qb_name
22
31
 
23
32
  render 'index'
24
33
  end
@@ -3,8 +3,7 @@
3
3
  module Admin
4
4
  class ReportPaymentProvidersDatatable < Effective::Datatable
5
5
  filters do
6
- filter :start_date, nil, as: :date
7
- filter :end_date, nil, as: :date
6
+ filter_date_range :current_month
8
7
  end
9
8
 
10
9
  datatable do
@@ -16,11 +15,11 @@ module Admin
16
15
  col :returns, as: :price
17
16
  col :total, as: :price
18
17
 
19
- col :start_date, as: :date, search: false, sort: false, visible: false do
18
+ col :filtered_start_date, as: :date, search: false, sort: false, visible: false do
20
19
  date_range.begin&.strftime('%F')
21
20
  end
22
21
 
23
- col :end_date, as: :date, search: false, sort: false, visible: false do
22
+ col :filtered_end_date, as: :date, search: false, sort: false, visible: false do
24
23
  date_range.end&.strftime('%F')
25
24
  end
26
25
 
@@ -4,8 +4,7 @@ module Admin
4
4
  class ReportTransactionsDatatable < Effective::Datatable
5
5
 
6
6
  filters do
7
- filter :start_date, nil, as: :date
8
- filter :end_date, nil, as: :date
7
+ filter_date_range :current_month
9
8
  end
10
9
 
11
10
  datatable do
@@ -35,11 +34,11 @@ module Admin
35
34
 
36
35
  col :total, as: :price
37
36
 
38
- col :start_date, as: :date, search: false, sort: false, visible: false do
37
+ col :filtered_start_date, as: :date, search: false, sort: false, visible: false do
39
38
  date_range.begin&.strftime('%F')
40
39
  end
41
40
 
42
- col :end_date, as: :date, search: false, sort: false, visible: false do
41
+ col :filtered_end_date, as: :date, search: false, sort: false, visible: false do
43
42
  date_range.end&.strftime('%F')
44
43
  end
45
44
 
@@ -54,10 +53,5 @@ module Admin
54
53
  .where('total != 0')
55
54
  .includes(:user, [order_items: :purchasable])
56
55
  end
57
-
58
- def date_range
59
- @date_range ||= (filters[:start_date].presence)..(filters[:end_date].presence)
60
- end
61
-
62
56
  end
63
57
  end
@@ -1,10 +1,9 @@
1
- # Revenue: Grouped Transactions
1
+ # Revenue: Transactions Grouped By Name
2
2
 
3
3
  module Admin
4
- class ReportGroupedTransactionsDatatable < Effective::Datatable
4
+ class ReportTransactionsGroupedByNameDatatable < Effective::Datatable
5
5
  filters do
6
- filter :start_date, nil, as: :date
7
- filter :end_date, nil, as: :date
6
+ filter_date_range :current_month
8
7
  end
9
8
 
10
9
  datatable do
@@ -24,11 +23,11 @@ module Admin
24
23
  col :orders
25
24
  col :users
26
25
 
27
- col :start_date, as: :date, search: false, sort: false, visible: false do
26
+ col :filtered_start_date, as: :date, search: false, sort: false, visible: false do
28
27
  date_range.begin&.strftime('%F')
29
28
  end
30
29
 
31
- col :end_date, as: :date, search: false, sort: false, visible: false do
30
+ col :filtered_end_date, as: :date, search: false, sort: false, visible: false do
32
31
  date_range.end&.strftime('%F')
33
32
  end
34
33
 
@@ -70,9 +69,5 @@ module Admin
70
69
  @payment_providers ||= EffectiveOrders.payment_providers - ['free', 'pretend']
71
70
  end
72
71
 
73
- def date_range
74
- @date_range ||= (filters[:start_date].presence)..(filters[:end_date].presence)
75
- end
76
-
77
72
  end
78
73
  end
@@ -0,0 +1,73 @@
1
+ # Revenue: Transactions Grouped By Name
2
+
3
+ module Admin
4
+ class ReportTransactionsGroupedByQbNameDatatable < Effective::Datatable
5
+ filters do
6
+ filter_date_range :current_month
7
+ end
8
+
9
+ datatable do
10
+ length 250
11
+
12
+ col :qb_item_name
13
+ col :subtotal, as: :price
14
+ col :tax, as: :price
15
+ col :total, as: :price
16
+
17
+ payment_providers.each do |provider|
18
+ col(provider, as: :price)
19
+ end
20
+
21
+ col :orders_count
22
+
23
+ col :orders
24
+ col :users
25
+
26
+ col :start_date, as: :date, search: false, sort: false, visible: false do
27
+ date_range.begin&.strftime('%F')
28
+ end
29
+
30
+ col :end_date, as: :date, search: false, sort: false, visible: false do
31
+ date_range.end&.strftime('%F')
32
+ end
33
+
34
+ aggregate :total
35
+ end
36
+
37
+ collection do
38
+ start_date = date_range.begin&.strftime('%F')
39
+ end_date = date_range.end&.strftime('%F')
40
+
41
+ orders = Effective::Order.purchased.where(purchased_at: date_range).where('total != 0')
42
+ order_items = Effective::OrderItem.includes(:qb_order_item).where(order_id: orders).includes(:purchasable, order: :user)
43
+
44
+ items = order_items.group_by(&:qb_item_name).map do |name, items|
45
+ row = [
46
+ name,
47
+ items.sum { |item| item.subtotal }.to_i,
48
+ items.sum { |item| item.tax }.to_i,
49
+ items.sum { |item| item.total }.to_i,
50
+ ]
51
+
52
+ row += payment_providers.map do |payment_provider|
53
+ items.sum { |item| (item.order.payment_provider == payment_provider) ? item.total : 0 }.to_i
54
+ end
55
+
56
+ row += [
57
+ items.map(&:order_id).uniq.length,
58
+ items.map { |item| item.order },
59
+ items.map { |item| item.order.user },
60
+ start_date,
61
+ end_date
62
+ ]
63
+
64
+ row
65
+ end
66
+ end
67
+
68
+ def payment_providers
69
+ @payment_providers ||= EffectiveOrders.payment_providers - ['free', 'pretend']
70
+ end
71
+
72
+ end
73
+ end
data/config/routes.rb CHANGED
@@ -67,7 +67,8 @@ EffectiveOrders::Engine.routes.draw do
67
67
  resources :order_reports, only: [] do
68
68
  collection do
69
69
  get :transactions
70
- get :grouped_transactions
70
+ get :transactions_grouped_by_name
71
+ get :transactions_grouped_by_qb_name
71
72
  get :payment_providers
72
73
  end
73
74
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.1.4'.freeze
2
+ VERSION = '6.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.4
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -208,9 +208,10 @@ files:
208
208
  - app/controllers/effective/webhooks_controller.rb
209
209
  - app/datatables/admin/effective_customers_datatable.rb
210
210
  - app/datatables/admin/effective_orders_datatable.rb
211
- - app/datatables/admin/report_grouped_transactions_datatable.rb
212
211
  - app/datatables/admin/report_payment_providers_datatable.rb
213
212
  - app/datatables/admin/report_transactions_datatable.rb
213
+ - app/datatables/admin/report_transactions_grouped_by_name_datatable.rb
214
+ - app/datatables/admin/report_transactions_grouped_by_qb_name_datatable.rb
214
215
  - app/datatables/effective_orders_datatable.rb
215
216
  - app/helpers/effective_carts_helper.rb
216
217
  - app/helpers/effective_moneris_checkout_helper.rb