Added Invoice Support

This commit is contained in:
2016-01-24 18:54:34 -05:00
parent 98b89e7875
commit 0b74f2cf52
10 changed files with 113 additions and 12 deletions

View File

@@ -24,6 +24,7 @@ module IssuePatch
belongs_to :qbo_customer, primary_key: :id
belongs_to :qbo_item, primary_key: :id
belongs_to :qbo_estimate, primary_key: :id
belongs_to :qbo_invoice, primary_key: :id
end
end

View File

@@ -16,18 +16,22 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
# Update the customer and item database
QboCustomer.update_all
QboItem.update_all
QboInvoice.update_all
# Check to see if there is a quickbooks user attached to the issue
if context[:issue].qbo_customer && context[:issue].qbo_item
@selected_customer = context[:issue].qbo_customer.id
@selected_item = context[:issue].qbo_item.id
end
# Generate the drop down list of quickbooks contacts
@selected_customer = context[:issue].qbo_customer.id if context[:issue].qbo_customer
@selected_item = context[:issue].qbo_item.id if context[:issue].qbo_item
@selected_invoice = context[:issue].qbo_invoice.id if context[:issue].qbo_invoice
# Generate the drop down list of quickbooks customers
@select_customer = context[:form].select :qbo_customer_id, QboCustomer.all.pluck(:name, :id), :selected => @selected_customer, include_blank: true
# Generate the drop down list of quickbooks contacts
@select_item = context[:form].select :qbo_item_id, QboItem.all.pluck(:name, :id).reverse, :selected => @selected_item, include_blank: true
return "<p>#{@select_customer}</p> <p>#{@select_item}</p>"
# Generate the drop down list of quickbooks items
@select_item = context[:form].select :qbo_item_id, QboItem.all.pluck(:name, :id), :selected => @selected_item, include_blank: true
# Generate the drop down list of quickbooks invoices
@select_invoice = context[:form].select :qbo_invoice_id, QboInvoice.all.pluck(:doc_number, :id).sort! {|x, y| y <=> x}, :selected => @selected_invoice, include_blank: true
return "<p>#{@select_customer}</p> <p>#{@select_item}</p> <p>#{@select_invoice}</p>"
end
end

View File

@@ -30,7 +30,14 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
if issue.qbo_estimate
QboEstimate.update(issue.qbo_estimate.id)
@estimate = issue.qbo_estimate.doc_number
@link = link_to @estimate, qbo_estimate_pdf_path(issue.qbo_estimate.id)
@estimate_link = link_to @estimate, qbo_estimate_pdf_path(issue.qbo_estimate.id)
end
# Invoice Number
if issue.qbo_invoice
QboInvoice.update(issue.qbo_invoice.id)
@invoice = issue.qbo_invoice.doc_number
@invoice_link = link_to @invoice, qbo_invoice_pdf_path(issue.qbo_invoice.id)
end
return "<div class=\"attributes\">
@@ -46,7 +53,12 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
<div class=\"qbo_estimate_id attribute\">
<div class=\"label\"><span>Estimate</span>:</div>
<div class=\"value\">#{@link}</div>
<div class=\"value\">#{@estimate_link}</div>
</div>
<div class=\"qbo_invoice_id attribute\">
<div class=\"label\"><span>Invoice</span>:</div>
<div class=\"value\">#{@invoice_link}</div>
</div>
</div>"
end