Added support for item name & sku. Also added manual sync link

This commit is contained in:
2026-03-11 19:36:27 -04:00
parent 1febdc3e04
commit bfdf6b3065
7 changed files with 82 additions and 10 deletions

View File

@@ -12,11 +12,19 @@ class ItemsController < ApplicationController
before_action :require_login
def autocomplete
term = params[:q].to_s
items = Item.where("description LIKE ?", "%#{ActiveRecord::Base.sanitize_sql_like(term)}%").where(active: true).order(:description).limit(20)
term = ActiveRecord::Base.sanitize_sql_like(params[:q].to_s)
items = Item.where("description LIKE :t OR name LIKE :t OR sku LIKE :t", t: "%#{term}%")
.where(active: true)
.order(:description)
.limit(20)
render json: items.map { |i|
{ id: i.id, text: i.description, price: i.unit_price }
{ id: i.id, name: i.name, sku: i.sku, description: i.description, price: i.unit_price }
}
end
def sync
Item.sync
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
end
end

View File

@@ -29,6 +29,8 @@ class ItemSyncService < SyncServiceBase
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)

View File

@@ -2,4 +2,5 @@
<b><%=t(:label_item_count)%></b> <%= Item.count %> @ <%= Item.last_sync %>
<br/>
<%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %>
</div>
</div>
<%= link_to t(:label_sync_now), items_sync_path%>