Skip to content

Commit

Permalink
show warning when a new invoice can be generated
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellani committed Dec 14, 2023
1 parent b8e2491 commit 1038536
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/views/spree/admin/invoices/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- if show_generate_invoice_button?(@order)
.alert-box.warning
=t(:order_has_changed_and_invoice_might_not_be_up_to_date)

= render partial: 'spree/admin/shared/order_page_title'
= render partial: 'spree/admin/shared/order_tabs', locals: { current: 'Invoices' }

Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4182,6 +4182,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
line_item_adjustments: "Line Item Adjustments"
order_adjustments: "Order Adjustments"
order_total: "Order Total"
invoices:
index:
order_has_changed_and_invoice_might_not_be_up_to_date: "The order has changed since the last invoice update. The invoice shown here might not be up-to-date anymore."
overview:
enterprises_header:
ofn_with_tip: Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network.
Expand Down
4 changes: 3 additions & 1 deletion spec/system/admin/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,14 @@ def serching_for_customers
expect(page).to have_content "#{customer.first_name} #{customer.last_name} -"
expect(page.find("table").text).to have_content(table_header)

# the New invoice button should be visible
# the New invoice button + the warning should be visible
expect(page).to have_link "Create or Update Invoice"
expect(page).to have_content "The order has changed since the last invoice update. The invoice shown here might not be up-to-date anymore."
click_link "Create or Update Invoice"

# and disappear after clicking
expect(page).to have_no_link "Create or Update Invoice"
expect(page).to_not have_content "The order has changed since the last invoice update. The invoice shown here might not be up-to-date anymore."

# creating an invoice, displays a second row
expect(page.find("table").text).to have_content(table_contents)
Expand Down

0 comments on commit 1038536

Please sign in to comment.