Move items, accounts and estimate writing to redmine_qbo_billing

The QuickBooks product/service list and income accounts (models, syncs,
admin pages, routes, settings) now live in redmine_qbo_billing, which this
plugin requires. The closing-an-issue estimate is written through
RedmineQboBilling::EstimateWriter.create_estimate, so estimate building isn't
duplicated; it now also gets the customer email, VIN, default message and
expiration date.

Migrations: 002 now only links line items to items (skipped where the column
exists). 003 and 004 are removed; billing's migrations find the existing
items and accounts tables and leave them alone, so nothing is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-30 13:50:15 -04:00
1 parent 1f525aba11
commit 3a2d50ae8d
24 files changed
+43 -748

No files matched your search

-37
View File
@@ -1,37 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class AccountsController < ApplicationController
layout 'admin'
menu_item :redmine_qbo_lineitems
# Accounts come from QuickBooks; choosing the default and syncing are admin-only
before_action :require_admin
def index
@accounts = Account.where(classification: 'Revenue').order(:name)
end
def set_default
account = Account.find_by(id: params[:default_account_id])
if account&.update(default: true)
flash[:notice] = l(:notice_default_account_updated)
else
flash[:error] = l(:error_default_account_not_selected)
end
redirect_to accounts_path
end
def sync
Account.sync
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
end
end
-106
View File
@@ -1,106 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class ItemsController < ApplicationController
layout 'admin'
menu_item :redmine_qbo_lineitems
# The item catalog is pushed to QuickBooks, so managing it is admin-only. The autocomplete feeds the
# line item form on issues and is allowed with the "Add line items" or "Edit line items" permission.
before_action :require_admin, except: :autocomplete
before_action :authorize_global, only: :autocomplete
before_action :find_item, only: [:show, :edit, :update, :destroy]
# Used for autocomplete form
def autocomplete
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, name: i.name, sku: i.sku, description: i.description, price: i.unit_price }
}
end
def create
@item = Item.new(item_params)
if @item.save
redirect_to item_path(@item), notice: l(:notice_successful_create)
else
render :new, status: :unprocessable_entity
end
rescue => e
log "Unexpected error creating item: #{e.message}"
# Regex now matches across line breaks
existing_id = e.message[/Duplicate Name Exists Error:[\s\S]*Id=(\d+)/, 1]&.to_i
if existing_id
flash[:error] = "Name already exists. Redirecting to existing item."
redirect_to item_path(existing_id)
else
flash[:error] = e.message
redirect_to new_item_path
end
end
def destroy
@item.destroy
redirect_to items_path, notice: l(:notice_successful_delete)
end
def edit
end
def index
@items = Item.order(:name)
end
def new
@item = Item.new
end
def show
end
def sync
Item.sync
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
end
def update
if @item.update(item_params)
redirect_to item_path(@item), notice: l(:notice_successful_update)
else
render :edit, status: :unprocessable_entity
end
end
private
def find_item
@item = Item.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def item_params
params.require(:item).permit(:name, :description, :sku, :unit_price, :active, :account_id, :type, :taxable)
end
def log(msg)
Rails.logger.info "[ItemsController] #{msg}"
end
end
+19 -29
View File
@@ -24,10 +24,7 @@ class BillLineItemsJob < ActiveJob::Base
unbilled_entries = issue.line_items.where(billed: [false, nil]).lock
return if unbilled_entries.blank?
qbo = QboConnectionService.current!
qbo.perform_authenticated_request do |access_token|
create_estimate(issue, unbilled_entries, access_token, qbo)
end
create_estimate(issue, unbilled_entries)
# Only mark billed AFTER successful QBO creation
unbilled_entries.update_all(billed: true)
@@ -42,35 +39,28 @@ class BillLineItemsJob < ActiveJob::Base
private
# Create an Estimate record in QBO for each unbilled line item
def create_estimate(issue, unbilled_entries, access_token, qbo)
log "Creating Estimate records in QBO for #{issue.customer.name} from issue ##{issue.id}"
estimate = Quickbooks::Model::Estimate.new(customer_id: issue.customer.id)
estimate_service = Quickbooks::Service::Estimate.new( company_id: qbo.realm_id, access_token: access_token)
# Creates the QuickBooks estimate with redmine_qbo_billing, which writes every estimate: a first line
# saying where the lines came from, then the unbilled line items. The VIN comes from the issue's vehicle.
def create_estimate(issue, unbilled_entries)
log "Creating estimate in QBO for #{issue.customer.name} from issue ##{issue.id}"
memo = "Added from: #{issue.tracker} ##{issue.id}: #{issue.subject}"
estimate.private_note = memo
estimate.line_items << Quickbooks::Model::InvoiceLineItem.new(description: memo, detail_type: 'DescriptionOnly' )
unbilled_entries.each do |item|
log "Creating Line Item for #{item.description}"
line = Quickbooks::Model::InvoiceLineItem.new
line.amount = item.line_total
line.description = item.description
line.sales_item! do |detail|
detail.unit_price = item.unit_price
detail.quantity = item.quantity
# Assign "TAX" only if the item is taxable or unknown
if item.item.nil? || item.item.taxable
detail.tax_code_ref = Quickbooks::Model::BaseReference.new("TAX")
end
end
estimate.line_items << line
lines = [{ description: memo }]
unbilled_entries.each do |entry|
lines << {
item_id: entry.item_id,
description: entry.description,
quantity: entry.quantity,
rate: entry.unit_price,
# Taxable unless the item says otherwise (or the line has no item)
taxable: entry.item.nil? || entry.item.taxable != false
}
end
e = estimate_service.create(estimate)
log "Created estimate ##{e.doc_number}"
vin = issue.respond_to?(:vehicle) ? issue.vehicle&.vin : nil
estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines,
private_note: memo, vin: vin)
log "Created estimate ##{estimate.doc_number}"
end
def log(msg)
-41
View File
@@ -1,41 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class Account < QboBaseModel
has_many :items
validates_presence_of :id, :name
self.primary_key = :id
qbo_sync push: false
before_save :clear_other_defaults, if: :default?
# Returns the account marked as default
def self.get_default
find_by(default: true)
end
# Returns QBO Refrence object for the account
def ref
r = Quickbooks::Model::BaseReference.new
r.value = id
r.name = name
return r
end
def to_s
name
end
private
def clear_other_defaults
Account.where.not(id: id).update_all(default: false)
end
end
-68
View File
@@ -1,68 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class Item < QboBaseModel
belongs_to :account, optional: true
validates_presence_of :id, :description
validates :unit_price, numericality: { greater_than_or_equal_to: 0 }
self.primary_key = :id
self.inheritance_column = :_type_disabled
qbo_sync push: true
after_initialize :set_defaults, if: :new_record?
before_destroy :make_inactive
# Updates Both local & remote DB account ref (a blank or unknown account leaves QBO's ref unchanged)
def account_id=(id)
account = Account.find_by(id: id) if id.present?
details.income_account_ref = account.ref if account
super
end
# Updates Both local & remote DB description
def description=(s)
details.description = s
super
end
# Updates Both local & remote DB name
def name=(s)
details.name = s
super
end
def make_inactive
details.active = false
push_to_qbo
end
def set_defaults
self.taxable = true if taxable.nil?
end
# Updates Both local & remote DB sku
def sku=(s)
details.sku = s
super
end
# Updates Both local & remote DB type
def type=(s)
details.type = s.to_s
super
end
# Updates Both local & remote DB price
def unit_price=(s)
details.unit_price = s
super
end
end
-23
View File
@@ -1,23 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class AccountSyncService < SyncServiceBase
private
# Specify the local model this service syncs
def self.model_class
Account
end
map_attribute :active, :active?
map_attributes :classification, :description, :id, :name
end
-26
View File
@@ -1,26 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class ItemService < ServiceBase
private
def build_qbo_remote
log "Building new QBO Item"
# New items default to a non-inventory item in the default income account; the item form then
# sets the type and account the user chose.
item = Quickbooks::Model::Item.new
item.type = Quickbooks::Model::Item::NON_INVENTORY_TYPE
default_account = Account.get_default
item.income_account_ref = default_account.ref if default_account
item
end
end
-35
View File
@@ -1,35 +0,0 @@
#The MIT License (MIT)
#
#Copyright (c) 2026 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class ItemSyncService < SyncServiceBase
private
# Specify the local model this service syncs
def self.model_class
Item
end
# Specify a page size of 20, as the API only returns 20 items at a time.
def self.page_size
20
end
map_attribute :active, :active?
map_attribute :taxable, :taxable?
# Items without an income account (e.g. categories), or whose account hasn't synced yet, get none
# instead of failing the whole sync; the next sync fills it in.
map_attribute :account do |remote|
account_id = remote.income_account_ref&.value
account_id.present? ? Account.find_by(id: account_id.to_i) : nil
end
map_attributes :description, :id, :name, :sku, :type, :unit_price
end
-37
View File
@@ -1,37 +0,0 @@
<h2><%= l(:label_accounts) %></h2>
<%= form_tag set_default_accounts_path, method: :patch do %>
<div class="autoscroll">
<table class="list accounts">
<thead>
<tr>
<th style="width:50px;"><%= l(:label_default) %></th>
<th><%= l(:field_name) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:field_classification) %></th>
<th class="center"><%= l(:field_active) %></th>
</tr>
</thead>
<tbody>
<% @accounts.each do |account| %>
<tr class="<%= cycle("odd", "even") %>">
<td class="center">
<%= radio_button_tag "default_account_id", account.id, account.default %>
</td>
<td class="name"><strong><%= account.name %></strong></td>
<td class="description"><%= truncate(account.description, length: 80) %></td>
<td class="classification"><%= account.classification %></td>
<td class="active center">
<%= checked_image account.active %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<p class="buttons">
<%= submit_tag l(:button_save), class: 'button-small' %>
</p>
<% end %>
-50
View File
@@ -1,50 +0,0 @@
<%= labelled_form_for @item do |f| %>
<%= error_messages_for 'item' %>
<div class="box tabular">
<p>
<%= f.text_field :name, required: true, size: 60 %>
</p>
<p>
<%= f.text_field :sku, size: 30 %>
</p>
<p>
<%= f.text_area :description, rows: 4, class: 'wiki-edit' %>
</p>
<p>
<%= f.text_field :unit_price,
class: "price-field",
inputmode: "decimal",
autocomplete: "off"%>
</p>
<p>
<%= f.check_box :taxable %>
</p>
<p>
<%= f.label :account_id, l(:label_account) %>
<%= f.collection_select :account_id,
Account.where(classification: 'Revenue').order(:name),
:id,
:name,
{ selected: @item.account_id || Account.get_default&.id, include_blank: true } %>
</p>
<p>
<%= f.select :type,
Quickbooks::Model::Item::ITEM_TYPES.map { |t| [t, t] },
{ selected: @item.type || Quickbooks::Model::Item::NON_INVENTORY_TYPE } %>
</p>
<p>
<%= f.check_box :active %>
</p>
</div>
<%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel), items_path if controller.action_name == 'edit' %>
<% end %>
-3
View File
@@ -1,3 +0,0 @@
<h2><%=t(:label_edit_item)%></h2>
<%= render "form" %>
-56
View File
@@ -1,56 +0,0 @@
<div class="contextual">
<%= link_to l(:label_item_new), new_item_path, class: 'icon icon-add' %>
</div>
<h2><%= l(:label_items) %></h2>
<% if @items.any? %>
<div class="autoscroll">
<table class="list items">
<thead>
<tr>
<th><%= l(:field_name) %></th>
<th><%= l(:field_sku) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:field_unit_price) %></th>
<th class="center"><%= l(:field_taxable) %></th>
<th class="center"><%= l(:field_active) %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @items.each do |item| %>
<tr class="<%= cycle("odd", "even") %>">
<td class="name"><%= link_to item.name, item_path(item) %></td>
<td class="sku"><%= item.sku %></td>
<td class="description"><%= truncate(item.description, length: 60) %></td>
<td class="unit_price"><%= number_to_currency(item.unit_price) %></td>
<td class="taxable center">
<% if item.taxable %>
<span class="icon icon-ok" style="color: green;"><%= l(:general_text_Yes) %></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%= l(:general_text_No) %></span>
<% end %>
</td>
<td class="active center">
<% if item.active %>
<span class="icon icon-ok" style="color: green;"><%= l(:general_text_Yes) %></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%= l(:general_text_No) %></span>
<% end %>
</td>
<td class="buttons">
<%= link_to l(:button_edit), edit_item_path(item), class: 'icon icon-edit' %>
<%= link_to l(:button_delete), item_path(item),
method: :delete,
data: { confirm: l(:text_are_you_sure) },
class: 'icon icon-del' %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
-5
View File
@@ -1,5 +0,0 @@
<h2><%=t(:label_item_new)%></h2>
<%= render "form" %>
<%= link_to t(:label_back), items_path %>
-44
View File
@@ -1,44 +0,0 @@
<div class="contextual">
<%= link_to l(:button_edit), edit_item_path(@item), class: 'icon icon-edit' %>
<%= link_to l(:button_back), items_path, class: 'icon icon-list' %>
</div>
<h2><%= t(:item) %># <%= @item.id %> <%= @item.name %></h2>
<div class="issue details"> <div class="attributes">
<div class="splitcontent">
<div class="splitcontentleft">
<p><strong><%=t(:field_sku)%>:</strong> <%= @item.sku.presence || "-" %></p>
<p><strong><%=t(:label_type)%>:</strong> <%= @item.type.presence || "-" %></p>
<p><strong><%=t(:field_unit_price)%>:</strong> <%= number_to_currency(@item.unit_price) %></p>
</div>
<div class="splitcontentleft">
<p><strong><%=t(:label_account)%>:</strong> <%= @item.account&.name || "-" %></p>
<p>
<strong><%=t(:field_taxable)%>:</strong>
<% if @item.taxable %>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</p>
<p>
<strong><%=t(:label_active)%>:</strong>
<% if @item.active %>
<span class="icon icon-ok" style="color: green;"><%=t(:yes)%></span>
<% else %>
<span class="icon icon-not-ok" style="color: #999;"><%=t(:no)%></span>
<% end %>
</p>
</div>
</div>
<hr />
<p><strong><%=t(:label_description)%>:</strong></p>
<div class="wiki" style="padding-left: 20px;">
<%= @item.description.presence || "<em>No description provided</em>".html_safe %>
</div>
</div>
</div>
-39
View File
@@ -1,39 +0,0 @@
<div class="box tabular">
<p>
<label><strong><%= t(:label_item_count) %></strong></label>
<%= Item.count %>
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">
(@ <%= Item.last_sync %>)
</em>
</p>
<p>
<label><strong><%= t(:label_account_count) %></strong></label>
<%= Account.count %>
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">
(@ <%= Account.last_sync %>)
</em>
</p>
<p>
<label><strong><%= t(:label_last_sync) %> (QBO)</strong></label>
<%= Qbo.exists? ? Qbo.last_sync : l(:label_never_synced) %>
</p>
<p>
<label><strong><%= t(:label_default_account) %></strong></label>
<%= Account.get_default %>
</p>
</div>
<fieldset class="box">
<legend><%= l(:label_management_and_sync) %></legend>
<div style="margin-bottom: 15px;">
<%= link_to t(:label_sync_now_items), sync_items_path, class: 'button icon icon-reload' %>
<%= link_to t(:label_sync_now_accounts), sync_accounts_path, class: 'button icon icon-reload' %>
</div>
<div>
<%= link_to t(:label_items), items_path, class: 'icon icon-list' %>
<span style="margin: 0 10px; color: #ccc;">|</span>
<%= link_to t(:label_accounts), accounts_path, class: 'icon icon-list' %>
</div>
</fieldset>