mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-03 23:51:59 -04:00
Compare commits
8 Commits
2026.3.7
...
2302679c3a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2302679c3a | |||
| ec1ef72267 | |||
| 564158722d | |||
| 60a7f769ce | |||
| 1367937614 | |||
| 62adcb11cd | |||
| 896813983c | |||
| 89e3048c29 |
@@ -21,7 +21,7 @@ This plugin allows **billable line items** to be attached to a Redmine issue. Wh
|
|||||||
|
|
||||||
| Plugin Version | Redmine Version | Ruby Version |
|
| Plugin Version | Redmine Version | Ruby Version |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| 2026.3.5+ | 6.1.x | 3.2+ |
|
| 2026.3.6+ | 6.1.x | 3.2+ |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
BIN
Screenshots/Form.png
Normal file
BIN
Screenshots/Form.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 193 KiB |
BIN
Screenshots/Issue View.png
Normal file
BIN
Screenshots/Issue View.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 337 KiB |
@@ -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}"
|
||||||
|
|||||||
@@ -14,13 +14,8 @@ class ItemSyncJob < ApplicationJob
|
|||||||
|
|
||||||
# Performs a sync of items from QuickBooks Online.
|
# Performs a sync of items from QuickBooks Online.
|
||||||
def perform(full_sync: false, id: nil)
|
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'}..."
|
log "Starting #{full_sync ? 'full' : 'incremental'} sync for item ##{id || 'all'}..."
|
||||||
|
service = ItemSyncService.new
|
||||||
service = ItemSyncService.new(qbo: qbo)
|
|
||||||
|
|
||||||
if id.present?
|
if id.present?
|
||||||
service.sync_by_id(id)
|
service.sync_by_id(id)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,32 +14,29 @@ class Item < QboBaseModel
|
|||||||
validates_presence_of :id, :description
|
validates_presence_of :id, :description
|
||||||
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
|
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
|
||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
|
qbo_sync push: true
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -22,19 +22,7 @@ class ItemSyncService < SyncServiceBase
|
|||||||
20
|
20
|
||||||
end
|
end
|
||||||
|
|
||||||
# Map relevant attributes from the QBO Employee to the local Employee model
|
map_attribute :active, :active?
|
||||||
def process_attributes(local, remote)
|
map_attributes :description, :id, :name, :sku, :unit_price
|
||||||
log "Processing Item ##{remote.id}"
|
|
||||||
local.id = remote.id
|
|
||||||
local.description = remote.description
|
|
||||||
local.unit_price = remote.unit_price
|
|
||||||
local.active = remote.active?
|
|
||||||
local.name = remote.name
|
|
||||||
local.sku = remote.sku
|
|
||||||
end
|
|
||||||
|
|
||||||
def log(msg)
|
|
||||||
Rails.logger.info "[ItemSyncService] #{msg}"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
4
init.rb
4
init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
|
|||||||
name 'Redmine QBO Line Items plugin'
|
name 'Redmine QBO Line Items plugin'
|
||||||
author 'Rick Barrette'
|
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'
|
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.7'
|
version '2026.3.8'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
|
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '6.1.0'
|
requires_redmine version_or_higher: '6.1.0'
|
||||||
@@ -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.6'
|
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user