mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-07-01 16:51:07 -04:00
Compare commits
4 Commits
b939d834e9
...
0acf5ffca4
| Author | SHA1 | Date | |
|---|---|---|---|
| 0acf5ffca4 | |||
| 5b1d98aa07 | |||
| 3ca45a457f | |||
| c9d2a47a92 |
@@ -1,39 +1,57 @@
|
||||
<% if @issue.line_items.any? %>
|
||||
<% if @issue.line_items.any? || @issue.descendant_line_items_total > 0%>
|
||||
<hr/>
|
||||
<div>
|
||||
<p><strong><%= t :label_line_items %></strong></p>
|
||||
|
||||
<table class="list line-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:70%;"><%= t :label_description %></th>
|
||||
<th style="width:10%;"><%= t :label_qty %></th>
|
||||
<th style="width:10%;"><%= t :label_price %></th>
|
||||
<th style="width:10%;"><%= t :label_total %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% total = 0 %>
|
||||
|
||||
<tbody>
|
||||
<% total = 0 %>
|
||||
|
||||
<% @issue.line_items.each do |item| %>
|
||||
<% line_total = item.quantity.to_f * item.unit_price.to_f %>
|
||||
<% total += line_total %>
|
||||
<% if @issue.line_items.any?%>
|
||||
|
||||
<table class="list line-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><%= h item.description %></td>
|
||||
<td><%= item.quantity %></td>
|
||||
<td><%= number_to_currency(item.unit_price) %></td>
|
||||
<td><%= number_to_currency(line_total) %></td>
|
||||
<th style="width:70%;"><%= t :label_description %></th>
|
||||
<th style="width:10%;"><%= t :label_qty %></th>
|
||||
<th style="width:10%;"><%= t :label_price %></th>
|
||||
<th style="width:10%;"><%= t :label_total %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<% @issue.line_items.each do |item| %>
|
||||
<% line_total = item.quantity.to_f * item.unit_price.to_f %>
|
||||
<% total += line_total %>
|
||||
|
||||
<tr>
|
||||
<td><%= h item.description %></td>
|
||||
<td><%= item.quantity %></td>
|
||||
<td><%= number_to_currency(item.unit_price) %></td>
|
||||
<td><%= number_to_currency(line_total) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
<% end %>
|
||||
|
||||
<tfoot>
|
||||
<% if @issue.line_items.any?%>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align:right;"><strong><%= t :label_total %></strong></td>
|
||||
<td>
|
||||
<strong><%= number_to_currency(total) %></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if @issue.descendant_line_items_total > 0 %>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align:right;"><strong><%= t :label_running_total %></strong></td>
|
||||
<td>
|
||||
<strong>(<%= number_to_currency(@issue.descendant_line_items_total + total) %>)</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align:right;"><strong><%= t :label_total %></strong></td>
|
||||
<td><strong><%= number_to_currency(total) %></strong></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,7 @@ en:
|
||||
label_no: "No"
|
||||
label_qty: "Quantity"
|
||||
label_remove: "Remove"
|
||||
label_running_total: "Running Total"
|
||||
label_sync_now_accounts: "Sync Accounts"
|
||||
label_sync_now_items: "Sync Items"
|
||||
label_type: "Type"
|
||||
|
||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_lineitems do
|
||||
name 'Redmine QBO Line Items plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'A plugin for Redmine to extend the capabilitys of the Redmine QuickBooks Online plugin to attach billable line items to an isuue'
|
||||
version '2026.4.0'
|
||||
version '2026.4.2'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo_lineitems'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine version_or_higher: '6.1.0'
|
||||
|
||||
@@ -16,6 +16,30 @@ module LineItems
|
||||
has_many :line_items, dependent: :destroy
|
||||
accepts_nested_attributes_for :line_items, allow_destroy: true, reject_if: proc { |attrs| attrs['description'].blank? }
|
||||
|
||||
# Returns line items for immediate children
|
||||
def children_line_items
|
||||
LineItem.where(issue_id: self.children.pluck(:id))
|
||||
end
|
||||
|
||||
# Calculates the total value of all child line items
|
||||
def children_line_items_total
|
||||
children_line_items.sum(:line_total)
|
||||
end
|
||||
|
||||
# Returns line items for the entire tree below this issue
|
||||
def descendant_line_items
|
||||
LineItem.where(issue_id: self.descendants.pluck(:id))
|
||||
end
|
||||
|
||||
# Calculates the total value of entire tree below this issue
|
||||
def descendant_line_items_total
|
||||
descendant_line_items.sum(:line_total)
|
||||
end
|
||||
|
||||
def line_items_total
|
||||
line_items.sum(:line_total)
|
||||
end
|
||||
|
||||
def line_items_attributes=(attrs)
|
||||
attrs = attrs.stringify_keys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user