mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-04-02 15:11:58 -04:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 030340b35e | |||
| 097276e558 | |||
| ea73878c71 | |||
| 8ec60c8cd7 | |||
| 9cb38cfbb1 | |||
| 9a1678d353 | |||
| 28957c5dff | |||
| a67b75671e | |||
| 492ff000bf |
@@ -10,7 +10,6 @@ The goal of this project is to enable vehicle tracking for customer vehicles wit
|
||||
* **Parent Plugin:** [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo)
|
||||
|
||||
## Compatibility
|
||||
|
||||
| Plugin Version | Redmine Version | Ruby Version |
|
||||
| :--- | :--- | :--- |
|
||||
| 2026.1.2+ | Redmine 6.1 | 3.2+ |
|
||||
|
||||
@@ -60,10 +60,15 @@ class VehiclesController < ApplicationController
|
||||
# display a specific vehicle
|
||||
def show
|
||||
begin
|
||||
@vehicle = Vehicle.find_by_id(params[:id])
|
||||
@vehicle = Vehicle.includes(issues: [:estimate, :invoices]).find(params[:id])
|
||||
@vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin
|
||||
@issues = @vehicle.issues.order(id: :desc)
|
||||
@closed_issues = (@issues - @issues.open)
|
||||
@issues = @vehicle.issues
|
||||
.joins(:status)
|
||||
.includes(:estimate, :invoices, :status, :project, :tracker, :priority)
|
||||
.order(id: :desc)
|
||||
@open_issues = @issues.select { |i| !i.status.is_closed }
|
||||
@closed_issues = @issues.select { |i| i.status.is_closed }
|
||||
|
||||
flash[:error] = t :alert_no_customer if @vehicle.customer.nil?
|
||||
rescue
|
||||
flash[:error] = t :alert_vehicle_not_found
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="clearfix">
|
||||
<%=t(:field_customer)%>:
|
||||
<div class="input">
|
||||
<%= f.autocomplete_field :customer, autocomplete_customer_name_customers_path, value: @customer.name, update_elements: {id: '#customer_id', value: '#issue_customer'}, required: true %>
|
||||
<%= f.text_field :customer, class: "customer-name", autocomplete: "off", value: @customer.name, required: true,data: { autocomplete_url: "/customers/autocomplete" } %>
|
||||
<%= f.hidden_field :customer_id, id: "customer_id", value: @customer.id %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3>
|
||||
<h3><%=@open_issues.count%> <%=t(:label_open_issues)%></h3>
|
||||
|
||||
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %>
|
||||
<%= render partial: 'issues/list_simple', locals: {issues: @open_issues} %>
|
||||
|
||||
<h3><%=@closed_issues.count%> <%=t(:label_closed_issues)%></h3>
|
||||
|
||||
|
||||
@@ -12,6 +12,11 @@ async function handleCopy(event) {
|
||||
link = event.target;
|
||||
}
|
||||
|
||||
// If the text is already "Copied!", don't do anything
|
||||
if (text == "Copied!") {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Write to clipboard
|
||||
await navigator.clipboard.writeText(text);
|
||||
|
||||
12
init.rb
12
init.rb
@@ -14,14 +14,14 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
name 'Redmine QBO Vehicles plugin'
|
||||
author 'Rick Barrette'
|
||||
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
||||
version '2026.2.8'
|
||||
version '2026.3.2'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine version_or_higher: '6.1.0'
|
||||
|
||||
# Ensure redmine_qbo is installed
|
||||
begin
|
||||
requires_redmine_plugin :redmine_qbo, version_or_higher: '2026.1.2'
|
||||
requires_redmine_plugin :redmine_qbo, version_or_higher: '2026.3.13'
|
||||
rescue Redmine::PluginNotFound
|
||||
raise 'Please install the redmine_qbo plugin (https://github.com/rickbarrette/redmine_qbo)'
|
||||
end
|
||||
@@ -41,10 +41,4 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
|
||||
end
|
||||
|
||||
# Dynamically load all Hooks & Patches recursively
|
||||
base_dir = File.join(File.dirname(__FILE__), 'lib')
|
||||
|
||||
# '**' looks inside subdirectories, '*.rb' matches Ruby files
|
||||
Dir.glob(File.join(base_dir, '**', '*.rb')).sort.each do |file|
|
||||
require file
|
||||
end
|
||||
RedmineQboVehicles.setup
|
||||
23
lib/redmine_qbo_vehicles.rb
Normal file
23
lib/redmine_qbo_vehicles.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#The MIT License (MIT)
|
||||
#
|
||||
#Copyright (c) 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.
|
||||
|
||||
module RedmineQboVehicles
|
||||
def self.setup
|
||||
Issue.prepend Vehicles::Patches::IssuePatch
|
||||
Customer.prepend Vehicles::Patches::CustomerPatch
|
||||
|
||||
Vehicles::Hooks::CustomerShowHookListener
|
||||
Vehicles::Hooks::InvoiceHookListener
|
||||
Vehicles::Hooks::IssuesFormHookListener
|
||||
Vehicles::Hooks::IssuesShowHookListener
|
||||
Vehicles::Hooks::PdfHookListener
|
||||
Vehicles::Hooks::ViewHookListener
|
||||
end
|
||||
end
|
||||
@@ -17,13 +17,13 @@ module Vehicles
|
||||
|
||||
# Called by Redmine QBO Invoice
|
||||
def process_invoice_custom_fields(context={})
|
||||
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields"
|
||||
log "Processing invoice custom fields for invoice ##{context[:invoice].id}"
|
||||
issue = context[:issue]
|
||||
|
||||
# update the invoive custom fields with infomation from the issue if available
|
||||
context[:invoice].custom_fields.each do |cf|
|
||||
|
||||
Rails.logger.info "Checking invoice.custom field: #{cf.name}"
|
||||
log "Checking invoice custom field: #{cf.name}"
|
||||
|
||||
# VIN from the attached vehicle
|
||||
begin
|
||||
@@ -32,13 +32,13 @@ module Vehicles
|
||||
# TODO check cf_sync_confict flag once implemented
|
||||
if cf.string_value.to_s.blank?
|
||||
|
||||
Rails.logger.info "VIN was blank, updating the invoice vin in quickbooks"
|
||||
log "VIN was blank, updating the invoice vin in quickbooks"
|
||||
vin = context[:issue].vehicle.vin
|
||||
break if vin.nil?
|
||||
|
||||
if not cf.string_value.to_s.eql? vin
|
||||
cf.string_value = vin.to_s
|
||||
Rails.logger.info "VIN has changed"
|
||||
log "VIN has changed"
|
||||
context[:is_changed] = true
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ module Vehicles
|
||||
end
|
||||
rescue
|
||||
#do nothing
|
||||
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping"
|
||||
log "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping"
|
||||
return nil
|
||||
end
|
||||
end
|
||||
@@ -56,6 +56,12 @@ module Vehicles
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log(msg)
|
||||
Rails.logger.info "[InvoiceHookListener] #{msg}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -14,16 +14,12 @@ module Vehicles
|
||||
# Patches Redmine QBO Customer dynamically.
|
||||
# Adds a relationship for vehicle ownership by customers
|
||||
module CustomerPatch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
|
||||
Customer.class_eval do
|
||||
has_many :vehicles
|
||||
end
|
||||
|
||||
prepended do
|
||||
has_many :vehicles
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -8,23 +8,18 @@
|
||||
#
|
||||
#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.
|
||||
|
||||
require_dependency 'issue'
|
||||
|
||||
module Vehicles
|
||||
module Patches
|
||||
|
||||
# Patches Redmine's Issues dynamically.
|
||||
# Adds a relationship for attahcing a vehilce to an issue
|
||||
module IssuePatch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
|
||||
Issue.class_eval do
|
||||
belongs_to :vehicle
|
||||
end
|
||||
|
||||
prepended do
|
||||
belongs_to :vehicle
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user