From d3e4489cc4833c196eeef77f4fe0680c3f7e7a09 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 11 Jun 2013 12:16:13 -0700 Subject: More cleanup of billing code. --- billing/app/views/customer/edit.html.haml | 2 +- billing/app/views/customer/show.html.haml | 10 ++++++++-- billing/app/views/payments/_transaction_details.html.haml | 2 +- billing/app/views/payments/new.html.haml | 5 ++++- .../app/views/subscriptions/_subscription_details.html.haml | 12 ++++++++---- billing/app/views/subscriptions/create.html.haml | 1 + billing/app/views/subscriptions/destroy.html.haml | 4 +++- billing/app/views/subscriptions/index.html.haml | 7 ++++++- billing/app/views/subscriptions/show.html.haml | 5 ++++- 9 files changed, 36 insertions(+), 12 deletions(-) (limited to 'billing/app/views') diff --git a/billing/app/views/customer/edit.html.haml b/billing/app/views/customer/edit.html.haml index c2e5cb3..f9c1383 100644 --- a/billing/app/views/customer/edit.html.haml +++ b/billing/app/views/customer/edit.html.haml @@ -19,4 +19,4 @@ = link_to 'Change credit card', edit_credit_card_info_path(:id => @default_cc.token), :class => :btn = hidden_field_tag :tr_data, @tr_data = f.submit 'Save Customer Info', :class => :btn -= link_to 'Cancel', show_customer_path(@braintree_data.id), :class=> :btn \ No newline at end of file += link_to 'Show Customer Information', show_customer_path(@braintree_data.id), :class=> :btn \ No newline at end of file diff --git a/billing/app/views/customer/show.html.haml b/billing/app/views/customer/show.html.haml index d385d98..8ef5517 100644 --- a/billing/app/views/customer/show.html.haml +++ b/billing/app/views/customer/show.html.haml @@ -8,7 +8,13 @@ = render :partial => "payments/transaction_details", :locals => {:transaction => t} - counter += 1 = link_to 'Transaction History', payments_path +%h3 Subscriptions - if @active_subscription - %h3 Active Subscription = render :partial => "subscriptions/subscription_details", :locals => {:subscription => @active_subscription} - = link_to 'All subscriptions', subscriptions_path \ No newline at end of file +- else + %p + No active subscription + %p + = link_to 'subscribe to plan', new_subscription_path, :class => :btn +%p + = link_to 'All subscriptions', subscriptions_path diff --git a/billing/app/views/payments/_transaction_details.html.haml b/billing/app/views/payments/_transaction_details.html.haml index 53483d9..030639e 100644 --- a/billing/app/views/payments/_transaction_details.html.haml +++ b/billing/app/views/payments/_transaction_details.html.haml @@ -7,7 +7,7 @@ Status: = transaction.status Date - = transaction.created_at + = transaction.created_at.strftime("%Y-%m-%d") - if sub_start = transaction.subscription_details.billing_period_start_date From subscription which started = sub_start diff --git a/billing/app/views/payments/new.html.haml b/billing/app/views/payments/new.html.haml index d1d0aa9..14f6697 100644 --- a/billing/app/views/payments/new.html.haml +++ b/billing/app/views/payments/new.html.haml @@ -1,9 +1,12 @@ %h1 Payment -- if @result +- if @result and @result.errors.size > 0 %div{:style => "color: red;"} = h @result.errors.size error(s) +- if @result and @result.transaction.status == 'processor_declined' + %div{:style => "color: red;"} + Processor Declined = form_for :transaction, :params => @result && @result.params[:transaction], :errors => @result && @result.errors.for(:transaction), :builder => BraintreeFormHelper::BraintreeFormBuilder, :url => Braintree::TransparentRedirect.url, :html => {:autocomplete => "off"} do |f| #TODO: add helper = f.label :amount, "Amount" = f.text_field :amount diff --git a/billing/app/views/subscriptions/_subscription_details.html.haml b/billing/app/views/subscriptions/_subscription_details.html.haml index db9d75b..fb18210 100644 --- a/billing/app/views/subscriptions/_subscription_details.html.haml +++ b/billing/app/views/subscriptions/_subscription_details.html.haml @@ -6,10 +6,14 @@ = subscription.billing_day_of_month Start date: = subscription.first_billing_date - Paid through + Paid through: = subscription.paid_through_date - Price + Plan: + = subscription.plan_id + Price: = subscription.price - Status - = subscription.status + - color = (subscription.status == 'Active') ? "green" : "red" + Status: + %font{:color => color} + = subscription.status - # would be good to get plan name but not sure if that is possible? \ No newline at end of file diff --git a/billing/app/views/subscriptions/create.html.haml b/billing/app/views/subscriptions/create.html.haml index e0585ab..2b6c5e9 100644 --- a/billing/app/views/subscriptions/create.html.haml +++ b/billing/app/views/subscriptions/create.html.haml @@ -2,6 +2,7 @@ %h1 Subscription Status = @result.subscription.status + = render :partial => "subscription_details", :locals => {:subscription => @result.subscription} - else %h1 Error: diff --git a/billing/app/views/subscriptions/destroy.html.haml b/billing/app/views/subscriptions/destroy.html.haml index f888e6d..e7ed6e8 100644 --- a/billing/app/views/subscriptions/destroy.html.haml +++ b/billing/app/views/subscriptions/destroy.html.haml @@ -2,4 +2,6 @@ Subscription destroyed - else Error: - = @result.message \ No newline at end of file + = @result.message +%p + = link_to 'Customer Information', show_customer_path(@customer.braintree_customer_id), :class=> :btn \ No newline at end of file diff --git a/billing/app/views/subscriptions/index.html.haml b/billing/app/views/subscriptions/index.html.haml index c885f90..0e84619 100644 --- a/billing/app/views/subscriptions/index.html.haml +++ b/billing/app/views/subscriptions/index.html.haml @@ -1,2 +1,7 @@ +- active = false - @subscriptions.each do |s| - = render :partial => "subscription_details", :locals => {:subscription => s} \ No newline at end of file + - if s.status == 'Active' + - active = true + = render :partial => "subscription_details", :locals => {:subscription => s} +- if !active + = link_to 'subscribe to plan', new_subscription_path, :class => :btn \ No newline at end of file diff --git a/billing/app/views/subscriptions/show.html.haml b/billing/app/views/subscriptions/show.html.haml index a3d57f9..6f108be 100644 --- a/billing/app/views/subscriptions/show.html.haml +++ b/billing/app/views/subscriptions/show.html.haml @@ -1,4 +1,7 @@ -%h1 Current Subscription +%h1 + - if @subscription.status == 'Active' + Current + Subscription = render :partial => "subscription_details", :locals => {:subscription => @subscription} = link_to 'Cancel Subscription', subscription_path, :confirm => 'Are you sure you want to cancel this subscription?', :method => :delete, :class => 'btn btn-danger' if @subscription.status == 'Active' # permission check or should that just be on show? = link_to 'Show Customer Data', show_customer_path(@subscription_customer_id), :class => :btn \ No newline at end of file -- cgit v1.2.3