1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

fix payment method on invoices operated by a manager

This commit is contained in:
Sylvain 2020-05-04 11:36:06 +02:00
parent 881cc97e8d
commit 7640704568
2 changed files with 4 additions and 2 deletions

View File

@ -212,7 +212,8 @@ class Reservation < ApplicationRecord
end
def save_with_payment(operator_profile_id, coupon_code = nil, payment_intent_id = nil)
method = InvoicingProfile.find(operator_profile_id)&.user&.admin? ? nil : 'stripe'
operator = InvoicingProfile.find(operator_profile_id)&.user
method = operator&.admin? || (operator&.manager? && operator != user) ? nil : 'stripe'
build_invoice(
invoicing_profile: user.invoicing_profile,

View File

@ -46,7 +46,8 @@ class Subscription < ApplicationRecord
def generate_invoice(operator_profile_id, coupon_code = nil, payment_intent_id = nil)
coupon_id = nil
total = plan.amount
method = InvoicingProfile.find(operator_profile_id)&.user&.admin? ? nil : 'stripe'
operator = InvoicingProfile.find(operator_profile_id)&.user
method = operator&.admin? || (operator&.manager? && operator != user) ? nil : 'stripe'
unless coupon_code.nil?
@coupon = Coupon.find_by(code: coupon_code)