mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Warn about the customer's open issues on a new invoice
A new invoice lists the customer's open issues (any project, those the user can see) in a warning under the title, so work orders aren't left open once the work is billed. It's there when the page opens with a customer (from the customer page or an estimate) and follows the customer when it's changed: customer_info returns open_issues_html for invoices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
88160a985d
commit
4ba96e2dfd
5 files changed
+31
-2
No files matched your search
@@ -116,13 +116,19 @@ class QboEstimatesController < ApplicationController
|
||||
customer = Customer.find_by(id: params[:customer_id])
|
||||
return render(json: {}, status: :not_found) unless customer
|
||||
|
||||
render json: {
|
||||
info = {
|
||||
id: customer.id,
|
||||
name: customer.name,
|
||||
email: RedmineQboBilling::EstimateWriter.customer_email(customer),
|
||||
billing_address: RedmineQboBilling::EstimateWriter.customer_address(customer),
|
||||
field_options: RedmineQboBilling.field_options(customer)
|
||||
}
|
||||
# A new invoice warns about the customer's open issues
|
||||
if params[:document] == 'invoice'
|
||||
info[:open_issues_html] = render_to_string(partial: 'qbo_invoices/open_issues', formats: [:html],
|
||||
locals: { customer: customer })
|
||||
end
|
||||
render json: info
|
||||
end
|
||||
|
||||
# Product/service search for the line table (the QuickBooks item list)
|
||||
|
||||
@@ -446,7 +446,9 @@ $(function () {
|
||||
var id = $(this).val();
|
||||
if (!id) return;
|
||||
dirty = true;
|
||||
$.getJSON($form.data('customerInfoUrl'), { customer_id: id }).done(function (info) {
|
||||
$.getJSON($form.data('customerInfoUrl'), { customer_id: id, document: $form.data('document') }).done(function (info) {
|
||||
// A new invoice's open issues notice follows the customer
|
||||
if (info.open_issues_html !== undefined) $('#qbo-open-issues').replaceWith(info.open_issues_html);
|
||||
// Replace the email only if it was the previous customer's (or empty)
|
||||
if (!$email.val().trim() || $email.val() === loadedEmail) $email.val(info.email || '');
|
||||
loadedEmail = info.email || '';
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<%# A new invoice's customer still has open issues (work orders), so they're not left behind once billed.
|
||||
Replaced when the customer is changed (customer_info's open_issues_html). %>
|
||||
<%
|
||||
issues = customer ? customer.issues.open.visible.order(id: :desc).to_a : []
|
||||
%>
|
||||
<div id="qbo-open-issues">
|
||||
<% if issues.any? %>
|
||||
<div class="warning qbo-estimate-notice">
|
||||
<%= l(:text_invoice_customer_open_issues, count: issues.size) %>
|
||||
<ul>
|
||||
<% issues.each do |issue| %>
|
||||
<li><%= link_to_issue(issue, truncate: 60) %> (<%= issue.status %>)</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
<% html_title l(:label_new_invoice) %>
|
||||
|
||||
<%= render partial: 'qbo_estimates/header', locals: { form: @form } %>
|
||||
<%= render partial: 'qbo_invoices/open_issues', locals: { customer: (Customer.find_by(id: @form.customer_id) if @form.customer_id.present?) } %>
|
||||
<%= render partial: 'qbo_estimates/form', locals: { form: @form } %>
|
||||
@@ -256,6 +256,9 @@ en:
|
||||
notice_invoice_sent: "Invoice #%{number} emailed to %{email}"
|
||||
text_email_invoice_confirmation: "Email invoice #%{number} to %{email}?"
|
||||
text_invoice_from_estimate: "Made from estimate #%{number}. The estimate is closed when the invoice is saved."
|
||||
text_invoice_customer_open_issues:
|
||||
one: "This customer has an open issue. Make sure its work is finished and billed so it isn't left open:"
|
||||
other: "This customer has %{count} open issues. Make sure their work is finished and billed so none are left open:"
|
||||
text_line_bills_time: "Bills a QuickBooks time activity; saving marks the time as billed"
|
||||
text_replace_lines: "Tick the lines the time replaces (e.g. the estimate's labor lines). Each time entry takes the place of the line with its issue's description (e.g. Install Lift Kit), then any others in order."
|
||||
|
||||
|
||||
Reference in new issue
Block a user