effective_orders 6.1.3 → 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: d89c7eaee9322884706dfaacae71335ca4b8284b06ab69459194cb09b523eb53
4
- data.tar.gz: 2c667a68c9e3e68fe764cd3386495698d55c8c86c7d213ce5691e0a35f37821c
3
+ metadata.gz: a0ca6d841db809f3d3779be1189022a110fc684aa5fb5af9ecd8cf46ea629b03
4
+ data.tar.gz: 3687c937ca7240acf02172d7ba239e3b53606d7bc90b61d29274e883458408aa
5
5
  SHA512:
6
- metadata.gz: cadaa028284a3ee34b1cdfefe2165722cec9edd5307771d8c2e7c5f5fa5afff5ccbd3926d0c6a535369b163dd3987eb4be4afef1572aafd5c6367268cb7e9591
7
- data.tar.gz: c5cc2bee6db200d5ba490a61f987b5d00df5c7e7bc78c1bf7bfabb11e536ff2899c4fe1c8be3fef886fb62cfff266aa29b8164a0c3e864b8fa4800437e9ce923
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
@@ -17,6 +17,7 @@ module Effective
17
17
  end
18
18
 
19
19
  acts_as_addressable(billing: { singular: true }, shipping: { singular: true })
20
+ acts_as_reportable if respond_to?(:acts_as_reportable)
20
21
 
21
22
  attr_accessor :terms_and_conditions # Yes, I agree to the terms and conditions
22
23
  attr_accessor :confirmed_checkout # Set on the Checkout Step 1
@@ -85,6 +86,11 @@ module Effective
85
86
  scope :refunds, -> { purchased.where('total < ?', 0) }
86
87
  scope :pending_refunds, -> { not_purchased.where('total < ?', 0) }
87
88
 
89
+ # effective_reports
90
+ def reportable_scopes
91
+ { purchased: nil, not_purchased: nil, deferred: nil, refunds: nil, pending_refunds: nil }
92
+ end
93
+
88
94
  before_validation do
89
95
  self.state ||= EffectiveOrders::PENDING
90
96
  self.state = EffectiveOrders::CONFIRMED if pending? && confirmed_checkout
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.3'.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.3
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: 2022-12-29 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