mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-19 18:40:36 -05:00
Compare commits
3
Commits
2026.11.12
...
2026.11.13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1fb88e77c | ||
|
|
0a7b2e34b8 | ||
|
|
895733f534 |
No files matched your search
+3
-2
@@ -23,16 +23,17 @@ class Qbo < ActiveRecord::Base
|
|||||||
return I18n.t(:label_qbo_never_synced)
|
return I18n.t(:label_qbo_never_synced)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Token expiry times, or nil when QuickBooks isn't connected (the settings page shows N/A)
|
||||||
def self.oauth2_access_token_expires_at
|
def self.oauth2_access_token_expires_at
|
||||||
QboConnectionService.current!.oauth2_access_token_expires_at
|
QboConnectionService.current!.oauth2_access_token_expires_at
|
||||||
rescue
|
rescue
|
||||||
return I18n.t(:label_qbo_never_synced)
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.oauth2_refresh_token_expires_at
|
def self.oauth2_refresh_token_expires_at
|
||||||
QboConnectionService.current!.oauth2_refresh_token_expires_at
|
QboConnectionService.current!.oauth2_refresh_token_expires_at
|
||||||
rescue
|
rescue
|
||||||
return I18n.t(:label_qbo_never_synced)
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updates last sync time stamp
|
# Updates last sync time stamp
|
||||||
|
|||||||
@@ -16,6 +16,36 @@
|
|||||||
multiple: true, size: 8, id: 'settings_labor_item_ids' %>
|
multiple: true, size: 8, id: 'settings_labor_item_ids' %>
|
||||||
<em class="info"><%= l(:text_labor_items) %></em>
|
<em class="info"><%= l(:text_labor_items) %></em>
|
||||||
</p>
|
</p>
|
||||||
|
<%# QuickBooks custom fields to leave out of estimates and invoices (see RedmineQboBilling::Company). Hidden
|
||||||
|
fields that aren't found right now (e.g. no recent estimate has them) are kept as hidden. %>
|
||||||
|
<% company = RedmineQboBilling::Company %>
|
||||||
|
<% qbo_fields = company.all_custom_fields %>
|
||||||
|
<% hidden_ids = company.hidden_field_ids %>
|
||||||
|
<% sales_field = company.sales_person_field %>
|
||||||
|
<p class="qbo-custom-fields-setting">
|
||||||
|
<label><%= l(:label_qbo_hidden_custom_fields) %></label>
|
||||||
|
<%= hidden_field_tag 'settings[hidden_custom_field_ids][]', '', id: nil %>
|
||||||
|
<% (hidden_ids - qbo_fields.map { |f| f.id.to_i }).each do |id| %>
|
||||||
|
<%= hidden_field_tag 'settings[hidden_custom_field_ids][]', id, id: nil %>
|
||||||
|
<% end %>
|
||||||
|
<% if qbo_fields.empty? %>
|
||||||
|
<%= l(:label_none) %>
|
||||||
|
<% else %>
|
||||||
|
<% qbo_fields.each do |field| %>
|
||||||
|
<label class="block">
|
||||||
|
<%= check_box_tag 'settings[hidden_custom_field_ids][]', field.id, hidden_ids.include?(field.id.to_i),
|
||||||
|
id: "settings_hidden_custom_field_#{field.id}" %>
|
||||||
|
<%= field.name %>
|
||||||
|
<% if sales_field && sales_field.id.to_i == field.id.to_i %>
|
||||||
|
<em>(<%= l(:text_qbo_sales_person_field) %>)</em>
|
||||||
|
<% end %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to sprite_icon('reload', l(:button_refresh_quickbooks_fields)), refresh_company_qbo_estimates_path,
|
||||||
|
method: :post, class: 'icon icon-reload' %>
|
||||||
|
<em class="info"><%= l(:text_qbo_hidden_custom_fields) %></em>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% issue_builder = RedmineQboBilling::EstimateIssueBuilder %>
|
<% issue_builder = RedmineQboBilling::EstimateIssueBuilder %>
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ en:
|
|||||||
button_email_estimate: "Email"
|
button_email_estimate: "Email"
|
||||||
button_open_in_quickbooks: "Open in QuickBooks"
|
button_open_in_quickbooks: "Open in QuickBooks"
|
||||||
button_refresh_quickbooks_fields: "Refresh QuickBooks fields"
|
button_refresh_quickbooks_fields: "Refresh QuickBooks fields"
|
||||||
|
label_qbo_hidden_custom_fields: "Hide QuickBooks custom fields"
|
||||||
|
text_qbo_sales_person_field: "filled in with the sales person"
|
||||||
|
text_qbo_hidden_custom_fields: "Ticked fields are left off estimates and invoices. QuickBooks doesn't tell apps which custom fields are inactive, and a field stays on its old estimates after it's turned off, so tick ones you no longer use (e.g. a renamed \"Sales Rep old\"). The sales person goes in the first field shown whose name has \"sales\" or \"rep\" in it."
|
||||||
button_reload_estimate: "Reload the estimate"
|
button_reload_estimate: "Reload the estimate"
|
||||||
button_save_and_send: "Save and send"
|
button_save_and_send: "Save and send"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
name 'Redmine QBO plugin'
|
name 'Redmine QBO plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'A pluging for Redmine to connect with QuickBooks Online: customers, time activities for billable hours when an issue is closed, and estimates, invoices and payments written in Redmine'
|
description 'A pluging for Redmine to connect with QuickBooks Online: customers, time activities for billable hours when an issue is closed, and estimates, invoices and payments written in Redmine'
|
||||||
version '2026.11.12'
|
version '2026.11.13'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
settings default: {empty: true}, partial: 'qbo/settings'
|
settings default: {empty: true}, partial: 'qbo/settings'
|
||||||
|
|||||||
@@ -34,11 +34,26 @@ module RedmineQboBilling
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
# All enabled sales form custom fields, in QuickBooks' order
|
# The sales form custom fields the plugin uses, in QuickBooks' order: all those found, except the ones
|
||||||
|
# hidden in the plugin settings. Everything else (the editor, the sales person, other plugins' VIN and
|
||||||
|
# mileage) goes through here, so a hidden field is never shown or filled in.
|
||||||
def custom_fields
|
def custom_fields
|
||||||
|
hidden = hidden_field_ids
|
||||||
|
all_custom_fields.reject { |f| hidden.include?(f.id.to_i) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Every custom field found, hidden ones included (listed on the plugin settings page)
|
||||||
|
def all_custom_fields
|
||||||
Array(settings[:custom_fields]).map { |f| Field.new(f[:id], f[:name]) }
|
Array(settings[:custom_fields]).map { |f| Field.new(f[:id], f[:name]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Fields hidden in the plugin settings. QuickBooks doesn't tell apps which custom fields are inactive,
|
||||||
|
# and a field stays on its old estimates after it's turned off (e.g. a renamed "Sales Rep old"), so the
|
||||||
|
# plugin can't leave those out by itself.
|
||||||
|
def hidden_field_ids
|
||||||
|
Array((Setting.plugin_redmine_qbo || {})['hidden_custom_field_ids']).map(&:to_i).reject(&:zero?)
|
||||||
|
end
|
||||||
|
|
||||||
# The first enabled custom field whose name matches, e.g. a plugin's VIN field (/\bvin\b/i), or nil
|
# The first enabled custom field whose name matches, e.g. a plugin's VIN field (/\bvin\b/i), or nil
|
||||||
def custom_field_matching(pattern)
|
def custom_field_matching(pattern)
|
||||||
custom_fields.detect { |f| f.name.to_s =~ pattern }
|
custom_fields.detect { |f| f.name.to_s =~ pattern }
|
||||||
|
|||||||
Reference in new issue
Block a user