Skip to content

Instantly share code, notes, and snippets.

@avidas
Last active August 11, 2017 15:38
Show Gist options
  • Save avidas/a3d454a33ff3e1446aae50ee9c800926 to your computer and use it in GitHub Desktop.
Save avidas/a3d454a33ff3e1446aae50ee9c800926 to your computer and use it in GitHub Desktop.
Cancel Move In / Move Out for Finalized SD Invoice Reservations https://jira.we.co/browse/REVENG-121
# JIRA: REVENG-121
# cancel move in for Office 16-116 in Tower 49 for Gimbal EUAETK
begin
Rails.logger.info "JIRA REVENG-121 starting to cancel move in for Office 16-116 in Tower 49 for Gimbal EUAETK"
TenantService.switch_to_rest_of_world_tenant
pr = PrimaryReservation.find(600203682)
pr.canceled_at = DateTime.new
pr.save!
Rails.logger.info "JIRA REVENG-121 done canceling move in for Office 16-116 in Tower 49 for Gimbal EUAETK "
end
# cancel move out for office 337 in Yangping Luy for δΈŠζ΅·ε”θ‰Ύζ–‡εŒ–δΌ ζ’­ζœ‰ι™ε…¬εΈ - KIB7YC
begin
Rails.logger.info "JIRA REVENG-121 starting to cancel move out for Office 337 for Gimbal EUAETK"
TenantService.switch_to_apac_tenant
reservable = Account.find_by_short_code("KIB7YC").primary_reservations.map(&:reservable).select { |res| res.type == "Office" && res.name == "337" }.first
pr = Account.find_by_short_code("KIB7YC").primary_reservations.where("reservable_id = #{reservable.id}").first
pr.ended_on = nil
pr.save!
Rails.logger.info "JIRA REVENG-121 done canceling move out for Office 337 for Gimbal EUAETK "
end
@ianguffy
Copy link

For canceling the move-out: isn't reservable the same as pr? Why is query again for a primary_reservation with the same reservable.id as the one we already have?

Minor: do we have a stylistic preference for [0] vs .first?

@avidas
Copy link
Author

avidas commented Aug 10, 2017

pr is the primary reservation and reservable is the associated reservable with the reservation. It could be possible to do this with one query here. Since this was a script I was not too worried about performance.

first reads better to me, I could update that.

@ianguffy
Copy link

Ok, looks good to me πŸ‘

@kshsieh
Copy link

kshsieh commented Aug 10, 2017

πŸ‘

@kgoettsc
Copy link

minor: .detect does the same thing as .select{}.first

@novasponge
Copy link

on line 9, should we say move in instead of move out

@novasponge
Copy link

also, if you just canceled move out should you revert all the changes that happened while we process move out? For example, since it is a confirmed move out. lots of associated reservations are changed and security refund reservations are created. should you revert those?

@jhjwind
Copy link

jhjwind commented Aug 11, 2017

@novasponge for this account, everything else has been fixed manually by billing. we just need to cancel their move in.

@jhjwind
Copy link

jhjwind commented Aug 11, 2017

πŸ‘

@novasponge
Copy link

@jhjwind what about the other one with cancel move out? Has billing fixed everything manually?

@avidas
Copy link
Author

avidas commented Aug 11, 2017

For the cancel move out case, I talked to Michelle about it and it did not seem like a concern to have the cms offer them discounts as need be. We should certainly consider the impact on our systems, but does not seem like an issue from ops perspective.

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