mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Sync services and other items without a description or rate
QuickBooks only requires an item's name, but the local Item required a description and a rate, so services such as Labor (often with neither) failed validation and were silently skipped by the sync. Name is now the only requirement; a missing description syncs as blank and a missing rate as 0. Product/service pickers and the labor setting list sellable items only (no Categories or Bundles). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
6 files changed
+18
-6
No files matched your search
+9
-1
@@ -11,8 +11,16 @@
|
||||
class Item < QboBaseModel
|
||||
belongs_to :account, optional: true
|
||||
|
||||
validates_presence_of :id, :description
|
||||
# QuickBooks only requires a name: services such as Labor often have no description or rate
|
||||
validates_presence_of :id, :name
|
||||
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
|
||||
|
||||
# QuickBooks item types that can't go on an estimate or invoice line themselves
|
||||
UNSELLABLE_TYPES = %w[Category Group].freeze
|
||||
|
||||
# Active products/services that can go on a line (services, non-inventory and inventory items), for the
|
||||
# pickers and the labor products/services setting
|
||||
scope :sellable, -> { where(active: true).where.not(type: UNSELLABLE_TYPES).or(where(active: true, type: nil)) }
|
||||
self.primary_key = :id
|
||||
self.inheritance_column = :_type_disabled
|
||||
qbo_sync push: true
|
||||
|
||||
Reference in new issue
Block a user