Skip to content

Commit

Permalink
Added a warning on payment submit if the uninvoiced amount is greater…
Browse files Browse the repository at this point in the history
… than 0.00
  • Loading branch information
brighton36 committed May 8, 2011
1 parent 6d8f4fb commit cbfe4b7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
5 changes: 1 addition & 4 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
* Do a mila on-site inspection when you get back in town

Now for the final Controller Adjustments:
* Show a pop-up warning if someone tries to commit a payment w/o allocating the full amount...
* Get the actual create/update actions working
* I'd say to start by just disabling any active_scaffold handling of :invoice_assignments
* Test the case of an error in validation ( is there a limit on the method_identifier? or just unselected no payment perhaps...)
Expand All @@ -17,7 +14,7 @@ Now for the final Controller Adjustments:

--- Put a beta version on mario? ...

* We shoud do the payment assignments on the invoices controller to
* We shoud do the payment assignments on the invoices controller too
* Only on the show action
* Make the is_published a row_link
* But - only assignments should be editable on published invoices. Once they unpublish it - we can do more...
Expand Down
26 changes: 26 additions & 0 deletions app/helpers/admin/payments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,32 @@ def amount_unallocated_field_id
"record_amount_unallocated_%s" % @record.id
end

# All this craziness exists to show a modal dialog asking the user to confirm any payment that isn't fully allocated.
def submit_tag(*args)
if (/\A(?:#{as_(:update)}|#{as_(:create)})\Z/.match args[0])
action = args[0] == as_(:update) ? :update : :create

button_to_function(
args[0],
"amt_unalloc = $$('#record_amount_unallocated_%s span');
if (amt_unalloc.length > 0 && amt_unalloc.first().innerHTML != '%s') {
show_modal_after_close(%s,%s);
} else {
$('%s').onsubmit();
}" % [
@record.id,
Money.new(0).format,
render(:file => 'admin/payments/commit_payment_warning.rhtml', :layout => false, :locals => {:action => action}).to_json,
{:title => 'Are you sure you wish to save?', :width => 600}.to_json,
element_form_id(:action => action)
],
args[1]
)
else
super(*args)
end
end

private

# This method is a little weird. But, its used in a couple places to determine what the amount oustanding
Expand Down
8 changes: 8 additions & 0 deletions app/views/admin/payments/commit_payment_warning.rhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1>This payment has not been fully allocated.</h1>

<p>Are you sure you wish to commit this payment without having fully assigned its balance to an outstanding invoice(s)?</p>
<p>
<%= button_to_function h("Yes, I'll assign it later"), "Modalbox.hide();$('%s').onsubmit();" % element_form_id(:action => action), :class => "MB_focusable" %>
or
<%= link_to_function 'No, let me assign this in full', "Modalbox.hide();", :class => "MB_focusable", :title => 'No' %>
</p>

0 comments on commit cbfe4b7

Please sign in to comment.