mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-02-13 09:34:00 -05:00
Compare commits
19 Commits
2026.1.3
...
f30d735e52
| Author | SHA1 | Date | |
|---|---|---|---|
| f30d735e52 | |||
| a30d8f56d8 | |||
| d22fcd4f66 | |||
| f649d4e902 | |||
| 2db17f3675 | |||
| d37933fe82 | |||
| 3efc545f0a | |||
| adcc116841 | |||
| 8bb98d2408 | |||
| 88b0ffcd6b | |||
| 48deb3b7c8 | |||
| e2ea22afdf | |||
| 717a61b024 | |||
| a932551b96 | |||
| e09990cd42 | |||
| ad8aa8e2e8 | |||
| 707abc00a9 | |||
| 1199af0886 | |||
| 5a2832b751 |
56
README.md
56
README.md
@@ -1,53 +1,55 @@
|
||||
# Redmine QuickBooks Online Vehicles
|
||||
|
||||
A redmine plugin to compliment the Redmine QuickBooks Online Vehicles plug in.
|
||||
A Redmine plugin to complement the [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo) plugin.
|
||||
|
||||
The goal of this project is to allow add vehicle tracking for customer vehicles.
|
||||
The goal of this project is to enable vehicle tracking for customer vehicles within Redmine.
|
||||
|
||||
## Requirements
|
||||
|
||||
* **Redmine:** 6.1+
|
||||
* **Parent Plugin:** [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo)
|
||||
|
||||
## Compatibility
|
||||
|
||||
| Redmine QBO Plugin Version | Redmine Version |
|
||||
| :--- | :--- |
|
||||
| Version 2026.1.2+ | Redmine 6.1 |
|
||||
| Plugin Version | Redmine Version | Ruby Version |
|
||||
| :--- | :--- | :--- |
|
||||
| 2026.1.2+ | Redmine 6.1 | 3.2+ |
|
||||
|
||||
## Features
|
||||
|
||||
Adds vehicles that are owned by customers that can be attached to issues.
|
||||
* **Asset Tracking:** Adds vehicles owned by customers to the system.
|
||||
* **Issue Association:** Allows these vehicles to be attached directly to Redmine issues for better service tracking.
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Clone the plugin:**
|
||||
Clone this repo into your plugin folder and checkout a tagged version.
|
||||
```bash
|
||||
cd path/to/redmine/plugins
|
||||
git clone git@github.com:rickbarrette/redmine_qbo_vehicles.git
|
||||
cd redmine_qbo_vehicles
|
||||
git checkout <tag>
|
||||
```
|
||||
|
||||
2. **Install dependencies:** *Crucial for Redmine 6 / Rails 7 compatibility.*
|
||||
|
||||
Bash
|
||||
|
||||
1. **Clone the plugin:**
|
||||
Navigate to your Redmine plugins directory and clone the repository.
|
||||
```bash
|
||||
cd path/to/redmine/plugins
|
||||
git clone git@github.com:rickbarrette/redmine_qbo_vehicles.git
|
||||
cd redmine_qbo_vehicles
|
||||
git checkout <tag>
|
||||
```
|
||||
*(Note: Replace `<tag>` with the specific release version you wish to use, or omit the last line to use the main branch.)*
|
||||
|
||||
2. **Install dependencies:**
|
||||
*Crucial for Redmine 6 / Rails 7 compatibility.*
|
||||
```bash
|
||||
bundle install
|
||||
```
|
||||
|
||||
3. **Migrate your database:**
|
||||
|
||||
Bash
|
||||
|
||||
```
|
||||
```bash
|
||||
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
||||
```
|
||||
|
||||
4. **Restart Redmine:** You must restart your Redmine server instance for the plugin and hooks to load.
|
||||
4. **Restart Redmine:**
|
||||
You must restart your Redmine server instance (e.g., Puma, Passenger, Unicorn) for the plugin and hooks to load correctly.
|
||||
|
||||
## Usage
|
||||
|
||||
Simply add vehicles to customers via Customer Profile
|
||||
|
||||
Once a customer is attached to the customer, they can be attached to an issue.
|
||||
1. **Add a Vehicle:** Navigate to a Customer Profile. You will see a new option to add vehicles to that customer.
|
||||
2. **Link to Issue:** Once a vehicle is added to a customer, it can be selected and attached to an Issue relevant to that customer.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ class VehiclesController < ApplicationController
|
||||
begin
|
||||
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(page: params[:page])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash[:error] = t :alert_vehicle_not_found
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -48,7 +49,7 @@ class VehiclesController < ApplicationController
|
||||
def create
|
||||
@vehicle = Vehicle.new(allowed_params)
|
||||
if @vehicle.save
|
||||
flash[:notice] = "New Vehicle Created"
|
||||
flash[:notice] = t :notice_vehicle_created
|
||||
redirect_to @vehicle
|
||||
else
|
||||
flash[:error] = @vehicle.errors.full_messages.to_sentence
|
||||
@@ -64,6 +65,7 @@ class VehiclesController < ApplicationController
|
||||
@issues = @vehicle.issues.order(id: :desc)
|
||||
@closed_issues = (@issues - @issues.open)
|
||||
rescue
|
||||
flash[:error] = t :alert_vehicle_not_found
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -74,6 +76,7 @@ class VehiclesController < ApplicationController
|
||||
@vehicle = Vehicle.find_by_id(params[:id])
|
||||
@customer = @vehicle.customer
|
||||
rescue
|
||||
flash[:error] = t :alert_vehicle_not_found
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -84,7 +87,7 @@ class VehiclesController < ApplicationController
|
||||
begin
|
||||
@vehicle = Vehicle.find_by_id(params[:id])
|
||||
if @vehicle.update(allowed_params)
|
||||
flash[:notice] = "Vehicle updated"
|
||||
flash[:notice] = t :notice_vehicle_updated
|
||||
redirect_to @vehicle
|
||||
else
|
||||
redirect_to edit_vehicle_path
|
||||
@@ -92,6 +95,7 @@ class VehiclesController < ApplicationController
|
||||
#show any errors anyways
|
||||
flash[:error] = @vehicle.errors.full_messages.to_sentence unless @vehicle.errors.empty?
|
||||
rescue
|
||||
flash[:error] = t :alert_vehicle_not_updated
|
||||
render_404
|
||||
end
|
||||
end
|
||||
@@ -100,9 +104,10 @@ class VehiclesController < ApplicationController
|
||||
def destroy
|
||||
begin
|
||||
Vehicle.find_by_id(params[:id]).destroy
|
||||
flash[:notice] = "Vehicle deleted successfully"
|
||||
flash[:notice] = t :notice_vehicle_deleted
|
||||
redirect_to action: :index
|
||||
rescue
|
||||
flash[:error] = t :alert_vehicle_not_deleted
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,6 +72,16 @@ class Vehicle < ActiveRecord::Base
|
||||
self.name = to_s
|
||||
end
|
||||
|
||||
# reurns all invoices for this vehicle
|
||||
def invoices
|
||||
self.issues.flat_map(&:invoices).uniq.compact
|
||||
end
|
||||
|
||||
# returns all estimates for this vehicle
|
||||
def estimates
|
||||
self.issues.flat_map(&:estimate).uniq.compact
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# init method to pull JSON details from NHTSA
|
||||
|
||||
@@ -10,9 +10,5 @@
|
||||
|
||||
<div class="vehicle_notes attribute">
|
||||
<div class="label"><span><%=t(:field_notes)%></span>:</div>
|
||||
<div class="value">
|
||||
<pre id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; ">
|
||||
<%=notes%>
|
||||
</pre>
|
||||
</div>
|
||||
<pre class="value" id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; "><%=notes%></pre>
|
||||
</div>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<tr>
|
||||
<th><%= t(:field_customer)%></th>
|
||||
<td><%= link_to vehicle.customer.name, customer_path(vehicle.customer) %></td>
|
||||
<td><%= link_to(vehicle.customer.name, customer_path(vehicle.customer)) if vehicle.customer %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<% vehicles.each do |vehicle| %>
|
||||
<div class="row">
|
||||
<div>
|
||||
<%= check_box_tag "vehicle_ids[]", vehicle.id, false, onchange: "updateLink()", data: { url: vehicle_path(vehicle).html_safe, text: vehicle.to_s }, class: "appointment" %>
|
||||
<b><%= link_to "##{vehicle.id}", vehicle_path(vehicle) %> </b>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
<%= render partial: 'vehicles/details', locals: {vehicle: @vehicle} %>
|
||||
|
||||
<div class="splitcontent">
|
||||
<div class="splitcontentleft">
|
||||
<h4><%=t(:estimates)%>:</h4>
|
||||
<%= render partial: 'estimates/list', locals: {estimates: @vehicle.estimates} %>
|
||||
</div>
|
||||
|
||||
<div class="splitcontentleft">
|
||||
<h4><%=t(:label_invoices)%>:</h4>
|
||||
<%= render partial: 'invoices/list', locals: {invoices: @vehicle.invoices} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3>
|
||||
|
||||
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %>
|
||||
|
||||
@@ -24,3 +24,10 @@ en:
|
||||
label_cusomer_vehicles: "Customer Vehicles"
|
||||
label_new_vehicle: "New Customer Vehicle"
|
||||
button_new_vehice: "New Vehicle"
|
||||
notice_vehicle_created: "Vehicle was successfully created."
|
||||
notice_vehicle_updated: "Vehicle was successfully updated."
|
||||
notice_vehicle_deleted: "Vehicle was successfully deleted."
|
||||
alert_vehicle_not_found: "Vehicle not found."
|
||||
alert_vehicle_not_deleted: "Vehicle could not be deleted."
|
||||
alert_vehicle_not_created: "Vehicle could not be created."
|
||||
alert_vehicle_not_updated: "Vehicle could not be updated."
|
||||
6
init.rb
6
init.rb
@@ -14,7 +14,7 @@ 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.1.3'
|
||||
version '2026.2.1'
|
||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||
author_url 'https://barrettefabrication.com'
|
||||
requires_redmine version_or_higher: '6.1.0'
|
||||
@@ -27,13 +27,13 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
||||
end
|
||||
|
||||
# Add safe attributes for core models
|
||||
Issue.safe_attributes 'vehicle_id'
|
||||
Issue.safe_attributes :vehicle_id
|
||||
|
||||
# Permissions for security
|
||||
permission :view_vehicles, vehicles: :new, public: false
|
||||
|
||||
# Register top menu items
|
||||
menu :top_menu, :vehicles, { controller: :vehicles, action: :index }, caption: 'Vehicles', if: Proc.new { User.current.logged? }
|
||||
menu :top_menu, :vehicles, { controller: :vehicles, action: :index }, caption: :field_vehicles, if: Proc.new { User.current.logged? }
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ module Vehicles
|
||||
locals: {
|
||||
vehicle: context[:form].select( :vehicle_id,
|
||||
context[:issue].customer ? context[:issue].customer.vehicles.pluck(:name, :id) : [],
|
||||
selected: context[:issue].vehicle,
|
||||
selected: context[:issue].vehicle ? context[:issue].vehicle.id : nil,
|
||||
include_blank: true )
|
||||
}
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ module Vehicles
|
||||
context[:controller].send(:render_to_string, {
|
||||
partial: 'issues/show_issue_view_right',
|
||||
locals: {
|
||||
vehicle: link_to(context[:issue].vehicle),
|
||||
vehicle: context[:issue].vehicle ? link_to(context[:issue].vehicle) : nil,
|
||||
split_vin: context[:issue].vehicle ? context[:issue].vehicle.vin.to_s.scan(/.{1,9}/) : nil,
|
||||
notes: context[:issue].vehicle ? context[:issue].vehicle.notes : nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user