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%"}
.right_column{:style => "width:70%"}
- unless @unaccepted_tasks.empty? && @next_tasks.empty? && @unassigned_tasks_number == 0
.box_title
%h2=_ "Tasks"
.column_content
@ -27,45 +27,42 @@
= _("There are") + " #{@unassigned_tasks_number} " + link_to(_("unassigned task(s)"), :controller => "tasks")
%p{:style => "clear:both"}= link_to _("My tasks"), :controller => "tasks", :action => "myTasks"
- unless @messages.empty?
.right_column{:style => "width:70%"}
- unless @messages.empty?
.box_title
%h2=_ "Unread messages"
.column_content
= render :partial => 'messages/unread'
%p= link_to _("All messages"), :controller => 'messages', :action => 'inbox'
- if @orderGroup
// Current orders
= render :partial => 'ordering/currentOrders'
- if @orderGroup
// Current orders
= render :partial => 'ordering/currentOrders'
// OrderGroup overview
.right_column{:style => "width:70%"}
.box_title
%h2=_ "My ordergroup"
.column_content
%p
%b= @orderGroup.name
|
=_ "Account balance:"
= number_to_currency(@orderGroup.account_balance)
%span{:style => "color:grey"}
(zuletzt aktualisiert vor
= distance_of_time_in_words(Time.now, @orderGroup.account_updated) + ")"
%h3=_ "Last transactions"
%table
%tr
%th=_ "When"
%th=_ "Who"
%th=_ "Note"
%th=_ "Amount"
- for ft in @financial_transactions
%tr{:class => cycle('even','odd')}
%td= format_time(ft.created_on)
%td= h(ft.user.nil? ? '?' : ft.user.nick)
%td= h(ft.note)
- color = ft.amount < 0 ? 'red' : 'black'
%td{:style => "color:#{color}; width:5em", :class => "currency"}= number_to_currency(ft.amount)
%br/
= link_to _("more ..."), :action => "myOrdergroup"
.box_title
%h2=_ "My ordergroup"
.column_content
%p
%b= @orderGroup.name
|
=_ "Account balance:"
= number_to_currency(@orderGroup.account_balance)
%span{:style => "color:grey"}
(zuletzt aktualisiert vor
= distance_of_time_in_words(Time.now, @orderGroup.account_updated) + ")"
%h3=_ "Last transactions"
%table
%tr
%th=_ "When"
%th=_ "Who"
%th=_ "Note"
%th=_ "Amount"
- for ft in @financial_transactions
%tr{:class => cycle('even','odd')}
%td= format_time(ft.created_on)
%td= h(ft.user.nil? ? '?' : ft.user.nick)
%td= h(ft.note)
- color = ft.amount < 0 ? 'red' : 'black'
%td{:style => "color:#{color}; width:5em", :class => "currency"}= number_to_currency(ft.amount)
%br/
= link_to _("more ..."), :action => "myOrdergroup"

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,34 +1,32 @@
- if @orderGroup
.right_column{:style => "width:70%"}
.box_title
%h2=_ "Running orders"
.column_content
- unless @currentOrders.empty?
%table.list
%thead
%tr
%th=_ "Name"
%th=_ "Supplier"
%th=_ "End"
%th=_ "Who ordered?"
%th=_ "Sum"
%tbody
- total = 0
- @currentOrders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
%td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil?
- if (groupOrder = order.group_orders.find(:first, :conditions => ["order_group_id = ?", @orderGroup.id]))
- total += groupOrder.price
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
%td= number_to_currency(groupOrder.price)
- else
%td
%td
- if total > 0
%p
=_ "Total sum"
%b= number_to_currency(total)
- else
%i=_ "There aren't current orders at the moment."
.box_title
%h2=_ "Running orders"
.column_content
- unless @currentOrders.empty?
%table.list
%thead
%tr
%th=_ "Name"
%th=_ "Supplier"
%th=_ "End"
%th=_ "Who ordered?"
%th=_ "Sum"
%tbody
- total = 0
- @currentOrders.each do |order|
%tr{:class => cycle('even', 'odd', :name => 'current_orders')}
%td= link_to order.name, :controller => 'ordering', :action => 'order', :id => order
%td=h order.supplier.name
%td=h format_time(order.ends) unless order.ends.nil?
- if (groupOrder = order.group_orders.find(:first, :conditions => ["order_group_id = ?", @orderGroup.id]))
- total += groupOrder.price
%td=h groupOrder.updated_by.nil? ? '??' : "#{groupOrder.updated_by.nick} (#{format_time(groupOrder.updated_on)})"
%td= number_to_currency(groupOrder.price)
- else
%td
%td
- if total > 0
%p
=_ "Total sum"
%b= number_to_currency(total)
- else
%i=_ "There aren't current orders at the moment."

View file

@ -19,12 +19,13 @@
%th= _('Available')
%th{:class => "currency"}= number_to_currency(@orderGroup.account_balance - @currentOrdersValue - @nonbookedOrdersValue)
// Current Orders
= render :partial => "currentOrders"
.right_column{:style => "width:70%"}
// Current Orders
- if @orderGroup
= render :partial => "currentOrders"
// finished, nonbooked Orders
- unless @finishedOrders.empty?
.right_column{:style => "width:70%"}
// finished, nonbooked Orders
- unless @finishedOrders.empty?
.box_title
%h2= _('unrecorded orders')
.column_content
@ -34,9 +35,8 @@
= _('total order value')
%b= number_to_currency(@nonbookedOrdersValue)
// bookedOrders
- unless @bookedOrders.empty?
.right_column{:style => "width:70%"}
// bookedOrders
- unless @bookedOrders.empty?
.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

@ -133,31 +133,31 @@ abbr, acronym {
background: #f5f5f5;
padding: 0 10px 0px 5px;
float: left; }
.menu ul, #start_nav ul {
.menu ul, #start_nav ul {
list-style-type: none;
margin: 0 0 0.2em 0;
padding: 0; }
.menu ul li, #start_nav ul li {
.menu ul li, #start_nav ul li {
border-bottom: 1px solid #dedede;
color: #666;
margin: 0.8em 0 0 0;
font-weight: bold; }
.menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited {
.menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited {
display: block;
padding: 0.25em 1em;
text-decoration: none;
width: 12em; }
.menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus {
.menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus {
background-color: #e3e3e3; }
.menu ul li ul, #start_nav ul li ul {
.menu ul li ul, #start_nav ul li ul {
margin: 0;
padding: 0; }
.menu ul li ul li, #start_nav ul li ul li {
.menu ul li ul li, #start_nav ul li ul li {
border-top: 1px solid #dedede;
border-bottom: none;
margin: 0;
font-weight: normal; }
.menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited {
.menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited {
width: 11.5em;
padding: 0 1em 0.1em 1.5em;
font-weight: normal;
@ -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