mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
[bug] stripe subscription generation fails if the user already has a subscription
This commit is contained in:
parent
4c313d180b
commit
07017e4a49
@ -3,6 +3,7 @@
|
||||
- Fix a bug: unable to export members list if no subscriptions was taken
|
||||
- Fix a bug: most OpenAPI endpoints were dysfunctional
|
||||
- Fix a bug: unable to open some modals when the logo was undefined
|
||||
- Fix a bug: stripe subscription generation fails if the user already has a subscription
|
||||
|
||||
## v5.0.6 2021 June 21
|
||||
|
||||
|
@ -63,7 +63,7 @@ class PDF::PaymentSchedule < Prawn::Document
|
||||
align: :right,
|
||||
inline_format: true
|
||||
name = full_name
|
||||
subscription = payment_schedule.payment_schedule_objects.find(&:subscription).subscription
|
||||
subscription = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.subscription
|
||||
|
||||
# object
|
||||
move_down 25
|
||||
|
@ -38,7 +38,7 @@ class CartService
|
||||
|
||||
def from_payment_schedule(payment_schedule)
|
||||
@customer = payment_schedule.user
|
||||
plan = payment_schedule.payment_schedule_objects.find(&:subscription)&.subscription&.plan
|
||||
plan = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }&.subscription&.plan
|
||||
|
||||
coupon = CartItem::Coupon.new(@customer, @operator, payment_schedule.coupon&.code)
|
||||
schedule = CartItem::PaymentSchedule.new(plan, coupon, true)
|
||||
|
@ -162,7 +162,7 @@ class PaymentScheduleService
|
||||
item.update_attributes(state: 'canceled')
|
||||
end
|
||||
# cancel subscription
|
||||
subscription = payment_schedule.payment_schedule_objects.find(&:subscription).subscription
|
||||
subscription = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.subscription
|
||||
subscription.expire(DateTime.current)
|
||||
|
||||
subscription.canceled_at
|
||||
@ -181,7 +181,7 @@ class PaymentScheduleService
|
||||
}
|
||||
|
||||
# the subscription and reservation items
|
||||
subscription = payment_schedule_item.payment_schedule.payment_schedule_objects.find(&:subscription).subscription
|
||||
subscription = payment_schedule_item.payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.subscription
|
||||
if payment_schedule_item.payment_schedule.main_object.object_type == Reservation.name
|
||||
details[:reservation] = payment_schedule_item.details['other_items']
|
||||
reservation = payment_schedule_item.payment_schedule.main_object.reservation
|
||||
@ -200,7 +200,7 @@ class PaymentScheduleService
|
||||
##
|
||||
def complete_next_invoice(payment_schedule_item, invoice)
|
||||
# the subscription item
|
||||
subscription = payment_schedule_item.payment_schedule.payment_schedule_objects.find(&:subscription).subscription
|
||||
subscription = payment_schedule_item.payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.subscription
|
||||
|
||||
# sub-price for the subscription
|
||||
details = { subscription: payment_schedule_item.details['recurring'] }
|
||||
|
@ -14,7 +14,7 @@ class Stripe::Service < Payment::Service
|
||||
|
||||
case payment_schedule.main_object.object_type
|
||||
when Reservation.name
|
||||
subscription = payment_schedule.payment_schedule_objects.find(&:subscription).object
|
||||
subscription = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.object
|
||||
reservable_stp_id = payment_schedule.main_object.object.reservable&.payment_gateway_object&.gateway_object_id
|
||||
when Subscription.name
|
||||
subscription = payment_schedule.main_object.object
|
||||
|
@ -787,7 +787,7 @@ class Reservations::CreateTest < ActionDispatch::IntegrationTest
|
||||
# Check the answer
|
||||
result = json_response(response.body)
|
||||
assert_equal payment_schedule.id, result[:id], 'payment schedule id does not match'
|
||||
subscription = payment_schedule.payment_schedule_objects.find(&:subscription).object
|
||||
subscription = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.object
|
||||
assert_equal plan.id, subscription.plan_id, 'subscribed plan does not match'
|
||||
end
|
||||
|
||||
@ -909,7 +909,7 @@ class Reservations::CreateTest < ActionDispatch::IntegrationTest
|
||||
# Check the answer
|
||||
result = json_response(response.body)
|
||||
assert_equal payment_schedule.id, result[:id], 'payment schedule id does not match'
|
||||
subscription = payment_schedule.payment_schedule_objects.find(&:subscription).object
|
||||
subscription = payment_schedule.payment_schedule_objects.find { |pso| pso.object_type == Subscription.name }.object
|
||||
assert_equal plan.id, subscription.plan_id, 'subscribed plan does not match'
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user