Skip to content

Instantly share code, notes, and snippets.

@avidas
Last active December 28, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avidas/d1cb9f3e79545ca899ed01ddb48d350b to your computer and use it in GitHub Desktop.
Save avidas/d1cb9f3e79545ca899ed01ddb48d350b to your computer and use it in GitHub Desktop.
begin
ActiveRecord::Base.transaction do
TenantService.switch_to_rest_of_world_tenant
office_of_baby_uuid = '8083d9a1-ec36-480f-b257-31fd67cd0001'
office_of_baby = Account.find_by_uuid office_of_baby_uuid
oob_primary_res = office_of_baby.primary_reservations.active.last
oob_conf_allotment = oob_primary_res.conference_room_allotments.active.last
oob_conf_allotment.started_on = oob_primary_res.started_on
oob_conf_allotment.save!
oob_change_request = ChangeRequest.where(account_uuid: office_of_baby_uuid).last
oob_membership_agreement = oob_change_request.membership_agreement
ExecuteService.new(oob_membership_agreement).perform!
oob_primary_res.reload
raise ActiveRecord::Rollback, "Failed to move out #{office_of_baby_uuid}" unless
oob_primary_res.ended_on == oob_change_request.reservation_ended_on
end
end
@jhjwind
Copy link

jhjwind commented Dec 28, 2017

👍

@avidas
Copy link
Author

avidas commented Dec 28, 2017

Context: For this move out, we sent the move out paperwork, paperwork was signed but paperwork could not get executed. This happens on trying to save the move out reservation, in particular when we try to create the conference room allotment within reservation_service.save!

Usually this should not happen, but the active check for conference room allotments gets tricked due to https://jira.we.co/browse/REVENG-562.

By moving up the conference room allotment started_on to be an earlier date, we unblock sales and don't negatively impact invoices.

@monkeyfox
Copy link

👍

@RonaTross
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment