Drop the Qbo prefix

This commit is contained in:
2022-03-09 21:31:56 -05:00
parent 08fa4aefc4
commit 24f8be6e80
29 changed files with 176 additions and 142 deletions

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT)
#
#Copyright (c) 2017 rick barrette
#Copyright (c) 2022 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
@@ -14,6 +14,6 @@ class HeaderFooterHookListener < Redmine::Hook::ViewListener
end
def view_layouts_base_body_bottom(context = {})
return "<div id='qbo_footer' align='center'><b>#{I18n.translate(:label_last_sync)}: </b> #{Qbo.last_sync if Qbo.exists?}</div>"
return "<div id='footer' align='center'><b>#{I18n.translate(:label_last_sync)}: </b> #{Qbo.last_sync if Qbo.exists?}</div>"
end
end

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT)
#
#Copyright (c) 2020 rick barrette
#Copyright (c) 2022 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
@@ -24,9 +24,9 @@ module IssuePatch
unloadable # Send unloadable so it will not be unloaded in development
belongs_to :customer, primary_key: :id
belongs_to :customer_token, primary_key: :id
belongs_to :qbo_estimate, primary_key: :id
has_and_belongs_to_many :qbo_invoices
#, :association_foreign_key => 'issue_id', :class_name => 'Issue', :join_table => 'issues_qbo_invoices'
belongs_to :estimate, primary_key: :id
has_and_belongs_to_many :invoices
#, :association_foreign_key => 'issue_id', :class_name => 'Issue', :join_table => 'issues_invoices'
belongs_to :vehicle, primary_key: :id
end
@@ -49,7 +49,7 @@ module IssuePatch
return unless customer
# Get unbilled time entries
spent_time = time_entries.where(qbo_billed: [false, nil])
spent_time = time_entries.where(billed: [false, nil])
spent_hours ||= spent_time.sum(:hours) || 0
if spent_hours > 0 then
@@ -65,7 +65,7 @@ module IssuePatch
spent_time.each do |entry|
h[entry.activity.name] += entry.hours
# update time entries billed status
entry.qbo_billed = true
entry.billed = true
entry.save
end
@@ -83,8 +83,8 @@ module IssuePatch
# Create the new billable time entry and upload it
time_entry.description = "#{tracker} ##{id}: #{subject} #{"(Partial @ #{done_ratio}%)" if not closed?}"
# TODO entry.user.qbo_employee.id
time_entry.employee_id = assigned_to.qbo_employee_id
# TODO entry.user.employee.id
time_entry.employee_id = assigned_to.employee_id
time_entry.customer_id = customer_id
time_entry.billable_status = "Billable"
time_entry.hours = hours

View File

@@ -31,7 +31,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
# Check to see if the issue already belongs to a customer
selected_customer = context[:issue].customer ? context[:issue].customer.id : nil
selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil
selected_estimate = context[:issue].estimate ? context[:issue].estimate.id : nil
selected_vehicle = context[:issue].vehicles_id ? context[:issue].vehicles_id : nil
# Load customer information
@@ -59,14 +59,14 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
else
vehicles = [nil].compact
end
estimates = customer.qbo_estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
estimates = customer.estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
else
vehicles = [nil].compact
estimates = [nil].compact
end
# Generate the drop down list of quickbooks estimates & vehicles
select_estimate = f.select :qbo_estimate_id, estimates, :selected => selected_estimate, include_blank: true
select_estimate = f.select :estimate_id, estimates, :selected => selected_estimate, include_blank: true
vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true
# Pass all prebuilt form components to our partial

View File

@@ -21,16 +21,16 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
end
# Estimate Number
if issue.qbo_estimate
estimate = issue.qbo_estimate.doc_number
estimate_link = link_to estimate, estimate_path( issue.qbo_estimate.id ), :target => "_blank"
if issue.estimate
estimate = issue.estimate.doc_number
estimate_link = link_to estimate, estimate_path( issue.estimate.id ), :target => "_blank"
end
# Invoice Number
invoice_link = ""
if issue.qbo_invoice_ids
issue.qbo_invoice_ids.each do |i|
invoice = QboInvoice.find i
if issue.invoice_ids
issue.invoice_ids.each do |i|
invoice = Invoice.find i
invoice_link = invoice_link + link_to( invoice.doc_number, invoice_path( i ), :target => "_blank").to_s + " "
invoice_link = invoice_link.html_safe
end

View File

@@ -17,7 +17,7 @@ module QueryPatch
unless @available_columns
@available_columns = self.class.available_columns.dup
@available_columns << QueryColumn.new(:customer, :sortable => "#{Issue.table_name}.customer_id", :groupable => true, :caption => :field_customer)
@available_columns << QueryColumn.new(:qbo_billed, :sortable => "#{TimeEntry.table_name}.qbo_billed", :groupable => true, :caption => :field_qbo_billed)
@available_columns << QueryColumn.new(:billed, :sortable => "#{TimeEntry.table_name}.billed", :groupable => true, :caption => :field_billed)
end
super
end

View File

@@ -16,14 +16,14 @@ module TimeEntryQueryPatch
def available_columns
unless @available_columns
@available_columns = self.class.available_columns.dup
@available_columns << QueryColumn.new(:qbo_billed, :sortable => "#{TimeEntry.table_name}.name", :groupable => true, :caption => :field_qbo_billed)
@available_columns << QueryColumn.new(:billed, :sortable => "#{TimeEntry.table_name}.name", :groupable => true, :caption => :field_billed)
end
super
end
# Add QBO options to the filter
def initialize_available_filters
add_available_filter "qbo_billed", :type => :boolean
add_available_filter "billed", :type => :boolean
super
end

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT)
#
#Copyright (c) 2017 rick barrette
#Copyright (c) 2022 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
@@ -21,7 +21,7 @@ module UserPatch
# Same as typing in the class
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
belongs_to :qbo_employee, primary_key: :id
belongs_to :employee, primary_key: :id
end
end

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT)
#
#Copyright (c) 2017 rick barrette
#Copyright (c) 2022 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
@@ -14,12 +14,12 @@ class UsersShowHookListener < Redmine::Hook::ViewListener
def view_users_form(context={})
# Update the users
#QboEmployee.update_all
#Employee.update_all
# Check to see if there is a quickbooks user attached to the issue
@selected = context[:user].qbo_employee.id if context[:user].qbo_employee
@selected = context[:user].employee.id if context[:user].employee
# Generate the drop down list of quickbooks contacts
return "<p>#{context[:form].select :qbo_employee_id, QboEmployee.all.pluck(:name, :id), :selected => @selected, include_blank: true}</p>"
return "<p>#{context[:form].select :employee_id, Employee.all.pluck(:name, :id), :selected => @selected, include_blank: true}</p>"
end
end