Adding basic template for account page

This commit is contained in:
Rob Harrington
2015-07-03 15:45:17 +08:00
parent 92eb5ed367
commit 8bbda5715d
4 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
class Admin::AccountController < Spree::Admin::BaseController
def show
@enterprises = spree_current_user.owned_enterprises
# .group_by('enterprise.id').joins(:billable_periods)
# .select('SUM(billable_periods.turnover) AS turnover').order('turnover DESC')
end
end

View File

@@ -4,6 +4,14 @@ class BillablePeriod < ActiveRecord::Base
default_scope where(deleted_at: nil)
def display_turnover
Spree::Money.new(turnover, {currency: Spree::Config[:currency]})
end
def display_bill
Spree::Money.new(bill, {currency: Spree::Config[:currency]})
end
def bill
# Will make this more sophisicated in the future in that it will use global config variables to calculate
return 0 if trial?

View File

@@ -0,0 +1,22 @@
- content_for :page_title do
= t(:account)
- @enterprises.each do |enterprise|
%h2= enterprise.name
%table
%thead
%th Begins
%th Ends
%th Sells
%th Trial?
%th Turnover
%th Bill
- enterprise.billable_periods.each do |billable_period|
%tr
%td= billable_period.begins_at.strftime("%F %T")
%td= billable_period.ends_at.strftime("%F %T")
%td= billable_period.sells
%td= billable_period.trial?
%td= billable_period.display_turnover
%td= billable_period.display_bill

View File

@@ -0,0 +1,21 @@
require 'spec_helper'
feature 'Account Page' do
include AuthenticationWorkflow
describe "updating" do
let!(:user) { create(:user) }
let!(:enterprise) { create(:distributor_enterprise, owner: user) }
before do
quick_login_as user
end
context "as an enterprise user" do
it "loads the page" do
visit admin_account_path
expect(page).to have_content "Account"
end
end
end
end