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
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_article = OrderArticle.find(params[:id])
|
||||
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
|
||||
render action: :edit
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# An OrderArticle represents a single Article that is part of an Order.
|
||||
class OrderArticle < ActiveRecord::Base
|
||||
|
||||
attr_reader :update_current_price
|
||||
|
||||
belongs_to :order
|
||||
belongs_to :article
|
||||
belongs_to :article_price
|
||||
|
@ -82,24 +84,33 @@ class OrderArticle < ActiveRecord::Base
|
|||
# Updates order_article and belongings during balancing process
|
||||
def update_article_and_price!(article_attributes, price_attributes, order_article_attributes)
|
||||
OrderArticle.transaction do
|
||||
# Updates self
|
||||
self.update_attributes!(order_article_attributes)
|
||||
|
||||
# Updates article
|
||||
article.update_attributes!(article_attributes)
|
||||
|
||||
# Updates article_price belonging to current order article
|
||||
article_price.attributes = price_attributes
|
||||
if article_price.changed?
|
||||
# Updates also price attributes of article if update_current_price is selected
|
||||
if update_current_price
|
||||
article.update_attributes!(price_attributes)
|
||||
self.article_price = article.article_prices.first # Assign new created article price to order article
|
||||
else
|
||||
# Creates a new article_price if neccessary
|
||||
price = build_article_price(price_attributes)
|
||||
price.created_at = order.ends
|
||||
price.save!
|
||||
# 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
|
||||
group_order_articles.each { |goa| goa.group_order.update_price! }
|
||||
update_ordergroup_prices
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Updates units_to_order
|
||||
self.attributes = order_article_attributes
|
||||
self.save!
|
||||
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
|
||||
|
@ -123,10 +134,10 @@ class OrderArticle < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#TODO: Delayed job maybe??
|
||||
def update_ordergroup_prices
|
||||
group_order_articles.each { |goa| goa.group_order.update_price! }
|
||||
end
|
||||
handle_asynchronously :update_ordergroup_prices
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -9,11 +9,14 @@
|
|||
= f.input :name
|
||||
= f.input :order_number
|
||||
= f.input :unit
|
||||
= simple_fields_for @order_article.article_price do |f|
|
||||
= f.input :unit_quantity
|
||||
= f.input :price
|
||||
= f.input :tax
|
||||
= f.input :deposit
|
||||
|
||||
= form.input :update_current_price, as: :boolean
|
||||
|
||||
.modal-footer
|
||||
= button_tag "Schließen", class: 'btn', data: {dismiss: 'modal'}
|
||||
= form.submit class: 'btn btn-primary'
|
|
@ -284,6 +284,11 @@ de:
|
|||
amount: 'Betrag'
|
||||
phone: "Telefon"
|
||||
user_tokens: 'Mitglieder'
|
||||
price: 'Preis (netto)'
|
||||
unit_quantity: 'Gebindegröße'
|
||||
order_number: 'Bestellnummer'
|
||||
tax: 'MwSt'
|
||||
deposit: 'Pfand'
|
||||
user:
|
||||
nick: "Benutzerinnenname"
|
||||
first_name: "Vorname"
|
||||
|
@ -342,11 +347,6 @@ de:
|
|||
unit: 'Einheit'
|
||||
note: 'Notiz'
|
||||
article_category: 'Kategorie'
|
||||
price: 'Preis (netto)'
|
||||
unit_quantity: 'Gebindegröße'
|
||||
order_number: 'Bestellnummer'
|
||||
tax: 'MwSt'
|
||||
deposit: 'Pfand'
|
||||
stock_article:
|
||||
supplier: 'Lieferant'
|
||||
delivery:
|
||||
|
@ -373,7 +373,7 @@ de:
|
|||
deposit_credit: Pfand gutgeschrieben
|
||||
order_article:
|
||||
units_to_order: Menge
|
||||
|
||||
update_current_price: Globalen Preis aktualisieren
|
||||
|
||||
hints:
|
||||
tax: 'In Prozent, Standard sind 7,0'
|
||||
|
@ -390,3 +390,4 @@ de:
|
|||
private: Nachricht erscheint nicht im Foodsoft Posteingang
|
||||
order_article:
|
||||
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)
|
||||
for workgroup in workgroups
|
||||
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})
|
||||
workgroup.tasks.create(workgroup.task_attributes(date))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue