effective_orders 6.1.4 → 6.1.5

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: a0ca6d841db809f3d3779be1189022a110fc684aa5fb5af9ecd8cf46ea629b03
4
+ data.tar.gz: 3687c937ca7240acf02172d7ba239e3b53606d7bc90b61d29274e883458408aa
5
5
  SHA512:
6
- metadata.gz: f95f8037a92ece1208a9637676d2eec45e5a4ba15d593a1b22d6a9befc1323a30e96c96d70eed847a207583abfc6488cee444f74085ef3911aea4cbf8260b37a
7
- data.tar.gz: 78f2caf56e27d306b7a242e6e3a84172a5fcaa01105a6d6516c4da1c8589cd74e7a0513ad4f45f3204461dba8dea39af92691332b2d021eb26821995722dd0d7
6
+ metadata.gz: cefb88bdb77f53fd85905b7e41ac481da3e2b9f8c02fe207bf622f76a2eba83335f80b1d20fef6a8c264564f1bef54382ac46614ed4ab90d57ff7917f874c6e5
7
+ data.tar.gz: dbe3298d7e427ac041a9f42aa6d60d6a1894b07d6b4b66d855b6b02aee4c7ca3a7256dc7526d750bf6aabfcb80cd1d2a6b75e3c03cbd51395d69455ad278f91a
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
@@ -1,7 +1,7 @@
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
6
  filter :start_date, nil, as: :date
7
7
  filter :end_date, nil, as: :date
@@ -0,0 +1,78 @@
1
+ # Revenue: Transactions Grouped By Name
2
+
3
+ module Admin
4
+ class ReportTransactionsGroupedByQbNameDatatable < Effective::Datatable
5
+ filters do
6
+ filter :start_date, nil, as: :date
7
+ filter :end_date, nil, as: :date
8
+ end
9
+
10
+ datatable do
11
+ length 250
12
+
13
+ col :qb_item_name
14
+ col :subtotal, as: :price
15
+ col :tax, as: :price
16
+ col :total, as: :price
17
+
18
+ payment_providers.each do |provider|
19
+ col(provider, as: :price)
20
+ end
21
+
22
+ col :orders_count
23
+
24
+ col :orders
25
+ col :users
26
+
27
+ col :start_date, as: :date, search: false, sort: false, visible: false do
28
+ date_range.begin&.strftime('%F')
29
+ end
30
+
31
+ col :end_date, as: :date, search: false, sort: false, visible: false do
32
+ date_range.end&.strftime('%F')
33
+ end
34
+
35
+ aggregate :total
36
+ end
37
+
38
+ collection do
39
+ start_date = date_range.begin&.strftime('%F')
40
+ end_date = date_range.end&.strftime('%F')
41
+
42
+ orders = Effective::Order.purchased.where(purchased_at: date_range).where('total != 0')
43
+ order_items = Effective::OrderItem.includes(:qb_order_item).where(order_id: orders).includes(:purchasable, order: :user)
44
+
45
+ items = order_items.group_by(&:qb_item_name).map do |name, items|
46
+ row = [
47
+ name,
48
+ items.sum { |item| item.subtotal }.to_i,
49
+ items.sum { |item| item.tax }.to_i,
50
+ items.sum { |item| item.total }.to_i,
51
+ ]
52
+
53
+ row += payment_providers.map do |payment_provider|
54
+ items.sum { |item| (item.order.payment_provider == payment_provider) ? item.total : 0 }.to_i
55
+ end
56
+
57
+ row += [
58
+ items.map(&:order_id).uniq.length,
59
+ items.map { |item| item.order },
60
+ items.map { |item| item.order.user },
61
+ start_date,
62
+ end_date
63
+ ]
64
+
65
+ row
66
+ end
67
+ end
68
+
69
+ def payment_providers
70
+ @payment_providers ||= EffectiveOrders.payment_providers - ['free', 'pretend']
71
+ end
72
+
73
+ def date_range
74
+ @date_range ||= (filters[:start_date].presence)..(filters[:end_date].presence)
75
+ end
76
+
77
+ end
78
+ 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.1.5'.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.1.5
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-02-21 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