effective_orders 6.18.4 → 6.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d30ecbd0854168592005b06f14661ded4e48e61a8b4b4a181e652c0c3826cbc
4
- data.tar.gz: 42506cd1c6268406fa3e7cb8802799905d5e10fc0ace73fd4982c7f8500cb9de
3
+ metadata.gz: fe4877e8b611ca4cf5aae18c2f43d0e62a6dc333e76634c74d098efe952199b6
4
+ data.tar.gz: 7fdb4b4fda03ea47a941a032ee320fff2a6f432fd452e596bb2cfae40ed04569
5
5
  SHA512:
6
- metadata.gz: bc88b76583abd395fda539b6a237218f3e625fc88f83c878b0d0d71e114a2002c701aaf574bee9cc179a15fd6d24a9291a642bf66c407c8e729a5783a4fc0595
7
- data.tar.gz: 215adf0b221c134a2925c52ed4312ed1daec375cd0977db3a82464fe35e7bc9dff5c16e613c635faf7191a42398c856a3d9b72eb3cba5ea2085525377109a5d6
6
+ metadata.gz: 35d1d862fc154790c9e03ab1e01cd679340ae2c6da181cb26c6206fbaa6d6e3d1788e2b98516ba204e4e575ad98b12331ce81db0c41f5883fab3ca6ce99d1c70
7
+ data.tar.gz: 468b756bce436cacd7e9132d126edff379f61991dc984cc1ac140dec93750459caa379aedd184c9c5f846770d2566ecf16639c0f2980baa7557acf8746e72c63
@@ -0,0 +1,13 @@
1
+ module Admin
2
+ class ItemNamesController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_orders) }
5
+
6
+ include Effective::CrudController
7
+
8
+ if (config = EffectiveOrders.layout)
9
+ layout(config.kind_of?(Hash) ? config[:admin] : config)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ module Admin
2
+ class EffectiveItemNamesDatatable < Effective::Datatable
3
+ filters do
4
+ scope :unarchived, label: 'All'
5
+ scope :archived
6
+ end
7
+
8
+ datatable do
9
+ order :name
10
+
11
+ col :id, visible: false
12
+ col :name
13
+ col :archived, visible: false
14
+
15
+ actions_col
16
+ end
17
+
18
+ collection do
19
+ Effective::ItemName.all
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module EffectiveActsAsPurchasableHelper
2
+ def acts_as_purchasable_fields(form, options = {})
3
+ raise 'expected a form builder' unless form.respond_to?(:object)
4
+ render('effective/acts_as_purchasable/fields', { form: form }.merge(options))
5
+ end
6
+
7
+ def qb_item_name_field(form, options = {})
8
+ raise 'expected a form builder' unless form.respond_to?(:object)
9
+ raise 'expected an object that responds to qb_item_name' unless form.object.respond_to?(:qb_item_name)
10
+
11
+ collection = Effective::ItemName.unarchived.or(Effective::ItemName.where(name: form.object.qb_item_name.to_s)).sorted.pluck(:name)
12
+
13
+ options = options.reverse_merge(
14
+ label: (EffectiveOrders.quickbooks? ? "Quickbooks #{etd(Effective::ItemName)}" : et(Effective::ItemName)),
15
+ hint: "Can't find the #{etd(Effective::ItemName)} you need? #{link_to('Click here to add one', effective_orders.admin_item_names_path, target: '_blank')}"
16
+ )
17
+
18
+ form.select :qb_item_name, collection, options
19
+ end
20
+
21
+ # This is called on the My Sales Page and is intended to be overridden in the app if needed
22
+ def acts_as_purchasable_path(purchasable, action = :show)
23
+ polymorphic_path(purchasable)
24
+ end
25
+ end
@@ -71,11 +71,6 @@ module EffectiveOrdersHelper
71
71
  end
72
72
  end
73
73
 
74
- # This is called on the My Sales Page and is intended to be overridden in the app if needed
75
- def acts_as_purchasable_path(purchasable, action = :show)
76
- polymorphic_path(purchasable)
77
- end
78
-
79
74
  def order_payment_to_html(order)
80
75
  content_tag(:pre) do
81
76
  raw JSON.pretty_generate(order.payment).html_safe.gsub('\"', '').gsub("[\n\n ]", '[]').gsub("{\n }", '{}')
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # This is a CRUD model to populate the select field to choose qb_item_name on acts_as_purchasable objects.
4
+
5
+ module Effective
6
+ class ItemName < ActiveRecord::Base
7
+ self.table_name = (EffectiveOrders.item_names_table_name || :item_names).to_s
8
+
9
+ acts_as_archived
10
+ log_changes if respond_to?(:log_changes)
11
+
12
+ effective_resource do
13
+ name :string
14
+ archived :boolean
15
+
16
+ timestamps
17
+ end
18
+
19
+ scope :sorted, -> { order(:name) }
20
+
21
+ validates :name, uniqueness: true, presence: true
22
+
23
+ def to_s
24
+ name.presence || model_name.human
25
+ end
26
+
27
+ end
28
+ end
@@ -810,7 +810,7 @@ module Effective
810
810
 
811
811
  # Went from delayed to cheque
812
812
  if delayed_payment? && !delayed_payment_provider?
813
- assign_attributes(delayed_payment: false, delayed_payment_date: nil, delayed_payment_intent: nil, delayed_payment_total: nil)
813
+ assign_attributes(delayed_payment_intent: nil, delayed_payment_total: nil)
814
814
  end
815
815
 
816
816
  if current_user&.email.present?
@@ -90,7 +90,7 @@ module Effective
90
90
  # first or build
91
91
  def qb_item_name
92
92
  raise('expected Effective Quickbooks gem') unless defined?(EffectiveQbSync) || defined?(EffectiveQbOnline)
93
- (qb_order_item || build_qb_order_item(name: purchasable&.qb_item_name)).name
93
+ (qb_order_item || build_qb_order_item(name: purchasable.try(:qb_item_name))).name
94
94
  end
95
95
 
96
96
  end
@@ -0,0 +1,7 @@
1
+ = tabs do
2
+ = tab(item_name) do
3
+ = render '/admin/item_names/form_item_name', item_name: item_name
4
+
5
+ - if item_name.persisted?
6
+ = tab('Logs') do
7
+ = render_datatable(item_name.log_changes_datatable, inline: true, namespace: :admin)
@@ -0,0 +1,4 @@
1
+ = effective_form_with(model: [:admin, item_name], engine: true) do |f|
2
+ = f.text_field :name
3
+ = f.check_box :archived, label: "Yes, this #{etd(f.object)} is archived. It will not be displayed."
4
+ = effective_submit(f)
@@ -13,7 +13,7 @@
13
13
 
14
14
  .col= pf.price_field :price
15
15
 
16
- - if EffectiveOrders.qb_sync? || EffectiveOrders.qb_online?
17
- .col= pf.text_field :qb_item_name, label: 'Quickbooks Item'
16
+ .col
17
+ .mt-4= qb_item_name_field(pf)
18
18
 
19
19
  .col= pf.check_box :tax_exempt, label: "Tax&nbsp;Exempt", title: 'When checked, tax will not be applied to this item'
@@ -0,0 +1,3 @@
1
+ = form.price_field :price
2
+ = qb_item_name_field(form)
3
+ = form.check_box :tax_exempt, label: "Yes, this #{etd(form.object)} is tax exempt"
@@ -2,9 +2,26 @@
2
2
  %h1.effective-heading= @page_title
3
3
 
4
4
  %p.effective-orders-page-content
5
- You have indicated that this order will be paid by #{@order.payment_provider}.
6
- Your order will not be considered purchased until we receive your payment.
7
- Please contact us at your earliest convenience.
5
+ - if @order.delayed? && @order.deferred? && @order.delayed_payment_provider?
6
+ %p
7
+ = succeed('.') do
8
+ - distance = distance_of_time_in_words(Time.zone.now, @order.delayed_payment_date.beginning_of_day)
9
+
10
+ The payment date for this order
11
+
12
+ - if @order.delayed_payment_date_upcoming?
13
+ is in #{distance} from now on #{@order.delayed_payment_date.strftime('%F')}
14
+ - elsif @order.delayed_payment_date_today?
15
+ was today
16
+ - else
17
+ was #{distance} ago on #{@order.delayed_payment_date.strftime('%F')}
18
+
19
+ %p Your existing #{@order.delayed_payment_method} will be charged on the payment date.
20
+
21
+ - elsif @order.deferred?
22
+ You have indicated that this order will be paid by #{@order.payment_provider}.
23
+ Your order will not be considered purchased until we receive your payment.
24
+ Please contact us at your earliest convenience.
8
25
 
9
26
  = render @order
10
27
 
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  EffectiveOrders::Engine.routes.draw do
2
+ acts_as_archived
3
+
2
4
  scope module: 'effective' do
3
5
  resources :orders, except: [:destroy] do
4
6
  member do
@@ -49,6 +51,7 @@ EffectiveOrders::Engine.routes.draw do
49
51
 
50
52
  namespace :admin do
51
53
  resources :customers, only: [:index, :show]
54
+ resources :item_names, except: [:show, :destroy], concerns: :acts_as_archived
52
55
 
53
56
  resources :orders do
54
57
  member do
@@ -110,6 +110,16 @@ class CreateEffectiveOrders < ActiveRecord::Migration[6.0]
110
110
 
111
111
  add_index :customers, :user_id
112
112
 
113
+ create_table :item_names do |t|
114
+ t.string :name
115
+ t.boolean :archived, default: false
116
+
117
+ t.datetime :updated_at
118
+ t.datetime :created_at
119
+ end
120
+
121
+ add_index :item_names, [:name, :archived]
122
+
113
123
  create_table :subscriptions do |t|
114
124
  t.integer :customer_id
115
125
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.18.4'.freeze
2
+ VERSION = '6.19.1'.freeze
3
3
  end
@@ -16,7 +16,7 @@ module EffectiveOrders
16
16
  def self.config_keys
17
17
  [
18
18
  :orders_table_name, :order_items_table_name, :carts_table_name, :cart_items_table_name,
19
- :customers_table_name, :subscriptions_table_name, :products_table_name,
19
+ :customers_table_name, :subscriptions_table_name, :products_table_name, :item_names_table_name,
20
20
  :layout,
21
21
  :orders_collection_scope, :order_tax_rate_method,
22
22
  :obfuscate_order_ids, :use_effective_qb_sync, :use_effective_qb_online,
@@ -212,6 +212,10 @@ module EffectiveOrders
212
212
  use_effective_qb_online && defined?(EffectiveQbOnline)
213
213
  end
214
214
 
215
+ def self.quickbooks?
216
+ use_effective_qb_sync || use_effective_qb_online
217
+ end
218
+
215
219
  def self.surcharge?
216
220
  credit_card_surcharge_percent.to_f > 0.0
217
221
  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.18.4
4
+ version: 6.19.1
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: 2025-01-15 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -202,6 +202,7 @@ files:
202
202
  - app/assets/stylesheets/effective_orders/_cart.scss
203
203
  - app/assets/stylesheets/effective_orders/_order.scss
204
204
  - app/controllers/admin/customers_controller.rb
205
+ - app/controllers/admin/item_names_controller.rb
205
206
  - app/controllers/admin/order_items_controller.rb
206
207
  - app/controllers/admin/order_reports_controller.rb
207
208
  - app/controllers/admin/orders_controller.rb
@@ -226,12 +227,14 @@ files:
226
227
  - app/controllers/effective/subscripter_controller.rb
227
228
  - app/controllers/effective/webhooks_controller.rb
228
229
  - app/datatables/admin/effective_customers_datatable.rb
230
+ - app/datatables/admin/effective_item_names_datatable.rb
229
231
  - app/datatables/admin/effective_orders_datatable.rb
230
232
  - app/datatables/admin/report_payment_providers_datatable.rb
231
233
  - app/datatables/admin/report_transactions_datatable.rb
232
234
  - app/datatables/admin/report_transactions_grouped_by_name_datatable.rb
233
235
  - app/datatables/admin/report_transactions_grouped_by_qb_name_datatable.rb
234
236
  - app/datatables/effective_orders_datatable.rb
237
+ - app/helpers/effective_acts_as_purchasable_helper.rb
235
238
  - app/helpers/effective_carts_helper.rb
236
239
  - app/helpers/effective_deluxe_delayed_helper.rb
237
240
  - app/helpers/effective_deluxe_helper.rb
@@ -249,6 +252,7 @@ files:
249
252
  - app/models/effective/cart_item.rb
250
253
  - app/models/effective/customer.rb
251
254
  - app/models/effective/deluxe_api.rb
255
+ - app/models/effective/item_name.rb
252
256
  - app/models/effective/order.rb
253
257
  - app/models/effective/order_item.rb
254
258
  - app/models/effective/product.rb
@@ -259,6 +263,8 @@ files:
259
263
  - app/views/admin/customers/_actions.html.haml
260
264
  - app/views/admin/customers/index.html.haml
261
265
  - app/views/admin/customers/show.html.haml
266
+ - app/views/admin/item_names/_form.html.haml
267
+ - app/views/admin/item_names/_form_item_name.html.haml
262
268
  - app/views/admin/order_items/index.html.haml
263
269
  - app/views/admin/order_reports/index.html.haml
264
270
  - app/views/admin/orders/_form.html.haml
@@ -269,6 +275,7 @@ files:
269
275
  - app/views/admin/orders/_order_actions.html.haml
270
276
  - app/views/admin/orders/_order_item_fields.html.haml
271
277
  - app/views/admin/orders/checkout.html.haml
278
+ - app/views/effective/acts_as_purchasable/_fields.html.haml
272
279
  - app/views/effective/carts/_cart.html.haml
273
280
  - app/views/effective/carts/_cart_actions.html.haml
274
281
  - app/views/effective/carts/show.html.haml