Added support for making items inactive

This commit is contained in:
2026-03-08 15:14:36 -04:00
parent 88b452b889
commit 30b493e2f9
3 changed files with 3 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ class ItemsController < ApplicationController
def autocomplete
term = params[:q].to_s
items = Item.where("description LIKE ?", "%#{term}%").order(:description).limit(20)
items = Item.where("description LIKE ?", "%#{ActiveRecord::Base.sanitize_sql_like(term)}%").where(active: true).order(:description).limit(20)
render json: items.map { |i|
{ id: i.id, text: i.description, price: i.unit_price }

View File

@@ -17,16 +17,12 @@ class ItemSyncService < SyncServiceBase
Item
end
# Determine if the remote entity should be deleted locally (e.g. if it's marked inactive in QBO)
def destroy_remote?(remote)
!remote.active?
end
# Map relevant attributes from the QBO Employee to the local Employee model
def process_attributes(local, remote)
local.id = remote.id
local.description = remote.description
local.unit_price = remote.unit_price
local.active = remote.active?
end
end