mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Added accounts to allow for assinging income account to items, and selecting default income account. Also added item type selection
This commit is contained in:
39
app/views/accounts/index.html.erb
Normal file
39
app/views/accounts/index.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<h1>Accounts</h1>
|
||||
|
||||
<%= form_with url: set_default_accounts_path, method: :patch, local: true do %>
|
||||
<table style="width:100%; border-collapse: collapse; margin-bottom: 1em;">
|
||||
<thead style="background-color: #f2f2f2;">
|
||||
<tr>
|
||||
<th style="padding: 8px; border: 1px solid #ddd;">Default</th>
|
||||
<th style="padding: 8px; border: 1px solid #ddd;">Name</th>
|
||||
<th style="padding: 8px; border: 1px solid #ddd;">Description</th>
|
||||
<th style="padding: 8px; border: 1px solid #ddd;">Classification</th>
|
||||
<th style="padding: 8px; border: 1px solid #ddd;">Active</th>
|
||||
</tr>
|
||||
</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>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5" style="padding: 8px; text-align: right;">
|
||||
<%= submit_tag "Save Default Account", style: "padding: 6px 12px; font-weight: bold;" %>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<% end %>
|
||||
@@ -1,8 +1,8 @@
|
||||
<%= form_with model: @item, local: true do |f| %>
|
||||
|
||||
<% if @item.errors.any? %>
|
||||
<div id="errorExplanation">
|
||||
<h2><%= pluralize(@item.errors.count, "error") %></h2>
|
||||
<div id="errorExplanation" style="border: 1px solid #f00; padding: 10px; background-color: #fee; margin-bottom: 1em;">
|
||||
<h2 style="color: #900;"><%= pluralize(@item.errors.count, "error") %> prohibited this item from being saved:</h2>
|
||||
<ul>
|
||||
<% @item.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
@@ -11,33 +11,59 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<%= f.label :name %><br>
|
||||
<%= f.text_field :name, required: true %>
|
||||
</p>
|
||||
<table style="width: 100%; border-collapse: collapse;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<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>
|
||||
|
||||
<p>
|
||||
<%= f.label :sku %><br>
|
||||
<%= f.text_field :sku %>
|
||||
</p>
|
||||
<tr>
|
||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :sku %></td>
|
||||
<td style="padding: 8px;"><%= f.text_field :sku, style: "width: 100%;" %></td>
|
||||
</tr>
|
||||
|
||||
<p>
|
||||
<%= f.label :description %><br>
|
||||
<%= f.text_area :description, rows: 3 %>
|
||||
</p>
|
||||
<tr>
|
||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :description %></td>
|
||||
<td style="padding: 8px;"><%= f.text_area :description, rows: 3, style: "width: 100%;" %></td>
|
||||
</tr>
|
||||
|
||||
<p>
|
||||
<%= f.label :unit_price %><br>
|
||||
<%= f.number_field :unit_price, step: 0.01 %>
|
||||
</p>
|
||||
<tr>
|
||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :unit_price %></td>
|
||||
<td style="padding: 8px;"><%= f.number_field :unit_price, step: 0.01, style: "width: 100%;" %></td>
|
||||
</tr>
|
||||
|
||||
<p>
|
||||
<%= f.label :active %>
|
||||
<%= f.check_box :active %>
|
||||
</p>
|
||||
<tr>
|
||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :account %></td>
|
||||
<td style="padding: 8px;">
|
||||
<%= f.collection_select :account_id,
|
||||
Account.where(classification: 'Revenue').order(:name),
|
||||
:id,
|
||||
:name,
|
||||
{ selected: @item.account_id || Account.get_default&.id },
|
||||
{ include_blank: true, style: "width: 100%;" } %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<p>
|
||||
<%= f.submit %>
|
||||
<tr>
|
||||
<td style="padding: 8px; vertical-align: top;"><%= f.label :type %></td>
|
||||
<td style="padding: 8px;">
|
||||
<%= f.select :type,
|
||||
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>
|
||||
|
||||
<% end %>
|
||||
@@ -1,26 +1,35 @@
|
||||
<h2><%= @item.name %></h2>
|
||||
<h2 style="margin-bottom: 1em; border-bottom: 2px solid #ccc; padding-bottom: 4px;"><%= @item.name %></h2>
|
||||
|
||||
<p>
|
||||
<strong>SKU:</strong>
|
||||
<%= @item.sku %>
|
||||
</p>
|
||||
<table style="width: 100%; border-collapse: collapse; margin-bottom: 1.5em;">
|
||||
<tbody>
|
||||
<tr style="background-color: #f9f9f9;">
|
||||
<td style="padding: 8px; font-weight: bold; width: 150px;">SKU:</td>
|
||||
<td style="padding: 8px;"><%= @item.sku.presence || "-" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px; font-weight: bold;">Description:</td>
|
||||
<td style="padding: 8px;"><%= @item.description.presence || "-" %></td>
|
||||
</tr>
|
||||
<tr style="background-color: #f9f9f9;">
|
||||
<td style="padding: 8px; font-weight: bold;">Unit Price:</td>
|
||||
<td style="padding: 8px;"><%= number_to_currency(@item.unit_price) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px; font-weight: bold;">Type:</td>
|
||||
<td style="padding: 8px;"><%= @item.type.presence || "-" %></td>
|
||||
</tr>
|
||||
<tr style="background-color: #f9f9f9;">
|
||||
<td style="padding: 8px; font-weight: bold;">Account:</td>
|
||||
<td style="padding: 8px;"><%= @item.account&.name || "-" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px; font-weight: bold;">Active:</td>
|
||||
<td style="padding: 8px;"><%= @item.active ? "Yes" : "No" %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<strong>Description:</strong>
|
||||
<%= @item.description %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Unit Price:</strong>
|
||||
<%= number_to_currency(@item.unit_price) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Active:</strong>
|
||||
<%= @item.active ? "Yes" : "No" %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to "Edit", edit_item_path(@item), class: "icon icon-edit" %>
|
||||
<%= link_to "Back", items_path %>
|
||||
</p>
|
||||
<div style="margin-top: 1em;">
|
||||
<%= link_to "Edit", edit_item_path(@item), class: "btn btn-primary", style: "margin-right: 8px;" %>
|
||||
<%= link_to "Back", items_path, class: "btn btn-secondary" %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user