Created
July 2, 2012 13:07
-
-
Save marcusleemitchell/3033182 to your computer and use it in GitHub Desktop.
finance rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :finance do | |
desc "Move booking monitory values to payment" | |
task :move_payment_data => :environment do | |
ActiveRecord::Base.connection.execute("CREATE UNIQUE INDEX index_unique_payments_on_booking_id_and_type ON payments (booking_id,type);" | |
ActiveRecord::Base.connection.execute("INSERT payments (booking_id,type,credit_card_fee_amount,credit_card_cost,earning_FROM_credit_card,money_kept_by_adyen,currency_code,exchange_rate_id,used_for_authorisation,cc_charged,payment_faked_option,commission_amount,commission_reduction,commissionable_amount_for_guest,pre_reduction_commission_amount,uncommissionable_amount_for_guest,cash_in,cash_in_date,total_amount_guest_pays,total_price_of_stay_for_host,total_price_of_stay,payment_on_hold) | |
SELECT id,'InitialPayment',credit_card_fee_amount,credit_card_cost,earning_FROM_credit_card,money_kept_by_adyen,currency_code,exchange_rate_id,used_for_authorisation,cc_charged,payment_faked_option,commission_amount,commission_reduction,commissionable_amount_for_guest,pre_reduction_commission_amount,uncommissionable_amount_for_guest,cash_in,cash_in_date,total_amount_guest_pays,total_price_of_stay_for_host,total_price_of_stay,payment_on_hold | |
FROM bookings | |
ON DUPLICATE KEY UPDATE | |
credit_card_fee_amount = VALUES(credit_card_fee_amount), | |
credit_card_cost = VALUES(credit_card_cost), | |
earning_FROM_credit_card = VALUES(earning_from_credit_card), | |
money_kept_by_adyen = VALUES(money_kept_by_adyen), | |
currency_code = VALUES(currency_code), | |
exchange_rate_id = VALUES(exchange_rate_id), | |
used_for_authorisation = VALUES(used_for_authorisation), | |
cc_charged = VALUES(cc_charged), | |
payment_faked_option = VALUES(payment_faked_option), | |
commission_amount = VALUES(commission_amount), | |
commission_reduction = VALUES(commission_reduction), | |
commissionable_amount_for_guest = VALUES(commissionable_amount_for_guest), | |
pre_reduction_commission_amount = VALUES(pre_reduction_commission_amount), | |
uncommissionable_amount_for_guest = VALUES(uncommissionable_amount_for_guest), | |
cash_in = VALUES(cash_in), | |
cash_in_date = VALUES(cash_in_date), | |
total_amount_guest_pays = VALUES(total_amount_guest_pays), | |
total_price_of_stay_for_host = VALUES(total_price_of_stay_for_host), | |
total_price_of_stay = VALUES(total_price_of_stay), | |
payment_on_hold = VALUES(payment_on_hold); | |
" | |
ActiveRecord::Base.connection.execute("DROP INDEX index_unique_payments_on_booking_id_and_type ON payments;") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment