Fixed deliveries.

This commit is contained in:
benni 2012-10-17 20:45:52 +02:00
parent 552c553b77
commit 9af26e1da6
14 changed files with 184 additions and 225 deletions

View File

@ -24,7 +24,7 @@ gem 'haml-rails'
gem 'kaminari' gem 'kaminari'
gem 'client_side_validations' gem 'client_side_validations'
gem 'simple_form' gem 'simple_form'
gem 'rails3_acts_as_paranoid', "~>0.1.4" gem 'rails3_acts_as_paranoid', "~>0.2.0"
gem 'inherited_resources' gem 'inherited_resources'
gem 'localize_input', :git => "git://github.com/bennibu/localize_input.git" gem 'localize_input', :git => "git://github.com/bennibu/localize_input.git"
gem 'wikicloth' gem 'wikicloth'

View File

@ -116,8 +116,8 @@ GEM
activesupport (= 3.2.8) activesupport (= 3.2.8)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.2.8) railties (= 3.2.8)
rails3_acts_as_paranoid (0.1.4) rails3_acts_as_paranoid (0.2.4)
activerecord (~> 3.1) activerecord (~> 3.2)
railties (3.2.8) railties (3.2.8)
actionpack (= 3.2.8) actionpack (= 3.2.8)
activesupport (= 3.2.8) activesupport (= 3.2.8)
@ -186,7 +186,7 @@ DEPENDENCIES
mysql2 mysql2
prawn prawn
rails (= 3.2.8) rails (= 3.2.8)
rails3_acts_as_paranoid (~> 0.1.4) rails3_acts_as_paranoid (~> 0.2.0)
sass-rails (~> 3.2.3) sass-rails (~> 3.2.3)
simple-navigation simple-navigation
simple-navigation-bootstrap simple-navigation-bootstrap

View File

@ -3,9 +3,10 @@ module DeliveriesHelper
def link_to_invoice(delivery) def link_to_invoice(delivery)
if delivery.invoice if delivery.invoice
link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice], link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice],
:title => "Rechnung anzeigen" title: "Rechnung anzeigen"
else else
link_to "Rechnung anlegen", new_finance_invoice_path(:supplier_id => delivery.supplier.id, :delivery_id => delivery.id) link_to "Rechnung anlegen", new_finance_invoice_path(supplier_id: delivery.supplier.id, delivery_id: delivery.id),
class: 'btn btn-mini'
end end
end end

View File

@ -1,7 +1,7 @@
class StockChange < ActiveRecord::Base class StockChange < ActiveRecord::Base
belongs_to :delivery belongs_to :delivery
belongs_to :order belongs_to :order
belongs_to :stock_article belongs_to :stock_article, with_deleted: true
validates_presence_of :stock_article_id, :quantity validates_presence_of :stock_article_id, :quantity
validates_numericality_of :quantity validates_numericality_of :quantity

View File

@ -15,6 +15,7 @@ class Supplier < ActiveRecord::Base
validates :name, :presence => true, :length => { :in => 4..30 }, :uniqueness => true validates :name, :presence => true, :length => { :in => 4..30 }, :uniqueness => true
validates :phone, :presence => true, :length => { :in => 8..20 } validates :phone, :presence => true, :length => { :in => 8..20 }
validates :address, :presence => true, :length => { :in => 8..50 } validates :address, :presence => true, :length => { :in => 8..50 }
validates_length_of :order_howto, :note, maximum: 250
# validates_length_of :name, :in => 4..30 # validates_length_of :name, :in => 4..30
# validates_uniqueness_of :name # validates_uniqueness_of :name

View File

@ -1,4 +1,4 @@
- content_for :head do - content_for :javascript do
:javascript :javascript
$(function() { $(function() {
$('.destroy_stock_change').live('click', function() { $('.destroy_stock_change').live('click', function() {
@ -12,32 +12,29 @@
}) })
}); });
.left_column(style="width:50%") .row-fluid
= simple_form_for [@supplier,@delivery], :validate => true do |f| .span6
.box_title = simple_form_for [@supplier, @delivery], validate: true do |f|
%h2 Lieferung anlegen
.column_content
= f.hidden_field :supplier_id = f.hidden_field :supplier_id
%b Lagerartikel des Lieferanten
#stock_changes #stock_changes
= f.fields_for :stock_changes do |stock_change_form| = f.fields_for :stock_changes do |stock_change_form|
%p %p
= stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier) = stock_change_form.select :stock_article_id, stock_articles_for_select(@supplier)
Menge Menge
= stock_change_form.text_field :quantity, :size => 5, :autocomplete => 'off' = stock_change_form.text_field :quantity, size: 5, autocomplete: 'off'
= stock_change_form.hidden_field :_destroy = stock_change_form.hidden_field :_destroy
= link_to "Artikel aus Lieferung entfernen", "#", :class => 'destroy_stock_change' = link_to "Artikel aus Lieferung entfernen", "#", class: 'destroy_stock_change'
%p %p
= link_to "Lagerartikel der Lieferung hinzufügen", {:action => 'add_stock_change', :supplier_id => @supplier.id}, :remote => true = link_to "Lagerartikel der Lieferung hinzufügen", {action: 'add_stock_change', supplier_id: @supplier.id}, remote: true
%hr/ %hr/
= f.input :delivered_on = f.input :delivered_on, as: :date_picker
= f.input :note, :input_html => {:size => '35x4'} = f.input :note, input_html: {size: '35x4'}
= f.submit .form-actions
= f.submit class: 'btn btn-primary'
= link_to "oder abbrechen", supplier_deliveries_path(@supplier)
.right_column{:style => "width:45%;"} .span6
.box_title
%h2 Neuen Lagerartikel anlegen %h2 Neuen Lagerartikel anlegen
.column_content
%p %p
//TODO: Fix this!! //TODO: Fix this!!
Suche nach Artikeln aus dem Suche nach Artikeln aus dem
@ -46,7 +43,4 @@
= text_field_tag 'article_name' = text_field_tag 'article_name'
%hr/ %hr/
#stock_article_form #stock_article_form
= render :partial => 'stock_article_form', :locals => {:stock_article => @supplier.stock_articles.build} = render 'stock_article_form', stock_article: @supplier.stock_articles.build
%p{:style => "clear:both"}
= link_to 'Zurück', supplier_deliveries_path(@supplier)

View File

@ -1,5 +1,5 @@
= simple_form_for stock_article, add_stock_article_supplier_deliveries_path(@supplier), :remote => true, = simple_form_for stock_article, url: add_stock_article_supplier_deliveries_path(@supplier), remote: true,
:validate => true do |f| validate: true do |f|
= f.hidden_field :supplier_id = f.hidden_field :supplier_id
= f.input :name = f.input :name
= f.input :unit = f.input :unit
@ -8,4 +8,4 @@
= f.input :tax = f.input :tax
= f.input :deposit = f.input :deposit
= f.association :article_category = f.association :article_category
= f.submit = f.submit class: 'btn'

View File

@ -1,25 +1,23 @@
- title "#{@supplier.name}/Lieferungen" - title "#{@supplier.name}/Lieferungen"
%table.list{:style => "width:50em"} %table.table.table-striped
%thead %thead
%tr %tr
%th Geliefert am %th Geliefert am
%th Rechnungsbetrag %th.numeric Rechnungsbetrag
%th Notiz %th Notiz
%th
%th
%th
%tbody %tbody
- for delivery in @deliveries - for delivery in @deliveries
%tr %tr
%td=h delivery.delivered_on %td=h delivery.delivered_on
%td= link_to_invoice(delivery) %td.numeric= link_to_invoice(delivery)
%td= truncate delivery.note %td= truncate delivery.note
%td= link_to 'Anzeigen', [@supplier, delivery] %td
%td= link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,delivery) = link_to 'Anzeigen', [@supplier, delivery], class: 'btn btn-mini'
%td= link_to 'Löschen', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete = link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,delivery), class: 'btn btn-mini'
= link_to 'Löschen', [@supplier,delivery], :confirm => 'Are you sure?', :method => :delete,
class: 'btn btn-mini btn-danger'
%br/ = link_to "Neue Lieferung für #{@supplier.name} anlegen", new_supplier_delivery_path(@supplier), class: 'btn btn-primary'
= link_to "Neue Lieferung für #{@supplier.name} anlegen", new_supplier_delivery_path(@supplier)
| |
= link_to "Lieferantenübersicht", suppliers_path = link_to "Lieferantenübersicht", suppliers_path

View File

@ -1,3 +1,3 @@
- title "Neue Lieferung von #{@supplier.name}" - title "Neue Lieferung von #{@supplier.name}"
= render :partial => 'form' = render 'form'

View File

@ -1,55 +1,52 @@
- title "Lieferung anzeigen" - title "Lieferung anzeigen"
%p %dl
%b Lieferantin: %dt Lieferantin
=h @delivery.supplier.name %dd= @delivery.supplier.name
%p %dt Geliefert am
%b Geliefert am: %dd= @delivery.delivered_on
= @delivery.delivered_on %dt Rechnungsbetrag:
%p %dd= link_to_invoice(@delivery)
%b Rechnungsbetrag: - if @delivery.invoice
= link_to_invoice(@delivery) %dt bereinigter Rechnungsbetrag:
- if @delivery.invoice %dd= number_to_currency @delivery.invoice.net_amount
%p %dt Notiz:
%b bereinigter Rechnungsbetrag: %dd= simple_format @delivery.note
= number_to_currency @delivery.invoice.net_amount
%p
%b Notiz:
= simple_format @delivery.note
%h2 Artikel %h2 Artikel
%table.list{:style => "width:30em"} %table.table.table-striped(style="width:500px")
%tr %thead
%th Artikel
%th Einheit
%th Menge
%th Nettopreis
%th Summe
- total_net, total_gross = 0,0
- for stock_change in @delivery.stock_changes.find :all, :include => :stock_article
- quantity = stock_change.quantity
- sum = quantity * stock_change.stock_article.price
- total_net += sum
- total_gross += quantity * stock_change.stock_article.gross_price
%tr %tr
%td= stock_change.stock_article.name %th Artikel
%td= stock_change.stock_article.unit %th Einheit
%td= quantity %th.numeric Menge
%td= number_to_currency stock_change.stock_article.price %th.numeric Nettopreis
%td= number_to_currency sum %th.numeric Summe
%p %tbody
Nettosumme: - total_net, total_gross = 0,0
= number_to_currency total_net - @delivery.stock_changes.all.each do |stock_change|
%p - quantity = stock_change.quantity
Bruttosumme: - sum = quantity * stock_change.stock_article.price
= number_to_currency total_gross - total_net += sum
- total_gross += quantity * stock_change.stock_article.gross_price
%tr
%td= stock_change.stock_article.name
%td= stock_change.stock_article.unit
%td.numeric= quantity
%td.numeric= number_to_currency stock_change.stock_article.price
%td.numeric= number_to_currency sum
%tfoot
%tr
%td(colspan="4") Nettosumme
%td.numeric= number_to_currency total_net
%tr
%td(colspan="4") Bruttosumme
%td.numeric= number_to_currency total_gross
- if @delivery.invoice
%tr
%td(colspan="4") Brutto - bereinigter Rechnungsbetrag:
%td.numeric= number_to_currency total_gross - @delivery.invoice.net_amount
- if @delivery.invoice %p
%p = link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,@delivery), class: 'btn'
%b Brutto - bereinigter Rechnungsbetrag: = link_to 'Lieferungsübersicht', supplier_deliveries_path(@supplier)
= number_to_currency total_gross - @delivery.invoice.net_amount
%br/
= link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,@delivery)
|
= link_to 'Lieferungsübersicht', supplier_deliveries_path(@supplier)

View File

@ -1,6 +1,6 @@
- simple_form_for @supplier do |f| = simple_form_for @supplier do |f|
- if @supplier.shared_supplier - if @supplier.shared_supplier
%p Lieferantin wird mit externer Datenbank verknüpft. .alert.alert-success Lieferantin ist mit externer Datenbank verknüpft.
= f.hidden_field :shared_supplier_id = f.hidden_field :shared_supplier_id
= f.input :name = f.input :name
= f.input :address = f.input :address
@ -12,8 +12,9 @@
= f.input :contact_person = f.input :contact_person
= f.input :customer_number = f.input :customer_number
= f.input :delivery_days = f.input :delivery_days
= f.input :order_howto = f.input :order_howto, as: :text, input_html: {rows: 5}
= f.input :note = f.input :note, as: :text, input_html: {rows: 5}
= f.input :min_order_quantity = f.input :min_order_quantity
= f.submit .form-actions
= link_to 'oder abbrechen', suppliers_path = f.submit class: 'btn'
= link_to 'oder abbrechen', suppliers_path

View File

@ -1,46 +1,29 @@
- title "Artikeldatenbank" - title "Lieferanten"
.left_column{:style => "width:60%"} %p
.box_title = link_to 'Neue Lieferantin anlegen', new_supplier_path, class: 'btn btn-primary'
%h2 Lieferantinnen oder
.column_content = link_to 'importiere', shared_suppliers_suppliers_path
%p aus der externen Artikeldatenbank.
%i %table.table.table-striped
Erstelle eine %thead
= link_to 'neue Lieferantin', new_supplier_path %tr
oder %th Name
= link_to 'importiere', shared_suppliers_suppliers_path %th Telefon
aus der externen Artikeldatenbank. %th Kunden-Nr
%table.list %th
%thead %th
%tr %th
%th Name %tbody
%th Telefon - for supplier in @suppliers
%th Kunden-Nr
%th
%th
%th
%tbody
- for supplier in @suppliers
%tr{:class => cycle('even','odd', :name => 'suppliers')}
%td= link_to h(supplier.name) , supplier
%td=h supplier.phone
%td=h supplier.customer_number
%td= link_to "Artikel (#{supplier.articles.count})", supplier_articles_path(supplier)
%td= link_to "im Lager (#{supplier.stock_articles.count})", stock_articles_path
%td= link_to "Lieferungen (#{supplier.deliveries.count})", supplier_deliveries_path(supplier)
.right_column{:style => "width:37%"}
.box_title
%h2 Letzte Lieferungen
.column_content
%table
%tr %tr
%th Datum %td= link_to h(supplier.name) , supplier
%th Betrag %td= supplier.phone
%th Lieferantin %td= supplier.customer_number
- for delivery in @deliveries %td= link_to "Artikel (#{supplier.articles.count})", supplier_articles_path(supplier)
%tr %td= link_to "im Lager (#{supplier.stock_articles.count})", stock_articles_path
%td= link_to delivery.delivered_on, [delivery.supplier, delivery] %td= link_to "Lieferungen (#{supplier.deliveries.count})", supplier_deliveries_path(supplier)
%td= link_to_invoice(delivery) %td
%td=h delivery.supplier.name = link_to "Bearbeiten", edit_supplier_path(supplier), class: 'btn btn-mini'
= link_to "Löschen", supplier_path(supplier), method: :delete,
confirm: "Achtung, willst Du wirklich den Lieferanten #{supplier.name} löschen?", class: 'btn btn-mini btn-danger'

View File

@ -1,27 +1,28 @@
%h1 Externe Listen - title "Externe Listen"
%p %p
%i Hier werden die Lieferantinnen der externen Datenbank angezeigt.
Hier werden die Lieferantinnen der externen Datenbank angezeigt. %br/
%br/ Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten)
Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten) %br/
%br/ Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.
Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.
#shared_suppliers %table.table.table-striped
%i externe Lieferantinnen %thead
%table
%tr %tr
%th Lieferantin %th Lieferantin
%th Adresse %th Adresse
%th Notiz %th Notiz
%th Liefertag %th Liefertag
%th abonniert? %th abonniert?
%th %tbody
- for shared_supplier in @shared_suppliers - for shared_supplier in @shared_suppliers
%tr{:class => cycle('even', 'odd', :name => "shared_suppliers")} %tr
%td=h shared_supplier.name %td= shared_supplier.name
%td=h shared_supplier.address %td= shared_supplier.address
%td=h shared_supplier.note %td= shared_supplier.note
%td=h shared_supplier.delivery_days %td= shared_supplier.delivery_days
%td= image_tag("icon_message.gif", :size => "16x16", :border => "0",:alt => "abonniert!") if shared_supplier.supplier %td
%td= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier) unless shared_supplier.supplier - if shared_supplier.supplier
%i.icon-ok
- else
= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'

View File

@ -1,74 +1,57 @@
- title "Lieferantin #{h(@supplier.name)}" - title @supplier.name
.left_column{:style => "width:45%"} .row-fluid
.box_title .span6
%h2=h @supplier.name
.column_content
- if shared_supplier = @supplier.shared_supplier - if shared_supplier = @supplier.shared_supplier
%p .alert.alert-info
%strong Die Lieferantin ist mit der externen Artikledatenbank verknüpft. Die Lieferantin ist mit der externen Artikledatenbank verknüpft.
%table{:style => "width:40em"} %dl.dl-horizontal
%tr %dt Adresse:
%td Adresse: %dd= @supplier.address
%td{:style => "font-weight:bold"}=h @supplier.address %dt Telefon:
%tr %dd= @supplier.phone
%td Telefon: %dt Telefon2:
%td{:style => "font-weight:bold"}=h @supplier.phone %dd= @supplier.phone2
%tr %dt FAX:
%td Telefon2: %dd= @supplier.fax
%td{:style => "font-weight:bold"}=h @supplier.phone2 %dt Email:
%tr %dd= @supplier.email
%td FAX: %dt Hompage:
%td{:style => "font-weight:bold"}=h @supplier.fax %dd= @supplier.url
%tr %dt Kontakt-Person:
%td Email: %dd= @supplier.contact_person
%td{:style => "font-weight:bold"}=h @supplier.email %dt Kundennummer:
%tr %dd= @supplier.customer_number
%td Hompage: %dt Liefertage:
%td{:style => "font-weight:bold"}=h @supplier.url %dd= @supplier.delivery_days
%tr %dt BestellHowTo:
%td Kontakt-Person: %dd= @supplier.order_howto
%td{:style => "font-weight:bold"}=h @supplier.contact_person %dt Notiz:
%tr %dd= @supplier.note
%td Kundennummer: %dt Liefertage:
%td{:style => "font-weight:bold"}=h @supplier.customer_number %dd= @supplier.delivery_days
%tr %dt Mindestbestellmenge:
%td Liefertage: %dd= @supplier.min_order_quantity
%td{:style => "font-weight:bold"}=h @supplier.delivery_days
%tr .clearfix
%td BestellHowTo:
%td{:style => "font-weight:bold"}=h @supplier.order_howto
%tr
%td Notiz:
%td{:style => "font-weight:bold"}=h @supplier.note
%tr
%td Liefertage:
%td{:style => "font-weight:bold"}=h @supplier.delivery_days
%tr
%td Mindestbestellmenge:
%td{:style => "font-weight:bold"}=h @supplier.min_order_quantity
%br/
- if @current_user.role_suppliers? - if @current_user.role_suppliers?
= link_to 'Bearbeiten', edit_supplier_path(@supplier) .form-actions
| = link_to 'Bearbeiten', edit_supplier_path(@supplier), class: 'btn'
= link_to 'Löschen', @supplier, :confirm => 'Bist Du sicher?', :method => :delete = link_to 'Löschen', @supplier, :confirm => 'Bist Du sicher?', :method => :delete, class: 'btn btn-danger'
|
= link_to 'zurück', suppliers_path
.right_column{:style => "width:45%"} .span6
.box_title
%h2 Letzte Lieferungen %h2 Letzte Lieferungen
.column_content %table.table.table-horizontal
%table %thead
%tr
%th Datum
%th Betrag
- for delivery in @deliveries
%tr %tr
%td= link_to delivery.delivered_on, [@supplier, delivery] %th Datum
%td= link_to_invoice(delivery) %th Betrag
%p %tbody
= link_to "Neue Lieferung anlegen", new_supplier_delivery_path(@supplier) - for delivery in @deliveries
| %tr
%td= link_to delivery.delivered_on, [@supplier, delivery]
%td= link_to_invoice(delivery)
.form-actions
= link_to "Neue Lieferung anlegen", new_supplier_delivery_path(@supplier), class: 'btn'
= link_to "Zeige alle Lieferungen", supplier_deliveries_path(@supplier) = link_to "Zeige alle Lieferungen", supplier_deliveries_path(@supplier)