Skip to content

Instantly share code, notes, and snippets.

@maazrk
Last active October 7, 2020 07:10
Show Gist options
  • Save maazrk/0c04bc3e97ba30170e2e0b463fff44cf to your computer and use it in GitHub Desktop.
Save maazrk/0c04bc3e97ba30170e2e0b463fff44cf to your computer and use it in GitHub Desktop.
group_id = 3746359
existing_account_number = '3746359'
order_handler = OrderManagement::Base.new({:group_id => group_id})
cancellation_date = '2020-08-26'.to_date # date when renewal was booked
subscription_number = 'A-S00021357'
optional_hash = {:account_number => existing_account_number, :contract_effective_date => cancellation_date, :send_txn_entry => false, :do_not_expire_plans => true, :run_billing => true}
response = order_handler.cancel_subscription(subscription_number, optional_hash)
# check the credit memo generated on zuora before running below code to settle it
credit_memo_handler = CreditMemoManagement::Base.new({:group_id => group_id})
credit_settle_response = credit_memo_handler.settle_multiple_or_last_credit_memo
#update orders
group = Group.find(group_id)
expired_date = cancellation_date
o1 = Order.find(548762)
o1.active_line_items.each do |li|
all_gps = li.all_associated_group_plans(group)
all_gps.each { |gp| gp.update_attributes(:block => true, :block_date => expired_date) }
end
o1.deactivate_active_line_items
o1.update_attributes(:status => "failed")
o2 = Order.find(548763)
o2.deactivate_active_line_items
o2.update_attributes(:status => "failed")
# expire previous cancelled line items
Order.find(530220).deactivate_active_line_items
# billing_comm
BillingCommunication.find(1100935).update_attributes(:status => 2)
SubscriptionSessionInfo.find(177956).update_attributes(:status => 2)
cancelled_order_id = 548763
opportunity_id = '0060I00000g6VdpQAE'
future_order = false
ExecuteMethodWorker.perform_async('AdminController', 'push_order_cancellation_to_sfdc', [group_id, cancelled_order_id, opportunity_id, future_order])
# Zombie side script
Transaction.find(2918535).update_attributes(:status => 'Failed')
Transaction.find(2918534).update_attributes(:status => 'Failed')
Transaction.find(2918533).update_attributes(:status => 'Failed')
Transaction.find(2918532).update_attributes(:status => 'Failed')
new_txn = Transaction.find(2818468).dup
new_txn.purchase_date = "2020-08-26"
new_txn.description = "Expired"
new_txn.admin_description = 'plan_period_expired_admin'
new_txn.save!
new_txn = Transaction.find(2818467).dup
new_txn.purchase_date = "2020-08-26"
new_txn.description = "Expired"
new_txn.admin_description = 'plan_period_expired_admin'
new_txn.save!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment