Updated finance/invoices

This commit is contained in:
benni 2012-04-20 18:33:47 +02:00
parent 4a8e286d98
commit b295f62322
7 changed files with 37 additions and 64 deletions

View File

@ -1,7 +1,7 @@
class Finance::InvoicesController < ApplicationController
def index
@invoices = Invoice.find(:all, :order => "date DESC")
@invoices = Invoice.includes(:supplier, :delivery, :order).order(:date.desc).paginate(page: params[:page])
respond_to do |format|
format.html # index.html.erb

View File

@ -5,23 +5,12 @@ class Invoice < ActiveRecord::Base
belongs_to :order
validates_presence_of :supplier_id
validates_numericality_of :amount, :deposit, :deposit_credit
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)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit=(deposit)
self[:deposit] = String.delocalized_decimal(deposit)
end
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
def deposit_credit=(deposit)
self[:deposit_credit] = String.delocalized_decimal(deposit)
end
# Replace numeric seperator with database format
localize_input_of :amount, :deposit, :deposit_credit
# Amount without deposit
def net_amount

View File

@ -1,4 +1,4 @@
- title "#{@supplier.name}/deliveries"
- title "#{@supplier.name}/Lieferungen"
%table.list{:style => "width:50em"}
%thead

View File

@ -1,43 +1,18 @@
- form_for([:finance, @invoice]) do |f|
= f.error_messages
= simple_form_for([:finance, @invoice]) do |f|
= f.hidden_field :delivery_id
= f.hidden_field :order_id
- if @invoice.delivery
%p= "Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft."
%p Diese Rechnung ist mit einer #{link_to("Lieferung", [@invoice.supplier,@invoice.delivery])} verknüpft.
- if @invoice.order
%p= "Diese Rechnung ist mit einer #{link_to "Bestellung", @invoice.order} verknüpft."
%p
Lieferantin
%br/
= f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] }
%p
Rechnungsnummer
%br/
= f.text_field :number
%p
Rechnungsdatum
%br/
= f.date_select :date
%p
Bezahlt am
%br/
= f.date_select :paid_on, :include_blank => true
%p
Rechnungsbetrag
%br/
= f.text_field :amount
%p
Pfand berechnet
%br/
= f.text_field :deposit
%p
Pfand gutgeschrieben
%br/
= f.text_field :deposit_credit
%p
Notiz
%br/
= f.text_area :note, :size => "28x8"
%p
= f.submit "Speichern"
%p Diese Rechnung ist mit einer #{link_to("Bestellung", @invoice.order)} verknüpft.
= f.association :supplier, hint: false
= f.input :number
= f.input :date
= f.input :paid_on
= f.input :amount, as: :string
= f.input :deposit, as: :string
= f.input :deposit_credit, as: :string
= f.input :note
= f.submit

View File

@ -1,5 +1,7 @@
<% title "Rechnungen" %>
<p><%= will_paginate @invoices %></p>
<table class="list" style="width:70em">
<thead>
<tr>
@ -19,13 +21,13 @@
<% for invoice in @invoices %>
<tr>
<td><%= link_to h(invoice.number), finance_invoice_path(invoice)%></td>
<td><%=h invoice.supplier.name %></td>
<td><%= invoice.supplier.name %></td>
<td><%= format_date invoice.date %></td>
<td><%= format_date invoice.paid_on %></td>
<td><%= number_to_currency invoice.amount %></td>
<td><%= link_to "Lieferung", [invoice.supplier,invoice.delivery] if invoice.delivery %></td>
<td><%= link_to format_date(invoice.order.ends), :controller => 'balancing', :action => 'new', :id => invoice.order if invoice.order %></td>
<td><%=h truncate(invoice.note) %></td>
<td><%= truncate(invoice.note) %></td>
<td><%= link_to icon(:edit), edit_finance_invoice_path(invoice) %></td>
<td><%= link_to icon(:delete), finance_invoice_path(invoice), :confirm => 'Are you sure?', :method => :delete %></td>
</tr>

View File

@ -2,29 +2,29 @@
%p
%b Lieferantin:
=h @invoice.supplier.name
= @invoice.supplier.name
- if @invoice.delivery
%p
%b Lieferung:
="Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft."
Diese Rechnung ist mit einer #{link_to "Lieferung", [@invoice.supplier,@invoice.delivery]} verknüpft.
%p
%b Rechnungsnummer:
=h @invoice.number
= @invoice.number
%p
%b Datum:
=h @invoice.date
= @invoice.date
%p
%b Bezahlt am:
=h @invoice.paid_on
= @invoice.paid_on
%p
%b Rechnungsbetrag:
=h @invoice.amount
= number_to_currency @invoice.amount
%p
%b Pfand berechnet:
=h @invoice.deposit
= number_to_currency @invoice.deposit
%p
%b Pfand gutgeschrieben:
=h @invoice.deposit_credit
= number_to_currency @invoice.deposit_credit
%p
%b Notiz:
=h @invoice.note

View File

@ -345,6 +345,13 @@ de:
order:
starts: "Läuft vom"
ends: "Endet am"
invoice:
supplier: Lieferant
number: Nummer
date: Rechnungsdatum
paid_on: Bezahlt am
deposit: Pfand berechnet
deposit_credit: Pfand gutgeschrieben
hints:
tax: 'In Prozent, Standard sind 7,0'