mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 09:24:23 -05:00
Compare commits
97 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb039368bb | |||
| 0dea5917a7 | |||
| a8ccde6c81 | |||
| 787ae1b8df | |||
| 276c89d4ac | |||
| 9a395ee25c | |||
| 475c86eabe | |||
| 259737a488 | |||
| 362cb77381 | |||
| 8cfab17136 | |||
| f0018ab87d | |||
| 8f87eb3e60 | |||
| 2b093903b3 | |||
| 05017dcc4f | |||
| 0e9b5fa17a | |||
| dd335aff71 | |||
| 0f61bf54ce | |||
| 14cb22d743 | |||
| 702ab5013e | |||
| 235e2c6e7b | |||
| 2e89a60d63 | |||
| 3d5ef2cd8a | |||
| de8eff9bd2 | |||
| a9561d1694 | |||
| aa33de00d2 | |||
| ffc589fe80 | |||
| 229e4e8d39 | |||
| d6dda2cdd6 | |||
| b8a101fddb | |||
| c8a875b301 | |||
| df8e3a7465 | |||
| d91a6e3939 | |||
| 48a2d683dd | |||
| 44bf42c548 | |||
| d34e6cb0fd | |||
| d8e7356ca3 | |||
| 60e6dbaa6f | |||
| 47e5a7d0e4 | |||
| 9fa2165907 | |||
| 7385d7018c | |||
| 6124c1b307 | |||
| b73535c6da | |||
| 1581023656 | |||
| 0d21e2967d | |||
| 0dc7d83fbe | |||
| cd18067384 | |||
| 6c99f7095c | |||
| eeaafce427 | |||
| b7cb27b5da | |||
| 3e6286da7c | |||
| 30ceea7fd5 | |||
| de9e973fd9 | |||
| 49a3bd5790 | |||
| f1745930b1 | |||
| d9beda8171 | |||
| 65f343fb74 | |||
| 892bd65fac | |||
| 0251191844 | |||
| 65f6f52252 | |||
| 4d94308bcc | |||
| 7dcd8b24d2 | |||
| 11da8e7a43 | |||
| 56c895388d | |||
| 8ec9567f15 | |||
| be3dd0d131 | |||
| 92f51d9884 | |||
| c4904a0ac2 | |||
| 0d87e5fb21 | |||
| d38e3e1702 | |||
| fec59a7495 | |||
| a3b5ad0cb0 | |||
| bf21451819 | |||
| c6d3d9673b | |||
| 3f5334a92d | |||
| bde7b83752 | |||
| c788e5724a | |||
| 295cd12f9d | |||
| 4a432481d9 | |||
| 4a37d83694 | |||
| 15a2a16379 | |||
| 18fc7a6c8c | |||
| 7aba8cdce3 | |||
| 382e6675f1 | |||
| 116d6896f4 | |||
| c9ced52112 | |||
| 01b4bb4e53 | |||
| a266da2cd7 | |||
| 578e7ba807 | |||
| b923e15d46 | |||
| 1310d1e63e | |||
| a8e1e8429c | |||
| 1b54b40f6c | |||
| 6d7530922d | |||
| 23698986b1 | |||
| 1b4c377940 | |||
| d33c0c9aa5 | |||
| 09d8c0024f |
@@ -18,6 +18,14 @@ class VehiclesController < ApplicationController
|
|||||||
|
|
||||||
# display a list of all vehicles
|
# display a list of all vehicles
|
||||||
def index
|
def index
|
||||||
|
if params[:customer_id]
|
||||||
|
begin
|
||||||
|
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(:page => params[:page])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
|
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
|
||||||
if only_one_non_zero?(@vehicles)
|
if only_one_non_zero?(@vehicles)
|
||||||
@@ -30,6 +38,9 @@ class VehiclesController < ApplicationController
|
|||||||
def new
|
def new
|
||||||
@vehicle = Vehicle.new
|
@vehicle = Vehicle.new
|
||||||
@customers = Customer.all.order(:name)
|
@customers = Customer.all.order(:name)
|
||||||
|
if params[:customer]
|
||||||
|
@customer = Customer.find_by_id(params[:customer])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# create a new vehicle
|
# create a new vehicle
|
||||||
@@ -92,6 +103,15 @@ class VehiclesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns a dynamic list of vehicles owned by a customer
|
||||||
|
def update_vehicles
|
||||||
|
@vehicles = Customer.find_by_id(params[:customer_id].to_i).vehicles
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render(:text => "not implemented") }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def only_one_non_zero?( array )
|
def only_one_non_zero?( array )
|
||||||
|
|||||||
@@ -46,11 +46,23 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
|
#update the information in the database
|
||||||
invoice = get_base.service.fetch_by_id(id)
|
invoice = get_base.service.fetch_by_id(id)
|
||||||
qbo_invoice = find_or_create_by(id: invoice.id)
|
qbo_invoice = find_or_create_by(id: invoice.id)
|
||||||
qbo_invoice.doc_number = invoice.doc_number
|
qbo_invoice.doc_number = invoice.doc_number
|
||||||
qbo_invoice.id = invoice.id
|
qbo_invoice.id = invoice.id
|
||||||
qbo_invoice.save!
|
qbo_invoice.save!
|
||||||
|
|
||||||
|
# Scan the line items for hashtags and attach to the applicable issues
|
||||||
|
invoice.line_items.each { |line|
|
||||||
|
if line.description
|
||||||
|
line.description.scan(/#(\w+)/).flatten.each { |issue|
|
||||||
|
i = Issue.find_by_id(issue.to_i)
|
||||||
|
i.qbo_invoice = QboInvoice.find_by_id(invoice.id.to_i)
|
||||||
|
i.save!
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update(id)
|
def self.update(id)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td/>
|
|
||||||
<td>
|
<td>
|
||||||
<%= button_to "Edit Customer", edit_customer_path(customer), method: :get%>
|
<%= button_to "Edit Customer", edit_customer_path(customer), method: :get%>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<h1>Customer #<%= @customer.id %></h1>
|
<h1>Customer #<%= @customer.id %></h1>
|
||||||
<br/>
|
<br/>
|
||||||
|
<h2>Details:</h2>
|
||||||
<%= render :partial => 'customers/details', locals: {customer: @customer} %>
|
<%= render :partial => 'customers/details', locals: {customer: @customer} %>
|
||||||
<br/>
|
<br/>
|
||||||
|
<h2>Vehicles:</h2>
|
||||||
<%= render :partial => 'vehicles/list' %>
|
<%= render :partial => 'vehicles/list' %>
|
||||||
|
<%= button_to "New Vehicle", new_customer_vehicle_path(@customer), method: :get %>
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<h2>Issues:</h2>
|
||||||
<%= render :partial => 'issues/list_simple', locals: {issues: @issues} %>
|
<%= render :partial => 'issues/list_simple', locals: {issues: @issues} %>
|
||||||
|
|||||||
@@ -72,6 +72,36 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_au
|
|||||||
<br/>
|
<br/>
|
||||||
Note: You need to authenticate after saving your key and secret above
|
Note: You need to authenticate after saving your key and secret above
|
||||||
<br/>
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<!-- this will display a button that the user clicks to start the flow -->
|
<!-- this will display a button that the user clicks to start the flow -->
|
||||||
<ipp:connectToIntuit></ipp:connectToIntuit>
|
<ipp:connectToIntuit></ipp:connectToIntuit>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Customer Count:</b> <%= Customer.count%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Item Count:</b> <%= QboItem.count %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Employee Count:</b> <%= QboEmployee.count %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Invoice Count:</b> <%= QboInvoice.count %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Estimate Count:</b> <%= QboEstimate.count %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Last Sync: </b> <%= Qbo.last_sync %> <%= link_to " Sync Now", qbo_sync_path %>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Customer</th>
|
<th>Customer</th>
|
||||||
<td><%= vehicle.customer.name %></td>
|
<td><%= link_to vehicle.customer.name, customer_path(vehicle.customer) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
Customer:
|
Customer:
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= f.collection_select :customer_id, @customers, :id, :name, include_blank: true, :selected => @customer, :required => true%>
|
<%= f.collection_select :customer_id, @customers, :id, :name, include_blank: true, :selected => params[:customer_id], :required => true%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<%= will_paginate @vehicles %>
|
<%= will_paginate @vehicles %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1
app/views/vehicles/_vehicle.html.erb
Normal file
1
app/views/vehicles/_vehicle.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<option value="<%= vehicle.id %>"><%= vehicle.to_s.titleize %></option>
|
||||||
1
app/views/vehicles/update_vehicles.js.erb
Normal file
1
app/views/vehicles/update_vehicles.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#issue_vehicles_id").empty().append("<%= escape_javascript(render(:partial => @vehicles)) %>")
|
||||||
16
assets/javascripts/vehicles.js
Normal file
16
assets/javascripts/vehicles.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
# All this logic will automatically be available in application.js.
|
||||||
|
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||||
|
|
||||||
|
$ ->
|
||||||
|
$(document).on 'change', '#issue_customer_id', (evt) ->
|
||||||
|
$.ajax 'update_vehicles',
|
||||||
|
type: 'GET'
|
||||||
|
dataType: 'script'
|
||||||
|
data: {
|
||||||
|
customer_id: $("#issue_customer_id option:selected").val()
|
||||||
|
}
|
||||||
|
error: (jqXHR, textStatus, errorThrown) ->
|
||||||
|
console.log("AJAX Error: #{textStatus}")
|
||||||
|
success: (data, textStatus, jqXHR) ->
|
||||||
|
console.log("Dynamic vehicle select OK!")
|
||||||
@@ -20,5 +20,11 @@ get 'qbo/invoice/:id', :to => 'invoice#show', as: :invoice
|
|||||||
|
|
||||||
post 'qbo/webhook', :to => 'qbo#qbo_webhook'
|
post 'qbo/webhook', :to => 'qbo#qbo_webhook'
|
||||||
|
|
||||||
|
#ajax
|
||||||
|
get "update_vehicles" => 'vehicles#update_vehicles', as: 'update_vehicles'
|
||||||
|
|
||||||
|
resources :customers do
|
||||||
|
resources :vehicles
|
||||||
|
end
|
||||||
|
|
||||||
resources :vehicles
|
resources :vehicles
|
||||||
resources :customers
|
|
||||||
|
|||||||
10
init.rb
10
init.rb
@@ -25,7 +25,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
name 'Redmine Quickbooks Online plugin'
|
name 'Redmine Quickbooks Online plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues'
|
description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues'
|
||||||
version '0.1.0'
|
version '0.2.0'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'http://rickbarrette.org'
|
author_url 'http://rickbarrette.org'
|
||||||
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
||||||
@@ -46,8 +46,12 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
WillPaginate.per_page = 10
|
WillPaginate.per_page = 10
|
||||||
|
|
||||||
# Register QBO top menu item
|
# Register QBO top menu item
|
||||||
menu :top_menu, :qbo, { :controller => :qbo, :action => :index }, :caption => 'Quickbooks', :if => Proc.new { User.current.admin? }
|
#menu :top_menu, :qbo, { :controller => :qbo, :action => :index }, :caption => 'Quickbooks', :if => Proc.new { User.current.admin? }
|
||||||
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
|
|
||||||
menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new { User.current.logged? }
|
menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new { User.current.logged? }
|
||||||
|
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
|
||||||
|
|
||||||
|
menu :application_menu, :new_customer, { :controller => :customers, :action => :new }, :caption => 'New Customer', :if => Proc.new { User.current.logged? }
|
||||||
|
|
||||||
|
permission :customers, { :customers => [:index, :new] }, :public => false
|
||||||
|
menu :project_menu, :customers, { :controller => 'customers', :action => 'new' }, :caption => 'New Customer', :after => :activity, :param => :project_id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
class IssuesFormHookListener < Redmine::Hook::ViewListener
|
class IssuesFormHookListener < Redmine::Hook::ViewListener
|
||||||
|
|
||||||
|
# Load the javascript
|
||||||
|
def view_layouts_base_html_head(context = {})
|
||||||
|
javascript_include_tag 'vehicles', :plugin => 'redmine_qbo'
|
||||||
|
end
|
||||||
|
|
||||||
# Edit Issue Form
|
# Edit Issue Form
|
||||||
# Show a dropdown for quickbooks contacts
|
# Show a dropdown for quickbooks contacts
|
||||||
def view_issues_form_details_bottom(context={})
|
def view_issues_form_details_bottom(context={})
|
||||||
|
|||||||
Reference in New Issue
Block a user