mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 08:43:23 -05:00
Adding transactions
-Need to create a customers table to store contact information of customers who are not a user. -Need to scope "User Transactions" for users, staff, and admin. Need to have a "All Shop Transactions" tab. -Need to add conditional UX to form.
This commit is contained in:
parent
a9533e6249
commit
11e738b428
@ -10,7 +10,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
|||||||
|
|
||||||
#all users
|
#all users
|
||||||
# (had to use hash for borders to get the title to display properly)
|
# (had to use hash for borders to get the title to display properly)
|
||||||
@@app_tab_panel_items = [ :bikes_border, {layout: :fit, wrappedComponent: :brands_and_models_border, title: "Brands/Models"}]
|
@@app_tab_panel_items = [ :transactions, :bikes_border, {layout: :fit, wrappedComponent: :brands_and_models_border, title: "Brands/Models"}]
|
||||||
|
|
||||||
#for users
|
#for users
|
||||||
if controller.current_user.user?
|
if controller.current_user.user?
|
||||||
|
17
app/components/transactions.rb
Normal file
17
app/components/transactions.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class Transactions < Netzke::Basepack::Grid
|
||||||
|
def configure(c)
|
||||||
|
super
|
||||||
|
c.model = "Transaction"
|
||||||
|
c.strong_default_attrs = { :vendor_id => controller.current_user.id }
|
||||||
|
c.columns = [
|
||||||
|
:amount,
|
||||||
|
:item,
|
||||||
|
{ :name => :bike__serial_number},
|
||||||
|
{ :name => :vendor, :getter => lambda { |rec|
|
||||||
|
user = rec.vendor
|
||||||
|
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
@ -2,6 +2,8 @@ class Bike < ActiveRecord::Base
|
|||||||
acts_as_loggable
|
acts_as_loggable
|
||||||
attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height,
|
attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height,
|
||||||
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id
|
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id
|
||||||
|
|
||||||
|
has_many :transactions
|
||||||
|
|
||||||
has_one :owner, :class_name => 'User'
|
has_one :owner, :class_name => 'User'
|
||||||
belongs_to :bike_brand
|
belongs_to :bike_brand
|
||||||
|
8
app/models/transaction.rb
Normal file
8
app/models/transaction.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class Transaction < ActiveRecord::Base
|
||||||
|
acts_as_loggable
|
||||||
|
attr_accessible :vendor_id, :customer_id, :customer_type, :bike_id, :amount, :item
|
||||||
|
|
||||||
|
belongs_to :vendor, :class_name => 'User', :foreign_key => 'vendor_id'
|
||||||
|
belongs_to :bike
|
||||||
|
|
||||||
|
end
|
@ -10,6 +10,7 @@ class User < ActiveRecord::Base
|
|||||||
:first_name, :last_name, :nickname, :user_role_id, :bike_id,
|
:first_name, :last_name, :nickname, :user_role_id, :bike_id,
|
||||||
:user_profiles_attributes
|
:user_profiles_attributes
|
||||||
|
|
||||||
|
has_many :transactions
|
||||||
has_many :user_profiles
|
has_many :user_profiles
|
||||||
accepts_nested_attributes_for :user_profiles, allow_destroy: false
|
accepts_nested_attributes_for :user_profiles, allow_destroy: false
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
class CreateTransactions < ActiveRecord::Migration
|
class CreateTransactions < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :transactions do |t|
|
create_table :transactions do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "vendor_id", :null => false
|
||||||
|
t.integer "customer_id"
|
||||||
|
t.integer "customer_type"
|
||||||
t.integer "bike_id"
|
t.integer "bike_id"
|
||||||
t.integer "amount", :null => false
|
t.integer "amount", :null => false
|
||||||
|
t.string "item", :null => false
|
||||||
#Adding whether or not a user sold or purchased the bike
|
#Adding whether or not a user sold or purchased the bike
|
||||||
#could be used to help keep track of external sales.
|
#could be used to help keep track of external sales.
|
||||||
#aka, a collective member (user) sold a bike to
|
#aka, a collective member (user) sold a bike to
|
||||||
@ -11,6 +14,7 @@ class CreateTransactions < ActiveRecord::Migration
|
|||||||
#Currently this model automatically assumes that the user is
|
#Currently this model automatically assumes that the user is
|
||||||
#purchasing a bike, or a part for a bike from the collective
|
#purchasing a bike, or a part for a bike from the collective
|
||||||
#t.boolean "user_sold_flag", :default => false
|
#t.boolean "user_sold_flag", :default => false
|
||||||
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
11
db/schema.rb
11
db/schema.rb
@ -88,9 +88,14 @@ ActiveRecord::Schema.define(:version => 20121229160809) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "transactions", :force => true do |t|
|
create_table "transactions", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "vendor_id", :null => false
|
||||||
t.integer "bike_id"
|
t.integer "customer_id"
|
||||||
t.integer "amount", :null => false
|
t.integer "customer_type"
|
||||||
|
t.integer "bike_id"
|
||||||
|
t.integer "amount", :null => false
|
||||||
|
t.string "item", :null => false
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "user_actions", :force => true do |t|
|
create_table "user_actions", :force => true do |t|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user