Merge branch 'master' into master-rails3-merging
Conflicts: .gitignore .rbenv-version app/controllers/finance/balancing_controller.rb app/views/finance/balancing/_order_article_form.html.haml Fixed updating current price in finance balancing.
This commit is contained in:
commit
620ec946f1
7 changed files with 37 additions and 19 deletions
|
@ -1 +1 @@
|
||||||
1.9.3-p327
|
1.9.3-p327
|
1
VERSION
Normal file
1
VERSION
Normal file
|
@ -0,0 +1 @@
|
||||||
|
3.1.1
|
|
@ -26,7 +26,7 @@ class Finance::OrderArticlesController < ApplicationController
|
||||||
@order = Order.find(params[:order_id])
|
@order = Order.find(params[:order_id])
|
||||||
@order_article = OrderArticle.find(params[:id])
|
@order_article = OrderArticle.find(params[:id])
|
||||||
begin
|
begin
|
||||||
@order_article.update_article_and_price!(params[:article], params[:price], params[:order_article])
|
@order_article.update_article_and_price!(params[:article], params[:article_price], params[:order_article])
|
||||||
rescue
|
rescue
|
||||||
render action: :edit
|
render action: :edit
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# An OrderArticle represents a single Article that is part of an Order.
|
# An OrderArticle represents a single Article that is part of an Order.
|
||||||
class OrderArticle < ActiveRecord::Base
|
class OrderArticle < ActiveRecord::Base
|
||||||
|
|
||||||
|
attr_reader :update_current_price
|
||||||
|
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
belongs_to :article
|
belongs_to :article
|
||||||
belongs_to :article_price
|
belongs_to :article_price
|
||||||
|
@ -82,26 +84,35 @@ class OrderArticle < ActiveRecord::Base
|
||||||
# Updates order_article and belongings during balancing process
|
# Updates order_article and belongings during balancing process
|
||||||
def update_article_and_price!(article_attributes, price_attributes, order_article_attributes)
|
def update_article_and_price!(article_attributes, price_attributes, order_article_attributes)
|
||||||
OrderArticle.transaction do
|
OrderArticle.transaction do
|
||||||
|
# Updates self
|
||||||
|
self.update_attributes!(order_article_attributes)
|
||||||
|
|
||||||
# Updates article
|
# Updates article
|
||||||
article.update_attributes!(article_attributes)
|
article.update_attributes!(article_attributes)
|
||||||
|
|
||||||
|
# Updates article_price belonging to current order article
|
||||||
article_price.attributes = price_attributes
|
article_price.attributes = price_attributes
|
||||||
if article_price.changed?
|
if article_price.changed?
|
||||||
# Creates a new article_price if neccessary
|
# Updates also price attributes of article if update_current_price is selected
|
||||||
price = build_article_price(price_attributes)
|
if update_current_price
|
||||||
price.created_at = order.ends
|
article.update_attributes!(price_attributes)
|
||||||
price.save!
|
self.article_price = article.article_prices.first # Assign new created article price to order article
|
||||||
|
else
|
||||||
|
# Creates a new article_price if neccessary
|
||||||
|
# Set created_at timestamp to order ends, to make sure the current article price isn't changed
|
||||||
|
create_article_price!(price_attributes.merge(created_at: order.ends)) and save
|
||||||
|
end
|
||||||
|
|
||||||
# Updates ordergroup values
|
# Updates ordergroup values
|
||||||
group_order_articles.each { |goa| goa.group_order.update_price! }
|
update_ordergroup_prices
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updates units_to_order
|
|
||||||
self.attributes = order_article_attributes
|
|
||||||
self.save!
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_current_price=(value)
|
||||||
|
@update_current_price = (value == true or value == '1') ? true : false
|
||||||
|
end
|
||||||
|
|
||||||
# Units missing for the next full unit_quantity of the article
|
# Units missing for the next full unit_quantity of the article
|
||||||
def missing_units
|
def missing_units
|
||||||
units = article.unit_quantity - ((quantity % article.unit_quantity) + tolerance)
|
units = article.unit_quantity - ((quantity % article.unit_quantity) + tolerance)
|
||||||
|
@ -123,10 +134,10 @@ class OrderArticle < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO: Delayed job maybe??
|
|
||||||
def update_ordergroup_prices
|
def update_ordergroup_prices
|
||||||
group_order_articles.each { |goa| goa.group_order.update_price! }
|
group_order_articles.each { |goa| goa.group_order.update_price! }
|
||||||
end
|
end
|
||||||
|
handle_asynchronously :update_ordergroup_prices
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
= f.input :name
|
= f.input :name
|
||||||
= f.input :order_number
|
= f.input :order_number
|
||||||
= f.input :unit
|
= f.input :unit
|
||||||
|
= simple_fields_for @order_article.article_price do |f|
|
||||||
= f.input :unit_quantity
|
= f.input :unit_quantity
|
||||||
= f.input :price
|
= f.input :price
|
||||||
= f.input :tax
|
= f.input :tax
|
||||||
= f.input :deposit
|
= f.input :deposit
|
||||||
|
|
||||||
|
= form.input :update_current_price, as: :boolean
|
||||||
|
|
||||||
.modal-footer
|
.modal-footer
|
||||||
= button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'}
|
= button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'}
|
||||||
= form.submit class: 'btn btn-primary'
|
= form.submit class: 'btn btn-primary'
|
|
@ -284,6 +284,11 @@ de:
|
||||||
amount: 'Betrag'
|
amount: 'Betrag'
|
||||||
phone: "Telefon"
|
phone: "Telefon"
|
||||||
user_tokens: 'Mitglieder'
|
user_tokens: 'Mitglieder'
|
||||||
|
price: 'Preis (netto)'
|
||||||
|
unit_quantity: 'Gebindegröße'
|
||||||
|
order_number: 'Bestellnummer'
|
||||||
|
tax: 'MwSt'
|
||||||
|
deposit: 'Pfand'
|
||||||
user:
|
user:
|
||||||
nick: "Benutzerinnenname"
|
nick: "Benutzerinnenname"
|
||||||
first_name: "Vorname"
|
first_name: "Vorname"
|
||||||
|
@ -342,11 +347,6 @@ de:
|
||||||
unit: 'Einheit'
|
unit: 'Einheit'
|
||||||
note: 'Notiz'
|
note: 'Notiz'
|
||||||
article_category: 'Kategorie'
|
article_category: 'Kategorie'
|
||||||
price: 'Preis (netto)'
|
|
||||||
unit_quantity: 'Gebindegröße'
|
|
||||||
order_number: 'Bestellnummer'
|
|
||||||
tax: 'MwSt'
|
|
||||||
deposit: 'Pfand'
|
|
||||||
stock_article:
|
stock_article:
|
||||||
supplier: 'Lieferant'
|
supplier: 'Lieferant'
|
||||||
delivery:
|
delivery:
|
||||||
|
@ -373,7 +373,7 @@ de:
|
||||||
deposit_credit: Pfand gutgeschrieben
|
deposit_credit: Pfand gutgeschrieben
|
||||||
order_article:
|
order_article:
|
||||||
units_to_order: Menge
|
units_to_order: Menge
|
||||||
|
update_current_price: Globalen Preis aktualisieren
|
||||||
|
|
||||||
hints:
|
hints:
|
||||||
tax: 'In Prozent, Standard sind 7,0'
|
tax: 'In Prozent, Standard sind 7,0'
|
||||||
|
@ -390,3 +390,4 @@ de:
|
||||||
private: Nachricht erscheint nicht im Foodsoft Posteingang
|
private: Nachricht erscheint nicht im Foodsoft Posteingang
|
||||||
order_article:
|
order_article:
|
||||||
units_to_order: Anzahl gelieferter Gebinde
|
units_to_order: Anzahl gelieferter Gebinde
|
||||||
|
update_current_price: Ändert auch den Preis für aktuelle Bestellungen
|
||||||
|
|
|
@ -22,7 +22,9 @@ namespace :foodsoft do
|
||||||
workgroups = Workgroup.where(weekly_task: true)
|
workgroups = Workgroup.where(weekly_task: true)
|
||||||
for workgroup in workgroups
|
for workgroup in workgroups
|
||||||
puts "Create weekly tasks for #{workgroup.name}"
|
puts "Create weekly tasks for #{workgroup.name}"
|
||||||
workgroup.next_weekly_tasks[3..5].each do |date|
|
# Loop through next tasks weekly tasks method,
|
||||||
|
# skip the next 3 weeks, to allow manually deleting tasks
|
||||||
|
workgroup.next_weekly_tasks[3..-1].each do |date|
|
||||||
unless workgroup.tasks.exists?({:due_date => date, :weekly => true})
|
unless workgroup.tasks.exists?({:due_date => date, :weekly => true})
|
||||||
workgroup.tasks.create(workgroup.task_attributes(date))
|
workgroup.tasks.create(workgroup.task_attributes(date))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue