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
def close_direct!(user)
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
end

View File

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

View File

@ -48,12 +48,18 @@
#comments= render :partial => 'shared/comments', locals: {comments: @order.comments.includes(:user)}
- 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
- 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?
= 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
= 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.
comments: Comments
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
edit_note: Edit note
edit_order: Edit order
@ -556,8 +558,6 @@ en:
orders:
clear: accounting
cleared: accounted (%{amount})
close: settle directly
confirm: Do you really want to settle the order?
end: End
ended: closed
name: Supplier
@ -1110,6 +1110,7 @@ en:
orders_settled: Settled
title: Manage orders
model:
close_direct_message: Order settled without charging member accounts.
error_closed: Order was already settled
error_nosel: At least one article must be selected
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.
comments: Notities
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
edit_note: Notitie bewerken
edit_order: Bestelling bewerken
@ -554,8 +556,6 @@ nl:
orders:
clear: balans
cleared: afgerekend (%{amount})
close: direct afrekenen
confirm: Weet je zeker dat de je bestelling wilt afrekenen?
end: Einde
ended: gesloten
name: Leverancier