effective_products 0.3.6 → 0.3.8

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: 006c2b27675ae29a8501335d6871b82c4fc620d506735742507f32959b6480dd
4
- data.tar.gz: ba32bd1465cbd5b74415afb6f4e51712486190c02917915d05002251e8ad9fc6
3
+ metadata.gz: 8126cdc9fd87848c7da280fb0e2ecc23cd4c83beb1f5efbb07aa2b0d7ebdbb1f
4
+ data.tar.gz: 71481f64c82b4a422bfc7b348e286cf8099c50adf6b897774e3a4ea76890f43e
5
5
  SHA512:
6
- metadata.gz: 7332f32313fe53a91d3fee09f05e324ecf3261a43ae2a7055b0297fc474f0a81ccccf47c358e6b2879b6024b9e92a5096c7e76de5757a8dde4de6833ae0fabf0
7
- data.tar.gz: e1658a2f562c294c0e8b3f434118449752e2c61d5b4750ef74dc7280f6162e7312e570c6821f690f219cd96e3fed6655234c51f20e67919280bf2e17667cb892
6
+ metadata.gz: b4c894fff91b9dc09933d3ed0d461c7698f33f5f8f45ed964ec07d622a7a78bf42650cc9a283522984f7a6e1df7bb705ea3a4fed4310ada9c6828128c688e753
7
+ data.tar.gz: 36ebdab52e77a293f8f5905a6cb1b0a531442bdb5f7303d57937c452d09a0fd650663c6a5042f19f50271a8c816312391a9b5ae124ebf3696b4da08d7c28fb03
@@ -134,6 +134,10 @@ module EffectiveProductsStampWizard
134
134
  save!
135
135
  end
136
136
 
137
+ def stamp_categories
138
+ EffectiveProducts.stamp_categories
139
+ end
140
+
137
141
  private
138
142
 
139
143
  def present_stamps
@@ -72,15 +72,15 @@ module Effective
72
72
  validates :shipping_address, presence: true, unless: -> { category == 'Digital-only' }
73
73
 
74
74
  validate(if: -> { name.present? && name_confirmation.present? }) do
75
- self.errors.add(:name_confirmation, "doesn't match name") unless name == name_confirmation
75
+ errors.add(:name_confirmation, "doesn't match name") unless name == name_confirmation
76
76
  end
77
77
 
78
78
  validate(if: -> { category.present? }) do
79
- self.errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
79
+ errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
80
80
  end
81
81
 
82
82
  validate(if: -> { admin_action }) do
83
- self.errors.add(:owner_id, "must have a membership") unless owner && owner.try(:membership).present?
83
+ errors.add(:owner_id, "must have a membership") unless owner && owner.try(:membership).present?
84
84
  end
85
85
 
86
86
  def to_s
@@ -114,19 +114,25 @@ module Effective
114
114
 
115
115
  # This is the Admin Save and Mark Paid action
116
116
  def mark_paid!
117
- update!(admin_action: true) # Make sure we have an owner with a membership
118
- raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
117
+ assign_attributes(admin_action: true)
119
118
 
120
- category = owner.membership.categories.first
119
+ category = owner&.membership&.categories&.first
121
120
 
122
- assign_attributes(
123
- price: category.stamp_fee,
124
- tax_exempt: category.stamp_fee_tax_exempt,
125
- qb_item_name: category.stamp_fee_qb_item_name
126
- )
121
+ if category.present?
122
+ assign_attributes(
123
+ price: category.stamp_fee,
124
+ tax_exempt: category.stamp_fee_tax_exempt,
125
+ qb_item_name: category.stamp_fee_qb_item_name
126
+ )
127
+ end
127
128
 
128
- submitted!
129
- Effective::Order.new(items: self, user: owner).mark_as_purchased!
129
+ submitted! # Will fail with invalid owner membership anyway
130
+
131
+ if category.present?
132
+ Effective::Order.new(items: self, user: owner).mark_as_purchased!
133
+ end
134
+
135
+ true
130
136
  end
131
137
 
132
138
  end
@@ -14,6 +14,6 @@
14
14
  = fr.hidden_field :owner_id
15
15
  = fr.hidden_field :owner_type
16
16
 
17
- = render('effective/stamps/fields', f: fr)
17
+ = render('effective/stamps/fields', f: fr, parent: resource)
18
18
 
19
19
  = f.save 'Save and Continue'
@@ -4,12 +4,8 @@
4
4
  = f.text_field :name
5
5
  = f.text_field :name_confirmation, hint: 'must match name'
6
6
 
7
- - collection = EffectiveProducts.stamp_categories
8
-
9
- - if collection.length == 1
10
- = f.hidden_field :category, value: collection.first
11
- - else
12
- = f.select :category, collection
7
+ - collection = local_assigns[:parent].try(:stamp_categories) || EffectiveProducts.stamp_categories
8
+ = f.select :category, collection
13
9
 
14
10
  %h4 Shipping address
15
11
  = effective_address_fields(f, :shipping)
@@ -1,3 +1,3 @@
1
1
  module EffectiveProducts
2
- VERSION = '0.3.6'.freeze
2
+ VERSION = '0.3.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_products
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
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: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails