fix for bad onboarding time set

This commit is contained in:
Seth Call 2018-03-12 21:53:24 -05:00
parent efe1ee5d7d
commit d5783eb99d
11 changed files with 302 additions and 12 deletions

63
admin/app/admin/charge.rb Normal file
View File

@ -0,0 +1,63 @@
ActiveAdmin.register JamRuby::Charge, :as => 'Charges' do
menu :label => 'Charge', :parent => 'JamClass'
config.sort_order = 'created_at desc'
config.batch_actions = false
config.per_page = 100
config.paginate = true
config.filters = true
controller do
active_admin_config.includes.push :user
end
filter :user_email_cont, label: 'Name', as: :string
index do
column "Actions" do |charge|
links = ''.html_safe
links << link_to("View", resource_path(charge), :class => "member_link view_link")
links << link_to("Edit", edit_resource_path(charge), :class => "member_link edit_link")
links
end
column "User" do |charge|
link_to charge.user.name, charge.user.admin_url
end
column :billed
column :billing_error_reason
column :billing_attempts
column :amount_in_cents
column :fee_in_cents
column :created_at
column :updated_at
column "Stripe" do |charge|
link_to "Link", "https://dashboard.stripe.com/payments/#{charge.stripe_charge_id}" if charge.stripe_charge_id
end
end
show do
attributes_table do
row "User" do |charge|
link_to charge.user.name, charge.user.admin_url
end
row :amount_in_cents
row :fee_in_cents
row :billed
row :billed_at
row :post_processed
row :post_processed_at
row :billing_error_reason
row :billing_error_detail
row :billing_should_retry
row :billing_attempts
row :stripe_charge_id
row :created_at
row :updated_at
row "Stripe" do |charge|
link_to "Link", "https://dashboard.stripe.com/payments/#{charge.stripe_charge_id}" if charge.stripe_charge_id
end
end
end
end

View File

@ -22,7 +22,7 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
filter :student_full_name_or_user_email_cont, label: 'Student Name Or Email', as: :string
filter :by_search_teacher_in, label: 'Teacher Name Or Email', as: :string
filter :by_lesson_package_type_in, label: 'Card Type', as: :select, collection: -> { LessonPackageType.all.map {|t| [t.admin_name, t.id]}}
filter :by_lesson_package_type_in, label: 'Card Type', as: :select, collection: -> { LessonPackageType.all.map { |t| [t.admin_name, t.id] } }
controller do
active_admin_config.includes.push :teacher, :music_session
@ -75,7 +75,7 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
column "Teacher" do |lesson_session|
teacher = lesson_session.teacher
span do
# link_to "#{teacher.name} (#{teacher.email})", "#{Rails.application.config.external_root_url}/client#/profile/teacher/#{teacher.id}"
# link_to "#{teacher.name} (#{teacher.email})", "#{Rails.application.config.external_root_url}/client#/profile/teacher/#{teacher.id}"
link_to teacher.admin_name, teacher.admin_url
end
end
@ -119,14 +119,14 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
row "Teacher" do |lesson_session|
teacher = lesson_session.teacher
span do
# link_to teacher.admin_name, "#{Rails.application.config.external_root_url}/client#/profile/teacher/#{teacher.id}"
# link_to teacher.admin_name, "#{Rails.application.config.external_root_url}/client#/profile/teacher/#{teacher.id}"
link_to teacher.admin_name, teacher.admin_url
end
end
row "Student" do |lesson_session|
student = lesson_session.student
span do
# link_to student.admin_name, "#{Rails.application.config.external_root_url}/client#/profile/#{student.id}"
# link_to student.admin_name, "#{Rails.application.config.external_root_url}/client#/profile/#{student.id}"
link_to student.admin_name, student.admin_url
end
end
@ -149,6 +149,101 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
end
end
end
row "Distribution" do |lesson_session|
distribution = lesson_session.teacher_distribution
if distribution
payment = distribution.teacher_payment
if payment
charge = payment.teacher_payment_charge
end
end
div do
if distribution
table_for distribution do
column :amount_in_cents
column :distributed
column :ready
column :teacher_fee_in_cents
column :reduced_roll_forward_amount_in_cents
column :created_at
column :updated_at
column do
link_to "Link", distribution.admin_url
end
end
else
''
end
end
end
row "Teacher Payment" do |lesson_session|
distribution = lesson_session.teacher_distribution
if distribution
payment = distribution.teacher_payment
end
div do
if payment
table_for payment do
column :amount_in_cents
column :fee_in_cents
column :created_at
column :updated_at
column do
link_to "Link", payment.admin_url
end
end
else
''
end
end
end
row "Stripe Charge" do |lesson_session|
distribution = lesson_session.teacher_distribution
if distribution
payment = distribution.teacher_payment
if payment
charge = payment.teacher_payment_charge
end
end
div do
if charge
table_for charge do
column :amount_in_cents
column :fee_in_cents
column :billed
column :billed_at
column :post_processed
column :post_processed_at
column :billing_error_reason
column :billing_error_detail
column :billing_should_retry
column :billing_attempts
column :stripe_charge_id
column :created_at
column :updated_at
column do
link_to "Stripe", "https://dashboard.stripe.com/payments/#{charge.stripe_charge_id}" if charge.stripe_charge_id
end
column do
link_to "Link", charge.admin_url
end
end
else
''
end
end
end
row "Admin Marked" do |lesson_session|
span do
lesson_session.admin_marked
@ -177,11 +272,17 @@ ActiveAdmin.register JamRuby::LessonSession, :as => 'LessonSessions' do
end
row "Chat Messages" do |lesson_session|
div do
table_for ChatMessage.unscoped.where(lesson_session:lesson_session).order(:created_at) do
table_for ChatMessage.unscoped.where(lesson_session: lesson_session).order(:created_at) do
column :created_at
column do |chat_msg| chat_msg.purpose ? chat_msg.purpose : 'Chat Msg' end
column 'Sender' do |chat_msg| link_to(chat_msg.user.name, chat_msg.user.admin_url) end
column :target_user do |chat_msg| chat_msg.target_user ? link_to(chat_msg.target_user.name, chat_msg.target_user.admin_url) : '' end
column do |chat_msg|
chat_msg.purpose ? chat_msg.purpose : 'Chat Msg'
end
column 'Sender' do |chat_msg|
link_to(chat_msg.user.name, chat_msg.user.admin_url)
end
column :target_user do |chat_msg|
chat_msg.target_user ? link_to(chat_msg.target_user.name, chat_msg.target_user.admin_url) : ''
end
column :message
column :id
end

View File

@ -0,0 +1,51 @@
ActiveAdmin.register JamRuby::TeacherDistribution, :as => 'TeacherDistributions' do
menu :label => 'Teacher Distributions', :parent => 'JamClass'
config.sort_order = 'created_at desc'
config.batch_actions = false
config.per_page = 100
config.paginate = true
config.filters = true
controller do
active_admin_config.includes.push :teacher
end
filter :teacher_full_name_or_teacher_email_cont, label: 'Name', as: :string
index do
column "Teacher" do |distribution|
link_to distribution.teacher.name, distribution.teacher.admin_url
end
column :amount_in_cents
column :distributed
column :ready
column :teacher_fee_in_cents
column :reduced_roll_forward_amount_in_cents
column :created_at
column :updated_at
column do
link_to "Link", distribution.admin_url
end
end
show do
attributes_table do
row "Teacher" do |distribution|
link_to distribution.teacher.name, distribution.teacher.admin_url
end
row :amount_in_cents
row :distributed
row :ready
row :teacher_fee_in_cents
row :reduced_roll_forward_amount_in_cents
row :created_at
row :updated_at
row do
link_to "Link", distribution.admin_url
end
end
end
end

View File

@ -0,0 +1,45 @@
ActiveAdmin.register JamRuby::TeacherPayment, :as => 'TeacherPayments' do
menu :label => 'Teacher Payments', :parent => 'JamClass'
config.sort_order = 'created_at desc'
config.batch_actions = false
config.per_page = 100
config.paginate = true
config.filters = true
controller do
active_admin_config.includes.push :teacher
end
filter :teacher_full_name_or_teacher_email_cont, label: 'Name', as: :string
index do
column "Actions" do |payment|
links = ''.html_safe
links << link_to("View", resource_path(payment), :class => "member_link view_link")
links << link_to("Edit", edit_resource_path(payment), :class => "member_link edit_link")
links
end
column "Teacher" do |payment|
link_to payment.teacher.name, payment.teacher.admin_url
end
column :amount_in_cents
column :fee_in_cents
column :created_at
column :updated_at
end
show do
attributes_table do
row "Teacher" do |payment|
link_to payment.teacher.name, payment.teacher.admin_url
end
row :amount_in_cents
row :fee_in_cents
row :created_at
row :updated_at
end
end
end

View File

@ -0,0 +1,7 @@
class JamRuby::Charge
ransacker :user_full_name, formatter: proc { |v| v.mb_chars.downcase.to_s } do |parent|
Arel::Nodes::NamedFunction.new('LOWER',
[Arel::Nodes::NamedFunction.new('concat_ws',
[Arel::Nodes::SqlLiteral.new("' '"), 'users.first_name', 'users.last_name'])])
end
end

View File

@ -0,0 +1,7 @@
class JamRuby::TeacherDistribution
ransacker :teacher_full_name, formatter: proc { |v| v.mb_chars.downcase.to_s } do |parent|
Arel::Nodes::NamedFunction.new('LOWER',
[Arel::Nodes::NamedFunction.new('concat_ws',
[Arel::Nodes::SqlLiteral.new("' '"), 'teachers.first_name', 'teachers.last_name'])])
end
end

View File

@ -0,0 +1,7 @@
class JamRuby::TeacherPayment
ransacker :teacher_full_name, formatter: proc { |v| v.mb_chars.downcase.to_s } do |parent|
Arel::Nodes::NamedFunction.new('LOWER',
[Arel::Nodes::NamedFunction.new('concat_ws',
[Arel::Nodes::SqlLiteral.new("' '"), 'teachers.first_name', 'teachers.last_name'])])
end
end

View File

@ -33,6 +33,10 @@ module JamRuby
self.save(validate: false)
end
def admin_url
APP_CONFIG.admin_root_url + "/admin/charges/" + id
end
def charge(force = false)
@stripe_charge = nil

View File

@ -197,7 +197,10 @@ module JamRuby
rescue
"temp fix"
end
end
def admin_url
APP_CONFIG.admin_root_url + "/admin/teacher_distributions/" + id
end
end
end

View File

@ -71,6 +71,10 @@ module JamRuby
amount_in_cents - fee_in_cents
end
def admin_url
APP_CONFIG.admin_root_url + "/admin/teacher_payments/" + id
end
# will find, for a given teacher, an outstading unsuccessful payment or make a new one.
# it will then associate a charge with it, and then execute the charge.
def self.charge(teacher)

View File

@ -38,7 +38,6 @@ profileUtils = context.JK.ProfileUtils
$this = $(this)
id = $this.attr('data-id')
day = $this.attr('data-date')
console.log("id-day: #{id}-#{day}")
$this.datepicker({
dateFormat: "D M d yy",
@ -79,6 +78,7 @@ profileUtils = context.JK.ProfileUtils
})
)
afterShow: (e) ->
@screenVisible = true
logger.debug("AccountOnboardingScreen: afterShow")
@ -115,7 +115,6 @@ profileUtils = context.JK.ProfileUtils
for match in this.state.onboardings
if match.id == onboarding.id
$.extend(match, onboarding)
console.log("UPDATED ONBOARDING", onboarding)
break
this.setState({onboardings: this.state.onboardings})
@ -259,7 +258,6 @@ profileUtils = context.JK.ProfileUtils
</tr>`)
else if @state.onboardings.length > 0
for onboarding in @state.onboardings
console.log("onboarding", onboarding)
hours = []
for hour in ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
@ -267,7 +265,7 @@ profileUtils = context.JK.ProfileUtils
key = '00'
else
key = hour
hours.push(`<option key={key} value={key}>{hour}</option>`)
hours.push(`<option key={key} value={new Number(key)}>{hour}</option>`)
minutes = []
for minute in ['00', '15', '30', '45']