Created namespace 'finance' and moved invoices into it.

This commit is contained in:
Benjamin Meichsner 2009-01-10 19:36:58 +01:00
parent 30f3d199d3
commit 1d85b880f2
17 changed files with 163 additions and 133 deletions

View file

@ -1,4 +1,4 @@
class InvoicesController < ApplicationController
class Finance::InvoicesController < ApplicationController
def index
@invoices = Invoice.find(:all, :order => "date DESC")
@ -39,7 +39,7 @@ class InvoicesController < ApplicationController
respond_to do |format|
if @invoice.save
flash[:notice] = 'Invoice was successfully created.'
format.html { redirect_to(@invoice) }
format.html { redirect_to([:finance, @invoice]) }
format.xml { render :xml => @invoice, :status => :created, :location => @invoice }
else
format.html { render :action => "new" }
@ -56,7 +56,7 @@ class InvoicesController < ApplicationController
respond_to do |format|
if @invoice.update_attributes(params[:invoice])
flash[:notice] = 'Invoice was successfully updated.'
format.html { redirect_to(@invoice) }
format.html { redirect_to([:finance, @invoice]) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
@ -72,7 +72,7 @@ class InvoicesController < ApplicationController
@invoice.destroy
respond_to do |format|
format.html { redirect_to(invoices_path) }
format.html { redirect_to(finance_invoices_path) }
format.xml { head :ok }
end
end

View file

@ -12,6 +12,7 @@ class FinanceController < ApplicationController
def index
@financial_transactions = FinancialTransaction.find(:all, :order => "created_on DESC", :limit => 8)
@orders = Order.find(:all, :conditions => 'finished = 1 AND booked = 0', :order => 'ends DESC')
@unpaid_invoices = Invoice.unpaid
end
#list all ordergroups

View file

@ -21,6 +21,8 @@ class Invoice < ActiveRecord::Base
validates_presence_of :supplier_id
validates_uniqueness_of :date, :scope => [:supplier_id]
named_scope :unpaid, :conditions => { :paid_on => nil }
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def amount=(amount)
self[:amount] = String.delocalized_decimal(amount)

View file

@ -1,5 +1,24 @@
%h1 Finanzbereich
.left_column{:style => 'width: 50%'}
.box_title
%h2 Unpaid invoices
.column_content
%p= link_to "Show all invoices", invoices_path
%table.list
%thead
%tr
%th Date
%th Amount
%th Supplier
%th
%tbody
- for invoice in @unpaid_invoices
%tr{:class => cycle("even","odd", :name => "invoices")}
%td= format_date(invoice.date)
%td= number_to_currency(invoice.amount)
%td=h invoice.supplier.name
%td= link_to "Edit", edit_invoice_path(invoice)
.box_title
%h2 letzte Überweisungen
.column_content

View file

@ -1,6 +1,6 @@
<h1>Editing invoice</h1>
<% form_for(@invoice) do |f| %>
<% form_for([:finance, @invoice]) do |f| %>
<%= f.error_messages %>
<p>
@ -32,5 +32,5 @@
</p>
<% end %>
<%= link_to 'Show', @invoice %> |
<%= link_to 'Back', invoices_path %>
<%= link_to 'Show', [:finance, @invoice] %> |
<%= link_to 'Back', finance_invoices_path %>

View file

@ -0,0 +1,38 @@
<% title "Invoices" %>
<table class="list" style="width:70em">
<thead>
<tr>
<th>Supplier</th>
<th>Number</th>
<th>Date</th>
<th>Paid on</th>
<th>Amount</th>
<th>Delivery</th>
<th>Note</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% for invoice in @invoices %>
<tr>
<td><%=h invoice.supplier.name %></td>
<td><%=h invoice.number %></td>
<td><%= invoice.date %></td>
<td><%= invoice.paid_on %></td>
<td><%= invoice.amount %></td>
<td><%=h invoice.delivery_id %></td>
<td><%=h truncate(invoice.note) %></td>
<td><%= link_to 'Show', finance_invoice_path(invoice) %></td>
<td><%= link_to 'Edit', edit_finance_invoice_path(invoice) %></td>
<td><%= link_to 'Destroy', finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</tbody>
</table>
<br />
<%= link_to 'New invoice', new_finance_invoice_path %>

View file

@ -1,6 +1,6 @@
<h1>New invoice</h1>
<% form_for(@invoice) do |f| %>
<% form_for([:finance, @invoice]) do |f| %>
<%= f.error_messages %>
<p>
@ -32,4 +32,4 @@
</p>
<% end %>
<%= link_to 'Back', invoices_path %>
<%= link_to 'Back', finance_invoices_path %>

View file

@ -36,5 +36,5 @@
</p>
<%= link_to 'Edit', edit_invoice_path(@invoice) %> |
<%= link_to 'Back', invoices_path %>
<%= link_to 'Edit', edit_finance_invoice_path(@invoice) %> |
<%= link_to 'Back', finance_invoices_path %>

View file

@ -3,8 +3,8 @@
#start_nav
= render :partial => 'start_nav'
- unless @unaccepted_tasks.empty? && @next_tasks.empty? && @unassigned_tasks_number == 0
.right_column{:style => "width:70%"}
- unless @unaccepted_tasks.empty? && @next_tasks.empty? && @unassigned_tasks_number == 0
.box_title
%h2=_ "Tasks"
.column_content
@ -28,7 +28,6 @@
%p{:style => "clear:both"}= link_to _("My tasks"), :controller => "tasks", :action => "myTasks"
- unless @messages.empty?
.right_column{:style => "width:70%"}
.box_title
%h2=_ "Unread messages"
.column_content
@ -39,9 +38,7 @@
// Current orders
= render :partial => 'ordering/currentOrders'
// OrderGroup overview
.right_column{:style => "width:70%"}
.box_title
%h2=_ "My ordergroup"
.column_content

View file

@ -1,32 +0,0 @@
<% title "Invoices" %>
<table class="list" style="width:70em">
<tr>
<th>Supplier</th>
<th>Number</th>
<th>Date</th>
<th>Paid on</th>
<th>Amount</th>
<th>Delivery</th>
<th>Note</th>
</tr>
<% for invoice in @invoices %>
<tr>
<td><%=h invoice.supplier.name %></td>
<td><%=h invoice.number %></td>
<td><%= invoice.date %></td>
<td><%= invoice.paid_on %></td>
<td><%= invoice.amount %></td>
<td><%=h invoice.delivery_id %></td>
<td><%=h truncate(invoice.note) %></td>
<td><%= link_to 'Show', invoice %></td>
<td><%= link_to 'Edit', edit_invoice_path(invoice) %></td>
<td><%= link_to 'Destroy', invoice, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New invoice', new_invoice_path %>

View file

@ -31,7 +31,7 @@
:subnav => [
{ :name => "Ordergroups", :url => "/finance/listOrdergroups" },
{ :name => "Balance orders", :url => "/finance/listOrders" },
{ :name => "Invoices", :url => invoices_path }
{ :name => "Invoices", :url => finance_invoices_path }
]
},
{ :name => "Administration", :url => "/admin", :active => ["admin"],

View file

@ -1,5 +1,3 @@
- if @orderGroup
.right_column{:style => "width:70%"}
.box_title
%h2=_ "Running orders"
.column_content

View file

@ -19,12 +19,13 @@
%th= _('Available')
%th{:class => "currency"}= number_to_currency(@orderGroup.account_balance - @currentOrdersValue - @nonbookedOrdersValue)
.right_column{:style => "width:70%"}
// Current Orders
- if @orderGroup
= render :partial => "currentOrders"
// finished, nonbooked Orders
- unless @finishedOrders.empty?
.right_column{:style => "width:70%"}
.box_title
%h2= _('unrecorded orders')
.column_content
@ -36,7 +37,6 @@
// bookedOrders
- unless @bookedOrders.empty?
.right_column{:style => "width:70%"}
.box_title
%h2= _('balanced orders')
.column_content

View file

@ -1,6 +1,10 @@
ActionController::Routing::Routes.draw do |map|
map.resources :invoices
map.namespace :finance do |finance|
finance.resources :invoices
end
#map.resources :invoices
map.resources :suppliers,
:has_many => [:deliveries],
:collection => { :shared_suppliers => :get }

View file

@ -291,7 +291,8 @@ div.box_title {
div.column_content {
background: #e4eed6;
color: black;
padding: 10px; }
padding: 10px;
margin-bottom: 2em; }
div.column_content h2 {
color: black;
font-size: 1.3em;

View file

@ -291,7 +291,8 @@ div.box_title {
div.column_content {
background: #e4eed6;
color: black;
padding: 10px; }
padding: 10px;
margin-bottom: 2em; }
div.column_content h2 {
color: black;
font-size: 1.3em;

View file

@ -329,6 +329,7 @@ div.column_content
:background = !boxContent
:color black
:padding 10px
margin-bottom: 2em
h2
:color black
:font-size 1.3em