mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-08-19 12:50:43 -04:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b72c82fb2b | ||
|
|
b901e64149 | ||
|
|
7abb1aa06c | ||
|
|
dfd3a641db | ||
|
|
75e5aeb668 | ||
|
|
ea29990cfa | ||
|
|
c31ec82e61 | ||
|
|
938f9d9f3b | ||
|
|
f2b0186ee2 | ||
|
|
9373963c94 | ||
|
|
396a56ceec | ||
|
|
b3c3006b56 | ||
|
|
576ca5a0a9 | ||
|
|
d18a0c180a | ||
|
|
baca0ed6c7 | ||
|
|
6bf84dd61a | ||
|
|
61b02831e3 | ||
|
|
7c79f2388a | ||
|
|
36267893bd | ||
|
|
e681203a45 | ||
|
|
681e7f8047 | ||
|
|
4a6c414d9e |
@@ -89,17 +89,6 @@ Supported automation:
|
|||||||
|
|
||||||
Invoices containing an Issue reference (e.g. `#123`) automatically attach to the corresponding Issue.
|
Invoices containing an Issue reference (e.g. `#123`) automatically attach to the corresponding Issue.
|
||||||
|
|
||||||
### Custom Field Synchronization
|
|
||||||
|
|
||||||
Invoice custom fields can be mapped to Issue custom fields.
|
|
||||||
|
|
||||||
Example use case:
|
|
||||||
|
|
||||||
* Mileage In/Out recorded in Redmine
|
|
||||||
|
|
||||||
* Automatically synchronized to the QuickBooks invoice.
|
|
||||||
|
|
||||||
|
|
||||||
### Customer Synchronization
|
### Customer Synchronization
|
||||||
|
|
||||||
Customer records are automatically updated in the local database when changes occur in QuickBooks.
|
Customer records are automatically updated in the local database when changes occur in QuickBooks.
|
||||||
@@ -119,9 +108,10 @@ Available hooks:
|
|||||||
|
|
||||||
|Type|Hook|Note
|
|Type|Hook|Note
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|
View Hook|:customer_actions_top, { customer: @customer }| Used to add action links to customer view
|
||||||
|
View Hook|:customer_actions_bottom, { customer: @customer} | Used to add action links to customer view
|
||||||
View Hook|:pdf_left, { issue: issue } | Used to add text to left side of PDF
|
View Hook|:pdf_left, { issue: issue } | Used to add text to left side of PDF
|
||||||
View Hook|:pdf_right, { issue: issue } | Used to add text to right side of PDF
|
View Hook|:pdf_right, { issue: issue } | Used to add text to right side of PDF
|
||||||
Hook|process_invoice_custom_fields, { issue: issue, invoice: invoice } | Used to process invoice custom fields
|
|
||||||
View Hook|:show_customer_view_right, { customer: customer } | Used to show partials on right side of customer view
|
View Hook|:show_customer_view_right, { customer: customer } | Used to show partials on right side of customer view
|
||||||
Hook| :qbo_additional_entities | Used to add additional entites to be processed by the WebhookProcessJob
|
Hook| :qbo_additional_entities | Used to add additional entites to be processed by the WebhookProcessJob
|
||||||
Hook| :qbo_full_sync | Used to add a Class to be called by the QboSyncDispatcher
|
Hook| :qbo_full_sync | Used to add a Class to be called by the QboSyncDispatcher
|
||||||
@@ -154,7 +144,7 @@ https://redmine.yourdomain.com/qbo/webhook
|
|||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
## 1\. Clone the Plugin
|
## 1. Clone the Plugin
|
||||||
|
|
||||||
Install the plugin into your Redmine plugins directory.
|
Install the plugin into your Redmine plugins directory.
|
||||||
|
|
||||||
@@ -169,7 +159,7 @@ Use a **tagged release** for stability.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2\. Install Dependencies
|
## 2. Install Dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bundle install
|
bundle install
|
||||||
@@ -179,7 +169,7 @@ Required for **Redmine 6 / Rails 7 compatibility**.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3\. Run Database Migrations
|
## 3. Run Database Migrations
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
||||||
@@ -187,7 +177,7 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 4\. Restart Redmine
|
## 4. Restart Redmine
|
||||||
|
|
||||||
Restart your Redmine server so the plugin and hooks are loaded.
|
Restart your Redmine server so the plugin and hooks are loaded.
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class Customer < QboBaseModel
|
|||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
qbo_sync push: true
|
qbo_sync push: true
|
||||||
|
|
||||||
|
# Normalize the local database column :name
|
||||||
|
normalizes :name, with: ->(name) { name.to_s.strip.titleize }
|
||||||
|
|
||||||
acts_as_searchable columns: %w[name phone_number mobile_phone_number ],
|
acts_as_searchable columns: %w[name phone_number mobile_phone_number ],
|
||||||
scope: ->(_context) { left_joins(:project) },
|
scope: ->(_context) { left_joins(:project) },
|
||||||
date_column: :updated_at
|
date_column: :updated_at
|
||||||
@@ -61,8 +64,9 @@ class Customer < QboBaseModel
|
|||||||
|
|
||||||
# Updates Both local DB name & QBO display_name
|
# Updates Both local DB name & QBO display_name
|
||||||
def name=(s)
|
def name=(s)
|
||||||
details.display_name = s
|
super(s)
|
||||||
super
|
# Write the normalized value from Active Record to QBO details
|
||||||
|
details.display_name = self.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalizes phone numbers by removing non-digit characters. This method is called before validation to ensure that phone numbers are stored in a consistent format, which can help with searching and integration with external systems like QuickBooks Online.
|
# Normalizes phone numbers by removing non-digit characters. This method is called before validation to ensure that phone numbers are stored in a consistent format, which can help with searching and integration with external systems like QuickBooks Online.
|
||||||
|
|||||||
@@ -10,12 +10,16 @@
|
|||||||
|
|
||||||
class Estimate < QboBaseModel
|
class Estimate < QboBaseModel
|
||||||
|
|
||||||
has_and_belongs_to_many :issues
|
has_many :issues
|
||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
validates_presence_of :doc_number, :id
|
validates_presence_of :doc_number, :id
|
||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
qbo_sync push: false
|
qbo_sync push: false
|
||||||
|
|
||||||
|
def name
|
||||||
|
to_s
|
||||||
|
end
|
||||||
|
|
||||||
# returns a human readable string
|
# returns a human readable string
|
||||||
def to_s
|
def to_s
|
||||||
return self[:doc_number]
|
return self[:doc_number]
|
||||||
|
|||||||
@@ -8,31 +8,6 @@
|
|||||||
#
|
#
|
||||||
#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.
|
#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 InvoicePushService
|
class EstimateService < ServiceBase
|
||||||
|
|
||||||
def initialize(invoice)
|
|
||||||
@invoice = invoice
|
|
||||||
end
|
|
||||||
|
|
||||||
# Push invoice changes to QBO if the invoice is linked to any issues with custom field changes that need to be synced
|
|
||||||
def push
|
|
||||||
return if @invoice.qbo_sync_locked?
|
|
||||||
log "Pushing invoice ##{@invoice.id} to QBO due to linked issue custom field changes"
|
|
||||||
@invoice.update_column(:qbo_sync_locked, true)
|
|
||||||
remote = QboConnectionService.with_qbo_service(entity: Invoice) do |service|
|
|
||||||
remote = service.fetch_by_id(@invoice.id)
|
|
||||||
# modify remote object here if needed
|
|
||||||
service.update(remote)
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
Rails.logger.error "[InvoicePushService] #{e.message}"
|
|
||||||
ensure
|
|
||||||
@invoice.update_column(:qbo_sync_locked, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def log(msg)
|
|
||||||
Rails.logger.info "[InvoicePushService] #{msg}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -29,8 +29,6 @@ class InvoiceAttachmentService
|
|||||||
issue.save! if issue.changed?
|
issue.save! if issue.changed?
|
||||||
log "Attached invoice ##{@invoice.id} to issue ##{issue.id}"
|
log "Attached invoice ##{@invoice.id} to issue ##{issue.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
InvoiceCustomFieldSyncService.new(issue, @invoice, @remote).sync
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
#The MIT License (MIT)
|
|
||||||
#
|
|
||||||
#Copyright (c) 2016 - 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 InvoiceCustomFieldSyncService
|
|
||||||
|
|
||||||
def initialize(issue, invoice, remote)
|
|
||||||
@issue = issue
|
|
||||||
@invoice = invoice
|
|
||||||
@remote = remote
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sync custom fields on the issue based on the invoice data, then push changes to QBO if any fields were updated
|
|
||||||
def sync
|
|
||||||
return if @invoice.qbo_sync_locked?
|
|
||||||
|
|
||||||
log "Syncing custom fields for issue ##{@issue.id} based on invoice ##{@invoice.doc_number}"
|
|
||||||
|
|
||||||
changed = false
|
|
||||||
|
|
||||||
# Process Invoice Custom Fields via Hooks
|
|
||||||
Redmine::Hook.call_hook(
|
|
||||||
:process_invoice_custom_fields,
|
|
||||||
issue: @issue,
|
|
||||||
invoice: @remote
|
|
||||||
).each do |context|
|
|
||||||
next unless context
|
|
||||||
changed ||= context[:is_changed]
|
|
||||||
log "Custom fields updated by hook, marking invoice for push to QBO" if context[:is_changed]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Process Issue Custom Values from any issue custom fields that match the invoice custom fields
|
|
||||||
begin
|
|
||||||
value = @issue.custom_values.find_by(custom_field_id: CustomField.find_by_name(cf.name).id)
|
|
||||||
|
|
||||||
# Check to see if the value is blank...
|
|
||||||
if not value.value.to_s.blank?
|
|
||||||
# Check to see if the value is diffrent
|
|
||||||
if not cf.string_value.to_s.eql? value.value.to_s
|
|
||||||
# update the custom field on the invoice
|
|
||||||
cf.string_value = value.value.to_s
|
|
||||||
is_changed = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
# Nothing to do here, there is no match
|
|
||||||
end
|
|
||||||
|
|
||||||
push_if_changed if changed
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# If any custom fields were changed during the sync process, this method will trigger a push of the invoice data to QuickBooks Online to ensure that the remote data stays in sync with the local changes. It uses the InvoicePushService to handle the actual communication with QBO.
|
|
||||||
def push_if_changed
|
|
||||||
InvoicePushService.new(@invoice).push
|
|
||||||
end
|
|
||||||
|
|
||||||
def log(msg)
|
|
||||||
Rails.logger.info "[InvoiceCustomFieldSyncService] #{msg}"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,11 +1,73 @@
|
|||||||
<%= link_to t(:label_appointment), "https://calendar.google.com/calendar/render?action=TEMPLATE&text=#{@customer.name}+-&details=#{ link_to t(:customer_details), "https://#{Setting.host_name}#{customer_path @customer.id}"}%0A#{@customer.primary_phone}%3Cbr/%3E+&dates=#{Time.now.strftime("%Y%m%d")}T090000/#{Time.now.strftime("%Y%m%d")}T170000", target: :_blank, id: :appointment_link %>
|
<%= call_hook :customer_actions_top, { customer: @customer } %>
|
||||||
|
|
||||||
<br/>
|
<p>
|
||||||
<br/>
|
<%= link_to t(:label_new_issue), new_issue_path(issue: { customer_id: @customer.id }), id: "dynamic-new-issue-link", target: :_blank %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<%= link_to t(:label_create_estimate), "https://qbo.intuit.com/app/estimate?nameId=#{@customer.id}", target: :_blank %>
|
<p>
|
||||||
|
<%= link_to t(:label_create_estimate), "https://qbo.intuit.com/app/estimate?nameId=#{@customer.id}", target: :_blank %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<br/>
|
<p>
|
||||||
<br/>
|
<%= link_to t(:label_create_payment), "https://qbo.intuit.com/app/recvpayment?nameId=#{@customer.id}", target: :_blank %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<%= call_hook :customer_actions_bottom, { customer: @customer } %>
|
||||||
|
|
||||||
<%= button_to t(:label_edit_customer), edit_customer_path(@customer), method: :get%>
|
<%= button_to t(:label_edit_customer), edit_customer_path(@customer), method: :get%>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function handleSingleSelect(event, className) {
|
||||||
|
if (event.target.checked) {
|
||||||
|
// Uncheck all other checkboxes of the same type
|
||||||
|
document.querySelectorAll('.' + className).forEach(cb => {
|
||||||
|
if (cb !== event.target) {
|
||||||
|
cb.checked = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
updateLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind single-select behavior to checkboxes once the DOM is loaded
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
document.querySelectorAll('.estimate-checkbox').forEach(cb => {
|
||||||
|
cb.addEventListener('change', (e) => handleSingleSelect(e, 'estimate-checkbox'));
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.vehicle-checkbox').forEach(cb => {
|
||||||
|
cb.addEventListener('change', (e) => handleSingleSelect(e, 'vehicle-checkbox'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateLink() {
|
||||||
|
const link = document.getElementById('dynamic-new-issue-link');
|
||||||
|
if (!link) return;
|
||||||
|
|
||||||
|
// Cache the pristine base URL on first run
|
||||||
|
if (!link.dataset.baseUrl) {
|
||||||
|
link.dataset.baseUrl = link.getAttribute('href');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build base URL object
|
||||||
|
let url = new URL(link.dataset.baseUrl, window.location.origin);
|
||||||
|
|
||||||
|
// 1. Handle Single Estimate
|
||||||
|
const checkedEstimate = document.querySelector('.estimate-checkbox:checked');
|
||||||
|
if (checkedEstimate) {
|
||||||
|
url.searchParams.set('issue[estimate_id]', checkedEstimate.value);
|
||||||
|
} else {
|
||||||
|
url.searchParams.delete('issue[estimate_id]');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Handle Single Vehicle
|
||||||
|
const checkedVehicle = document.querySelector('.vehicle-checkbox:checked');
|
||||||
|
if (checkedVehicle) {
|
||||||
|
url.searchParams.set('issue[vehicle_id]', checkedVehicle.value);
|
||||||
|
} else {
|
||||||
|
url.searchParams.delete('issue[vehicle_id]');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the link's href attribute
|
||||||
|
link.setAttribute('href', url.toString());
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -2,57 +2,53 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_name)%></th>
|
<th><%= t(:label_name) %></th>
|
||||||
<td><%= customer.name %></td>
|
<td><%= customer.name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_email)%></th>
|
<th><%= t(:label_email) %></th>
|
||||||
<td><%= customer.email %></td>
|
<td><%= customer.email %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_primary_phone)%></th>
|
<th><%= t(:label_primary_phone) %></th>
|
||||||
<td><%= number_to_phone(customer&.primary_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td>
|
<td><%= number_to_phone(customer&.primary_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_mobile_phone)%></th>
|
<th><%= t(:label_mobile_phone) %></th>
|
||||||
<td><%= number_to_phone(customer&.mobile_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td>
|
<td><%= number_to_phone(customer&.mobile_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_billing_address)%></th>
|
<th><%= t(:label_billing_address) %></th>
|
||||||
<td><pre><%= @billing_address %></pre></td>
|
<td><pre><%= @billing_address %></pre></td>
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th><%=t(:label_shipping_address)%></th>
|
|
||||||
<td><pre><%= @shipping_address %></pre></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_account_balance)%></th>
|
<th><%= t(:label_shipping_address) %></th>
|
||||||
<td>$<%= customer.balance %></td>
|
<td><pre><%= @shipping_address %></pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2"><h4><%=t(:field_notes)%></hr></th>
|
<th><%= t(:label_account_balance) %></th>
|
||||||
|
<td>$<%= customer.balance %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<% if customer.notes.present? %>
|
||||||
<td colspan="2">
|
<tr>
|
||||||
<pre id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit;">
|
<th colspan="2"><h4><%= t(:field_notes) %></h4></th>
|
||||||
<%= customer.notes %>
|
</tr>
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<script>
|
<tr>
|
||||||
const preElement = document.getElementById('note-display');
|
<td colspan="2">
|
||||||
// This takes the text, trims the edges, and puts it back
|
<div class="wiki">
|
||||||
preElement.textContent = preElement.textContent.trim();
|
<%= textilizable(customer, :notes) %>
|
||||||
</script>
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<%=t(:label_display_name)%>
|
<%=t(:label_display_name)%>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= f.text_field :name, required: true, autocomplete: "off" %>
|
<%= f.text_field :name, required: true, class: "customer-name", autocomplete: "off", data: { autocomplete_url: "/customers/autocomplete" } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -32,20 +32,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<%=t(:field_notes)%>:
|
<%=t(:field_notes)%>:
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<p>
|
<p>
|
||||||
<%= content_tag :span, id: "issue_description_and_toolbar" do %>
|
<%= f.text_area :notes,
|
||||||
<%= f.text_area :notes,
|
rows: 8,
|
||||||
cols: 60,
|
class: 'wiki-edit',
|
||||||
rows: 10,
|
style: 'width: 95%;',
|
||||||
accesskey: accesskey(:edit),
|
id: 'customer_appointment_description' %>
|
||||||
class: 'wiki-edit',
|
<%= wikitoolbar_for 'customer_appointment_description' %>
|
||||||
no_label: true %>
|
</p>
|
||||||
<% end %>
|
|
||||||
</p>
|
|
||||||
<%= wikitoolbar_for :issue_description %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<% estimates.sort.reverse.each do |estimate| %>
|
<% estimates.sort.reverse.each do |estimate| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<%= check_box_tag "estimate_ids[]", estimate.id, false, onchange: "updateLink()", data: { url: estimate_path(estimate), text: "Estimate ##{estimate.to_s}" }, class: "estimate-checkbox appointment" %>
|
<%= check_box_tag "estimate_ids[]", estimate.id, false, onchange: "updateLink()", data: { text: "Estimate ##{estimate.doc_number}" }, class: "estimate-checkbox appointment" %>
|
||||||
<b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %></b> <%= estimate.txn_date %>
|
<b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %></b> <%= estimate.txn_date %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ en:
|
|||||||
label_closed_issues: "Closed Issues"
|
label_closed_issues: "Closed Issues"
|
||||||
label_connected: "Successfully connected to QuickBooks"
|
label_connected: "Successfully connected to QuickBooks"
|
||||||
label_create_estimate: "Create Estimate"
|
label_create_estimate: "Create Estimate"
|
||||||
|
label_create_payment: "Create Payment"
|
||||||
label_customer_count: "Customer Count"
|
label_customer_count: "Customer Count"
|
||||||
label_customer_link_expires: "This customer link expires in"
|
label_customer_link_expires: "This customer link expires in"
|
||||||
|
label_customer: "Customer"
|
||||||
label_customers: "Customers"
|
label_customers: "Customers"
|
||||||
label_delete: "Delete"
|
label_delete: "Delete"
|
||||||
label_deposit_into: "Deposit to Account"
|
label_deposit_into: "Deposit to Account"
|
||||||
@@ -49,6 +51,7 @@ en:
|
|||||||
label_error: "Error"
|
label_error: "Error"
|
||||||
label_estimate_404: "Estimate not found"
|
label_estimate_404: "Estimate not found"
|
||||||
label_estimate_count: "Estimate Count"
|
label_estimate_count: "Estimate Count"
|
||||||
|
label_estimate: "Estimate"
|
||||||
label_estimates: "Estimates"
|
label_estimates: "Estimates"
|
||||||
label_hours: "Hours"
|
label_hours: "Hours"
|
||||||
label_invoice_404: "Invoice not found"
|
label_invoice_404: "Invoice not found"
|
||||||
@@ -62,6 +65,7 @@ en:
|
|||||||
label_model: "Model"
|
label_model: "Model"
|
||||||
label_name: "Name"
|
label_name: "Name"
|
||||||
label_new_customer: "New Customer"
|
label_new_customer: "New Customer"
|
||||||
|
label_new_issue: "New Issue"
|
||||||
label_qbo_never_synced: "Never Synced"
|
label_qbo_never_synced: "Never Synced"
|
||||||
label_no_customers: "There are no customers matching the search term(s)."
|
label_no_customers: "There are no customers matching the search term(s)."
|
||||||
label_no_estimates: "No Estimates"
|
label_no_estimates: "No Estimates"
|
||||||
|
|||||||
@@ -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 to create Time Activity Entries for billable hours logged when an Issue is closed'
|
description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed'
|
||||||
version '2026.3.15'
|
version '2026.8.1'
|
||||||
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'
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ module RedmineQbo
|
|||||||
# View User
|
# View User
|
||||||
def view_users_form(context={})
|
def view_users_form(context={})
|
||||||
|
|
||||||
# Update the users
|
|
||||||
#Employee.update_all
|
|
||||||
|
|
||||||
# Check to see if there is a quickbooks user attached to the issue
|
# Check to see if there is a quickbooks user attached to the issue
|
||||||
@selected = context[:user]&.employee&.id
|
@selected = context[:user]&.employee&.id
|
||||||
|
|
||||||
|
|||||||
@@ -11,27 +11,51 @@
|
|||||||
module RedmineQbo
|
module RedmineQbo
|
||||||
module Patches
|
module Patches
|
||||||
module AttachmentsControllerPatch
|
module AttachmentsControllerPatch
|
||||||
module Helper
|
|
||||||
# Check if login is globally required to access the application
|
|
||||||
def check_if_login_required
|
|
||||||
# Return true if the user is already logged in
|
|
||||||
return true if User.current.logged?
|
|
||||||
|
|
||||||
# Pull up the attachment and verify if we have a valid token for the issue
|
|
||||||
attachment = Attachment.find_by(id: params[:id])
|
|
||||||
return require_login if attachment.nil?
|
|
||||||
|
|
||||||
token = CustomerToken.where("token = ? AND expires_at > ?", session[:token], Time.current).first
|
|
||||||
return true if token&.issue_id == attachment.container_id
|
|
||||||
|
|
||||||
# Default to requiring login if all else fails
|
|
||||||
require_login if Setting.login_required?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.apply
|
def self.apply
|
||||||
AttachmentsController.class_eval do
|
AttachmentsController.class_eval do
|
||||||
helper Helper
|
# 1. PREPEND: Must run before ANY of Redmine's ApplicationController filters
|
||||||
|
prepend_before_action :set_customer_token_thread
|
||||||
|
|
||||||
|
# 2. Skip global login redirects if the user holds a valid token for this file
|
||||||
|
skip_before_action :check_if_login_required, if: :valid_customer_token?
|
||||||
|
skip_before_action :check_project_privacy, raise: false, if: :valid_customer_token?
|
||||||
|
|
||||||
|
# Note: We do NOT need to skip :read_authorize anymore.
|
||||||
|
# Because we patched Attachment#visible?, read_authorize will pass naturally!
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_customer_token_thread
|
||||||
|
if session[:token].present?
|
||||||
|
Thread.current[:customer_token] = CustomerToken.active.find_by(token: session[:token])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid_customer_token?
|
||||||
|
token = Thread.current[:customer_token]
|
||||||
|
return false unless token
|
||||||
|
|
||||||
|
# Handle "Download All" zip requests (object_type=issues, object_id=ID)
|
||||||
|
if params[:action] == 'download_all'
|
||||||
|
return params[:object_type] == 'issues' && params[:object_id].to_i == token.issue_id
|
||||||
|
end
|
||||||
|
|
||||||
|
# Handle normal single attachment requests (show, download, thumbnail)
|
||||||
|
attachment = Attachment.find_by(id: params[:id])
|
||||||
|
return false unless attachment
|
||||||
|
|
||||||
|
# Allow if attachment belongs directly to the Issue
|
||||||
|
if attachment.container_type == 'Issue' && attachment.container_id == token.issue_id
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Allow if attachment belongs to a Journal (comment) on the Issue
|
||||||
|
if attachment.container_type == 'Journal' && attachment.container.journalized_type == 'Issue' && attachment.container.journalized_id == token.issue_id
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ module RedmineQbo
|
|||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
prepended do
|
prepended do
|
||||||
belongs_to :customer, class_name: 'Customer', foreign_key: :customer_id, optional: true
|
belongs_to :customer
|
||||||
belongs_to :customer_token, primary_key: :id, optional: true
|
belongs_to :customer_token
|
||||||
belongs_to :estimate, primary_key: :id, optional: true
|
belongs_to :estimate
|
||||||
has_and_belongs_to_many :invoices
|
has_and_belongs_to_many :invoices
|
||||||
|
|
||||||
before_save :titlize_subject
|
before_save :titlize_subject
|
||||||
|
|||||||
Reference in New Issue
Block a user