accountability 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/accountability/order_groups_controller.rb +14 -0
- data/app/models/accountability/account.rb +1 -0
- data/app/models/accountability/application_record.rb +4 -0
- data/app/models/accountability/order_group.rb +4 -0
- data/app/models/accountability/order_item.rb +3 -1
- data/lib/accountability/rails/routes.rb +4 -1
- data/lib/accountability/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea198d3d5114628829df3f4b29e3d33ee1dff1899113b42846704842bd7bfdd8
|
4
|
+
data.tar.gz: 9f9496c534dd51ec485b94f4e6557d3be874e96168f3e7d5b00283ed1397cec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3daace9c9b8bced32115713766b9d5d171210b32ba5ad0969a73c3e3ee77d18be31b3a0d15daa3061870b1954a751462f7d9bf1f048de427e86fad9c13c9dc21
|
7
|
+
data.tar.gz: 595718d2f8de2b35468b016742c96d32cb037aa0498bba29b45d8994cb09c22aad9686255728bd7a4745363f60e911b5c71d59265d48484407bd177510a0c3c1
|
@@ -55,6 +55,16 @@ module Accountability
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def checkout
|
59
|
+
@order_group.assign_account!(helpers.current_account) if @order_group.unassigned?
|
60
|
+
|
61
|
+
if @order_group.checkout!
|
62
|
+
redirect_to after_checkout_path(@order_group), notice: 'Checkout complete'
|
63
|
+
else
|
64
|
+
redirect_back fallback_location: accountability_order_group_path(@order_group), alert: 'Failed to check out'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
58
68
|
private
|
59
69
|
|
60
70
|
def set_order_group
|
@@ -64,5 +74,9 @@ module Accountability
|
|
64
74
|
def order_group_params
|
65
75
|
params.require(:order_group).permit
|
66
76
|
end
|
77
|
+
|
78
|
+
def after_checkout_path(_order_group)
|
79
|
+
accountability_order_groups_path
|
80
|
+
end
|
67
81
|
end
|
68
82
|
end
|
@@ -13,6 +13,7 @@ module Accountability
|
|
13
13
|
has_many :credits, dependent: :destroy
|
14
14
|
has_many :debits, dependent: :destroy
|
15
15
|
has_many :billing_configurations, dependent: :destroy
|
16
|
+
has_one :primary_billing_configuration, -> { order(primary: :desc) }, class_name: 'BillingConfiguration', inverse_of: :account
|
16
17
|
|
17
18
|
enum statement_schedule: %i[end_of_month bi_weekly]
|
18
19
|
|
@@ -12,6 +12,10 @@ class Accountability::ApplicationRecord < ActiveRecord::Base
|
|
12
12
|
|
13
13
|
def validate_validatable_attributes
|
14
14
|
validatable_attribute_names.each do |attribute_name|
|
15
|
+
# This is a fragile, temporary patch for an issue caused by the misuse of class attributes.
|
16
|
+
# TODO: Rework validatable_attributes with isolated variable scope
|
17
|
+
next unless self.respond_to? attribute_name
|
18
|
+
|
15
19
|
attribute = public_send attribute_name
|
16
20
|
|
17
21
|
next if attribute.blank?
|
@@ -29,6 +29,10 @@ module Accountability
|
|
29
29
|
order_items.each(&:accrue_credit!)
|
30
30
|
end
|
31
31
|
|
32
|
+
def raw_total
|
33
|
+
order_items.sum(&:default_price)
|
34
|
+
end
|
35
|
+
|
32
36
|
# The `product` parameter accepts Product, String, and Integer objects
|
33
37
|
def add_item!(product, source_scope: nil)
|
34
38
|
product = Product.find(product) unless product.is_a? Product
|
@@ -37,7 +37,10 @@ module ActionDispatch::Routing
|
|
37
37
|
resources :products, controller: options.dig(:controllers, :products), path: options.dig(:routes, :products)
|
38
38
|
|
39
39
|
resources :order_groups, controller: options.dig(:controllers, :order_groups), path: options.dig(:routes, :order_groups) do
|
40
|
-
member
|
40
|
+
member do
|
41
|
+
post :add_item
|
42
|
+
put :checkout
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accountability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Stowers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_accountability_merchant
|