Added checkbox to ignore warnings. Added translations.
This commit is contained in:
parent
bb25bdc6eb
commit
805071f3fb
4 changed files with 14 additions and 4 deletions
|
@ -2,6 +2,8 @@
|
||||||
#
|
#
|
||||||
class Order < ActiveRecord::Base
|
class Order < ActiveRecord::Base
|
||||||
|
|
||||||
|
attr_accessor :ignore_warnings
|
||||||
|
|
||||||
# Associations
|
# Associations
|
||||||
has_many :order_articles, :dependent => :destroy
|
has_many :order_articles, :dependent => :destroy
|
||||||
has_many :articles, :through => :order_articles
|
has_many :articles, :through => :order_articles
|
||||||
|
@ -215,19 +217,19 @@ class Order < ActiveRecord::Base
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def starts_before_ends
|
def starts_before_ends
|
||||||
errors.add(:ends, I18n.t('articles.model.error_starts_before_ends')) if (ends && starts && ends <= starts)
|
errors.add(:ends, I18n.t('orders.model.error_starts_before_ends')) if (ends && starts && ends <= starts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_articles
|
def include_articles
|
||||||
errors.add(:articles, I18n.t('articles.model.error_nosel')) if article_ids.empty?
|
errors.add(:articles, I18n.t('orders.model.error_nosel')) if article_ids.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def keep_ordered_articles
|
def keep_ordered_articles
|
||||||
chosen_order_articles = order_articles.find_all_by_article_id(article_ids)
|
chosen_order_articles = order_articles.find_all_by_article_id(article_ids)
|
||||||
to_be_removed = order_articles - chosen_order_articles
|
to_be_removed = order_articles - chosen_order_articles
|
||||||
to_be_removed_but_ordered = to_be_removed.select { |a| a.quantity > 0 or a.tolerance > 0 }
|
to_be_removed_but_ordered = to_be_removed.select { |a| a.quantity > 0 or a.tolerance > 0 }
|
||||||
unless to_be_removed_but_ordered.empty?
|
unless to_be_removed_but_ordered.empty? or ignore_warnings
|
||||||
errors.add(:articles, "Die markierten Artikel wurden in der laufenden Bestellung bereits bestellt. Wenn Du sie hier abwählst, werden alle bestehenden Bestellungen dieses Artikels gelöscht. Bei Lagerbestellungen kann dies je nach Verwendung bedeuten, dass bereits gekaufte Artikel nicht abgerechnet werden!")
|
errors.add(:articles, I18n.t('orders.model.warning_ordered'))
|
||||||
@erroneous_article_ids = to_be_removed_but_ordered.map { |a| a.article_id }
|
@erroneous_article_ids = to_be_removed_but_ordered.map { |a| a.article_id }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,3 +56,7 @@
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.submit class: 'btn'
|
= f.submit class: 'btn'
|
||||||
= link_to t('ui.or_cancel'), orders_path
|
= link_to t('ui.or_cancel'), orders_path
|
||||||
|
- unless @order.erroneous_article_ids.empty?
|
||||||
|
|
||||||
|
= check_box_tag 'order[ignore_warnings]'
|
||||||
|
= t '.ignore_warnings'
|
||||||
|
|
|
@ -1297,6 +1297,7 @@ de:
|
||||||
finish:
|
finish:
|
||||||
notice: Die Bestellung wurde beendet.
|
notice: Die Bestellung wurde beendet.
|
||||||
form:
|
form:
|
||||||
|
ignore_warnings: Warnungen ignorieren
|
||||||
name: Name
|
name: Name
|
||||||
note: Notiz
|
note: Notiz
|
||||||
origin: Herkunft
|
origin: Herkunft
|
||||||
|
@ -1324,6 +1325,7 @@ de:
|
||||||
error_starts_before_ends: muss nach dem Bestellstart liegen (oder leer bleiben)
|
error_starts_before_ends: muss nach dem Bestellstart liegen (oder leer bleiben)
|
||||||
notice_close: ! 'Bestellung: %{name}, bis %{ends}'
|
notice_close: ! 'Bestellung: %{name}, bis %{ends}'
|
||||||
stock: Lager
|
stock: Lager
|
||||||
|
warning_ordered: 'Warnung: Die rot markierten Artikel wurden in der laufenden Bestellung bereits bestellt. Wenn Du sie hier abwählst, werden alle bestehenden Bestellungen dieses Artikels gelöscht. Bei Lagerbestellungen kann dies je nach Verwendung bedeuten, dass bereits gekaufte Artikel nicht abgerechnet werden!'
|
||||||
new:
|
new:
|
||||||
title: Neue Bestellung anlegen
|
title: Neue Bestellung anlegen
|
||||||
orders:
|
orders:
|
||||||
|
|
|
@ -1299,6 +1299,7 @@ en:
|
||||||
finish:
|
finish:
|
||||||
notice: The order has been closed.
|
notice: The order has been closed.
|
||||||
form:
|
form:
|
||||||
|
ignore_warnings: Ignore warnings
|
||||||
name: Name
|
name: Name
|
||||||
note: Note
|
note: Note
|
||||||
origin: Origin
|
origin: Origin
|
||||||
|
@ -1326,6 +1327,7 @@ en:
|
||||||
error_starts_before_ends: must be after the start date (or remain empty)
|
error_starts_before_ends: must be after the start date (or remain empty)
|
||||||
notice_close: ! 'Order: %{name}, until %{ends}'
|
notice_close: ! 'Order: %{name}, until %{ends}'
|
||||||
stock: Stock
|
stock: Stock
|
||||||
|
warning_ordered: 'Warning: Articles marked red have already been ordered within this open order. If you uncheck them here, all existing orders of these articles will be deleted. In case of stock orders this might mean that already bought articles will not be accounted for!'
|
||||||
new:
|
new:
|
||||||
title: Create new order
|
title: Create new order
|
||||||
orders:
|
orders:
|
||||||
|
|
Loading…
Reference in a new issue