Fold redmine_qbo_billing into redmine_qbo

Estimates, invoices and payments written in Redmine, issues from estimates,
and the QuickBooks product/service list and accounts are now part of this
plugin (the RedmineQboBilling code, its controllers, views, strings and
permissions), so there's one plugin and one version instead of two that had
to match.

- The customer page, estimate and invoice lists and the issue page render the
  Create Estimate / Create invoice / Receive payment and Edit links directly;
  the hooks that only existed to let billing add them are gone. Users without
  the billing permissions still get the links to QuickBooks.
- Migrations 043-046 create the items and accounts tables and the estimate
  line links, skipping whatever an existing database already has
  (redmine_qbo_lineitems' tables are used as they are), and copy calendar's
  existing estimate line links in.
- The billing settings are a section of this plugin's settings page.
- The hooks other plugins use stay: qbo_billing_issue_values,
  qbo_billing_validate, qbo_billing_issue_defaults, qbo_billing_issues_created
  and view_qbo_estimate_contextual.
- rake redmine_qbo:relate_estimate_issues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-30 23:47:01 -04:00
1 parent 48a4185c16
commit 9121e079a0
67 files changed
+5570 -19

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 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:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# The QuickBooks product/service list. The table was created by redmine_qbo_lineitems before items moved
# into this plugin, so each step is skipped when an existing database already has it: nothing is dropped or
# copied, the existing table is simply used from here on.
class CreateItemsTable < ActiveRecord::Migration[7.0]
def up
return if table_exists?(:items)
create_table :items do |t|
t.text :description, null: false
t.decimal :unit_price,
precision: 15,
scale: 4,
null: false,
default: 0
t.boolean :active, default: true, null: false
t.timestamps
end
end
def down
drop_table :items if table_exists?(:items)
end
end
+22
View File
@@ -0,0 +1,22 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 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:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Item name and SKU (skipped where redmine_qbo_lineitems already added them)
class AddItemNameAndSku < ActiveRecord::Migration[7.0]
def up
add_column :items, :name, :string, null: false unless column_exists?(:items, :name)
add_column :items, :sku, :string unless column_exists?(:items, :sku)
end
def down
remove_column :items, :sku if column_exists?(:items, :sku)
remove_column :items, :name if column_exists?(:items, :name)
end
end
+37
View File
@@ -0,0 +1,37 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 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:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# QuickBooks income accounts, and each item's account, type and taxable flag
# (skipped where redmine_qbo_lineitems already created them)
class CreateAccountsTable < ActiveRecord::Migration[7.0]
def up
unless table_exists?(:accounts)
create_table :accounts do |t|
t.text :name, null: false
t.text :description
t.boolean :active, default: true, null: false
t.boolean :default, default: false, null: false
t.text :classification
t.timestamps
end
end
add_reference :items, :account, foreign_key: true unless column_exists?(:items, :account_id)
add_column :items, :type, :string unless column_exists?(:items, :type)
add_column :items, :taxable, :boolean, null: true unless column_exists?(:items, :taxable)
end
def down
remove_column :items, :taxable if column_exists?(:items, :taxable)
remove_column :items, :type if column_exists?(:items, :type)
remove_reference :items, :account, foreign_key: true if column_exists?(:items, :account_id)
drop_table :accounts if table_exists?(:accounts)
end
end
@@ -0,0 +1,46 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 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:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Records which issue was created from which QuickBooks estimate line, so a line can't be turned into an
# issue twice. Issues redmine_qbo_calendar created from appointment estimates are copied in, so they still
# count as created.
class CreateQboEstimateLineIssues < ActiveRecord::Migration[7.0]
class LineIssue < ActiveRecord::Base
self.table_name = 'qbo_estimate_line_issues'
end
def up
unless table_exists?(:qbo_estimate_line_issues)
create_table :qbo_estimate_line_issues do |t|
t.bigint :estimate_id, null: false
t.string :line_id, null: false
t.references :issue, null: false, index: { unique: true }
t.datetime :created_on, null: false
end
add_index :qbo_estimate_line_issues, [:estimate_id, :line_id], unique: true, name: 'index_qbo_estimate_line_issues_on_line'
end
return unless table_exists?(:appointment_estimate_issues)
LineIssue.reset_column_information
existing_issue_ids = select_values('SELECT id FROM issues').map(&:to_i).to_set
select_all('SELECT estimate_id, line_id, issue_id, created_on FROM appointment_estimate_issues').each do |row|
next unless existing_issue_ids.include?(row['issue_id'].to_i)
next if LineIssue.exists?(estimate_id: row['estimate_id'], line_id: row['line_id']) || LineIssue.exists?(issue_id: row['issue_id'])
LineIssue.create!(estimate_id: row['estimate_id'], line_id: row['line_id'], issue_id: row['issue_id'],
created_on: row['created_on'] || Time.current)
end
end
def down
drop_table :qbo_estimate_line_issues if table_exists?(:qbo_estimate_line_issues)
end
end