diff --git a/app/controllers/application.rb b/app/controllers/application.rb index f7a12a65..73578bcd 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -127,5 +127,5 @@ class ApplicationController < ActionController::Base def send_email_messages Message.send_emails if Message.pending? end - + end diff --git a/app/controllers/deliveries_controller.rb b/app/controllers/deliveries_controller.rb new file mode 100644 index 00000000..dd9f6f87 --- /dev/null +++ b/app/controllers/deliveries_controller.rb @@ -0,0 +1,94 @@ +class DeliveriesController < ApplicationController + + before_filter :find_supplier + + # GET /deliveries + # GET /deliveries.xml + def index + @deliveries = @supplier.deliveries.find(:all) + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @deliveries } + end + end + + # GET /deliveries/1 + # GET /deliveries/1.xml + def show + @delivery = Delivery.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @delivery } + end + end + + # GET /deliveries/new + # GET /deliveries/new.xml + def new + @delivery = @supplier.deliveries.build + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @delivery } + end + end + + # GET /deliveries/1/edit + def edit + @delivery = Delivery.find(params[:id]) + end + + # POST /deliveries + # POST /deliveries.xml + def create + @delivery = Delivery.new(params[:delivery]) + + respond_to do |format| + if @delivery.save + flash[:notice] = 'Delivery was successfully created.' + format.html { redirect_to([@supplier,@delivery]) } + format.xml { render :xml => @delivery, :status => :created, :location => @delivery } + else + format.html { render :action => "new" } + format.xml { render :xml => @delivery.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /deliveries/1 + # PUT /deliveries/1.xml + def update + @delivery = Delivery.find(params[:id]) + + respond_to do |format| + if @delivery.update_attributes(params[:delivery]) + flash[:notice] = 'Delivery was successfully updated.' + format.html { redirect_to([@supplier,@delivery]) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @delivery.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /deliveries/1 + # DELETE /deliveries/1.xml + def destroy + @delivery = Delivery.find(params[:id]) + @delivery.destroy + + respond_to do |format| + format.html { redirect_to(supplier_deliveries_url(@supplier)) } + format.xml { head :ok } + end + end + + protected + + def find_supplier + @supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id] + end +end diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb new file mode 100644 index 00000000..fa657891 --- /dev/null +++ b/app/controllers/invoices_controller.rb @@ -0,0 +1,79 @@ +class InvoicesController < ApplicationController + + def index + @invoices = Invoice.find(:all, :order => "date DESC") + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @invoices } + end + end + + def show + @invoice = Invoice.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @invoice } + end + end + + def new + @invoice = Invoice.new + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @invoice } + end + end + + def edit + @invoice = Invoice.find(params[:id]) + end + + # POST /invoices + # POST /invoices.xml + def create + @invoice = Invoice.new(params[:invoice]) + + respond_to do |format| + if @invoice.save + flash[:notice] = 'Invoice was successfully created.' + format.html { redirect_to(@invoice) } + format.xml { render :xml => @invoice, :status => :created, :location => @invoice } + else + format.html { render :action => "new" } + format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /invoices/1 + # PUT /invoices/1.xml + def update + @invoice = Invoice.find(params[:id]) + + respond_to do |format| + if @invoice.update_attributes(params[:invoice]) + flash[:notice] = 'Invoice was successfully updated.' + format.html { redirect_to(@invoice) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @invoice.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /invoices/1 + # DELETE /invoices/1.xml + def destroy + @invoice = Invoice.find(params[:id]) + @invoice.destroy + + respond_to do |format| + format.html { redirect_to(invoices_path) } + format.xml { head :ok } + end + end +end diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index fb8fd8f2..498d807b 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -1,19 +1,12 @@ class SuppliersController < ApplicationController before_filter :authenticate_suppliers, :except => [:index, :list] - verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } - # messages MSG_SUPPLIER_DESTOYED = "Lieferant wurde gelöscht" MSG_SUPPLIER_UPDATED = 'Lieferant wurde aktualisiert' MSG_SUPPLIER_CREATED = "Lieferant wurde erstellt" def index - list - render :action => 'list' - end - - def list @supplier_column_names = ["Name", "Telefon", "Email", "Kundennummer"] @supplier_columns = ["name", "phone", "email", "customer_number"] @suppliers = Supplier.find :all @@ -40,7 +33,7 @@ class SuppliersController < ApplicationController @supplier = Supplier.new(params[:supplier]) if @supplier.save flash[:notice] = MSG_SUPPLIER_CREATED - redirect_to :action => 'list' + redirect_to suppliers_path else render :action => 'new' end @@ -54,19 +47,20 @@ class SuppliersController < ApplicationController @supplier = Supplier.find(params[:id]) if @supplier.update_attributes(params[:supplier]) flash[:notice] = MSG_SUPPLIER_UPDATED - redirect_to :action => 'show', :id => @supplier + redirect_to @supplier else render :action => 'edit' end end def destroy - Supplier.find(params[:id]).destroy + @supplier = Supplier.find(params[:id]) + @supplier.destroy flash[:notice] = MSG_SUPPLIER_DESTOYED - redirect_to :action => 'list' + redirect_to suppliers_path rescue => e flash[:error] = _("An error has occurred: ") + e.message - redirect_to :action => 'show', :id => params[:id] + redirect_to @supplier end # gives a list with all available shared_suppliers diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9466ba8d..0b3404ed 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -84,5 +84,8 @@ module ApplicationHelper def title(page_title) content_for(:title) { page_title } end - + + def tab_is_active?(tab) + tab[:active].detect {|c| c == controller.controller_name } + end end diff --git a/app/models/article.rb b/app/models/article.rb index 0db95af8..07e3a5c7 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,20 +1,26 @@ -# articles are the internal products which can ordered by ordergroups -# -# articles have the following attributes: -# * name -# * supplier_id -# * article_category_id -# * unit (string, e.g. 500gr, 1liter) -# * note -# * availability (boolean) -# * net_price, decimal (net price, which will be edited by the user) -# * gross_price, decimal (gross price (or long price), incl. tax, deposit, price markup ... see environment.rb) -# * tax, float (the VAT, value added tax. default is 7.00 which means 7.00%) -# * deposit, decimal (deposit, e.g. for bottles) -# * unit_quantity, int (the internal(FC) size of trading unit) -# * order_number, varchar (for the supplier) -# * created_at, timestamp -# * updated_at, timestamp +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: articles +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null +# unit :string(255) default(""), not null +# note :string(255) +# availability :boolean(1) default(TRUE), not null +# manufacturer :string(255) +# origin :string(255) +# shared_updated_on :datetime +# net_price :decimal(8, 2) +# gross_price :decimal(8, 2) default(0.0), not null +# tax :float +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null +# order_number :string(255) +# created_at :datetime +# updated_at :datetime # class Article < ActiveRecord::Base belongs_to :supplier diff --git a/app/models/article_category.rb b/app/models/article_category.rb index b62af15e..5b8ac32f 100644 --- a/app/models/article_category.rb +++ b/app/models/article_category.rb @@ -1,3 +1,13 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: article_categories +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# description :string(255) +# + class ArticleCategory < ActiveRecord::Base has_many :articles diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 6e56a4ec..326888d5 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -1,3 +1,14 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: assignments +# +# id :integer(4) not null, primary key +# user_id :integer(4) default(0), not null +# task_id :integer(4) default(0), not null +# accepted :boolean(1) +# + class Assignment < ActiveRecord::Base belongs_to :user diff --git a/app/models/delivery.rb b/app/models/delivery.rb new file mode 100644 index 00000000..883b939f --- /dev/null +++ b/app/models/delivery.rb @@ -0,0 +1,17 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: deliveries +# +# id :integer(4) not null, primary key +# supplier_id :integer(4) +# delivered_on :date +# created_at :datetime +# + +class Delivery < ActiveRecord::Base + + belongs_to :supplier + + validates_presence_of :supplier_id +end diff --git a/app/models/financial_transaction.rb b/app/models/financial_transaction.rb index a4d5641b..669c3574 100644 --- a/app/models/financial_transaction.rb +++ b/app/models/financial_transaction.rb @@ -1,11 +1,18 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: financial_transactions +# +# id :integer(4) not null, primary key +# order_group_id :integer(4) default(0), not null +# amount :decimal(8, 2) default(0.0), not null +# note :text default(""), not null +# user_id :integer(4) default(0), not null +# created_on :datetime not null +# + # financial transactions are the foodcoop internal financial transactions # only order_groups have an account balance and are happy to transfer money -# -# financial transaction have the following attributes: -# * order_group_id (int) -# * amount (decimal) -# * note (text) -# * created_on (datetime) class FinancialTransaction < ActiveRecord::Base belongs_to :order_group belongs_to :user diff --git a/app/models/group.rb b/app/models/group.rb index 817cc0cd..3a05ef78 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,13 +1,29 @@ -# Groups organize the User. -# -# Group have the following attributes -# * name -# * description -# * type (to specify, if it is a OrderGroup) -# * role_admin, role_suppliers, role_article_eta, role_finance, role_orders -# * weekly_task (if the group should do a job ervery week) -# * weekday (on which weekday should the job be done? 1 means monday and so on) +# == Schema Information +# Schema version: 20090102171850 # +# Table name: groups +# +# id :integer(4) not null, primary key +# type :string(255) default(""), not null +# name :string(255) default(""), not null +# description :string(255) +# actual_size :integer(4) +# account_balance :decimal(8, 2) default(0.0), not null +# account_updated :datetime +# created_on :datetime not null +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) +# task_name :string(255) +# task_description :string(255) +# task_required_users :integer(4) default(1) +# + +# Groups organize the User. # A Member gets the roles from the Group class Group < ActiveRecord::Base has_many :memberships, :dependent => :destroy diff --git a/app/models/group_order.rb b/app/models/group_order.rb index 18912146..7f7aadea 100644 --- a/app/models/group_order.rb +++ b/app/models/group_order.rb @@ -1,14 +1,18 @@ -# A GroupOrder represents an Order placed by an OrderGroup. -# -# Properties: -# * order_id (int): association to the Order -# * order_group_id (int): association to the OrderGroup -# * group_order_articles: collection of associated GroupOrderArticles -# * order_articles: collection of associated OrderArticles (through GroupOrderArticles) -# * price (decimal): the price of this GroupOrder (either maximum price if current order or the actual price if finished order) -# * lock_version (int): ActiveRecord optimistic locking column -# * updated_by (User): the user who last updated this order +# == Schema Information +# Schema version: 20090102171850 # +# Table name: group_orders +# +# id :integer(4) not null, primary key +# order_group_id :integer(4) default(0), not null +# order_id :integer(4) default(0), not null +# price :decimal(8, 2) default(0.0), not null +# lock_version :integer(4) default(0), not null +# updated_on :datetime not null +# updated_by_user_id :integer(4) default(0), not null +# + +# A GroupOrder represents an Order placed by an OrderGroup. class GroupOrder < ActiveRecord::Base belongs_to :order diff --git a/app/models/group_order_article.rb b/app/models/group_order_article.rb index 9db29b1a..f096b5af 100644 --- a/app/models/group_order_article.rb +++ b/app/models/group_order_article.rb @@ -1,12 +1,18 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_articles +# +# id :integer(4) not null, primary key +# group_order_id :integer(4) default(0), not null +# order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0), not null +# tolerance :integer(4) default(0), not null +# updated_on :datetime not null +# + # A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder. # The chronologically order of the OrderGroup - activity are stored in GroupOrderArticleQuantity -# -# Properties: -# * group_order_id (int): association to the GroupOrder -# * order_article_id (int): association to the OrderArticle -# * quantity (int): number of items ordered -# * tolerance (int): number of items ordered as tolerance -# * updated_on (timestamp): updated automatically by ActiveRecord # class GroupOrderArticle < ActiveRecord::Base diff --git a/app/models/group_order_article_quantity.rb b/app/models/group_order_article_quantity.rb index 6ea484e7..178bb613 100644 --- a/app/models/group_order_article_quantity.rb +++ b/app/models/group_order_article_quantity.rb @@ -1,11 +1,17 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_article_quantities +# +# id :integer(4) not null, primary key +# group_order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0) +# tolerance :integer(4) default(0) +# created_on :datetime not null +# + # stores the quantity, tolerance and timestamp of an GroupOrderArticle # Considers every update of an article-order, so may rows for one group_order_article ar possible. -# -# properties: -# * group_order_article_id (int) -# * quantity (int) -# * tolerance (in) -# * created_on (timestamp) class GroupOrderArticleQuantity < ActiveRecord::Base diff --git a/app/models/group_order_article_result.rb b/app/models/group_order_article_result.rb index ddf2d8e8..98de9894 100644 --- a/app/models/group_order_article_result.rb +++ b/app/models/group_order_article_result.rb @@ -1,11 +1,18 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_article_results +# +# id :integer(4) not null, primary key +# order_article_result_id :integer(4) default(0), not null +# group_order_result_id :integer(4) default(0), not null +# quantity :decimal(6, 3) default(0.0) +# tolerance :integer(4) +# + # An GroupOrderArticleResult represents a group-order for a single Article and its quantities, # according to the order quantity/tolerance. # The GroupOrderArticleResult is part of a finished Order, see OrderArticleResult. -# -# Properties: -# * order_article_result_id (int) -# * group_order_result_id (int): associated with OrderGroup through GroupOrderResult.group_name -# * quantity (int) # class GroupOrderArticleResult < ActiveRecord::Base diff --git a/app/models/group_order_result.rb b/app/models/group_order_result.rb index b631e782..4394ac99 100644 --- a/app/models/group_order_result.rb +++ b/app/models/group_order_result.rb @@ -1,10 +1,15 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_results +# +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# group_name :string(255) default(""), not null +# price :decimal(8, 2) default(0.0), not null +# + # OrderGroups, which participate on a specific order will have a line -# Properties: -# * order_id, int -# * group_name, the name of the group -# * price, decimal -# * group_order_article_results: collection of associated GroupOrderArticleResults -# class GroupOrderResult < ActiveRecord::Base belongs_to :order diff --git a/app/models/invite.rb b/app/models/invite.rb index 2cd7260d..942ba8f6 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -1,13 +1,19 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: invites +# +# id :integer(4) not null, primary key +# token :string(255) default(""), not null +# expires_at :datetime not null +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null +# email :string(255) default(""), not null +# + require 'digest/sha1' # Invites are created by foodcoop users to invite a new user into the foodcoop and their order group. -# -# Attributes: -# * token - the authentication token for this invite -# * group - the group the new user is to be made a member of -# * user - the inviting user -# * expires_at - the time this invite expires -# * email - the recipient's email address class Invite < ActiveRecord::Base belongs_to :user belongs_to :group diff --git a/app/models/invoice.rb b/app/models/invoice.rb new file mode 100644 index 00000000..2b5a7156 --- /dev/null +++ b/app/models/invoice.rb @@ -0,0 +1,28 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: invoices +# +# id :integer(4) not null, primary key +# supplier_id :integer(4) +# delivery_id :integer(4) +# number :string(255) +# date :date +# paid_on :date +# amount :decimal(8, 2) default(0.0), not null +# created_at :datetime +# updated_at :datetime +# + +class Invoice < ActiveRecord::Base + + belongs_to :supplier + + validates_presence_of :supplier_id + validates_uniqueness_of :date, :scope => [:supplier_id] + + # Custom attribute setter that accepts decimal numbers using localized decimal separator. + def amount=(amount) + self[:amount] = String.delocalized_decimal(amount) + end +end diff --git a/app/models/membership.rb b/app/models/membership.rb index c43ba73f..456a8670 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -1,3 +1,13 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: memberships +# +# id :integer(4) not null, primary key +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null +# + class Membership < ActiveRecord::Base belongs_to :user diff --git a/app/models/message.rb b/app/models/message.rb index 393ff6f6..05ec0dff 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,13 +1,19 @@ -# A message within the foodsoft. -# -# * sender (User) - the sending User (might be nil if it is a system message) -# * recipient (User) - the receiving User -# * recipients (String) - list of all recipients of this message as User.nick/Group.name -# * subject (string) - message subject -# * body (string) - message body -# * read? (boolean) - message read status -# * email_state (integer) - email state, one of EMAIL_STATE.values -# * created_on (timestamp) - creation timestamp +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: messages +# +# id :integer(4) not null, primary key +# sender_id :integer(4) +# recipient_id :integer(4) default(0), not null +# recipients :string(255) default(""), not null +# subject :string(255) default(""), not null +# body :text default(""), not null +# read :boolean(1) not null +# email_state :integer(4) default(0), not null +# created_on :datetime not null +# + class Message < ActiveRecord::Base belongs_to :sender, :class_name => "User", :foreign_key => "sender_id" belongs_to :recipient, :class_name => "User", :foreign_key => "recipient_id" diff --git a/app/models/order.rb b/app/models/order.rb index 56aa46d1..90031439 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,3 +1,25 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: orders +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# supplier_id :integer(4) default(0), not null +# starts :datetime not null +# ends :datetime +# note :string(255) +# finished :boolean(1) not null +# booked :boolean(1) not null +# lock_version :integer(4) default(0), not null +# updated_by_user_id :integer(4) +# invoice_amount :decimal(8, 2) default(0.0), not null +# deposit :decimal(8, 2) default(0.0) +# deposit_credit :decimal(8, 2) default(0.0) +# invoice_number :string(255) +# invoice_date :string(255) +# + class Order < ActiveRecord::Base has_many :order_articles, :dependent => :destroy has_many :articles, :through => :order_articles diff --git a/app/models/order_article.rb b/app/models/order_article.rb index d88c16a0..879d250a 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -1,12 +1,18 @@ -# An OrderArticle represents a single Article that is part of an Order. -# -# Properties: -# * order_id (int): association to the Order -# * article_id (int): association to the Article -# * quantity (int): number of items ordered by all OrderGroups for this order -# * tolerance (int): number of items ordered as tolerance by all OrderGroups for this order -# * units_to_order (int): number of packaging units to be ordered according to the order quantity/tolerance +# == Schema Information +# Schema version: 20090102171850 # +# Table name: order_articles +# +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# article_id :integer(4) default(0), not null +# quantity :integer(4) default(0), not null +# tolerance :integer(4) default(0), not null +# units_to_order :integer(4) default(0), not null +# lock_version :integer(4) default(0), not null +# + +# An OrderArticle represents a single Article that is part of an Order. class OrderArticle < ActiveRecord::Base belongs_to :order diff --git a/app/models/order_article_result.rb b/app/models/order_article_result.rb index 1a80153d..72264bf3 100644 --- a/app/models/order_article_result.rb +++ b/app/models/order_article_result.rb @@ -1,19 +1,24 @@ -# An OrderArticleResult represents a single Article that is part of a *finished* Order. -# -# Properties: -# * order_id (int): association to the Order -# * name (string): article name -# * unit (string) -# * note (string): for post-editing the ordered article. informations like "new tax is ..." -# * net_price (decimal): the net price -# * gross_price (decimal): incl tax, deposit, fc-markup -# * tax (int) -# * deposit (decimal) -# * fc_markup (float) -# * order_number (string) -# * unit_quantity (int): the internal(FC) size of trading unit -# * units_to_order (int): number of packaging units to be ordered according to the order quantity/tolerance +# == Schema Information +# Schema version: 20090102171850 # +# Table name: order_article_results +# +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# name :string(255) default(""), not null +# unit :string(255) default(""), not null +# note :string(255) +# net_price :decimal(8, 2) default(0.0) +# gross_price :decimal(8, 2) default(0.0), not null +# tax :float default(0.0), not null +# deposit :decimal(8, 2) default(0.0) +# fc_markup :float default(0.0), not null +# order_number :string(255) +# unit_quantity :integer(4) default(0), not null +# units_to_order :decimal(6, 3) default(0.0), not null +# + +# An OrderArticleResult represents a single Article that is part of a *finished* Order. class OrderArticleResult < ActiveRecord::Base belongs_to :order has_many :group_order_article_results, :dependent => :destroy diff --git a/app/models/order_group.rb b/app/models/order_group.rb index 7380a6a3..bbc76e89 100644 --- a/app/models/order_group.rb +++ b/app/models/order_group.rb @@ -1,3 +1,28 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: groups +# +# id :integer(4) not null, primary key +# type :string(255) default(""), not null +# name :string(255) default(""), not null +# description :string(255) +# actual_size :integer(4) +# account_balance :decimal(8, 2) default(0.0), not null +# account_updated :datetime +# created_on :datetime not null +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) +# task_name :string(255) +# task_description :string(255) +# task_required_users :integer(4) default(1) +# + # OrderGroups can order, they are "children" of the class Group # # OrderGroup have the following attributes, in addition to Group diff --git a/app/models/shared_article.rb b/app/models/shared_article.rb index c42481c1..5fe90129 100644 --- a/app/models/shared_article.rb +++ b/app/models/shared_article.rb @@ -1,3 +1,27 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: articles +# +# id :integer(4) not null, primary key +# name :string(255) not null +# supplier_id :integer(4) not null +# number :string(255) +# note :string(255) +# manufacturer :string(255) +# origin :string(255) +# unit :string(255) +# price :decimal(8, 2) default(0.0), not null +# tax :decimal(3, 1) default(7.0), not null +# deposit :decimal(8, 2) default(0.0), not null +# unit_quantity :decimal(4, 1) default(1.0), not null +# scale_quantity :decimal(4, 2) +# scale_price :decimal(8, 2) +# created_on :datetime +# updated_on :datetime +# list :string(255) +# + class SharedArticle < ActiveRecord::Base # connect to database from sharedLists-Application diff --git a/app/models/shared_supplier.rb b/app/models/shared_supplier.rb index 43430757..fd4d8f0a 100644 --- a/app/models/shared_supplier.rb +++ b/app/models/shared_supplier.rb @@ -1,3 +1,23 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: suppliers +# +# id :integer(4) not null, primary key +# name :string(255) not null +# address :string(255) not null +# phone :string(255) not null +# phone2 :string(255) +# fax :string(255) +# email :string(255) +# url :string(255) +# delivery_days :string(255) +# note :string(255) +# created_on :datetime +# updated_on :datetime +# lists :string(255) +# + class SharedSupplier < ActiveRecord::Base # connect to database from sharedLists-Application diff --git a/app/models/supplier.rb b/app/models/supplier.rb index e9548248..a30b9308 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -1,6 +1,31 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: suppliers +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# address :string(255) default(""), not null +# phone :string(255) default(""), not null +# phone2 :string(255) +# fax :string(255) +# email :string(255) +# url :string(255) +# contact_person :string(255) +# customer_number :string(255) +# delivery_days :string(255) +# order_howto :string(255) +# note :string(255) +# shared_supplier_id :integer(4) +# min_order_quantity :string(255) +# + class Supplier < ActiveRecord::Base has_many :articles, :dependent => :destroy has_many :orders + has_many :deliveries + has_many :invoices + attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, :delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity validates_length_of :name, :in => 4..30 diff --git a/app/models/task.rb b/app/models/task.rb index d80d04e5..99b7f517 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,3 +1,20 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: tasks +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# description :string(255) +# due_date :date +# done :boolean(1) +# group_id :integer(4) +# assigned :boolean(1) +# created_on :datetime not null +# updated_on :datetime not null +# required_users :integer(4) default(1) +# + class Task < ActiveRecord::Base has_many :assignments, :dependent => :destroy has_many :users, :through => :assignments diff --git a/app/models/user.rb b/app/models/user.rb index fe875ec7..1e4c4cc3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,13 +1,24 @@ -require 'digest/sha1' +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: users +# +# id :integer(4) not null, primary key +# nick :string(255) default(""), not null +# password_hash :string(255) default(""), not null +# password_salt :string(255) default(""), not null +# first_name :string(255) default(""), not null +# last_name :string(255) default(""), not null +# email :string(255) default(""), not null +# phone :string(255) +# address :string(255) +# created_on :datetime not null +# reset_password_token :string(255) +# reset_password_expires :datetime +# last_login :datetime +# -# A foodsoft user. -# -# * memberships -# * groups -# * first_name, last_name, email, phone, address -# * nick -# * password (stored as a hash) -# * settings (user properties via acts_as_configurable plugin) +require 'digest/sha1' # specific user rights through memberships (see Group) class User < ActiveRecord::Base has_many :memberships, :dependent => :destroy @@ -173,4 +184,4 @@ class User < ActiveRecord::Base self.groups.find(:all, :conditions => {:type => ""}) end -end \ No newline at end of file +end diff --git a/app/views/deliveries/edit.html.erb b/app/views/deliveries/edit.html.erb new file mode 100644 index 00000000..cad38f80 --- /dev/null +++ b/app/views/deliveries/edit.html.erb @@ -0,0 +1,17 @@ +

Editing delivery

+ +<% form_for([@supplier,@delivery]) do |f| %> + <%= f.error_messages %> + <%= f.hidden_field :supplier_id %> + +

+ <%= f.label :delivered_on %>
+ <%= f.date_select :delivered_on %> +

+

+ <%= f.submit "Update" %> +

+<% end %> + +<%= link_to 'Show', [@supplier,@delivery] %> | +<%= link_to 'Back', supplier_deliveries_path(@supplier) %> diff --git a/app/views/deliveries/index.html.erb b/app/views/deliveries/index.html.erb new file mode 100644 index 00000000..8bf63994 --- /dev/null +++ b/app/views/deliveries/index.html.erb @@ -0,0 +1,22 @@ +<% title "#{@supplier.name}/deliveries" %> + + + + + + + +<% for delivery in @deliveries %> + + + + + + + +<% end %> +
Delivered onInvoice
<%=h delivery.delivered_on %><%=h "invoice ..." %><%= link_to 'Show', [@supplier, delivery] %><%= link_to 'Edit', edit_supplier_delivery_path(@supplier,delivery) %><%= link_to 'Destroy', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete %>
+ +
+ +<%= link_to 'New delivery', new_supplier_delivery_path(@supplier) %> diff --git a/app/views/deliveries/new.html.erb b/app/views/deliveries/new.html.erb new file mode 100644 index 00000000..60388294 --- /dev/null +++ b/app/views/deliveries/new.html.erb @@ -0,0 +1,16 @@ +

New delivery

+ +<% form_for([@supplier,@delivery]) do |f| %> + <%= f.error_messages %> + <%= f.hidden_field :supplier_id %> + +

+ <%= f.label :delivered_on %>
+ <%= f.date_select :delivered_on %> +

+

+ <%= f.submit "Create" %> +

+<% end %> + +<%= link_to 'Back', supplier_deliveries_path(@supplier) %> diff --git a/app/views/deliveries/show.html.erb b/app/views/deliveries/show.html.erb new file mode 100644 index 00000000..d9ca7317 --- /dev/null +++ b/app/views/deliveries/show.html.erb @@ -0,0 +1,13 @@ +

+ Supplier: + <%=h @delivery.supplier_id %> +

+ +

+ Delivered on: + <%=h @delivery.delivered_on %> +

+ + +<%= link_to 'Edit', edit_supplier_delivery_path(@supplier,@delivery) %> | +<%= link_to 'Back', supplier_deliveries_path(@supplier) %> diff --git a/app/views/invoices/edit.html.erb b/app/views/invoices/edit.html.erb new file mode 100644 index 00000000..afa54dec --- /dev/null +++ b/app/views/invoices/edit.html.erb @@ -0,0 +1,36 @@ +

Editing invoice

+ +<% form_for(@invoice) do |f| %> + <%= f.error_messages %> + +

+ <%= f.label :supplier_id %>
+ <%= f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] } %> +

+

+ <%= f.label :number %>
+ <%= f.text_field :number %> +

+

+ <%= f.label :date %>
+ <%= f.date_select :date %> +

+

+ <%= f.label :paid_on %>
+ <%= f.date_select :paid_on, :include_blank => true %> +

+

+ <%= f.label :amount %>
+ <%= f.text_field :amount %> +

+

+ <%= f.label :note %>
+ <%= f.text_area :note %> +

+

+ <%= f.submit "Update" %> +

+<% end %> + +<%= link_to 'Show', @invoice %> | +<%= link_to 'Back', invoices_path %> diff --git a/app/views/invoices/index.html.erb b/app/views/invoices/index.html.erb new file mode 100644 index 00000000..3c08f4e1 --- /dev/null +++ b/app/views/invoices/index.html.erb @@ -0,0 +1,32 @@ +<% title "Invoices" %> + + + + + + + + + + + + +<% for invoice in @invoices %> + + + + + + + + + + + + +<% end %> +
SupplierNumberDatePaid onAmountDeliveryNote
<%=h invoice.supplier.name %><%=h invoice.number %><%= invoice.date %><%= invoice.paid_on %><%= invoice.amount %><%=h invoice.delivery_id %><%=h truncate(invoice.note) %><%= link_to 'Show', invoice %><%= link_to 'Edit', edit_invoice_path(invoice) %><%= link_to 'Destroy', invoice, :confirm => 'Are you sure?', :method => :delete %>
+ +
+ +<%= link_to 'New invoice', new_invoice_path %> diff --git a/app/views/invoices/new.html.erb b/app/views/invoices/new.html.erb new file mode 100644 index 00000000..3effdbc4 --- /dev/null +++ b/app/views/invoices/new.html.erb @@ -0,0 +1,35 @@ +

New invoice

+ +<% form_for(@invoice) do |f| %> + <%= f.error_messages %> + +

+ <%= f.label :supplier_id %>
+ <%= f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] } %> +

+

+ <%= f.label :number %>
+ <%= f.text_field :number %> +

+

+ <%= f.label :date %>
+ <%= f.date_select :date %> +

+

+ <%= f.label :paid_on %>
+ <%= f.date_select :paid_on, :include_blank => true %> +

+

+ <%= f.label :amount %>
+ <%= f.text_field :amount %> +

+

+ <%= f.label :note %>
+ <%= f.text_area :note %> +

+

+ <%= f.submit "Create" %> +

+<% end %> + +<%= link_to 'Back', invoices_path %> diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb new file mode 100644 index 00000000..890498c4 --- /dev/null +++ b/app/views/invoices/show.html.erb @@ -0,0 +1,40 @@ +<% title "Show invoice #{@invoice.number}" %> + +

+ Supplier: + <%=h @invoice.supplier.name %> +

+ +

+ Delivery: + <%=h @invoice.delivery_id %> +

+ +

+ Number: + <%=h @invoice.number %> +

+ +

+ Date: + <%=h @invoice.date %> +

+ +

+ Paid on: + <%=h @invoice.paid_on %> +

+ +

+ Amount: + <%=h @invoice.amount %> +

+ +

+ Note: + <%=h @invoice.note %> +

+ + +<%= link_to 'Edit', edit_invoice_path(@invoice) %> | +<%= link_to 'Back', invoices_path %> diff --git a/app/views/layouts/_main_tabnav.html.erb b/app/views/layouts/_main_tabnav.html.erb new file mode 100644 index 00000000..eaecae3c --- /dev/null +++ b/app/views/layouts/_main_tabnav.html.erb @@ -0,0 +1,61 @@ +<% + u = @current_user + tabs = [ + { :name => "Start", :url => root_path, :active => ["index", "messages", "tasks"], + :subnav => [ + { :name => "Members", :url => "/index/foodcoop_members"}, + { :name => "Workgroups", :url => "/index/workgroups"}, + { :name => "Tasks", :url => "/tasks"}, + { :name => "Messages", :url => "/messages/inbox"}, + { :name => "My Ordergroup", :url => my_order_group_path}, + { :name => "My Ordergroup", :url => my_profile_path} + ] + }, + { :name => "Orders", :url => "/ordering", :active => ["orders", "ordering"], + :subnav => [ + { :name => "Order", :url => "/ordering" }, + { :name => "My orders", :url => "/ordering/myOrders" }, + { :name => "Manage orders", :url => "/orders", :access? => (u.role_orders?) } + ] + }, + { :name => "Articles", :url => "/articles", :active => ["articles", "suppliers"], + :access? => (u.role_article_meta? || u.role_suppliers?), + :subnav => [ + { :name => "Show articles", :url => "/articles/list" }, + { :name => "Categories", :url => "/articles" }, + { :name => "Suppliers", :url => suppliers_path, :access? => (u.role_suppliers?) } + ] + }, + { :name => "Finance", :url => "/finance", :active => ["finance", "invoices"], + :access? => (u.role_finance?), + :subnav => [ + { :name => "Ordergroups", :url => "/finance/listOrdergroups" }, + { :name => "Balance orders", :url => "/finance/listOrders" }, + { :name => "Invoices", :url => invoices_path } + ] + }, + { :name => "Administration", :url => "/admin", :active => ["admin"], + :access? => (u.role_admin?), + :subnav => [ + { :name => "Users", :url => "/admin/listUsers" }, + { :name => "Groups", :url => "/admin/listGroups" } + ] + } + ] +-%> + \ No newline at end of file diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 609db973..e7f08e6d 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -18,7 +18,7 @@ %a{:href => "/"} foodsoft %span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= APP_CONFIG[:name] - #nav= render :partial => 'shared/nav' + #nav= render :partial => 'layouts/main_tabnav' #main #content diff --git a/app/views/shared/_nav.haml b/app/views/shared/_nav.haml deleted file mode 100644 index 243f645e..00000000 --- a/app/views/shared/_nav.haml +++ /dev/null @@ -1,52 +0,0 @@ -%ul - // Startarea - %li{:class => ("current" if controller.controller_name == 'index' || controller.controller_name == 'messages' || controller.controller_name == 'tasks')} - = link_to _('Startpage'), {:controller => 'index', :action => 'index'}, {:title => _('The Startpage. A good Startpoint.')} - %ul - %li= link_to _("Members"), {:controller => "index", :action => "foodcoop_members"}, {:title => _('Here you find a List with all Foodcoop members.')} - %li= link_to _("Workgroups"), {:controller => "index", :action => "workgroups"}, {:title => _('Here you find all Workgroups. For Example the sortinggroup with all their members.')} - %li= link_to _("Tasks"), {:controller => "tasks"}, {:title => _('Here you see the tasks. Please do something for the foodcoop!')} - - unread = Message.find_all_by_recipient_id_and_read(@current_user.id, false) - %li= link_to _("Messages") + "#{unread.nil? || unread.empty? ? '' : "(#{unread.size})"}", {:controller => 'messages', :action => 'inbox'}, {:title => _('Here you can read/write Messages from/to other foodcoop members')} - - if @current_user.find_ordergroup - %li= link_to _("My ordergroup"), {:controller => 'index', :action => 'myOrdergroup'}, {:title => _('Here are informations about your ordergroup. You can also see your accounts current')} - %li= link_to _("My Profile"), my_profile_path, {:title => _('Here are your personal Settings')} - - // Orders - - hasOrderGroup = !@current_user.find_ordergroup.nil? - - hasOrdersRole = @current_user.role_orders? - - - if hasOrderGroup || hasOrdersRole - %li{:class => ("current" if controller.controller_name == 'orders' || controller.controller_name == 'ordering')} - = hasOrderGroup ? link_to( _("Orders"), :controller => 'ordering') : link_to('Bestellungen', :controller => 'orders') - %ul - - if hasOrderGroup - %li= link_to _("Order"), :controller => "ordering" - %li= link_to _("My orders"), :controller => 'ordering', :action => "myOrders" - - if hasOrdersRole - %li= link_to _("Manage orders"), :controller => 'orders' - - // Articles, Suppliers - - if @current_user.role_article_meta? || @current_user.role_suppliers? - %li{:class => ("current" if controller.controller_name == 'articles' || controller.controller_name == 'suppliers')} - = link_to _("Articles"), :controller => 'articles', :action => 'index' - %ul - %li= link_to _("Show articles"), :controller => 'articles', :action => 'list' - %li= link_to _("Categories"), :controller => 'articles', :action => 'index' - %li= link_to _("Suppliers"), :controller => 'suppliers', :action => 'list' - - // Finance - - if @current_user.role_finance? - %li{:class => ("current" if controller.controller_name == 'finance')} - = link_to _("Finance"), :controller => 'finance' - %ul - %li= link_to _("Ordergroups"), :controller => 'finance', :action => 'listOrdergroups' - %li= link_to _("Balance orders"), :controller => 'finance', :action => 'listOrders' - - // Administration - - if @current_user.role_admin? - %li{:class => ("current" if controller.controller_name == 'admin')} - = link_to _("Administration"), :controller => 'admin' - %ul - %li= link_to _("User"), :controller => 'admin', :action => 'listUsers' - %li= link_to _("Groups"), :controller => 'admin', :action => 'listGroups' \ No newline at end of file diff --git a/app/views/suppliers/_form.haml b/app/views/suppliers/_form.haml index 38e7ba81..e3b3a2b7 100644 --- a/app/views/suppliers/_form.haml +++ b/app/views/suppliers/_form.haml @@ -1,6 +1,5 @@ = error_messages_for 'supplier' - - if @supplier.shared_supplier %p Lieferantin wird mit externer Datenbank verknüpft. .edit_form{:style=>"width:30em"} @@ -58,5 +57,4 @@ %label{:for => "supplier_min_order_quantity"} Mindestbestellmenge %td= @f.text_field :min_order_quantity = @f.hidden_field :shared_supplier_id - diff --git a/app/views/suppliers/edit.haml b/app/views/suppliers/edit.haml index bdf6c119..692f80dd 100644 --- a/app/views/suppliers/edit.haml +++ b/app/views/suppliers/edit.haml @@ -1,6 +1,6 @@ %h1 Lieferantin bearbeiten -- form_for :supplier, @supplier, :url => {:action => 'update', :id => @supplier} do |@f| +- form_for @supplier do |@f| = render :partial => 'form' = submit_tag 'Speichern' | - = link_to 'Abbrechen', :action => 'list' \ No newline at end of file + = link_to 'Abbrechen', suppliers_path \ No newline at end of file diff --git a/app/views/suppliers/list.haml b/app/views/suppliers/index.haml similarity index 71% rename from app/views/suppliers/list.haml rename to app/views/suppliers/index.haml index 785f0692..623deebe 100644 --- a/app/views/suppliers/list.haml +++ b/app/views/suppliers/index.haml @@ -1,11 +1,12 @@ -%h1 Lieferantinnen +- title "LieferantInnen" + - if @current_user.role_suppliers? %p %i Erstelle eine - = link_to 'neue Lieferantin', :action => 'new' + = link_to 'neue Lieferantin', new_supplier_path oder - = link_to 'importiere', :action => 'shared_suppliers' + = link_to 'importiere', shared_suppliers_suppliers_path aus der externen ArtikelDatenbank. .left_column{:style => "width:100%"} @@ -22,7 +23,7 @@ - for column in @supplier_columns %td - if column == 'name' - = link_to supplier[column], :action => 'show', :id => supplier + = link_to supplier[column], supplier - else =h supplier[column] %td= link_to 'Artikel anzeigen', :controller => 'articles', :action => 'list', :id => supplier \ No newline at end of file diff --git a/app/views/suppliers/new.haml b/app/views/suppliers/new.haml index 3d3096ae..c8a4d1a1 100644 --- a/app/views/suppliers/new.haml +++ b/app/views/suppliers/new.haml @@ -1,7 +1,7 @@ %h1 Neue Lieferantinn -- form_for :supplier, @supplier, :url => {:action => 'create'} do |@f| +- form_for @supplier do |@f| = render :partial => 'form' = submit_tag "Speichern" | - = link_to 'Abbrechen', :action => 'list' + = link_to 'Abbrechen', suppliers_path \ No newline at end of file diff --git a/app/views/suppliers/shared_suppliers.haml b/app/views/suppliers/shared_suppliers.haml index 9d6cbea2..53a0c948 100644 --- a/app/views/suppliers/shared_suppliers.haml +++ b/app/views/suppliers/shared_suppliers.haml @@ -24,4 +24,4 @@ %td=h shared_supplier.note %td=h shared_supplier.delivery_days %td= image_tag("icon_message.gif", :size => "16x16", :border => "0",:alt => "abonniert!") if shared_supplier.supplier - %td= link_to "abonnieren", :action => "new", :shared_supplier_id => shared_supplier unless shared_supplier.supplier \ No newline at end of file + %td= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier) unless shared_supplier.supplier \ No newline at end of file diff --git a/app/views/suppliers/show.haml b/app/views/suppliers/show.haml index 9766369d..cdfa56f9 100644 --- a/app/views/suppliers/show.haml +++ b/app/views/suppliers/show.haml @@ -47,8 +47,8 @@ %td{:style => "font-weight:bold"}=h @supplier.min_order_quantity %br/ - if @current_user.role_suppliers? - = link_to 'Bearbeiten', :action => 'edit', :id => @supplier + = link_to 'Bearbeiten', edit_supplier_path(@supplier) | - = link_to 'Löschen', { :action => 'destroy', :id => @supplier }, :confirm => 'Bist Du sicher?', :method => "post" + = link_to 'Löschen', @supplier, :confirm => 'Bist Du sicher?', :method => :delete | -= link_to 'zurück', :action => 'list' \ No newline at end of file += link_to 'zurück', suppliers_path \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 98efed4a..09e333d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,12 @@ ActionController::Routing::Routes.draw do |map| + map.resources :invoices + map.resources :suppliers, + :has_many => [:deliveries], + :collection => { :shared_suppliers => :get } + map.my_profile 'my_profile', :controller => 'index', :action => 'myProfile' + map.my_order_group 'my_order_group', :controller => 'index', :action => 'myOrdergroup' map.root :controller => 'index' diff --git a/db/migrate/20090102155714_create_invoices.rb b/db/migrate/20090102155714_create_invoices.rb new file mode 100644 index 00000000..136203a0 --- /dev/null +++ b/db/migrate/20090102155714_create_invoices.rb @@ -0,0 +1,19 @@ +class CreateInvoices < ActiveRecord::Migration + def self.up + create_table :invoices do |t| + t.integer :supplier_id + t.integer :delivery_id + t.string :number + t.date :date + t.date :paid_on + t.text :note + t.decimal :amount, :null => false, :precision => 8, :scale => 2, :default => 0.0 + + t.timestamps + end + end + + def self.down + drop_table :invoices + end +end diff --git a/db/migrate/20090102171850_create_deliveries.rb b/db/migrate/20090102171850_create_deliveries.rb new file mode 100644 index 00000000..58d43f35 --- /dev/null +++ b/db/migrate/20090102171850_create_deliveries.rb @@ -0,0 +1,13 @@ +class CreateDeliveries < ActiveRecord::Migration + def self.up + create_table :deliveries do |t| + t.integer :supplier_id + t.date :delivered_on + t.datetime :created_at + end + end + + def self.down + drop_table :deliveries + end +end diff --git a/db/schema.rb b/db/schema.rb index 66a3f7eb..8ef6ca61 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,5 +1,5 @@ # This file is auto-generated from the current state of the database. Instead of editing this file, -# please use the migrations feature of ActiveRecord to incrementally modify your database, and +# please use the migrations feature of Active Record to incrementally modify your database, and # then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your database schema. If you need @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 25) do +ActiveRecord::Schema.define(:version => 20090102155714) do create_table "article_categories", :force => true do |t| t.string "name", :default => "", :null => false @@ -93,8 +93,8 @@ ActiveRecord::Schema.define(:version => 25) do t.integer "tolerance" end - add_index "group_order_article_results", ["order_article_result_id"], :name => "index_group_order_article_results_on_order_article_result_id" add_index "group_order_article_results", ["group_order_result_id"], :name => "index_group_order_article_results_on_group_order_result_id" + add_index "group_order_article_results", ["order_article_result_id"], :name => "index_group_order_article_results_on_order_article_result_id" create_table "group_order_articles", :force => true do |t| t.integer "group_order_id", :default => 0, :null => false @@ -157,6 +157,18 @@ ActiveRecord::Schema.define(:version => 25) do add_index "invites", ["token"], :name => "index_invites_on_token" + create_table "invoices", :force => true do |t| + t.integer "supplier_id" + t.integer "delivery_id" + t.string "number" + t.date "date" + t.date "paid_on" + t.text "note" + t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "memberships", :force => true do |t| t.integer "group_id", :default => 0, :null => false t.integer "user_id", :default => 0, :null => false @@ -175,8 +187,8 @@ ActiveRecord::Schema.define(:version => 25) do t.datetime "created_on", :null => false end - add_index "messages", ["sender_id"], :name => "index_messages_on_sender_id" add_index "messages", ["recipient_id"], :name => "index_messages_on_recipient_id" + add_index "messages", ["sender_id"], :name => "index_messages_on_sender_id" create_table "order_article_results", :force => true do |t| t.integer "order_id", :default => 0, :null => false @@ -223,9 +235,9 @@ ActiveRecord::Schema.define(:version => 25) do t.string "invoice_date" end - add_index "orders", ["starts"], :name => "index_orders_on_starts" add_index "orders", ["ends"], :name => "index_orders_on_ends" add_index "orders", ["finished"], :name => "index_orders_on_finished" + add_index "orders", ["starts"], :name => "index_orders_on_starts" create_table "suppliers", :force => true do |t| t.string "name", :default => "", :null => false @@ -258,8 +270,8 @@ ActiveRecord::Schema.define(:version => 25) do t.integer "required_users", :default => 1 end - add_index "tasks", ["name"], :name => "index_tasks_on_name" add_index "tasks", ["due_date"], :name => "index_tasks_on_due_date" + add_index "tasks", ["name"], :name => "index_tasks_on_name" create_table "users", :force => true do |t| t.string "nick", :default => "", :null => false @@ -276,7 +288,7 @@ ActiveRecord::Schema.define(:version => 25) do t.datetime "last_login" end - add_index "users", ["nick"], :name => "index_users_on_nick", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["nick"], :name => "index_users_on_nick", :unique => true end diff --git a/test/fixtures/article_categories.yml b/test/fixtures/article_categories.yml index 360bf331..503d31fc 100644 --- a/test/fixtures/article_categories.yml +++ b/test/fixtures/article_categories.yml @@ -1,3 +1,13 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: article_categories +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# description :string(255) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html fruits: id: 1 diff --git a/test/fixtures/articles.yml b/test/fixtures/articles.yml index 5c609927..018eb3b7 100644 --- a/test/fixtures/articles.yml +++ b/test/fixtures/articles.yml @@ -1,3 +1,27 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: articles +# +# id :integer(4) not null, primary key +# name :string(255) not null +# supplier_id :integer(4) not null +# number :string(255) +# note :string(255) +# manufacturer :string(255) +# origin :string(255) +# unit :string(255) +# price :decimal(8, 2) default(0.0), not null +# tax :decimal(3, 1) default(7.0), not null +# deposit :decimal(8, 2) default(0.0), not null +# unit_quantity :decimal(4, 1) default(1.0), not null +# scale_quantity :decimal(4, 2) +# scale_price :decimal(8, 2) +# created_on :datetime +# updated_on :datetime +# list :string(255) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html banana: id: 1 diff --git a/test/fixtures/assignments.yml b/test/fixtures/assignments.yml index b49c4eb4..74a2fa48 100644 --- a/test/fixtures/assignments.yml +++ b/test/fixtures/assignments.yml @@ -1,3 +1,14 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: assignments +# +# id :integer(4) not null, primary key +# user_id :integer(4) default(0), not null +# task_id :integer(4) default(0), not null +# accepted :boolean(1) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html one: id: 1 diff --git a/test/fixtures/financial_transactions.yml b/test/fixtures/financial_transactions.yml index 8794d28a..efd751ab 100644 --- a/test/fixtures/financial_transactions.yml +++ b/test/fixtures/financial_transactions.yml @@ -1,3 +1,16 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: financial_transactions +# +# id :integer(4) not null, primary key +# order_group_id :integer(4) default(0), not null +# amount :decimal(8, 2) default(0.0), not null +# note :text default(""), not null +# user_id :integer(4) default(0), not null +# created_on :datetime not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 diff --git a/test/fixtures/group_order_article_quantities.yml b/test/fixtures/group_order_article_quantities.yml index 8794d28a..86c8320d 100644 --- a/test/fixtures/group_order_article_quantities.yml +++ b/test/fixtures/group_order_article_quantities.yml @@ -1,3 +1,15 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_article_quantities +# +# id :integer(4) not null, primary key +# group_order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0) +# tolerance :integer(4) default(0) +# created_on :datetime not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 diff --git a/test/fixtures/group_order_article_results.yml b/test/fixtures/group_order_article_results.yml index 8794d28a..4f798ab4 100644 --- a/test/fixtures/group_order_article_results.yml +++ b/test/fixtures/group_order_article_results.yml @@ -1,3 +1,15 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_article_results +# +# id :integer(4) not null, primary key +# order_article_result_id :integer(4) default(0), not null +# group_order_result_id :integer(4) default(0), not null +# quantity :decimal(6, 3) default(0.0) +# tolerance :integer(4) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 diff --git a/test/fixtures/group_order_results.yml b/test/fixtures/group_order_results.yml index 0a5da446..e34103d0 100644 --- a/test/fixtures/group_order_results.yml +++ b/test/fixtures/group_order_results.yml @@ -1,3 +1,14 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: group_order_results +# +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# group_name :string(255) default(""), not null +# price :decimal(8, 2) default(0.0), not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html one: id: 1 @@ -9,4 +20,4 @@ two: order_id: 1 group_name: Order Group 2 price: 99.95 - \ No newline at end of file + diff --git a/test/fixtures/groups.yml b/test/fixtures/groups.yml index 8d977982..8f3e6cc9 100644 --- a/test/fixtures/groups.yml +++ b/test/fixtures/groups.yml @@ -1,3 +1,28 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: groups +# +# id :integer(4) not null, primary key +# type :string(255) default(""), not null +# name :string(255) default(""), not null +# description :string(255) +# actual_size :integer(4) +# account_balance :decimal(8, 2) default(0.0), not null +# account_updated :datetime +# created_on :datetime not null +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) +# task_name :string(255) +# task_description :string(255) +# task_required_users :integer(4) default(1) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 @@ -10,4 +35,4 @@ another: admins: id: 3 name: Administrators - role_admin: true \ No newline at end of file + role_admin: true diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml index b42c5236..4d644770 100644 --- a/test/fixtures/memberships.yml +++ b/test/fixtures/memberships.yml @@ -1,3 +1,13 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: memberships +# +# id :integer(4) not null, primary key +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 @@ -7,4 +17,4 @@ another: id: 2 group_id: 1 user_id: 2 - \ No newline at end of file + diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index b49c4eb4..d8656bb1 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -1,3 +1,19 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: messages +# +# id :integer(4) not null, primary key +# sender_id :integer(4) +# recipient_id :integer(4) default(0), not null +# recipients :string(255) default(""), not null +# subject :string(255) default(""), not null +# body :text default(""), not null +# read :boolean(1) not null +# email_state :integer(4) default(0), not null +# created_on :datetime not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html one: id: 1 diff --git a/test/fixtures/order_article_results.yml b/test/fixtures/order_article_results.yml index 8794d28a..a743afdd 100644 --- a/test/fixtures/order_article_results.yml +++ b/test/fixtures/order_article_results.yml @@ -1,3 +1,23 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: order_article_results +# +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# name :string(255) default(""), not null +# unit :string(255) default(""), not null +# note :string(255) +# net_price :decimal(8, 2) default(0.0) +# gross_price :decimal(8, 2) default(0.0), not null +# tax :float default(0.0), not null +# deposit :decimal(8, 2) default(0.0) +# fc_markup :float default(0.0), not null +# order_number :string(255) +# unit_quantity :integer(4) default(0), not null +# units_to_order :decimal(6, 3) default(0.0), not null +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index 8794d28a..63a9d2f4 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -1,3 +1,25 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: orders +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# supplier_id :integer(4) default(0), not null +# starts :datetime not null +# ends :datetime +# note :string(255) +# finished :boolean(1) not null +# booked :boolean(1) not null +# lock_version :integer(4) default(0), not null +# updated_by_user_id :integer(4) +# invoice_amount :decimal(8, 2) default(0.0), not null +# deposit :decimal(8, 2) default(0.0) +# deposit_credit :decimal(8, 2) default(0.0) +# invoice_number :string(255) +# invoice_date :string(255) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 diff --git a/test/fixtures/suppliers.yml b/test/fixtures/suppliers.yml index 9da457a6..40ecc609 100644 --- a/test/fixtures/suppliers.yml +++ b/test/fixtures/suppliers.yml @@ -1,3 +1,25 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: suppliers +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# address :string(255) default(""), not null +# phone :string(255) default(""), not null +# phone2 :string(255) +# fax :string(255) +# email :string(255) +# url :string(255) +# contact_person :string(255) +# customer_number :string(255) +# delivery_days :string(255) +# order_howto :string(255) +# note :string(255) +# shared_supplier_id :integer(4) +# min_order_quantity :string(255) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html first: id: 1 @@ -12,4 +34,4 @@ first: phone2: 01234-7878787 address: berlin bio customer_number: 123478 - email: terra@terra.com \ No newline at end of file + email: terra@terra.com diff --git a/test/fixtures/tasks.yml b/test/fixtures/tasks.yml index b49c4eb4..5105c109 100644 --- a/test/fixtures/tasks.yml +++ b/test/fixtures/tasks.yml @@ -1,3 +1,20 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: tasks +# +# id :integer(4) not null, primary key +# name :string(255) default(""), not null +# description :string(255) +# due_date :date +# done :boolean(1) +# group_id :integer(4) +# assigned :boolean(1) +# created_on :datetime not null +# updated_on :datetime not null +# required_users :integer(4) default(1) +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html one: id: 1 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 8f0b478a..7a9e9e51 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,3 +1,23 @@ +# == Schema Information +# Schema version: 20090102171850 +# +# Table name: users +# +# id :integer(4) not null, primary key +# nick :string(255) default(""), not null +# password_hash :string(255) default(""), not null +# password_salt :string(255) default(""), not null +# first_name :string(255) default(""), not null +# last_name :string(255) default(""), not null +# email :string(255) default(""), not null +# phone :string(255) +# address :string(255) +# created_on :datetime not null +# reset_password_token :string(255) +# reset_password_expires :datetime +# last_login :datetime +# + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html admin: id: 1 @@ -13,4 +33,4 @@ test: nick: test first_name: Tim last_name: Tester - email: test@foo.test \ No newline at end of file + email: test@foo.test