session controller
This commit is contained in:
parent
ef153ad4b7
commit
fe16d513be
|
|
@ -55,6 +55,18 @@ module JamRuby
|
|||
amount_in_cents / 100.0
|
||||
end
|
||||
|
||||
def real_distribution_in_cents
|
||||
amount_in_cents - calculate_teacher_fee
|
||||
end
|
||||
|
||||
def calculate_teacher_fee
|
||||
if is_test_drive?
|
||||
0
|
||||
else
|
||||
(amount_in_cents * teacher.jamkazam_rate + 0.03).round
|
||||
end
|
||||
end
|
||||
|
||||
def student
|
||||
if lesson_session
|
||||
lesson_session.student
|
||||
|
|
|
|||
|
|
@ -51,15 +51,10 @@ module JamRuby
|
|||
24
|
||||
end
|
||||
|
||||
def calculate_teacher_fee
|
||||
if teacher_distribution.is_test_drive?
|
||||
0
|
||||
else
|
||||
(amount_in_cents * 0.28).round
|
||||
end
|
||||
def real_distribution_in_cents
|
||||
amount_in_cents - fee_in_cents
|
||||
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)
|
||||
|
|
@ -81,7 +76,7 @@ module JamRuby
|
|||
|
||||
|
||||
payment.amount_in_cents = payment.teacher_distribution.amount_in_cents
|
||||
payment.fee_in_cents = payment.calculate_teacher_fee
|
||||
payment.fee_in_cents = payment.teacher_distribution.calculate_teacher_fee
|
||||
|
||||
if payment.teacher_payment_charge.nil?
|
||||
charge = TeacherPaymentCharge.new
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ profileUtils = context.JK.ProfileUtils
|
|||
TILE_PAYMENT_METHOD: 'payment method'
|
||||
|
||||
STUDENT_TILES: ['payments to jamkazam', 'payment method']
|
||||
TEACHER_TILES: ['payments to you', 'payments to jamkazam']
|
||||
TEACHER_TILES: ['payments to jamkazam', 'payments to you']
|
||||
|
||||
onAppInit: (@app) ->
|
||||
@app.bindScreen('account/paymentHistory', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide})
|
||||
|
|
@ -68,7 +68,7 @@ profileUtils = context.JK.ProfileUtils
|
|||
else
|
||||
[]
|
||||
|
||||
componentDidUpdate: () ->
|
||||
componentDidUpdate: (prevProps, prevState) ->
|
||||
#@iCheckify()
|
||||
|
||||
if @state.next == null
|
||||
|
|
@ -82,6 +82,9 @@ profileUtils = context.JK.ProfileUtils
|
|||
else
|
||||
@registerInfiniteScroll(@contentBodyScroller)
|
||||
|
||||
if @activeTile(prevState.selected) != @activeTile()
|
||||
@refresh()
|
||||
|
||||
checkboxChanged: (e) ->
|
||||
checked = $(e.target).is(':checked')
|
||||
|
||||
|
|
@ -200,6 +203,55 @@ profileUtils = context.JK.ProfileUtils
|
|||
@paymentsToJamKazam()
|
||||
|
||||
paymentsToYou: () ->
|
||||
rows = []
|
||||
|
||||
for paymentHistory in this.state.sales
|
||||
paymentMethod = 'Stripe'
|
||||
|
||||
if paymentHistory.distributed
|
||||
date = paymentHistory.teacher_payment.teacher_payment_charge.last_billing_attempt_at
|
||||
status = 'Paid'
|
||||
else
|
||||
date = paymentHistory.created_at
|
||||
status = 'Collecting'
|
||||
date = context.JK.formatDate(date, true)
|
||||
|
||||
|
||||
amountClasses = {status: status}
|
||||
|
||||
row =
|
||||
`<tr>
|
||||
<td>{date}</td>
|
||||
<td className="capitalize">{paymentMethod}</td>
|
||||
<td>{description}</td>
|
||||
<td className="capitalize">{status}</td>
|
||||
<td className={classNames(amountClasses)}>{displayAmount}</td>
|
||||
</tr>`
|
||||
rows.push(row)
|
||||
|
||||
`<div>
|
||||
<table className="payment-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>DATE</th>
|
||||
<th>METHOD</th>
|
||||
<th>DESCRIPTION</th>
|
||||
<th>STATUS</th>
|
||||
<th>AMOUNT</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<a className="btn-next-pager" href="/api/sales?page=1">Next</a>
|
||||
<div className="end-of-payments-list end-of-list">No more payment history</div>
|
||||
<div className="input-aligner">
|
||||
<a className="back button-grey">BACK</a>
|
||||
</div>
|
||||
<br className="clearall" />
|
||||
</div>`
|
||||
|
||||
paymentMethod: () ->
|
||||
|
||||
|
|
@ -268,9 +320,9 @@ profileUtils = context.JK.ProfileUtils
|
|||
e.preventDefault()
|
||||
@setState({selected: selection})
|
||||
|
||||
activeTile: () ->
|
||||
if this.state.selected?
|
||||
this.state.selected
|
||||
activeTile: (selected = this.state.selected) ->
|
||||
if selected?
|
||||
selected
|
||||
else
|
||||
@tiles()[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,12 @@ BroadcastHolder = React.createClass(
|
|||
if this.state.notification
|
||||
|
||||
if this.state.notification.isLesson
|
||||
notification.push(`<InLessonBroadcast key={'lesson'} lessonSession={this.state.notification}/>`)
|
||||
result = `<InLessonBroadcast key={'lesson'} lessonSession={this.state.notification}/>`
|
||||
else
|
||||
notification.push(`<Broadcast key={this.state.notification.id} notification={this.state.notification}/>`)
|
||||
result = `<Broadcast key={this.state.notification.id} notification={this.state.notification}/>`
|
||||
|
||||
if result?
|
||||
notification.push(result)
|
||||
|
||||
`<div id="broadcast-notification-holder" className="broadcast-notification-holder" >
|
||||
<ReactCSSTransitionGroup transitionName="bn-slidedown">
|
||||
|
|
|
|||
|
|
@ -77,8 +77,11 @@ context = window
|
|||
<p>We apologize for your inconvenience, and we will work to remedy this situation.</p>
|
||||
</div>`
|
||||
|
||||
`<div className="broadcast-notification lesson">
|
||||
{content}
|
||||
</div>`
|
||||
if content?
|
||||
`<div className="broadcast-notification lesson">
|
||||
{content}
|
||||
</div>`
|
||||
else
|
||||
null
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -76,25 +76,34 @@ BroadcastStore = Reflux.createStore(
|
|||
|
||||
if !@currentLesson?
|
||||
logger.debug("BroadcastStore: ignoring lessonAnalysisDone")
|
||||
return
|
||||
|
||||
if @analysis.status == 'completed'
|
||||
logger.debug("BroadcastStore: lesson is over")
|
||||
@currentLesson.completed = true
|
||||
@currentLesson.success = @analysis.success
|
||||
@clearTimer()
|
||||
@changed()
|
||||
else if @analysis.analysis.reason != 'teacher_fault'
|
||||
logger.debug("BroadcastStore: not teacher fault; clearing lesson info")
|
||||
@clearLesson()
|
||||
else
|
||||
logger.debug("BroadcastStore: teacher is at fault")
|
||||
@teacherFault = true
|
||||
@clearTimer()
|
||||
@changed()
|
||||
|
||||
clearLesson: () ->
|
||||
if @currentLesson?
|
||||
@currentLesson = null
|
||||
if @currentLessonTimer?
|
||||
clearInterval(@currentLessonTimer)
|
||||
@currentLessonTimer = null
|
||||
@clearTimer()
|
||||
@teacherFault = false
|
||||
@changed()
|
||||
|
||||
clearTimer: () ->
|
||||
if @currentLessonTimer?
|
||||
clearInterval(@currentLessonTimer)
|
||||
@currentLessonTimer = null
|
||||
onSessionChange: (session) ->
|
||||
|
||||
@session = session
|
||||
|
|
|
|||
|
|
@ -1026,6 +1026,11 @@ ConfigureTracksActions = @ConfigureTracksActions
|
|||
|
||||
@currentSession = sessionData
|
||||
|
||||
if context.jamClient.UpdateSessionInfo?
|
||||
if @currentSession?
|
||||
context.jamClient.UpdateSessionInfo(@currentSession)
|
||||
else
|
||||
context.jamClient.UpdateSessionInfo({})
|
||||
#logger.debug("session changed")
|
||||
|
||||
@issueChange()
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
|
||||
.profile-tile {
|
||||
|
||||
float: left;
|
||||
float: right;
|
||||
@include border-box_sizing;
|
||||
height: 90px;
|
||||
position: relative;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ApiLessonSessionsController < ApiController
|
|||
if @lesson_session.analysed
|
||||
data = JSON.parse(@lesson_session.analysis)
|
||||
else
|
||||
data = LessonSession.analysis_to_json(LessonSessionAnalyser.analyse(@lesson_session), true)
|
||||
data = LessonSession.analysis_to_json(LessonSessionAnalyser.analyse(@lesson_session, true), true)
|
||||
end
|
||||
|
||||
response = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class ApiTeacherDistributionsController < ApiController
|
|||
def index
|
||||
data = TeacherDistribution.index(current_user, params)
|
||||
|
||||
@distributions = data[:query]
|
||||
@teacher_distributions = data[:query]
|
||||
@next = data[:next_page]
|
||||
render "api_teacher_distributions/index", :layout => nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,12 @@
|
|||
object @teacher_distribution
|
||||
|
||||
attributes :id, :description, :ready, :distributed, :created_at
|
||||
attributes :id, :description, :ready, :distributed, :created_at, :amount_in_cents, :real_distribution_in_cents
|
||||
|
||||
child(:teacher_payment => :teacher_payment) {
|
||||
attributes :real_distribution_in_cents, :created_at
|
||||
|
||||
child(:teacher_payment_charge => :teacher_payment_charge) {
|
||||
attributes: last_billing_attempt_at
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue