Added taxable flag

This commit is contained in:
2026-03-17 12:25:58 -04:00
parent f81fe0ef87
commit 24e3e4ba82
5 changed files with 20 additions and 1 deletions

View File

@@ -66,6 +66,7 @@ class ItemsController < ApplicationController
def new
@item = Item.new
@item.taxable.nil? ? true : @item.taxable
end
def show
@@ -95,7 +96,7 @@ class ItemsController < ApplicationController
end
def item_params
params.require(:item).permit(:name, :description, :sku, :unit_price, :active, :account_id, :type)
params.require(:item).permit(:name, :description, :sku, :unit_price, :active, :account_id, :type, :taxable)
end
private

View File

@@ -17,6 +17,7 @@ class Item < QboBaseModel
self.primary_key = :id
self.inheritance_column = :_type_disabled
qbo_sync push: true
after_initialize :set_defaults, if: :new_record?
# Updates Both local & remote DB account ref
def account_id=(id)
@@ -35,7 +36,15 @@ class Item < QboBaseModel
details.name = s
super
end
def ref
Quickbooks::Model::BaseReference.new
end
def set_defaults
self.taxable = true if taxable.nil?
end
# Updates Both local & remote DB sku
def sku=(s)
details.sku = s

View File

@@ -23,6 +23,7 @@ class ItemSyncService < SyncServiceBase
end
map_attribute :active, :active?
map_attribute :taxable, :taxable?
map_attributes :description, :id, :name, :sku, :type, :unit_price
end

View File

@@ -33,6 +33,13 @@
<td style="padding: 8px;"><%= f.number_field :unit_price, step: 0.01, style: "width: 100%;" %></td>
</tr>
<tr>
<td style="padding: 8px; vertical-align: middle;"><%= f.label :taxable %></td>
<td style="padding: 8px; vertical-align: middle;">
<%= f.check_box :taxable %>
</td>
</tr>
<tr>
<td style="padding: 8px; vertical-align: top;"><%= f.label :account %></td>
<td style="padding: 8px;">

View File

@@ -21,5 +21,6 @@ class CreateAccounts < ActiveRecord::Migration[7.0]
add_reference :items, :account, foreign_key: true
add_column :items, :type, :string
add_column :items, :taxable, :boolean, null: true
end
end