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 'client_side_validations'
gem 'simple_form'
gem 'rails3_acts_as_paranoid', "~>0.1.4"
gem 'rails3_acts_as_paranoid', "~>0.2.0"
gem 'inherited_resources'
gem 'localize_input', :git => "git://github.com/bennibu/localize_input.git"
gem 'wikicloth'

View file

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

View file

@ -3,9 +3,10 @@ module DeliveriesHelper
def link_to_invoice(delivery)
if delivery.invoice
link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice],
:title => "Rechnung anzeigen"
title: "Rechnung anzeigen"
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

View file

@ -1,7 +1,7 @@
class StockChange < ActiveRecord::Base
belongs_to :delivery
belongs_to :order
belongs_to :stock_article
belongs_to :stock_article, with_deleted: true
validates_presence_of :stock_article_id, :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 :phone, :presence => true, :length => { :in => 8..20 }
validates :address, :presence => true, :length => { :in => 8..50 }
validates_length_of :order_howto, :note, maximum: 250
# validates_length_of :name, :in => 4..30
# validates_uniqueness_of :name

View file

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

View file

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

View file

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

View file

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

View file

@ -1,55 +1,52 @@
- title "Lieferung anzeigen"
%p
%b Lieferantin:
=h @delivery.supplier.name
%p
%b Geliefert am:
= @delivery.delivered_on
%p
%b Rechnungsbetrag:
= link_to_invoice(@delivery)
- if @delivery.invoice
%p
%b bereinigter Rechnungsbetrag:
= number_to_currency @delivery.invoice.net_amount
%p
%b Notiz:
= simple_format @delivery.note
%dl
%dt Lieferantin
%dd= @delivery.supplier.name
%dt Geliefert am
%dd= @delivery.delivered_on
%dt Rechnungsbetrag:
%dd= link_to_invoice(@delivery)
- if @delivery.invoice
%dt bereinigter Rechnungsbetrag:
%dd= number_to_currency @delivery.invoice.net_amount
%dt Notiz:
%dd= simple_format @delivery.note
%h2 Artikel
%table.list{:style => "width:30em"}
%tr
%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
%table.table.table-striped(style="width:500px")
%thead
%tr
%td= stock_change.stock_article.name
%td= stock_change.stock_article.unit
%td= quantity
%td= number_to_currency stock_change.stock_article.price
%td= number_to_currency sum
%p
Nettosumme:
= number_to_currency total_net
%p
Bruttosumme:
= number_to_currency total_gross
%th Artikel
%th Einheit
%th.numeric Menge
%th.numeric Nettopreis
%th.numeric Summe
%tbody
- total_net, total_gross = 0,0
- @delivery.stock_changes.all.each do |stock_change|
- quantity = stock_change.quantity
- sum = quantity * stock_change.stock_article.price
- 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
%b Brutto - bereinigter Rechnungsbetrag:
= 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)
%p
= link_to 'Bearbeiten', edit_supplier_delivery_path(@supplier,@delivery), class: 'btn'
= 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
%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.input :name
= f.input :address
@ -12,8 +12,9 @@
= f.input :contact_person
= f.input :customer_number
= f.input :delivery_days
= f.input :order_howto
= f.input :note
= f.input :order_howto, as: :text, input_html: {rows: 5}
= f.input :note, as: :text, input_html: {rows: 5}
= f.input :min_order_quantity
= f.submit
= link_to 'oder abbrechen', suppliers_path
.form-actions
= 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%"}
.box_title
%h2 Lieferantinnen
.column_content
%p
%i
Erstelle eine
= link_to 'neue Lieferantin', new_supplier_path
oder
= link_to 'importiere', shared_suppliers_suppliers_path
aus der externen Artikeldatenbank.
%table.list
%thead
%tr
%th Name
%th Telefon
%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
%p
= link_to 'Neue Lieferantin anlegen', new_supplier_path, class: 'btn btn-primary'
oder
= link_to 'importiere', shared_suppliers_suppliers_path
aus der externen Artikeldatenbank.
%table.table.table-striped
%thead
%tr
%th Name
%th Telefon
%th Kunden-Nr
%th
%th
%th
%tbody
- for supplier in @suppliers
%tr
%th Datum
%th Betrag
%th Lieferantin
- for delivery in @deliveries
%tr
%td= link_to delivery.delivered_on, [delivery.supplier, delivery]
%td= link_to_invoice(delivery)
%td=h delivery.supplier.name
%td= link_to h(supplier.name) , supplier
%td= supplier.phone
%td= 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)
%td
= 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
%i
Hier werden die Lieferantinnen der externen Datenbank angezeigt.
%br/
Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten)
%br/
Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.
Hier werden die Lieferantinnen der externen Datenbank angezeigt.
%br/
Ihr könnt externe Lieferantinnen importieren, indem ihr sie einfach abonniert. (siehe unten)
%br/
Damit wird eine neue Lieferantin angelegt und mit der externen Datenbank verknüpft.
#shared_suppliers
%i externe Lieferantinnen
%table
%table.table.table-striped
%thead
%tr
%th Lieferantin
%th Adresse
%th Notiz
%th Liefertag
%th abonniert?
%th
%tbody
- for shared_supplier in @shared_suppliers
%tr{:class => cycle('even', 'odd', :name => "shared_suppliers")}
%td=h shared_supplier.name
%td=h shared_supplier.address
%td=h shared_supplier.note
%td=h shared_supplier.delivery_days
%td= image_tag("icon_message.gif", :size => "16x16", :border => "0",:alt => "abonniert!") if shared_supplier.supplier
%td= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier) unless shared_supplier.supplier
%tr
%td= shared_supplier.name
%td= shared_supplier.address
%td= shared_supplier.note
%td= shared_supplier.delivery_days
%td
- 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%"}
.box_title
%h2=h @supplier.name
.column_content
.row-fluid
.span6
- if shared_supplier = @supplier.shared_supplier
%p
%strong Die Lieferantin ist mit der externen Artikledatenbank verknüpft.
.alert.alert-info
Die Lieferantin ist mit der externen Artikledatenbank verknüpft.
%table{:style => "width:40em"}
%tr
%td Adresse:
%td{:style => "font-weight:bold"}=h @supplier.address
%tr
%td Telefon:
%td{:style => "font-weight:bold"}=h @supplier.phone
%tr
%td Telefon2:
%td{:style => "font-weight:bold"}=h @supplier.phone2
%tr
%td FAX:
%td{:style => "font-weight:bold"}=h @supplier.fax
%tr
%td Email:
%td{:style => "font-weight:bold"}=h @supplier.email
%tr
%td Hompage:
%td{:style => "font-weight:bold"}=h @supplier.url
%tr
%td Kontakt-Person:
%td{:style => "font-weight:bold"}=h @supplier.contact_person
%tr
%td Kundennummer:
%td{:style => "font-weight:bold"}=h @supplier.customer_number
%tr
%td Liefertage:
%td{:style => "font-weight:bold"}=h @supplier.delivery_days
%tr
%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/
%dl.dl-horizontal
%dt Adresse:
%dd= @supplier.address
%dt Telefon:
%dd= @supplier.phone
%dt Telefon2:
%dd= @supplier.phone2
%dt FAX:
%dd= @supplier.fax
%dt Email:
%dd= @supplier.email
%dt Hompage:
%dd= @supplier.url
%dt Kontakt-Person:
%dd= @supplier.contact_person
%dt Kundennummer:
%dd= @supplier.customer_number
%dt Liefertage:
%dd= @supplier.delivery_days
%dt BestellHowTo:
%dd= @supplier.order_howto
%dt Notiz:
%dd= @supplier.note
%dt Liefertage:
%dd= @supplier.delivery_days
%dt Mindestbestellmenge:
%dd= @supplier.min_order_quantity
.clearfix
- if @current_user.role_suppliers?
= link_to 'Bearbeiten', edit_supplier_path(@supplier)
|
= link_to 'Löschen', @supplier, :confirm => 'Bist Du sicher?', :method => :delete
|
= link_to 'zurück', suppliers_path
.form-actions
= link_to 'Bearbeiten', edit_supplier_path(@supplier), class: 'btn'
= link_to 'Löschen', @supplier, :confirm => 'Bist Du sicher?', :method => :delete, class: 'btn btn-danger'
.right_column{:style => "width:45%"}
.box_title
.span6
%h2 Letzte Lieferungen
.column_content
%table
%tr
%th Datum
%th Betrag
- for delivery in @deliveries
%table.table.table-horizontal
%thead
%tr
%td= link_to delivery.delivered_on, [@supplier, delivery]
%td= link_to_invoice(delivery)
%p
= link_to "Neue Lieferung anlegen", new_supplier_delivery_path(@supplier)
|
%th Datum
%th Betrag
%tbody
- 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)