Moved balancing logic into new namespace 'finance'.

This commit is contained in:
Benjamin Meichsner 2009-01-10 22:22:16 +01:00
parent c282cae79c
commit 47398c6a70
27 changed files with 277 additions and 268 deletions

View file

@ -0,0 +1,21 @@
%td= @article.name
%td= link_to_function image_tag("arrow_down_red.png", :size => "16x16", :border => 0), "Element.toggle('group_order_article_results_#{@article.id}')"
%td= @article.order_number
%td= @article.units_to_order
%td= @article.unit_quantity.to_s + ' * ' + @article.unit.to_s
%td= number_to_currency(@article.net_price)
%td= number_to_currency(@article.gross_price)
%td= @article.tax
%td= @article.deposit
%td
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Artikel ändern'), |
:url => {:action => 'editArticleResult', :id => @article}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td
= link_to_remote image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Artikel löschen'), |
:url => {:action => 'destroyArticleResult', :id => @article}, |
:confirm => 'Bist du sicher?', |
:method => 'post', |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |

View file

@ -0,0 +1,29 @@
= error_messages_for 'article'
%p
%b Notiz:
= @form.text_field 'note', :size => 30
%table
%tr
%th Name
%th Nr.
%th
%abbr{:title=>"Anzahl gelieferter Gebinde"} Menge
%th GebGr
%th Einheit
%th netto
%th MwSt.
%th Pfand
%tr
%td= @form.text_field 'name', :size => 20
%td= @form.text_field 'order_number', :size => 3
%td= @form.text_field 'units_to_order', :size => 5
%td= @form.text_field 'unit_quantity', :size => 3
%td= @form.text_field 'unit', :size => 5
%td= @form.text_field 'net_price', :size => 3
%td= @form.text_field 'tax', :size => 3
%td= @form.text_field 'deposit', :size => 3
= @form.hidden_field "order_id"
%br/
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,5 @@
%tr{:class => cycle('even', 'odd', :name => 'articles')}[@article]
= render :partial => 'articleResult'
%tr{:id => "group_order_article_results_#{@article.id}", :class => "results", :style => "display:none"}
= render :partial => 'groupOrderArticleResults'

View file

@ -0,0 +1,17 @@
%p
%b
Gelieferte Artikel:
= @order.order_article_results.size
- for article in @order.order_article_results
%table{:style=> "margin-bottom:1em; width:40em;"}[article]
%thead
%tr
%th{:colspan => "3"}= article.name + " (" + article.unit + " | " + article.unit_quantity.to_s + " | " + article.gross_price.to_s + ")"
%tbody
- for result in article.group_order_article_results
%tr{ :class => cycle('even', 'odd', :name => 'group')}
%td{:style=>"width:70%"}= result.group_order_result.group_name
%td= result.quantity
%td= article.gross_price * result.quantity
- reset_cycle("group")

View file

@ -0,0 +1,8 @@
%h2
Bearbeiten von
= @article.name
- remote_form_for 'order_article_result', @article, :url => {:action => 'updateArticleResult', :id => @article }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |@form| |
= render :partial => "articleResultForm"

View file

@ -0,0 +1,20 @@
%h2 Mengenänderung
%p
= @result.group_order_result.group_name
hat von
= @result.order_article_result.name
bekommen:
- remote_form_for 'group_order_article_result', @result, :url => {:action => 'updateGroupResult', :id => @result }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= error_messages_for 'group_order_article_result'
%p
%b Menge:
(Einheit:
= @result.order_article_result.unit
)
= form.text_field "quantity", :size => "6"
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,10 @@
%h2 Notiz bearbeiten
- remote_form_for 'order', @order, :url => {:action => 'updateOrderNote', :id => @order}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
%br/
= form.text_area "note", :size => "60x20"
%p
= submit_tag "Speichern"
|
= link_to_remote 'Abbrechen', :update => 'results', :url => { :action => 'edit', :id => @order, :view => 'groupsOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"

View file

@ -0,0 +1,20 @@
%p{:style => "float:left"}
%b Lieferung bearbeiten
%p{:style => "float:right"}
= link_to_remote "Artikel hinzufügen", :url => {:action => "newArticleResult", :id => @order}
%table{:class => "ordered_articles", :style => "clear:both"}
%thead
%tr
%th{:colspan => "2"} Artikel
%th Nr.
%th Menge
%th GebGr * Einheit
%th netto
%th brutto
%th MwSt
%th Pfand
%th{:colspan => "2"}
%tbody#result_table
- for @article in @order.order_article_results
= render :partial => "articleResults"

View file

@ -0,0 +1,27 @@
%h2 Bestelldaten ändern
- remote_form_for 'order', @order, :url => {:action => 'updateOrderSummary', :id => @order}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= error_messages_for 'order'
%table{:style => "width:10em"}
%tr
%td Rechnungsnummer:
%td= form.text_field "invoice_number", :size => 10
%tr
%td Rechnungsdatum:
%td= form.text_field "invoice_date", :size => 10
%tr
%td
%abbr{:title => "(incl. Pfand/Gutschriften)"} Rechnungsbeitrag
%td= form.text_field 'invoice_amount', :size => 10
%tr
%td
%abbr{:title => "z.B Kistepfand"} extra Pfand
%td= form.text_field 'deposit', :size => 10
%tr
%td Pfandgutschrift
%td= form.text_field 'deposit_credit', :size => 10
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,25 @@
%td{:colspan => "7"}
%p
Notiz:
= @article.note
%table
%thead
%tr
%td
%td{:style => "width:8em"} Gruppe
%td Einheiten
%td Gesamtpreis
%td{:colspan => "3",:style => "width:14em"}
= link_to_remote '[Gruppe hinzufügen]', :url => {:action => "newGroupResult", :id => @article}, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%tbody{:id => "groups_results_#{@article.id}"}
- for @result in @article.group_order_article_results
= render :partial => "groupResults"
%tfoot
%tr{:class => cycle('even', 'odd', :name => 'results'), :id => "sum_of_article_#{@article.id}"}
%td
%td{:style => "width:8em"} Summe
%td{:id => "totalArticleQuantity_#{@article.id}"}= @article.total[:quantity]
%td{:id => "totalArticlePrice_#{@article.id}", :class => "currency"}
= number_to_currency(@article.total[:price])
%td{:colspan => "3"}
- reset_cycle('results')

View file

@ -0,0 +1,17 @@
%td
%td{:style=>"width:50%"}= @result.group_order_result.group_name
%td{:id => "group_order_article_result_#{@result.id}_quantity"}= @result.quantity
%td{:class => "currency"}= number_to_currency(@result.order_article_result.gross_price * @result.quantity)
%td{:style=>"width:1em", :class => "actions"}
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Menge ändern'), |
:url => {:action => 'updateGroupResult', :id => @result}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td{:style=>"width:1em", :class => "actions"}
= link_to_remote image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Gruppenergebnis löschen'), |
:url => {:action => 'destroyGroupResult', :id => @result}, |
:confirm => 'Bist du sicher?', |
:method => 'post', |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%td

View file

@ -0,0 +1,2 @@
%tr{:class => cycle('even', 'odd', :name => 'results')}[@result]
= render :partial => "groupResult"

View file

@ -0,0 +1,30 @@
%p
%b
Gruppenbestellungen:
= @order.group_order_results.size
- for groupOrderResult in @order.group_order_results
%p
%table{:style => "width:40em"}[groupOrderResult]
%thead
%tr
%th{:colspan => "6"}= groupOrderResult.group_name
%tbody
- total = 0
- for result in groupOrderResult.group_order_article_results
- price = result.order_article_result.gross_price
- quantity = result.quantity
- subTotal = price * quantity
- total += subTotal
%tr{:class => cycle('even', 'odd', :name => 'article')}
%td= result.order_article_result.name
%td= quantity
%td{:class => "currency"}= number_to_currency(price)
%td= result.order_article_result.unit_quantity
%td= result.order_article_result.unit
%td= number_to_currency(subTotal)
%tfoot
%tr{:class => cycle('even', 'odd', :name => 'article')}
%td{:colspan => "5"} Summe
%td
%b= number_to_currency(total)
- reset_cycle("article")

View file

@ -0,0 +1,7 @@
%h2
Neuer gelieferter Artikel die Bestellung
- remote_form_for 'order_article_result', @article, :url => {:action => 'createArticleResult' }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |@form| |
= render :partial => "articleResultForm"

View file

@ -0,0 +1,17 @@
%h2
Neue Gruppenmenge für
= @result.order_article_result.name
- remote_form_for 'group_order_article_result', @result, :url => {:action => 'createGroupResult'}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |@form| |
= error_messages_for 'result'
%p
Gruppe:
= @form.select "group_order_result_id", OrderGroup.find(:all, :order => "name").collect {|og| [og.name, og.id] }
%p
Menge:
= @form.text_field "quantity", :size => 5
= @form.hidden_field "order_article_result_id"
%p
= submit_tag "Speichern"
|
= link_to_function 'Abbrechen', "Element.hide('edit_box')"

View file

@ -0,0 +1,60 @@
%p
%b=h @order.supplier ? @order.supplier.name : _('nonexistent')
| Rechnungsnummer:
= @order.invoice_number
| Rechnungsdatum:
= @order.invoice_date
|
= link_to_remote image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Rechnungsbetrag ändern'), |
:url => {:action => "editOrderSummary", :id => @order}, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')" |
%table
%tr
%td{:colspan => "2"}
%b Foodcoop
%td{:colspan => "2"}
%b Lieferant
%tr
%td
%abbr{:title => "gelieferten Artikel x Nettopreis"} Nettobetrag:
%td= number_to_currency(@order.sumPrice("clear"))
%td
Rechnungsbetrag
%small (incl. Pfand/Gutschriften)
%td#invoice_amount= number_to_currency(@order.invoice_amount)
%tr
%td
%abbr{:title => "Nettobetrag mit Pfand und MwSt."} Bruttobetrag:
%td= number_to_currency(@order.sumPrice("gross"))
%td
%span - extra Pfand
%small (Kistenpfand etc.)
%td#deposit= number_to_currency(@order.deposit)
%tr
%td
%abbr{:title => "Bruttobetrag mit Foodcoop Aufschlag"} FC Summe:
%td= number_to_currency(@order.sumPrice("fc"))
%td{:style => "border-bottom: 1px solid grey"}
+ Pfandgutschriften
%td{:style => "border-bottom: 1px solid grey"}
#deposit_credit= number_to_currency(@order.deposit_credit)
%tr
%td
%abbr{:title => "Zugeteilte Mengen x Bruttopreise (inkl. Aufschlag)"} Gruppenbeträge:
%td#groups_amount= number_to_currency(@order.sumPrice("groups"))
%td
Summe
%small (Rechungsbetrag ohne Pfand)
%td#clear_invoice= number_to_currency(@order.invoice_amount - @order.deposit + @order.deposit_credit)
%tr
%td{:colspan => "4"}
%abbr{:title => "Gruppenbeträge ohne Aufschlag minus Rechnung ohne Pfand. |
Im Idealfall sollte hier 0.00 stehen."} Differenz ohne Aufschlag: |
%span#fcProfit= number_to_currency(@order.fcProfit(false))
%tr
%td{:colspan => "4"}
%b
%abbr{:title => "= Gruppenbeträge - Rechnung ohne Pfand"} Differenz mit Aufschlag
= "(#{number_to_percentage(APP_CONFIG[:price_markup])}):"
%span#fcProfit= number_to_currency(@order.fcProfit)

View file

@ -0,0 +1,16 @@
%h1 Bestellung abschließen
.single_column#confirm{:style => "width:35em"}
%p
Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert.
%br/
Die Konten werden wie folgt belastet:
%table.list{:style => "width:35em"}
- for groupResult in @order.group_order_results
%tr{:class => cycle('even', 'odd')}
%td= groupResult.group_name
%td= number_to_currency(groupResult.price)
%p
%div{:style => "float:left"}
= button_to "Abschließen", :action => "close", :id => @order
%div{:style => "float:right"}
= link_to 'Zurück zur Abrechnung', :action => "new", :id => @order

View file

@ -0,0 +1,37 @@
%h1 beendete Bestellungen
%p
%i
Aktuell gibt es die Möglichkeit eine Bestellung mittels dem "abrechnen"-link zu verbuchen, d.h.
nach Bearbeitung der Liefermengen die Gruppenbeträge automatisiert zu verbuchen,
%br/
oder die Bestellung manuell abzurechnen (Kontostände selbst zu aktualisieren) und mittels "auf gebucht setzen"
die Bestellung als abgeschlossen zu deklarieren.
.left_column{:style => "width:70em"}
.box_title
.column_content
- unless @orders.empty?
= will_paginate @orders
%table.list
%thead
%tr
%th Name
%th Anbieter
%th Ende
%th Status
%th zuletzt bearbeitet von
%th
%tbody
- @orders.each do |order|
%tr{:class => cycle("even","odd", :name => "order")}
%td= link_to truncate(order.name), :action => "new", :id => order
%td=h order.supplier ? order.supplier.name : _('nonexistent')
%td=h format_time(order.ends) unless order.ends.nil?
%td= order.booked ? "abgerechnet (#{number_to_currency order.fcProfit})" : "beendet"
%td= order.updated_by.nil? ? '??' : order.updated_by.nick
%td
- unless order.booked
= link_to "abrechnen", :action => "new", :id => order
|
= link_to 'auf "gebucht" setzen', {:action => 'setAllBooked', :id => order}, :confirm => 'Wirklich alle Gruppenbestellungen für diese Bestellung auf "gebucht" setzen?', :method => "post"
- else
%i derzeit gibt es keine beendeten Bestellungen

View file

@ -0,0 +1,49 @@
%h1 Bestellung abrechnen
- if @order.booked
%p
%b Achtung, Bestellung wurde schon abgerechnet!
.left_column{:style => 'width: 50em'}
.box_title
%h2
= @order.name + " | " + format_date(@order.starts) + ' --> ' + format_date(@order.ends)
.column_content#summary
#order_summary
= render :partial => "summary"
.right_column{:style => 'width: 20em'}
.box_title
%h2 Aktionen
.column_content
%ul
- unless @order.booked
%li= link_to "Bestellung abschließen", :action => "confirm", :id => @order
.right_column{:style => 'clear:both;width: 28%'}
.box_title
%h2 Protokoll
.column_content
#note
- unless @order.note.empty?
= simple_format @order.note
- else
%p Hier kannst Du deine Abrechnung kommentieren
%small Protokoll bearbeiten:
= link_to_remote image_tag("b_edit.png", :size => "16x16", :border => "0"), |
:update => 'results', :url => { :action => 'new', :id => @order, :view => 'editNote' }, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" |
%hr/
#comments
= render :partial => 'shared/comments'
.left_column{:style => 'width: 69%'}
.box_title
#editOrderNav
%ul
%li= link_to_remote 'Gruppenübersicht', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'groupsOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%li= link_to_remote 'Artikelübersicht', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'articlesOverview' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
%li= link_to_remote 'Bestellung bearbeiten', :update => 'results', :url => { :action => 'new', :id => @order, :view => 'editResults' }, :before => "Element.show('loader')", :success => "Element.hide('loader')"
.column_content
#results
= render :partial => 'groupsOverview'
%p= link_to_top
#edit_box{:style => 'display:none'}