Guest User

Untitled

a guest
Dec 13th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).select{ |cr| cr.created_at == cr.updated_at }.each do |cr|
  2. cr.granted_at = cr.created_at
  3. cr.save
  4. end
  5.  
  6. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil, rebate_type:"Settlement").each do |cr|
  7. cr.update!(granted_at: cr.created_at)
  8. end
  9.  
  10. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).last
  11. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil, rebate_type:"").where.not(installment_month:nil).count
  12. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil, rebate_type:"").where.not(installment_month:nil).first
  13. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil, rebate_type:"").where.not(installment_month:nil).last
  14.  
  15. rebates = CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil, rebate_type:"").where.not(installment_month:nil).each do |cr|
  16. cr.assign_attributes(granted_at: cr.created_at)
  17. cr.save!(validate:false)
  18. end; rebates.length
  19.  
  20. rebate_types = CashRebate::AD_HOC_REBATE_TYPES + CashRebate::SCHEDULED_REBATE_TYPES + [""]
  21.  
  22. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).where.not(installment_month:nil, rebate_type: rebate_types).count
  23. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).where.not(installment_month:nil, rebate_type: rebate_types).first
  24. CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).where.not(installment_month:nil, rebate_type: rebate_types).last
  25.  
  26. rebates = CashRebate.where(state:["complete","forfeit","granted"], granted_at:nil).where.not(installment_month:nil, rebate_type: rebate_types).each do |cr|
  27. cr.assign_attributes(granted_at: cr.created_at)
  28. cr.save!(validate:false)
  29. end; rebates.length
  30.  
  31. CashRebate.where(state:["complete"], applied_at:nil).last
  32.  
  33. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"Settlement").count
  34. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"Settlement").first
  35. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"Settlement").last
  36.  
  37. rebates = CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"Settlement").each do |cr|
  38. cr.assign_attributes(applied_at: cr.created_at)
  39. cr.save!(validate:false)
  40. end; rebates.length
  41.  
  42. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"").count
  43. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"").first
  44. CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"").last
  45.  
  46. rebates = CashRebate.where(state:["complete"], applied_at:nil, rebate_type:"").each do |cr|
  47. cr.assign_attributes(applied_at: cr.date_of_processing.to_datetime)
  48. cr.save!(validate:false)
  49. end; rebates.length
Add Comment
Please, Sign In to add comment