Compare commits

..

3 Commits

Author SHA1 Message Date
886d5f4ace 2026.2.9 2026-02-16 08:15:46 -05:00
1ade938eb3 Fixed Querying issues by customer name 2026-02-16 08:13:57 -05:00
3111f391f3 Filter by customer works now 2026-02-15 21:34:22 -05:00
3 changed files with 29 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do
name 'Redmine QBO plugin' name 'Redmine QBO plugin'
author 'Rick Barrette' author 'Rick Barrette'
description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed' description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed'
version '2026.2.8' version '2026.2.9'
url 'https://github.com/rickbarrette/redmine_qbo' url 'https://github.com/rickbarrette/redmine_qbo'
author_url 'https://barrettefabrication.com' author_url 'https://barrettefabrication.com'
settings default: {empty: true}, partial: 'qbo/settings' settings default: {empty: true}, partial: 'qbo/settings'

View File

@@ -25,7 +25,7 @@ module RedmineQbo
# Same as typing in the class # Same as typing in the class
base.class_eval do base.class_eval do
belongs_to :customer, primary_key: :id belongs_to :customer, class_name: 'Customer', foreign_key: :customer_id, optional: true
belongs_to :customer_token, primary_key: :id belongs_to :customer_token, primary_key: :id
belongs_to :estimate, primary_key: :id belongs_to :estimate, primary_key: :id
has_and_belongs_to_many :invoices has_and_belongs_to_many :invoices

View File

@@ -13,6 +13,15 @@ require_dependency 'issue_query'
module RedmineQbo module RedmineQbo
module Patches module Patches
module QueryPatch module QueryPatch
def base_scope
scope = super
if filters['customer_name'].present?
scope = scope.left_outer_joins(:customer)
end
scope
end
# Add qbo options to the aviable columns # Add qbo options to the aviable columns
def available_columns def available_columns
@@ -26,10 +35,27 @@ module RedmineQbo
# Add customers to filters # Add customers to filters
def initialize_available_filters def initialize_available_filters
#add_available_filter "customer", type: :text #add_available_filter "customer_id", type: :list, name: l(:field_customer), :values => lambda {Customer.pluck(:name, :id).map {|name, id| [name, id.to_s]}}
add_available_filter( 'customer_name', type: :text, name: l(:field_customer))
super super
end end
def sql_for_customer_name_field(field, operator, value)
pattern = "%#{value.first}%"
sql = case operator
when '~'
"#{Customer.table_name}.name LIKE ?"
when '!~'
"#{Customer.table_name}.name NOT LIKE ?"
else
return nil
end
Issue.joins(:customer).sanitize_sql_for_conditions([sql, pattern])
end
end end
# Add module to Issue # Add module to Issue