mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Added taxable flag
This commit is contained in:
@@ -66,6 +66,7 @@ class ItemsController < ApplicationController
|
|||||||
|
|
||||||
def new
|
def new
|
||||||
@item = Item.new
|
@item = Item.new
|
||||||
|
@item.taxable.nil? ? true : @item.taxable
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -95,7 +96,7 @@ class ItemsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def item_params
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Item < QboBaseModel
|
|||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
self.inheritance_column = :_type_disabled
|
self.inheritance_column = :_type_disabled
|
||||||
qbo_sync push: true
|
qbo_sync push: true
|
||||||
|
after_initialize :set_defaults, if: :new_record?
|
||||||
|
|
||||||
# Updates Both local & remote DB account ref
|
# Updates Both local & remote DB account ref
|
||||||
def account_id=(id)
|
def account_id=(id)
|
||||||
@@ -36,6 +37,14 @@ class Item < QboBaseModel
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ref
|
||||||
|
Quickbooks::Model::BaseReference.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_defaults
|
||||||
|
self.taxable = true if taxable.nil?
|
||||||
|
end
|
||||||
|
|
||||||
# Updates Both local & remote DB sku
|
# Updates Both local & remote DB sku
|
||||||
def sku=(s)
|
def sku=(s)
|
||||||
details.sku = s
|
details.sku = s
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class ItemSyncService < SyncServiceBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
map_attribute :active, :active?
|
map_attribute :active, :active?
|
||||||
|
map_attribute :taxable, :taxable?
|
||||||
map_attributes :description, :id, :name, :sku, :type, :unit_price
|
map_attributes :description, :id, :name, :sku, :type, :unit_price
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -33,6 +33,13 @@
|
|||||||
<td style="padding: 8px;"><%= f.number_field :unit_price, step: 0.01, style: "width: 100%;" %></td>
|
<td style="padding: 8px;"><%= f.number_field :unit_price, step: 0.01, style: "width: 100%;" %></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :account %></td>
|
<td style="padding: 8px; vertical-align: top;"><%= f.label :account %></td>
|
||||||
<td style="padding: 8px;">
|
<td style="padding: 8px;">
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ class CreateAccounts < ActiveRecord::Migration[7.0]
|
|||||||
|
|
||||||
add_reference :items, :account, foreign_key: true
|
add_reference :items, :account, foreign_key: true
|
||||||
add_column :items, :type, :string
|
add_column :items, :type, :string
|
||||||
|
add_column :items, :taxable, :boolean, null: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user