mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Added support for making items inactive
This commit is contained in:
@@ -13,7 +13,7 @@ class ItemsController < ApplicationController
|
|||||||
|
|
||||||
def autocomplete
|
def autocomplete
|
||||||
term = params[:q].to_s
|
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|
|
render json: items.map { |i|
|
||||||
{ id: i.id, text: i.description, price: i.unit_price }
|
{ id: i.id, text: i.description, price: i.unit_price }
|
||||||
|
|||||||
@@ -17,16 +17,12 @@ class ItemSyncService < SyncServiceBase
|
|||||||
Item
|
Item
|
||||||
end
|
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
|
# Map relevant attributes from the QBO Employee to the local Employee model
|
||||||
def process_attributes(local, remote)
|
def process_attributes(local, remote)
|
||||||
local.id = remote.id
|
local.id = remote.id
|
||||||
local.description = remote.description
|
local.description = remote.description
|
||||||
local.unit_price = remote.unit_price
|
local.unit_price = remote.unit_price
|
||||||
|
local.active = remote.active?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -17,6 +17,7 @@ class CreateItems < ActiveRecord::Migration[7.0]
|
|||||||
scale: 4,
|
scale: 4,
|
||||||
null: false,
|
null: false,
|
||||||
default: 0
|
default: 0
|
||||||
|
t.boolean :active, default: true, null: false
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user