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
|
||||
|
||||
attr_accessor :ignore_warnings
|
||||
|
||||
# Associations
|
||||
has_many :order_articles, :dependent => :destroy
|
||||
has_many :articles, :through => :order_articles
|
||||
|
@ -215,19 +217,19 @@ class Order < ActiveRecord::Base
|
|||
protected
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def keep_ordered_articles
|
||||
chosen_order_articles = order_articles.find_all_by_article_id(article_ids)
|
||||
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 }
|
||||
unless to_be_removed_but_ordered.empty?
|
||||
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!")
|
||||
unless to_be_removed_but_ordered.empty? or ignore_warnings
|
||||
errors.add(:articles, I18n.t('orders.model.warning_ordered'))
|
||||
@erroneous_article_ids = to_be_removed_but_ordered.map { |a| a.article_id }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,3 +56,7 @@
|
|||
.form-actions
|
||||
= f.submit class: 'btn'
|
||||
= 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:
|
||||
notice: Die Bestellung wurde beendet.
|
||||
form:
|
||||
ignore_warnings: Warnungen ignorieren
|
||||
name: Name
|
||||
note: Notiz
|
||||
origin: Herkunft
|
||||
|
@ -1324,6 +1325,7 @@ de:
|
|||
error_starts_before_ends: muss nach dem Bestellstart liegen (oder leer bleiben)
|
||||
notice_close: ! 'Bestellung: %{name}, bis %{ends}'
|
||||
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:
|
||||
title: Neue Bestellung anlegen
|
||||
orders:
|
||||
|
|
|
@ -1299,6 +1299,7 @@ en:
|
|||
finish:
|
||||
notice: The order has been closed.
|
||||
form:
|
||||
ignore_warnings: Ignore warnings
|
||||
name: Name
|
||||
note: Note
|
||||
origin: Origin
|
||||
|
@ -1326,6 +1327,7 @@ en:
|
|||
error_starts_before_ends: must be after the start date (or remain empty)
|
||||
notice_close: ! 'Order: %{name}, until %{ends}'
|
||||
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:
|
||||
title: Create new order
|
||||
orders:
|
||||
|
|
Loading…
Reference in a new issue