Don't allow changes to settled orders (PR #614)
This commit is contained in:
parent
a524dd0325
commit
99052fa3a7
7 changed files with 24 additions and 7 deletions
|
@ -9,6 +9,7 @@ class GroupOrderArticle < ApplicationRecord
|
|||
|
||||
validates_presence_of :group_order, :order_article
|
||||
validates_uniqueness_of :order_article_id, :scope => :group_order_id # just once an article per group order
|
||||
validate :check_order_not_closed # don't allow changes to closed (aka settled) orders
|
||||
|
||||
scope :ordered, -> { includes(:group_order => :ordergroup).order('groups.name') }
|
||||
|
||||
|
@ -195,4 +196,12 @@ class GroupOrderArticle < ApplicationRecord
|
|||
def result_manually_changed?
|
||||
result != result_computed unless result.nil?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_order_not_closed
|
||||
if order_article.order.closed?
|
||||
errors.add(:order_article, I18n.t('model.group_order_article.order_closed'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
%th= heading_helper Article, :deposit
|
||||
%th{:colspan => "2"}
|
||||
= link_to t('.add_article'), new_order_order_article_path(@order), remote: true,
|
||||
class: 'btn btn-small'
|
||||
class: 'btn btn-small' unless @order.closed?
|
||||
%tbody#result_table
|
||||
- for order_article in @articles
|
||||
= render :partial => "order_article_result", :locals => {:order_article => order_article}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
%acronym{:title => t('shared.articles.received_desc')}= t 'shared.articles.received'
|
||||
%td= t('.total')
|
||||
%td{:colspan => "3",:style => "width:14em"}
|
||||
- unless order_article.order.closed?
|
||||
= link_to t('.add_group'), new_group_order_article_path(order_article_id: order_article.id),
|
||||
remote: true, class: 'btn btn-mini'
|
||||
%tbody
|
||||
|
@ -21,8 +22,9 @@
|
|||
%td.center= group_order_article_edit_result(group_order_article)
|
||||
%td.numeric= number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result)
|
||||
%td.actions{:style=>"width:1em"}
|
||||
= link_to t('ui.delete'), group_order_article_path(group_order_article), method: :delete,
|
||||
remote: true, class: 'btn btn-mini btn-danger'
|
||||
- unless order_article.order.closed?
|
||||
= link_to t('ui.delete'), group_order_article_path(group_order_article),
|
||||
method: :delete, remote: true, class: 'btn btn-mini btn-danger'
|
||||
%td
|
||||
- totals[:result] += group_order_article.result
|
||||
%tfoot
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
%td= order_article.price.deposit
|
||||
%td
|
||||
= link_to t('ui.edit'), edit_order_order_article_path(order_article.order, order_article), remote: true,
|
||||
class: 'btn btn-mini'
|
||||
class: 'btn btn-mini' unless order_article.order.closed?
|
||||
%td
|
||||
= link_to t('ui.delete'), order_order_article_path(order_article.order, order_article), method: :delete,
|
||||
remote: true, data: {confirm: t('.confirm')}, class: 'btn btn-danger btn-mini'
|
||||
remote: true, data: {confirm: t('.confirm')}, class: 'btn btn-danger btn-mini' unless order_article.order.closed?
|
||||
|
|
|
@ -1444,6 +1444,8 @@ de:
|
|||
redirect: Weiterleitung auf [[%{title}]]...
|
||||
user:
|
||||
no_ordergroup: keine Bestellgruppe
|
||||
group_order_article:
|
||||
order_closed: Bestellung ist geschlossen und kann nicht geändert werden
|
||||
navigation:
|
||||
admin:
|
||||
config: Einstellungen
|
||||
|
|
|
@ -1469,6 +1469,8 @@ en:
|
|||
redirect: Redirect to [[%{title}]]...
|
||||
user:
|
||||
no_ordergroup: no ordergroup
|
||||
group_order_article:
|
||||
order_closed: Order is closed and cannot be modified
|
||||
navigation:
|
||||
admin:
|
||||
config: Configuration
|
||||
|
|
|
@ -1399,6 +1399,8 @@ nl:
|
|||
redirect: Doorverwijzing naar [[%{title}]]...
|
||||
user:
|
||||
no_ordergroup: geen huishouden
|
||||
group_order_article:
|
||||
order_closed: Bestelling is gesloten en kan niet worden gewijzigd
|
||||
navigation:
|
||||
admin:
|
||||
config: Instellingen
|
||||
|
|
Loading…
Reference in a new issue