mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Adding basic template for account page
This commit is contained in:
8
app/controllers/admin/account_controller.rb
Normal file
8
app/controllers/admin/account_controller.rb
Normal 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
|
||||
@@ -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?
|
||||
|
||||
22
app/views/admin/account/show.html.haml
Normal file
22
app/views/admin/account/show.html.haml
Normal 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
|
||||
21
spec/features/admin/account_spec.rb
Normal file
21
spec/features/admin/account_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user