mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Updated views for items and accounts
This commit is contained in:
@@ -19,4 +19,9 @@ class AccountsController < ApplicationController
|
|||||||
account.update(default: true)
|
account.update(default: true)
|
||||||
redirect_to accounts_path, notice: "Default account updated."
|
redirect_to accounts_path, notice: "Default account updated."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync
|
||||||
|
Account.sync
|
||||||
|
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -28,6 +28,10 @@ class Account < QboBaseModel
|
|||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def clear_other_defaults
|
def clear_other_defaults
|
||||||
|
|||||||
@@ -1,39 +1,37 @@
|
|||||||
<h1>Accounts</h1>
|
<h2><%= l(:label_accounts) %></h2>
|
||||||
|
|
||||||
<%= form_with url: set_default_accounts_path, method: :patch, local: true do %>
|
<%= form_tag set_default_accounts_path, method: :patch do %>
|
||||||
<table style="width:100%; border-collapse: collapse; margin-bottom: 1em;">
|
<div class="autoscroll">
|
||||||
<thead style="background-color: #f2f2f2;">
|
<table class="list accounts">
|
||||||
<tr>
|
<thead>
|
||||||
<th style="padding: 8px; border: 1px solid #ddd;">Default</th>
|
<tr>
|
||||||
<th style="padding: 8px; border: 1px solid #ddd;">Name</th>
|
<th style="width:50px;"><%= l(:label_default) %></th>
|
||||||
<th style="padding: 8px; border: 1px solid #ddd;">Description</th>
|
<th><%= l(:field_name) %></th>
|
||||||
<th style="padding: 8px; border: 1px solid #ddd;">Classification</th>
|
<th><%= l(:field_description) %></th>
|
||||||
<th style="padding: 8px; border: 1px solid #ddd;">Active</th>
|
<th><%= l(:field_classification) %></th>
|
||||||
</tr>
|
<th class="center"><%= l(:field_active) %></th>
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<% @accounts.each_with_index do |account, index| %>
|
|
||||||
<tr style="background-color: <%= index.even? ? '#ffffff' : '#f9f9f9' %>;">
|
|
||||||
<td style="text-align: center; border: 1px solid #ddd; padding: 8px;">
|
|
||||||
<%= radio_button_tag "default_account_id", account.id, account.default %>
|
|
||||||
</td>
|
|
||||||
<td style="border: 1px solid #ddd; padding: 8px;"><%= account.name %></td>
|
|
||||||
<td style="border: 1px solid #ddd; padding: 8px;"><%= account.description %></td>
|
|
||||||
<td style="border: 1px solid #ddd; padding: 8px;"><%= account.classification %></td>
|
|
||||||
<td style="text-align: center; border: 1px solid #ddd; padding: 8px;">
|
|
||||||
<%= account.active ? "Yes" : "No" %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
</thead>
|
||||||
</tbody>
|
|
||||||
|
|
||||||
<tfoot>
|
<tbody>
|
||||||
<tr>
|
<% @accounts.each do |account| %>
|
||||||
<td colspan="5" style="padding: 8px; text-align: right;">
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
<%= submit_tag "Save Default Account", style: "padding: 6px 12px; font-weight: bold;" %>
|
<td class="center">
|
||||||
</td>
|
<%= radio_button_tag "default_account_id", account.id, account.default %>
|
||||||
</tr>
|
</td>
|
||||||
</tfoot>
|
<td class="name"><strong><%= account.name %></strong></td>
|
||||||
</table>
|
<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 %>
|
<% end %>
|
||||||
@@ -1,76 +1,47 @@
|
|||||||
<%= form_with model: @item, local: true do |f| %>
|
<%= labelled_form_for @item do |f| %>
|
||||||
|
<%= error_messages_for 'item' %>
|
||||||
|
|
||||||
<% if @item.errors.any? %>
|
<div class="box tabular">
|
||||||
<div id="errorExplanation" style="border: 1px solid #f00; padding: 10px; background-color: #fee; margin-bottom: 1em;">
|
<p>
|
||||||
<h2 style="color: #900;"><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
|
<%= f.text_field :name, required: true, size: 60 %>
|
||||||
<ul>
|
</p>
|
||||||
<% @item.errors.full_messages.each do |msg| %>
|
|
||||||
<li><%= msg %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<table style="width: 100%; border-collapse: collapse;">
|
<p>
|
||||||
<tbody>
|
<%= f.text_field :sku, size: 30 %>
|
||||||
<tr>
|
</p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :name %></td>
|
|
||||||
<td style="padding: 8px;"><%= f.text_field :name, required: true, style: "width: 100%;" %></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :sku %></td>
|
<%= f.text_area :description, rows: 4, class: 'wiki-edit' %>
|
||||||
<td style="padding: 8px;"><%= f.text_field :sku, style: "width: 100%;" %></td>
|
</p>
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :description %></td>
|
<%= f.number_field :unit_price, step: 0.01, size: 10 %>
|
||||||
<td style="padding: 8px;"><%= f.text_area :description, rows: 3, style: "width: 100%;" %></td>
|
</p>
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :unit_price %></td>
|
<%= f.check_box :taxable %>
|
||||||
<td style="padding: 8px;"><%= f.number_field :unit_price, step: 0.01, style: "width: 100%;" %></td>
|
</p>
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: middle;"><%= f.label :taxable %></td>
|
<%= f.label :account_id, l(:label_account) %>
|
||||||
<td style="padding: 8px; vertical-align: middle;">
|
<%= f.collection_select :account_id,
|
||||||
<%= f.check_box :taxable %>
|
Account.where(classification: 'Revenue').order(:name),
|
||||||
</td>
|
:id,
|
||||||
</tr>
|
:name,
|
||||||
|
{ selected: @item.account_id || Account.get_default&.id, include_blank: true } %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :account %></td>
|
<%= f.select :type,
|
||||||
<td style="padding: 8px;">
|
Quickbooks::Model::Item::ITEM_TYPES.map { |t| [t, t] },
|
||||||
<%= f.collection_select :account_id,
|
{ selected: @item.type || Quickbooks::Model::Item::NON_INVENTORY_TYPE } %>
|
||||||
Account.where(classification: 'Revenue').order(:name),
|
</p>
|
||||||
:id,
|
|
||||||
:name,
|
|
||||||
{ selected: @item.account_id || Account.get_default&.id },
|
|
||||||
{ include_blank: true, style: "width: 100%;" } %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :type %></td>
|
<%= f.check_box :active %>
|
||||||
<td style="padding: 8px;">
|
</p>
|
||||||
<%= f.select :type,
|
</div>
|
||||||
Quickbooks::Model::Item::ITEM_TYPES.map { |t| [t, t] },
|
|
||||||
{ selected: @item.type || Quickbooks::Model::Item::NON_INVENTORY_TYPE },
|
|
||||||
{ style: "width: 100%;" } %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td style="padding: 8px; vertical-align: middle;"><%= f.label :active %></td>
|
|
||||||
<td style="padding: 8px; vertical-align: middle;"><%= f.check_box :active %></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p style="text-align: right; margin-top: 1em;">
|
|
||||||
<%= f.submit "Save Item", style: "padding: 6px 12px; font-weight: bold;" %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<%= link_to l(:button_cancel), items_path if controller.action_name == 'edit' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -1,37 +1,48 @@
|
|||||||
<h2>Items</h2>
|
|
||||||
|
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= link_to "New Item", new_item_path, class: "icon icon-add" %>
|
<%= link_to l(:label_item_new), new_item_path, class: 'icon icon-add' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="list items">
|
<h2><%= l(:label_items) %></h2>
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>SKU</th>
|
|
||||||
<th>Description</th>
|
|
||||||
<th>Price</th>
|
|
||||||
<th>Active</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
<% if @items.any? %>
|
||||||
<% @items.each do |item| %>
|
<div class="autoscroll">
|
||||||
<tr>
|
<table class="list items">
|
||||||
<td><%= link_to item.name, item_path(item) %></td>
|
<thead>
|
||||||
<td><%= item.sku %></td>
|
<tr>
|
||||||
<td><%= item.description %></td>
|
<th><%= l(:field_name) %></th>
|
||||||
<td><%= number_to_currency(item.unit_price) %></td>
|
<th><%= l(:field_sku) %></th>
|
||||||
<td><%= item.active ? "Yes" : "No" %></td>
|
<th><%= l(:field_description) %></th>
|
||||||
<td>
|
<th><%= l(:field_unit_price) %></th>
|
||||||
<%= link_to "Edit", edit_item_path(item), class: "icon icon-edit" %>
|
<th class="center"><%= l(:field_taxable) %></th>
|
||||||
<%= link_to "Delete", item_path(item),
|
<th class="center"><%= l(:field_active) %></th>
|
||||||
method: :delete,
|
<th></th>
|
||||||
data: { confirm: "Are you sure?" },
|
</tr>
|
||||||
class: "icon icon-del" %>
|
</thead>
|
||||||
</td>
|
<tbody>
|
||||||
</tr>
|
<% @items.each do |item| %>
|
||||||
<% end %>
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
</tbody>
|
<td class="name"><%= link_to item.name, item_path(item) %></td>
|
||||||
</table>
|
<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">
|
||||||
|
<%= item.taxable ? content_tag(:span, '', class: 'icon icon-ok') : "" %>
|
||||||
|
</td>
|
||||||
|
<td class="active center">
|
||||||
|
<%= checked_image item.active %>
|
||||||
|
</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 %>
|
||||||
@@ -1,35 +1,44 @@
|
|||||||
<h2 style="margin-bottom: 1em; border-bottom: 2px solid #ccc; padding-bottom: 4px;"><%= @item.name %></h2>
|
<div class="contextual">
|
||||||
|
<%= link_to l(:button_edit), edit_item_path(@item), class: 'icon icon-edit' %>
|
||||||
<table style="width: 100%; border-collapse: collapse; margin-bottom: 1.5em;">
|
<%= link_to l(:button_back), items_path, class: 'icon icon-list' %>
|
||||||
<tbody>
|
</div>
|
||||||
<tr style="background-color: #f9f9f9;">
|
|
||||||
<td style="padding: 8px; font-weight: bold; width: 150px;">SKU:</td>
|
<h2><%= t(:item) %># <%= @item.id %> <%= @item.name %></h2>
|
||||||
<td style="padding: 8px;"><%= @item.sku.presence || "-" %></td>
|
|
||||||
</tr>
|
<div class="issue details"> <div class="attributes">
|
||||||
<tr>
|
<div class="splitcontent">
|
||||||
<td style="padding: 8px; font-weight: bold;">Description:</td>
|
<div class="splitcontentleft">
|
||||||
<td style="padding: 8px;"><%= @item.description.presence || "-" %></td>
|
<p><strong>SKU:</strong> <%= @item.sku.presence || "-" %></p>
|
||||||
</tr>
|
<p><strong>Type:</strong> <%= @item.type.presence || "-" %></p>
|
||||||
<tr style="background-color: #f9f9f9;">
|
<p><strong>Unit Price:</strong> <%= number_to_currency(@item.unit_price) %></p>
|
||||||
<td style="padding: 8px; font-weight: bold;">Unit Price:</td>
|
</div>
|
||||||
<td style="padding: 8px;"><%= number_to_currency(@item.unit_price) %></td>
|
|
||||||
</tr>
|
<div class="splitcontentleft">
|
||||||
<tr>
|
<p><strong>Account:</strong> <%= @item.account&.name || "-" %></p>
|
||||||
<td style="padding: 8px; font-weight: bold;">Type:</td>
|
<p>
|
||||||
<td style="padding: 8px;"><%= @item.type.presence || "-" %></td>
|
<strong>Taxable:</strong>
|
||||||
</tr>
|
<% if @item.taxable %>
|
||||||
<tr style="background-color: #f9f9f9;">
|
<span class="icon icon-ok" style="color: green;">Yes</span>
|
||||||
<td style="padding: 8px; font-weight: bold;">Account:</td>
|
<% else %>
|
||||||
<td style="padding: 8px;"><%= @item.account&.name || "-" %></td>
|
<span class="icon icon-not-ok" style="color: #999;">No</span>
|
||||||
</tr>
|
<% end %>
|
||||||
<tr>
|
</p>
|
||||||
<td style="padding: 8px; font-weight: bold;">Active:</td>
|
<p>
|
||||||
<td style="padding: 8px;"><%= @item.active ? "Yes" : "No" %></td>
|
<strong>Active:</strong>
|
||||||
</tr>
|
<% if @item.active %>
|
||||||
</tbody>
|
<span class="icon icon-ok" style="color: green;">Yes</span>
|
||||||
</table>
|
<% else %>
|
||||||
|
<span class="icon icon-not-ok" style="color: #999;">No</span>
|
||||||
<div style="margin-top: 1em;">
|
<% end %>
|
||||||
<%= link_to "Edit", edit_item_path(@item), class: "btn btn-primary", style: "margin-right: 8px;" %>
|
</p>
|
||||||
<%= link_to "Back", items_path, class: "btn btn-secondary" %>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p><strong>Description:</strong></p>
|
||||||
|
<div class="wiki" style="padding-left: 20px;">
|
||||||
|
<%= @item.description.presence || "<em>No description provided</em>".html_safe %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,6 +1,39 @@
|
|||||||
<div>
|
<div class="box tabular">
|
||||||
<b><%=t(:label_item_count)%></b> <%= Item.count %> @ <%= Item.last_sync %>
|
<p>
|
||||||
<br/>
|
<label><strong><%= t(:label_item_count) %></strong></label>
|
||||||
<%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %>
|
<%= 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 : 'Never synced' %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label><strong><%= t(:label_default_account) %></strong></label>
|
||||||
|
<%= Account.get_default %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<%= link_to t(:label_sync_now), sync_items_path %>
|
|
||||||
|
<fieldset class="box">
|
||||||
|
<legend>Management & Synchronization</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>
|
||||||
@@ -11,13 +11,26 @@
|
|||||||
# English strings go here for Rails i18n
|
# English strings go here for Rails i18n
|
||||||
# Usage I18n.t(:label)
|
# Usage I18n.t(:label)
|
||||||
en:
|
en:
|
||||||
|
field_classification: "Classification"
|
||||||
|
field_sku: "SKU"
|
||||||
|
field_taxable: "Taxable"
|
||||||
|
field_unit_price: "Unit Price"
|
||||||
|
|
||||||
|
label_account: "Account"
|
||||||
|
label_accounts: "Accounts"
|
||||||
|
label_account_count: "Number of Accounts:"
|
||||||
|
label_default_account: "Default Item Income Account"
|
||||||
label_description: "Description"
|
label_description: "Description"
|
||||||
label_item: "Item"
|
label_item: "Item"
|
||||||
label_item_count: "Item Count:"
|
label_item_count: "Item Count:"
|
||||||
|
label_items: "Items"
|
||||||
label_line_items: "Line Items"
|
label_line_items: "Line Items"
|
||||||
label_price: "Unit Price"
|
label_price: "Unit Price"
|
||||||
label_qty: "Quantity"
|
label_qty: "Quantity"
|
||||||
label_remove: "Remove"
|
label_remove: "Remove"
|
||||||
|
label_sync_now_accounts: "Sync Accounts"
|
||||||
|
label_sync_now_items: "Sync Items"
|
||||||
label_total: "Total"
|
label_total: "Total"
|
||||||
|
|
||||||
notice_added_from: "Added from issue #"
|
notice_added_from: "Added from issue #"
|
||||||
|
|
||||||
@@ -18,5 +18,6 @@ end
|
|||||||
resources :accounts do
|
resources :accounts do
|
||||||
collection do
|
collection do
|
||||||
patch :set_default
|
patch :set_default
|
||||||
|
get :sync
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user