mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-18 02:20:37 -05:00
Remove orphaned code
* customers#filter_estimates_by_customer and #filter_invoices_by_customer, their routes, permission entries and template: they filled an estimate dropdown on the old issue form, which is gone. * Routes with no action: accounts new/create/show/edit/update/destroy (only index, Set default and Sync exist) and customers#destroy. * Unused methods: AuthHelper#require_user, #allowed_to?, #check_permission; CustomersController#address_to_s; CustomerToken#expired? and .remove_expired_tokens; QboBaseModel#skip_qbo_push?; QboDraft.writable_document?; SyncServiceBase#extract_value. * CustomersController's before_action helpers are private. * The unused .autocomplete-meta style and 28 unused translation keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
92f9eb1bc7
commit
0d143e6eb1
11 files changed
+38
-161
No files matched your search
@@ -33,36 +33,6 @@ class CustomersController < ApplicationController
|
||||
before_action :require_admin, only: :sync
|
||||
skip_before_action :verify_authenticity_token, :check_if_login_required, only: [:view]
|
||||
|
||||
def address_to_s(address)
|
||||
return if address.nil?
|
||||
|
||||
lines = [
|
||||
address.line1,
|
||||
address.line2,
|
||||
address.line3,
|
||||
address.line4,
|
||||
address.line5
|
||||
].compact_blank
|
||||
|
||||
city_line = [
|
||||
address.city,
|
||||
address.country_sub_division_code,
|
||||
address.postal_code
|
||||
].compact_blank.join(" ")
|
||||
|
||||
lines << city_line unless city_line.blank?
|
||||
|
||||
lines.join("\n")
|
||||
end
|
||||
|
||||
def add_customer
|
||||
global_check_permission(:add_customers)
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
params.require(:customer).permit(:name, :email, :primary_phone, :mobile_phone, :phone_number, :notes)
|
||||
end
|
||||
|
||||
# Used for autocomplete forms. Fuzzy matching (nicknames, typos, word order, phone digits) helps
|
||||
# staff spot an existing customer before creating a duplicate. See CustomerSearchService.
|
||||
def autocomplete
|
||||
@@ -109,14 +79,6 @@ class CustomersController < ApplicationController
|
||||
render_404
|
||||
end
|
||||
|
||||
def filter_estimates_by_customer
|
||||
@filtered_estimates = Estimate.all.where(customer_id: params[:selected_customer])
|
||||
end
|
||||
|
||||
def filter_invoices_by_customer
|
||||
@filtered_invoices = Invoice.all.where(customer_id: params[:selected_customer])
|
||||
end
|
||||
|
||||
# Most matches a search lists (best first)
|
||||
SEARCH_LIMIT = 200
|
||||
|
||||
@@ -146,29 +108,6 @@ class CustomersController < ApplicationController
|
||||
@issue_counts = Issue.where(customer_id: @customers.map(&:id)).group(:customer_id).count
|
||||
end
|
||||
|
||||
def load_issue_data
|
||||
@journals = @issue.journals.preload(:details).preload(user: :email_address).reorder(:created_on, :id).to_a
|
||||
|
||||
@journals.each_with_index { |j, i| j.indice = i + 1 }
|
||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||
Journal.preload_journals_details_custom_fields(@journals)
|
||||
@journals.select! { |journal| journal.notes? || journal.visible_details.any? }
|
||||
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
|
||||
@changesets = @issue.changesets.visible.preload(:repository, :user).to_a
|
||||
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
|
||||
@relations = @issue.relations.select { |r| r.other_issue(@issue)&.visible? }
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@priorities = IssuePriority.active
|
||||
@time_entry = TimeEntry.new(issue: @issue, project: @issue.project)
|
||||
@relation = IssueRelation.new
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
Rails.logger.info "[CustomersController] #{msg}"
|
||||
end
|
||||
|
||||
def new
|
||||
@customer = Customer.new
|
||||
|
||||
@@ -253,8 +192,41 @@ class CustomersController < ApplicationController
|
||||
render_403
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_customer
|
||||
global_check_permission(:add_customers)
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
params.require(:customer).permit(:name, :email, :primary_phone, :mobile_phone, :phone_number, :notes)
|
||||
end
|
||||
|
||||
def load_issue_data
|
||||
@journals = @issue.journals.preload(:details).preload(user: :email_address).reorder(:created_on, :id).to_a
|
||||
|
||||
@journals.each_with_index { |j, i| j.indice = i + 1 }
|
||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||
Journal.preload_journals_details_custom_fields(@journals)
|
||||
@journals.select! { |journal| journal.notes? || journal.visible_details.any? }
|
||||
@journals.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
|
||||
@changesets = @issue.changesets.visible.preload(:repository, :user).to_a
|
||||
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||||
|
||||
@relations = @issue.relations.select { |r| r.other_issue(@issue)&.visible? }
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@priorities = IssuePriority.active
|
||||
@time_entry = TimeEntry.new(issue: @issue, project: @issue.project)
|
||||
@relation = IssueRelation.new
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
Rails.logger.info "[CustomersController] #{msg}"
|
||||
end
|
||||
|
||||
def view_customer
|
||||
global_check_permission(:view_customers)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -31,28 +31,6 @@ module AuthHelper
|
||||
require_login
|
||||
end
|
||||
|
||||
# Kept for plugins that still call it (e.g. redmine_qbo_vehicles): requires a logged-in user.
|
||||
# The old version effectively never ran; share-link customers use require_login_or_customer_token.
|
||||
def require_user
|
||||
return true if User.current.logged?
|
||||
|
||||
require_login
|
||||
end
|
||||
|
||||
def allowed_to?(action)
|
||||
return false if User.current.nil?
|
||||
project = Project.find_by(id: params[:project_id])
|
||||
return false if project.nil?
|
||||
User.current.allowed_to?(action, project)
|
||||
end
|
||||
|
||||
def check_permission(permission)
|
||||
if !allowed_to?(permission)
|
||||
flash[:error] = t :notice_forbidden
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def global_check_permission(permission)
|
||||
if !globaly_allowed_to?(permission)
|
||||
flash[:error] = t :notice_forbidden
|
||||
|
||||
@@ -21,16 +21,6 @@ class CustomerToken < ApplicationRecord
|
||||
|
||||
TOKEN_EXPIRATION = 1.month
|
||||
|
||||
# Check if the token has expired
|
||||
def expired?
|
||||
expires_at.present? && expires_at <= Time.current
|
||||
end
|
||||
|
||||
# Remove expired tokens from the database
|
||||
def self.remove_expired_tokens
|
||||
where("expires_at <= ?", Time.current).delete_all
|
||||
end
|
||||
|
||||
# Get or create a token for the given issue
|
||||
def self.get_token(issue)
|
||||
return unless issue
|
||||
|
||||
@@ -79,12 +79,6 @@ class QboBaseModel < ActiveRecord::Base
|
||||
QboSyncJob.perform_later(entity: model_name.name, id: id)
|
||||
end
|
||||
|
||||
# Flag used to update local without pushing to QBO.
|
||||
# This is used to prevent loops with the webhook
|
||||
def skip_qbo_push?
|
||||
!!skip_qbo_push
|
||||
end
|
||||
|
||||
def self.qbo_sync(push: true)
|
||||
self.qbo_push_enabled = push
|
||||
end
|
||||
|
||||
@@ -31,14 +31,6 @@ class QboDraft < ApplicationRecord
|
||||
where(document: documents)
|
||||
}
|
||||
|
||||
def self.writable_document?(document, user = User.current)
|
||||
case document.to_s
|
||||
when 'estimate' then RedmineQboBilling.writer?(user)
|
||||
when 'invoice' then RedmineQboBilling.invoice_writer?(user)
|
||||
else false
|
||||
end
|
||||
end
|
||||
|
||||
# The editor's fields as posted (estimate[...])
|
||||
def fields
|
||||
parsed = JSON.parse(data.presence || '{}')
|
||||
|
||||
@@ -80,15 +80,6 @@ class SyncServiceBase
|
||||
false
|
||||
end
|
||||
|
||||
def extract_value(remote, remote_attr)
|
||||
case remote_attr
|
||||
when Proc
|
||||
remote_attr.call(remote)
|
||||
else
|
||||
remote.public_send(remote_attr)
|
||||
end
|
||||
end
|
||||
|
||||
# Attribute Mapping DSL
|
||||
#
|
||||
# This DSL defines how attributes from a QuickBooks Online (QBO) entity
|
||||
@@ -157,7 +148,6 @@ class SyncServiceBase
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def map_attribute(local_attr, remote_attr = nil, &block)
|
||||
attribute_map[local_attr] =
|
||||
if block_given?
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
$('select#issue_estimate_id').html('<%= j content_tag(:option,'',value:"")+options_from_collection_for_select(@filtered_estimates, :id, :doc_number) %>');
|
||||
Reference in new issue
Block a user