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

View file

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

View file

@ -21,6 +21,8 @@ class Invoice < ActiveRecord::Base
validates_presence_of :supplier_id validates_presence_of :supplier_id
validates_uniqueness_of :date, :scope => [: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. # Custom attribute setter that accepts decimal numbers using localized decimal separator.
def amount=(amount) def amount=(amount)
self[:amount] = String.delocalized_decimal(amount) self[:amount] = String.delocalized_decimal(amount)

View file

@ -1,5 +1,24 @@
%h1 Finanzbereich %h1 Finanzbereich
.left_column{:style => 'width: 50%'} .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 .box_title
%h2 letzte Überweisungen %h2 letzte Überweisungen
.column_content .column_content

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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