Skip to content

Instantly share code, notes, and snippets.

View avidas's full-sized avatar
🎯
Busy creating tech debt

Avi Das avidas

🎯
Busy creating tech debt
View GitHub Profile
@avidas
avidas / reveng-121-cancel-mimo.rb
Last active August 11, 2017 15:38
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
@avidas
avidas / update_mexico_shortcodes.rb
Last active August 10, 2017 20:43
Reveng-137 - Change short codes for buildings
# JIRA: REVENG-137
begin
Rails.logger.info "JIRA REVENG-137 starting to update location codes"
Location.find_by_code('MXC08').update!(code: 'MXC01') # Insurgentes 601
Location.find_by_code('RJ04').update!(code: 'RJ03') # Piraja
Rails.logger.info "JIRA REVENG-137 done"
end
@avidas
avidas / reveng-121-cancel-mi.rb
Last active August 15, 2017 11:31
Cancel Move In 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(2017,9,1)
pr.save!
Rails.logger.info "JIRA REVENG-121 done canceling move in for Office 16-116 in Tower 49 for Gimbal EUAETK "
end
@avidas
avidas / reveng-121-cancel-mo.rb
Last active August 14, 2017 21:21
Cancel Move Out for Finalized SD Invoice Reservations https://jira.we.co/browse/REVENG-121
# 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).detect { |res| res.type == "Office" && res.name == "337" }
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
@avidas
avidas / reveng-149-clear-sidekiq-vars.rb
Last active August 30, 2017 19:40
REVENG-149 Clear Redis variables set for running Sidekiq cron jobs
# JIRA: REVENG-149
# Remove Sidekiq enterprise schedules so late payment notices do not get sent
#
# When Sidekiq enterprise creates a cron job, it sets the keys loop-UNIQUE-ID, loops-UNIQUE-ID
# This keys are not getting cleaned up from Redis when we remove the cron jobs from codebase
# and restart sidekiq and app servers.
require 'sidekiq/api'
begin
@avidas
avidas / update_invoice_refs.sh
Created November 15, 2017 23:26
Shell script to update invoice refs
#!/bin/bash
from=(
FeeHelper
InvoiceCorrection
InvoiceReverser
InvoiceOpener
LineItemReverser
TaxHelper
VatHelper
begin
TenantService.switch_to_rest_of_world_tenant
account = Account.find_by_short_code('HUJW06')
raise 'Incorrect Account' unless account.name == 'Shopic'
location = Location.find(98)
raise 'Incorrect Location' unless location.name == 'Ibn Gabirol'
prs = account.primary_reservations.active.select { |res| res.location_id == location.id }
begin
def cancel_price_escalation(account, location)
TenantService.switch_tenant_with_location_uuid(location.uuid)
prs = account.primary_reservations.active.select { |res| res.location_id == location.id }
prs.map{ |res| res.update_attributes(annual_escalator_rate: nil, escalation_date: nil) }
end
account = Account.find_by_short_code('1VHUN0')
raise 'Incorrect Account' unless account.name == 'UBQ'
begin
account = Account.find_by_short_code '7RFQTX'
location = Location.find_by_code 'ATL02'
price = account.anywhere_reservations.active.first.price
start_jan_date = Date.today.next_month.beginning_of_month
end_feb_date = Date.today.next_month.next_month.end_of_month
full_discount_for_two_months = { type: "discount", started_on: start_jan_date, ended_on: end_feb_date, price: -price }
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