Skip to content

Commit

Permalink
Purchase cross core order for reservation (#4405)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeticiaErrandonea authored Jul 2, 2024
1 parent a615174 commit 5d8b59b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/services/reservation_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def save(session_user)
# The purchase_order_path or cart_path will handle the backdating, but we need
# to do this here for merged reservations.
backdate_reservation_if_necessary(session_user)

purchase_original_cross_core_order

@success = :merged_order
elsif @order.order_details.one?
@success = :instrument_only_order
Expand Down Expand Up @@ -104,4 +107,19 @@ def status_q
ActiveSupport::StringInquirer.new(@success.to_s)
end

def purchase_original_cross_core_order
original_order = Order.find(@order.merge_with_order_id)

if original_order.order_details.one? && original_order.cross_core_project.present?
order_purchaser = OrderPurchaser.new(
order: original_order,
acting_as: original_order.user,
order_in_past: nil,
params: ActionController::Parameters.new({}),
user: original_order.created_by
)
order_purchaser.purchase_cross_core!
end
end

end
1 change: 1 addition & 0 deletions spec/system/admin/adding_to_a_cross_core_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
expect(project).to be_present
expect(project.orders.last.order_details.last.product).to eq(instrument)
expect(project.orders.last.account_id).to eq(facility2_account.id)
expect(project.orders.last.state).to eq("purchased")
end

it "brings you back to the facility order path on 'Cancel'" do
Expand Down

0 comments on commit 5d8b59b

Please sign in to comment.