18 Commits

Author SHA1 Message Date
50a02cc497 2026.3.12 2026-03-22 14:26:22 -04:00
b63e8f2a45 Updated hooks & patches 2026-03-21 20:02:11 -04:00
4b561ef4e3 added progressive row creation 2026-03-19 12:44:27 -04:00
1dadcf37b6 Added screenshots for items and accounts 2026-03-19 09:12:38 -04:00
ffaee10fef updated readme 2026-03-19 09:00:39 -04:00
58994e3c7d Updated readme 2026-03-19 08:56:47 -04:00
6365fe6679 2026.3.11 2026-03-19 08:45:32 -04:00
4d6c16373a Don't display form if issue if closed 2026-03-19 08:38:21 -04:00
20b7564c38 Added items to admin menu 2026-03-19 07:13:43 -04:00
9820646857 allow math on unit price field 2026-03-18 22:02:53 -04:00
647ce4c63a 2026.3.10 2026-03-17 23:36:29 -04:00
4367c77393 updaed locale 2026-03-17 20:49:58 -04:00
8c0ce8ce48 updated locale 2026-03-17 20:45:21 -04:00
9fd1f4fb7d removed back link 2026-03-17 20:37:58 -04:00
cca822c570 better display flags 2026-03-17 20:35:40 -04:00
795906b4f5 Sync Item account numbers 2026-03-17 20:26:52 -04:00
d5e59c120c Make qbo item inactive if deleted 2026-03-17 19:45:36 -04:00
e640e61648 Added missing label_item_new 2026-03-17 19:45:14 -04:00
21 changed files with 192 additions and 71 deletions

View File

@@ -10,8 +10,6 @@ This plugin allows **billable line items** to be attached to a Redmine issue. Wh
* **Redmine:** 6.1+
* **Ruby:** 3.2+
* **Parent Plugin:** [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo) (must be installed and configured)
@@ -19,9 +17,9 @@ This plugin allows **billable line items** to be attached to a Redmine issue. Wh
## Compatibility
| Plugin Version | Redmine Version | Ruby Version |
| Plugin Version | Redmine Version | Parent Plugin Version |
| --- | --- | --- |
| 2026.3.6+ | 6.1.x | 3.2+ |
| 2026.3.8+ | 6.1.x | 2026.3.9+ |
---
@@ -87,9 +85,10 @@ Before using this plugin:
1. Install and configure the parent plugin.
2. Ensure your **QuickBooks Online** company file is connected.
3. Verify that the products or services referenced in line items exist in QuickBooks.
3. Sync Accounts & Items via plugin settings
4. Set default income account for new items via plugin settings
---

BIN
Screenshots/accounts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

BIN
Screenshots/edit item.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
Screenshots/item.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
Screenshots/items.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

BIN
Screenshots/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

View File

@@ -18,6 +18,7 @@ class Item < QboBaseModel
self.inheritance_column = :_type_disabled
qbo_sync push: true
after_initialize :set_defaults, if: :new_record?
before_destroy :make_inactive
# Updates Both local & remote DB account ref
def account_id=(id)
@@ -37,6 +38,11 @@ class Item < QboBaseModel
super
end
def make_inactive
details.active = false
push_to_qbo
end
def ref
Quickbooks::Model::BaseReference.new
end

View File

@@ -24,6 +24,9 @@ class ItemSyncService < SyncServiceBase
map_attribute :active, :active?
map_attribute :taxable, :taxable?
map_attribute :account do |remote|
Account.find remote.income_account_ref.value.to_i
end
map_attributes :description, :id, :name, :sku, :type, :unit_price
end

View File

@@ -15,7 +15,10 @@
</p>
<p>
<%= f.number_field :unit_price, step: 0.01, size: 10 %>
<%= f.text_field :unit_price,
class: "price-field",
inputmode: "decimal",
autocomplete: "off"%>
</p>
<p>

View File

@@ -1,5 +1,3 @@
<h2>Edit Item</h2>
<h2><%=t(:label_edit_item)%></h2>
<%= render "form" %>
<%= link_to "Back", items_path %>
<%= render "form" %>

View File

@@ -26,10 +26,18 @@
<td class="description"><%= truncate(item.description, length: 60) %></td>
<td class="unit_price"><%= number_to_currency(item.unit_price) %></td>
<td class="taxable center">
<%= item.taxable ? content_tag(:span, '', class: 'icon icon-ok') : "" %>
<% if item.taxable %>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</td>
<td class="active center">
<%= checked_image item.active %>
<% if item.active %>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</td>
<td class="buttons">
<%= link_to l(:button_edit), edit_item_path(item), class: 'icon icon-edit' %>

View File

@@ -1,5 +1,5 @@
<h2>New Item</h2>
<h2><%=t(:label_item_new)%></h2>
<%= render "form" %>
<%= link_to "Back", items_path %>
<%= link_to t(:label_back), items_path %>

View File

@@ -8,27 +8,27 @@
<div class="issue details"> <div class="attributes">
<div class="splitcontent">
<div class="splitcontentleft">
<p><strong>SKU:</strong> <%= @item.sku.presence || "-" %></p>
<p><strong>Type:</strong> <%= @item.type.presence || "-" %></p>
<p><strong>Unit Price:</strong> <%= number_to_currency(@item.unit_price) %></p>
<p><strong><%=t(:field_sku)%>:</strong> <%= @item.sku.presence || "-" %></p>
<p><strong><%=t(:label_type)%>:</strong> <%= @item.type.presence || "-" %></p>
<p><strong><%=t(:field_unit_price)%>:</strong> <%= number_to_currency(@item.unit_price) %></p>
</div>
<div class="splitcontentleft">
<p><strong>Account:</strong> <%= @item.account&.name || "-" %></p>
<p><strong><%=t(:label_account)%>:</strong> <%= @item.account&.name || "-" %></p>
<p>
<strong>Taxable:</strong>
<strong><%=t(:field_taxable)%>:</strong>
<% if @item.taxable %>
<span class="icon icon-ok" style="color: green;">Yes</span>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;">No</span>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</p>
<p>
<strong>Active:</strong>
<strong><%=t(:label_active)%>:</strong>
<% if @item.active %>
<span class="icon icon-ok" style="color: green;">Yes</span>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;">No</span>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</p>
</div>
@@ -36,7 +36,7 @@
<hr />
<p><strong>Description:</strong></p>
<p><strong><%=t(:label_description)%>:</strong></p>
<div class="wiki" style="padding-left: 20px;">
<%= @item.description.presence || "<em>No description provided</em>".html_safe %>
</div>

View File

@@ -1,3 +1,9 @@
let lastKeyWasTab = false;
document.addEventListener("keydown", function (e) {
lastKeyWasTab = (e.key === "Tab");
});
(function () {
function initNestedForms() {
document.querySelectorAll("[data-nested-form]").forEach(function (wrapper) {
@@ -22,11 +28,28 @@
Date.now().toString()
);
//container.insertAdjacentHTML("beforeend", content);
container.insertAdjacentHTML("beforeend", content);
// initialize autocomplete on the new row
initLineItemAutocomplete(container.lastElementChild);
const newRow = container.lastElementChild;
// Ensure clean state
newRow.dataset.autoAdded = "false";
// Reset defaults
const qty = newRow.querySelector(".qty-field");
if (qty && !qty.value) qty.value = 1;
const price = newRow.querySelector(".price-field");
if (price) price.value = "";
// initialize autocomplete
initLineItemAutocomplete(newRow);
// Only focus if NOT tabbing
if (!lastKeyWasTab) {
const desc = newRow.querySelector(".line-item-description");
if (desc) desc.focus();
}
}
// REMOVE
@@ -56,9 +79,77 @@
document.addEventListener("turbo:load", initNestedForms);
})();
$(document).on("input", ".line-item-description", function(){
// Keep your existing behavior
$(document).on("input", ".line-item-description", function () {
let row = $(this).closest(".line-item");
row.find(".item-id-field").val("");
});
});
// -------------------------------
// AUTO-ADD NEW ROW LOGIC
// -------------------------------
// Reset autoAdded flag if cleared
document.addEventListener("input", function (e) {
if (!e.target.classList.contains("line-item-description")) return;
const row = e.target.closest(".line-item");
if (!row) return;
if (e.target.value.trim() === "") {
row.dataset.autoAdded = "false";
}
});
// Add row when leaving last description (without breaking TAB flow)
document.addEventListener("blur", function (e) {
if (!e.target.classList.contains("line-item-description")) return;
const input = e.target;
const row = input.closest(".line-item");
if (!row) return;
const wrapper = input.closest("[data-nested-form]");
if (!wrapper) return;
const container = wrapper.querySelector("[data-nested-form-container]");
if (!container) return;
// Active (visible + not destroyed) rows only
const rows = Array.from(
container.querySelectorAll(wrapper.dataset.wrapperSelector)
).filter(r => {
const destroy = r.querySelector("input[name*='[_destroy]']");
const hidden = window.getComputedStyle(r).display === "none";
return !(destroy && destroy.value === "1") && !hidden;
});
const lastRow = rows[rows.length - 1];
// Only last row
if (row !== lastRow) return;
// Must have content
if (input.value.trim() === "") return;
// Prevent duplicate firing
if (row.dataset.autoAdded === "true") return;
// If TAB, ensure user is leaving the row entirely
if (lastKeyWasTab) {
const next = document.activeElement;
if (row.contains(next)) {
return; // still inside row → allow normal tabbing
}
}
row.dataset.autoAdded = "true";
const addButton = wrapper.querySelector("[data-nested-form-add]");
if (addButton) addButton.click();
}, true); // capture phase required for blur

View File

@@ -16,21 +16,28 @@ en:
field_taxable: "Taxable"
field_unit_price: "Unit Price"
label_active: "Activie"
label_account: "Account"
label_accounts: "Accounts"
label_back: "Back"
label_account_count: "Number of Accounts:"
label_default_account: "Default Item Income Account"
label_description: "Description"
label_edit_item: "Edit Item"
label_item: "Item"
label_item_count: "Item Count:"
label_items: "Items"
label_line_items: "Line Items"
label_price: "Unit Price"
label_item_new: "New Item"
label_no: "No"
label_qty: "Quantity"
label_remove: "Remove"
label_sync_now_accounts: "Sync Accounts"
label_sync_now_items: "Sync Items"
label_type: "Type"
label_total: "Total"
label_yes: "Yes"
notice_added_from: "Added from issue #"

16
init.rb
View File

@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
name 'Redmine QBO Line Items plugin'
author 'Rick Barrette'
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to attach billable line items to an isuue'
version '2026.3.9'
version '2026.3.12'
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
author_url 'https://barrettefabrication.com'
requires_redmine version_or_higher: '6.1.0'
@@ -31,10 +31,12 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
Issue.safe_attributes :line_items_attributes
end
# Dynamically load all Hooks & Patches recursively
base_dir = File.join(File.dirname(__FILE__), 'lib')
# Administration menu extension
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :redmine_qbo_lineitems, { controller: 'items', action: 'index' },
icon: 'list',
caption: :label_items,
html: { class: 'icon icon-list' }
end
# '**' looks inside subdirectories, '*.rb' matches Ruby files
Dir.glob(File.join(base_dir, '**', '*.rb')).sort.each do |file|
require file
end
RedmineQboLineItems.setup

View File

@@ -8,10 +8,10 @@
#
#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.
module RedmineQboLineItems
module LineItems
module Hooks
class IssuesSaveHookListener < Redmine::Hook::ViewListener
class IssuesSaveHookListener < Redmine::Hook::Listener
# Called After Issue Saved
def controller_issues_edit_after_save(context={})

View File

@@ -8,10 +8,10 @@
#
#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.
module RedmineQboLineItems
module LineItems
module Hooks
class QboHookListener < Redmine::Hook::ViewListener
class QboHookListener < Redmine::Hook::Listener
# Called by WebhookProcessJob
def qbo_additional_entities(context={})

View File

@@ -8,7 +8,7 @@
#
#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.
module RedmineQboLineItems
module LineItems
module Hooks
class ViewHookListener < Redmine::Hook::ViewListener
@@ -25,6 +25,7 @@ module RedmineQboLineItems
end
def view_issues_edit_notes_bottom(context = {})
return if context[:issue].closed?
context[:controller].send(:render_to_string, {
partial: 'line_items/issue_form',
locals: {

View File

@@ -8,35 +8,17 @@
#
#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.
require_dependency 'issue'
module RedmineQboLineItems
module LineItems
module Patches
module IssuePatch
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
has_many :line_items, dependent: :destroy
accepts_nested_attributes_for :line_items,
allow_destroy: true,
reject_if: proc { |attrs| attrs['description'].blank? }
end
extend ActiveSupport::Concern
prepended do
has_many :line_items, dependent: :destroy
accepts_nested_attributes_for :line_items,
allow_destroy: true,
reject_if: proc { |attrs| attrs['description'].blank? }
end
module ClassMethods
end
module InstanceMethods
end
end
Issue.send(:include, IssuePatch)
end
end

View File

@@ -0,0 +1,21 @@
#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.
module RedmineQboLineItems
def self.setup
unless Issue.ancestors.include?(LineItems::Patches::IssuePatch)
Issue.prepend LineItems::Patches::IssuePatch
LineItems::Hooks::IssuesSaveHookListener
LineItems::Hooks::QboHookListener
LineItems::Hooks::ViewHookListener
end
end
end