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 class Finance::InvoicesController < ApplicationController
def index 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| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb

View file

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

View file

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

View file

@ -1,43 +1,18 @@
- form_for([:finance, @invoice]) do |f| = simple_form_for([:finance, @invoice]) do |f|
= f.error_messages
= f.hidden_field :delivery_id = f.hidden_field :delivery_id
= f.hidden_field :order_id = f.hidden_field :order_id
- if @invoice.delivery - 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 - if @invoice.order
%p= "Diese Rechnung ist mit einer #{link_to "Bestellung", @invoice.order} verknüpft." %p Diese Rechnung ist mit einer #{link_to("Bestellung", @invoice.order)} verknüpft.
%p
Lieferantin = f.association :supplier, hint: false
%br/ = f.input :number
= f.select :supplier_id, Supplier.all.collect { |s| [s.name, s.id] } = f.input :date
%p = f.input :paid_on
Rechnungsnummer = f.input :amount, as: :string
%br/ = f.input :deposit, as: :string
= f.text_field :number = f.input :deposit_credit, as: :string
%p = f.input :note
Rechnungsdatum = f.submit
%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"

View file

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

View file

@ -2,29 +2,29 @@
%p %p
%b Lieferantin: %b Lieferantin:
=h @invoice.supplier.name = @invoice.supplier.name
- if @invoice.delivery - if @invoice.delivery
%p %p
%b Lieferung: %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 %p
%b Rechnungsnummer: %b Rechnungsnummer:
=h @invoice.number = @invoice.number
%p %p
%b Datum: %b Datum:
=h @invoice.date = @invoice.date
%p %p
%b Bezahlt am: %b Bezahlt am:
=h @invoice.paid_on = @invoice.paid_on
%p %p
%b Rechnungsbetrag: %b Rechnungsbetrag:
=h @invoice.amount = number_to_currency @invoice.amount
%p %p
%b Pfand berechnet: %b Pfand berechnet:
=h @invoice.deposit = number_to_currency @invoice.deposit
%p %p
%b Pfand gutgeschrieben: %b Pfand gutgeschrieben:
=h @invoice.deposit_credit = number_to_currency @invoice.deposit_credit
%p %p
%b Notiz: %b Notiz:
=h @invoice.note =h @invoice.note

View file

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