6 Commits

9 changed files with 13 additions and 55 deletions

BIN
Screenshots/Form.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

BIN
Screenshots/Issue View.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 KiB

View File

@@ -12,6 +12,7 @@ class ItemsController < ApplicationController
before_action :require_login before_action :require_login
before_action :find_item, only: [:show, :edit, :update, :destroy] before_action :find_item, only: [:show, :edit, :update, :destroy]
# Used for autocomplete form
def autocomplete def autocomplete
term = ActiveRecord::Base.sanitize_sql_like(params[:q].to_s) term = ActiveRecord::Base.sanitize_sql_like(params[:q].to_s)
@@ -43,7 +44,7 @@ class ItemsController < ApplicationController
def edit def edit
end end
def index def index
@items = Item.order(:name) @items = Item.order(:name)
end end

View File

@@ -46,7 +46,9 @@ class BillLineItemsJob < ActiveJob::Base
estimate = Quickbooks::Model::Estimate.new(customer_id: issue.customer.id) estimate = Quickbooks::Model::Estimate.new(customer_id: issue.customer.id)
estimate_service = Quickbooks::Service::Estimate.new( company_id: qbo.realm_id, access_token: access_token) estimate_service = Quickbooks::Service::Estimate.new( company_id: qbo.realm_id, access_token: access_token)
estimate.line_items << Quickbooks::Model::InvoiceLineItem.new(description: "#{I18n.t(:notice_added_from)}#{issue.id} #{issue.subject}", detail_type: 'DescriptionOnly' ) memo = "Added from: #{issue.tracker} ##{issue.id}: #{issue.subject}"
estimate.private_note = memo
estimate.line_items << Quickbooks::Model::InvoiceLineItem.new(description: memo, detail_type: 'DescriptionOnly' )
unbilled_entries.each do |item| unbilled_entries.each do |item|
log "Creating Line Item for #{item.description}" log "Creating Line Item for #{item.description}"

View File

@@ -1,36 +0,0 @@
#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.
class ItemSyncJob < ApplicationJob
queue_as :default
retry_on StandardError, wait: 5.minutes, attempts: 5
# Performs a sync of items from QuickBooks Online.
def perform(full_sync: false, id: nil)
qbo = QboConnectionService.current!
raise "No QBO configuration found" unless qbo
log "Starting #{full_sync ? 'full' : 'incremental'} sync for item ##{id || 'all'}..."
service = ItemSyncService.new(qbo: qbo)
if id.present?
service.sync_by_id(id)
else
service.sync(full_sync: full_sync)
end
end
private
def log(msg)
Rails.logger.info "[ItemSyncJob] #{msg}"
end
end

View File

@@ -18,29 +18,25 @@ class Item < QboBaseModel
# Updates Both local & remote DB description # Updates Both local & remote DB description
def description=(s) def description=(s)
details details.description = s
@details.description = s
super super
end end
# Updates Both local & remote DB name # Updates Both local & remote DB name
def name=(s) def name=(s)
details details.name = s
@details.name = s
super super
end end
# Updates Both local & remote DB sku # Updates Both local & remote DB sku
def sku=(s) def sku=(s)
details details.sku = s
@details.sku = s
super super
end end
# Updates Both local & remote DB price # Updates Both local & remote DB price
def unit_price=(s) def unit_price=(s)
details details.unit_price = s
@details.unit_price = s
super super
end end

View File

@@ -28,12 +28,7 @@ class ItemService < ServiceBase
def default_income_account def default_income_account
log "Looking up sales income account" log "Looking up sales income account"
qbo = QboConnectionService.current! QboConnectionService.with_qbo_service(entity: Invoice) do |service|
qbo.perform_authenticated_request do |token|
service = Quickbooks::Service::Account.new(
company_id: qbo.realm_id,
access_token: token
)
service.query("SELECT * FROM Account WHERE AccountType='Income' AND Name LIKE '%Sales%'").first service.query("SELECT * FROM Account WHERE AccountType='Income' AND Name LIKE '%Sales%'").first
end end
end end

View File

@@ -22,7 +22,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
# Ensure redmine_qbo is installed # Ensure redmine_qbo is installed
begin begin
requires_redmine_plugin :redmine_qbo, version_or_higher: '2026.3.7' requires_redmine_plugin :redmine_qbo, version_or_higher: '2026.3.9'
rescue Redmine::PluginNotFound rescue Redmine::PluginNotFound
raise 'Please install the redmine_qbo plugin (https://github.com/rickbarrette/redmine_qbo)' raise 'Please install the redmine_qbo plugin (https://github.com/rickbarrette/redmine_qbo)'
end end

View File

@@ -21,8 +21,8 @@ module RedmineQboLineItems
# Called by the QboSyncDispatcher # Called by the QboSyncDispatcher
def qbo_full_sync (context={}) def qbo_full_sync (context={})
log "Adding ItemSyncJob to QBO sync dispatcher" log "Adding Item to QBO sync dispatcher"
return ItemSyncJob return Item
end end
private private