make settle directly less dangerous

(closes foodcoops#275)
This commit is contained in:
wvengen 2014-03-21 10:51:22 +01:00
parent ea8e4ee560
commit 852f3484ad
5 changed files with 18 additions and 12 deletions

View File

@ -224,6 +224,7 @@ class Order < ActiveRecord::Base
# Close the order directly, without automaticly updating ordergroups account balances # Close the order directly, without automaticly updating ordergroups account balances
def close_direct!(user) def close_direct!(user)
raise I18n.t('orders.model.error_closed') if closed? raise I18n.t('orders.model.error_closed') if closed?
comments.create(user: user, text: I18n.t('orders.model.close_direct_message'))
update_attributes! state: 'closed', updated_by: user update_attributes! state: 'closed', updated_by: user
end end

View File

@ -21,11 +21,9 @@
- unless order.closed? - unless order.closed?
- if current_user.role_orders? - if current_user.role_orders?
- unless order.stockit? - unless order.stockit?
= link_to t('orders.index.action_receive'), receive_order_path(order), class: 'btn btn-mini' = link_to t('orders.index.action_receive'), receive_order_path(order), class: 'btn btn-small'
- else - else
= link_to t('orders.index.action_receive'), '#', class: 'btn btn-mini disabled' = link_to t('orders.index.action_receive'), '#', class: 'btn btn-small disabled'
= link_to t('.clear'), new_finance_order_path(order_id: order.id), class: 'btn btn-mini btn-primary' = link_to t('.clear'), new_finance_order_path(order_id: order.id), class: 'btn btn-small btn-primary'
= link_to t('.close'), close_direct_finance_order_path(order),
:data => {:confirm => t('.confirm')}, :method => :patch, class: 'btn btn-mini'
- else - else
%i= t('.no_closed_orders') %i= t('.no_closed_orders')

View File

@ -48,12 +48,18 @@
#comments= render :partial => 'shared/comments', locals: {comments: @order.comments.includes(:user)} #comments= render :partial => 'shared/comments', locals: {comments: @order.comments.includes(:user)}
- content_for :actionbar do - content_for :actionbar do
- unless @order.invoice or @order.stockit?
= link_to t('.create_invoice'), new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier),
class: 'btn'
.btn-group .btn-group
- unless @order.invoice or @order.stockit?
= link_to t('.create_invoice'), new_finance_invoice_path(:order_id => @order, :supplier_id => @order.supplier),
class: 'btn'
- unless @order.closed? - unless @order.closed?
= link_to t('.confirm_order'), confirm_finance_order_path(@order), class: 'btn btn-primary' = link_to t('.confirm_order'), confirm_finance_order_path(@order), class: 'btn btn-primary'
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do
%span.caret
%ul.dropdown-menu
%li= link_to t('.confirm_order'), confirm_finance_order_path(@order)
%li= link_to t('.close_direct'), close_direct_finance_order_path(@order), method: :patch,
data: {confirm: t('.close_direct_confirm')}
#editOrderNav.btn-group.pull-right #editOrderNav.btn-group.pull-right
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do = link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do

View File

@ -542,6 +542,8 @@ en:
comment_on_transaction: Here you can add a comment to your accounting. comment_on_transaction: Here you can add a comment to your accounting.
comments: Comments comments: Comments
confirm_order: Settle order confirm_order: Settle order
close_direct: Skip settling
close_direct_confirm: 'You are about to settle the order without charging member acounts. Do this only when you have already debited member accounts manually, or if you really know what you are doing.'
create_invoice: Create invoice create_invoice: Create invoice
edit_note: Edit note edit_note: Edit note
edit_order: Edit order edit_order: Edit order
@ -556,8 +558,6 @@ en:
orders: orders:
clear: accounting clear: accounting
cleared: accounted (%{amount}) cleared: accounted (%{amount})
close: settle directly
confirm: Do you really want to settle the order?
end: End end: End
ended: closed ended: closed
name: Supplier name: Supplier
@ -1110,6 +1110,7 @@ en:
orders_settled: Settled orders_settled: Settled
title: Manage orders title: Manage orders
model: model:
close_direct_message: Order settled without charging member accounts.
error_closed: Order was already settled error_closed: Order was already settled
error_nosel: At least one article must be selected error_nosel: At least one article must be selected
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)

View File

@ -540,6 +540,8 @@ nl:
comment_on_transaction: Hier kun je een notitie aan de afrekening toevoegen. comment_on_transaction: Hier kun je een notitie aan de afrekening toevoegen.
comments: Notities comments: Notities
confirm_order: Afrekenen confirm_order: Afrekenen
close_direct: Afrekenen overslaan
close_direct_confirm: 'Je staat op het punt de bestelling af te sluiten zonder de bedragen in rekening te brengen bij de huishoudens. Doe dit alleen wanneer je deze bedragen al handmatig hebt afgeschreven, of als je echt weet wat je doet!'
create_invoice: Rekening toevoegen create_invoice: Rekening toevoegen
edit_note: Notitie bewerken edit_note: Notitie bewerken
edit_order: Bestelling bewerken edit_order: Bestelling bewerken
@ -554,8 +556,6 @@ nl:
orders: orders:
clear: balans clear: balans
cleared: afgerekend (%{amount}) cleared: afgerekend (%{amount})
close: direct afrekenen
confirm: Weet je zeker dat de je bestelling wilt afrekenen?
end: Einde end: Einde
ended: gesloten ended: gesloten
name: Leverancier name: Leverancier