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
begin
TenantService.switch_to_rest_of_world_tenant
account = Account.find_by_short_code '6HZMS1'
primary_reservations = account.primary_reservations.active.where(description: ['08-113', '08-100', '08-109'])
# Set commitment terms
start_date = Date.today.next_month.beginning_of_year
months = 12
primary_reservations.map{|res| CommitmentTermService.new(res).create(months, start_date) }
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('2XL9P8')
raise 'Incorrect Account' unless account.name == 'IAIelta'
begin
TenantService.switch_to_rest_of_world_tenant
mairap = Account.find_by short_code: '5KH06R'
res = mairap.primary_reservations.active.find_by(description: 'DD34')
res.commitment_term.archive!
end
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
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
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
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 }
@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
@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 / 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