1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

fixed new reservation process

This commit is contained in:
Sylvain 2020-12-21 12:02:51 +01:00
parent 40c78974b8
commit a4131e4d5c
3 changed files with 9 additions and 6 deletions

View File

@ -61,7 +61,7 @@ class InvoicesService
end
##
# Create a Stripe::Invoice with an associated array of Stripe::InvoiceItem matching the given parameters
# Create an Invoice with an associated array of InvoiceItem matching the given parameters
# @param payment_details {Hash} as generated by Price.compute
# @param operator_profile_id {Number} ID of the user that operates the invoice generation (may be an admin, a manager or the customer himself)
# @param reservation {Reservation} the booking reservation, if any
@ -88,7 +88,7 @@ class InvoicesService
end
##
# Generate an array of {Stripe::InvoiceItem} with the elements in provided reservation, price included.
# Generate an array of {InvoiceItem} with the elements in provided reservation, price included.
# @param invoice {Invoice} the parent invoice
# @param payment_details {Hash} as generated by Price.compute
##
@ -111,7 +111,7 @@ class InvoicesService
end
##
# Generate Stripe::InvoiceItem for each slot in the given reservation and save them in invoice.invoice_items.
# Generate an InvoiceItem for each slot in the given reservation and save them in invoice.invoice_items.
# This method must be called if reservation.reservable is an Event
##
def self.generate_event_item(invoice, reservation, payment_details)
@ -140,7 +140,7 @@ class InvoicesService
end
##
# Generate Stripe::InvoiceItem for each slot in the given reservation and save them in invoice.invoice_items.
# Generate an InvoiceItem for each slot in the given reservation and save them in invoice.invoice_items.
# This method must be called if reservation.reservable is a Space, a Machine or a Training
##
def self.generate_generic_item(invoice, reservation, payment_details)
@ -159,7 +159,7 @@ class InvoicesService
end
##
# Generate a Stripe::InvoiceItem for the given subscription and save it in invoice.invoice_items.
# Generate an InvoiceItem for the given subscription and save it in invoice.invoice_items.
# This method must be called only with a valid subscription
##
def self.generate_subscription_item(invoice, subscription, payment_details)

View File

@ -47,7 +47,9 @@ class PaymentScheduleService
end
def create(subscription, total, coupon: nil, operator: nil, payment_method: nil, reservation: nil, user: nil)
schedule = compute(reservation ? reservation.subscription.plan : subscription.plan, total, coupon)
subscription = reservation.generate_subscription if !subscription && reservation.plan_id
schedule = compute(subscription.plan, total, coupon)
ps = schedule[:payment_schedule]
items = schedule[:items]

View File

@ -31,6 +31,7 @@ class Reservations::Reserve
payment.save
debit_user_wallet(payment, user, reservation)
reservation.post_save
true
end
##