172 Commits
0.0.8 ... 0.3.0

Author SHA1 Message Date
1b767f78d2 Version bump 0.3.0
* Added Payments
* Other things that I don't remember...
2016-08-05 22:00:57 -04:00
f380969082 Update payments_controller.rb 2016-08-05 21:59:21 -04:00
df6acde327 Update payments_controller.rb 2016-08-05 21:57:31 -04:00
0318ffaa10 Update payments_controller.rb 2016-08-05 21:56:23 -04:00
51c1b38197 Update init.rb 2016-08-05 21:45:08 -04:00
d96bd1a3f4 Update init.rb 2016-08-05 21:44:00 -04:00
b6e43b5837 Update payment.rb 2016-08-05 21:41:52 -04:00
62fa98a656 Update payment.rb 2016-08-05 21:39:53 -04:00
bb5a080f25 Update payment.rb 2016-08-05 21:37:20 -04:00
2afa9e4166 Update payment.rb 2016-08-05 21:36:01 -04:00
b489a2771f Update payment.rb 2016-08-05 21:28:56 -04:00
0495ac1bc5 Update payment.rb 2016-08-05 21:26:11 -04:00
e3b49358bb Update payment.rb 2016-08-05 21:25:37 -04:00
08b365e69e Update payment.rb 2016-08-05 21:24:49 -04:00
5d4c49c85d Update payment.rb 2016-08-05 21:23:07 -04:00
5bc9ca34a4 Update payment.rb 2016-08-05 21:20:58 -04:00
630a1d144b Update payment.rb 2016-08-05 21:20:06 -04:00
491684f7df Update payment.rb 2016-08-05 21:18:33 -04:00
9a28247b7f Update payment.rb 2016-08-05 21:17:31 -04:00
5a91e21d45 Update payments_controller.rb 2016-08-05 21:08:05 -04:00
f6f1ca4c04 Update _form.html.erb 2016-08-05 21:01:31 -04:00
8daa10888f Update routes.rb 2016-08-05 21:00:03 -04:00
82449642d3 Update routes.rb 2016-08-05 20:58:55 -04:00
06ad2d6971 Update and rename app/views/payment/new.html.erb to app/views/payments/new.html.erb 2016-08-05 20:58:27 -04:00
4c4ca67be8 Rename app/views/payment/_form.html.erb to app/views/payments/_form.html.erb 2016-08-05 20:58:06 -04:00
b994f7c142 Update and rename payment_controller.rb to payments_controller.rb 2016-08-05 20:57:44 -04:00
97b483031d Update payment.rb 2016-08-05 20:56:04 -04:00
c624c20354 Update payment.rb 2016-08-05 20:53:55 -04:00
695e3bd24c Update payment.rb 2016-08-05 20:43:27 -04:00
ce4883cd4c Update payment_controller.rb 2016-08-05 20:42:25 -04:00
49e19cb73f Create payment.rb 2016-08-05 20:41:52 -04:00
31bb242a61 Update new.html.erb 2016-08-05 20:39:18 -04:00
2e533e8798 Rename app/views/payments/new.html.erb to app/views/payment/new.html.erb 2016-08-05 20:37:47 -04:00
e70d0c8d17 Rename app/views/payments/_form.html.erb to app/views/payment/_form.html.erb 2016-08-05 20:37:31 -04:00
d96ecd2b66 Create new.html.erb 2016-08-05 20:28:35 -04:00
a588ac19a6 Fixed typo 2016-08-05 20:27:25 -04:00
2bc8ec4f56 Added payments 2016-08-05 20:25:34 -04:00
578a5a1228 Create payment_controller.rb 2016-08-05 20:20:05 -04:00
416595ffea Create _form.html.erb 2016-08-05 20:09:49 -04:00
d3be59fbc5 Update _details.html.erb 2016-08-05 09:07:50 -04:00
3c3b4da313 Update _details.html.erb 2016-08-05 09:06:58 -04:00
501834419b Update _details.html.erb 2016-08-05 09:02:46 -04:00
75b25a9e44 Account Balance & Adresses 2016-08-05 09:01:09 -04:00
15912b2197 QueryValidationError: property 'PrimaryPhone' is not queryable 2016-08-05 08:52:33 -04:00
b093f6136e Update customer.rb 2016-08-05 08:49:59 -04:00
33db0a53ba Update customer.rb 2016-08-05 08:46:48 -04:00
7237d2e643 Search Phone Numbers 2016-08-05 08:43:44 -04:00
77b1c1dbef Update vehicle.rb 2016-08-05 00:56:28 -04:00
f3090bd1a4 Update vehicle.rb 2016-08-05 00:54:34 -04:00
89a131018c Update vehicles_controller.rb 2016-08-05 00:47:37 -04:00
de17fb80d1 Update _form.html.erb 2016-08-05 00:45:55 -04:00
a5f1d15156 Update vehicles_controller.rb 2016-08-05 00:45:23 -04:00
d3463ce41b Removed link 2016-08-05 00:39:53 -04:00
4503150b02 Removed hiding of notes 2016-08-05 00:37:29 -04:00
36cd00822e Removed New Vehicle Button 2016-08-05 00:33:14 -04:00
d285344a61 Added customer count 2016-08-05 00:30:00 -04:00
8418dfc0b5 Update vehicles_controller.rb 2016-08-05 00:04:31 -04:00
eb039368bb Version bump 0.2.0
* New Top & Application Menus
* Move quickbooks stats into QBO settings page
* Fixed New vehicle for customer link
* Added issue linking from hashtag numbers in QBO invoice line items
* Cleaned up customer & vehicle lists
* Implemented delete calls from web hook
* Added webhook token verification
* More...
2016-08-04 10:12:12 -04:00
0dea5917a7 Update _settings.html.erb 2016-08-04 10:06:07 -04:00
a8ccde6c81 Update _settings.html.erb 2016-08-04 10:05:07 -04:00
787ae1b8df Update _settings.html.erb 2016-08-04 10:03:28 -04:00
276c89d4ac Update init.rb 2016-08-04 09:59:12 -04:00
9a395ee25c Update _list.html.erb 2016-08-04 09:53:02 -04:00
475c86eabe Update show.html.erb 2016-08-04 09:52:32 -04:00
259737a488 Update show.html.erb 2016-08-04 09:51:47 -04:00
362cb77381 Update show.html.erb 2016-08-04 09:50:55 -04:00
8cfab17136 Update show.html.erb 2016-08-04 09:50:37 -04:00
f0018ab87d Update _details.html.erb 2016-08-04 09:49:52 -04:00
8f87eb3e60 Update show.html.erb 2016-08-04 09:48:19 -04:00
2b093903b3 Update show.html.erb 2016-08-04 09:46:22 -04:00
05017dcc4f Update show.html.erb 2016-08-04 09:45:39 -04:00
0e9b5fa17a Update show.html.erb 2016-08-04 09:44:09 -04:00
dd335aff71 Update _form.html.erb 2016-08-04 00:18:32 -04:00
0f61bf54ce Update index.html.erb 2016-08-04 00:15:33 -04:00
14cb22d743 Update vehicles_controller.rb 2016-08-04 00:13:47 -04:00
702ab5013e Update index.html.erb 2016-08-04 00:11:54 -04:00
235e2c6e7b Update routes.rb 2016-08-04 00:10:46 -04:00
2e89a60d63 Update vehicles_controller.rb 2016-08-04 00:09:52 -04:00
3d5ef2cd8a Update vehicles_controller.rb 2016-08-04 00:08:21 -04:00
de8eff9bd2 Update vehicles_controller.rb 2016-08-04 00:03:35 -04:00
a9561d1694 Update vehicles_controller.rb 2016-08-04 00:02:56 -04:00
aa33de00d2 Update index.html.erb 2016-08-04 00:01:15 -04:00
ffc589fe80 Update index.html.erb 2016-08-03 23:59:50 -04:00
229e4e8d39 Update index.html.erb 2016-08-03 23:57:28 -04:00
d6dda2cdd6 Update init.rb 2016-08-03 23:54:17 -04:00
b8a101fddb Update routes.rb 2016-08-03 23:50:55 -04:00
c8a875b301 Update init.rb 2016-08-03 23:45:30 -04:00
df8e3a7465 Update init.rb 2016-08-03 23:35:43 -04:00
d91a6e3939 Update init.rb 2016-08-03 23:15:38 -04:00
48a2d683dd Update init.rb 2016-08-03 23:13:55 -04:00
44bf42c548 Update init.rb 2016-08-03 23:11:00 -04:00
d34e6cb0fd Update issues_form_hook_listener.rb 2016-08-03 23:05:19 -04:00
d8e7356ca3 Update init.rb 2016-08-03 23:03:59 -04:00
60e6dbaa6f Update issues_form_hook_listener.rb 2016-08-03 22:50:53 -04:00
47e5a7d0e4 Update issues_form_hook_listener.rb 2016-08-03 22:48:26 -04:00
9fa2165907 Update issues_form_hook_listener.rb 2016-08-03 22:46:42 -04:00
7385d7018c Update issues_form_hook_listener.rb 2016-08-03 22:45:23 -04:00
6124c1b307 Update issues_form_hook_listener.rb 2016-08-03 22:44:56 -04:00
b73535c6da Update issues_form_hook_listener.rb 2016-08-03 22:43:40 -04:00
1581023656 Update vehicles.js 2016-08-03 22:39:33 -04:00
0d21e2967d Rename vehicles.js.cof to vehicles.js 2016-08-03 22:37:48 -04:00
0dc7d83fbe Update issues_form_hook_listener.rb 2016-08-03 22:37:30 -04:00
cd18067384 Rename vehicles.js to vehicles.js.coffee 2016-08-03 22:36:12 -04:00
6c99f7095c Update issues_form_hook_listener.rb 2016-08-03 22:35:49 -04:00
eeaafce427 Rename vehicles.js.coffee to vehicles.js 2016-08-03 22:32:19 -04:00
b7cb27b5da Update vehicles.js.coffee 2016-08-03 22:30:04 -04:00
3e6286da7c Update vehicles.js.coffee 2016-08-03 22:28:31 -04:00
30ceea7fd5 Update vehicles_controller.rb 2016-08-03 22:23:07 -04:00
de9e973fd9 Update routes.rb 2016-08-03 22:22:23 -04:00
49a3bd5790 Update routes.rb 2016-08-03 22:19:23 -04:00
f1745930b1 Update routes.rb 2016-08-03 22:15:43 -04:00
d9beda8171 Rename update_vehicles.js.coffee.erb to update_vehicles.js.erb 2016-08-03 22:14:23 -04:00
65f343fb74 Update vehicles_controller.rb 2016-08-03 22:13:18 -04:00
892bd65fac Rename update_vehicles.js.coffee to update_vehicles.js.coffee.erb 2016-08-03 22:10:50 -04:00
0251191844 Update vehicles_controller.rb 2016-08-03 22:05:25 -04:00
65f6f52252 Update update_vehicles.js.coffee 2016-08-03 21:58:47 -04:00
4d94308bcc Update vehicles_controller.rb 2016-08-03 21:57:50 -04:00
7dcd8b24d2 Update vehicles.js.coffee 2016-08-03 21:55:31 -04:00
11da8e7a43 Update vehicles_controller.rb 2016-08-03 21:54:05 -04:00
56c895388d Update vehicles.js.coffee 2016-08-03 21:53:31 -04:00
8ec9567f15 Update issues_form_hook_listener.rb 2016-08-03 21:50:02 -04:00
be3dd0d131 Rename assets/javascripts/app/assets/vehicles.js.coffee to assets/javascripts/vehicles.js.coffee 2016-08-03 21:40:04 -04:00
92f51d9884 Create _vehicle.html.erb 2016-08-03 21:34:10 -04:00
c4904a0ac2 Create update_vehicles.js.coffee 2016-08-03 21:29:01 -04:00
0d87e5fb21 Create vehicles.js.coffee 2016-08-03 21:26:21 -04:00
d38e3e1702 Update routes.rb 2016-08-03 21:22:34 -04:00
fec59a7495 Update vehicles_controller.rb 2016-08-03 21:20:08 -04:00
a3b5ad0cb0 Update show.html.erb 2016-08-03 21:16:31 -04:00
bf21451819 Update show.html.erb 2016-08-03 21:15:40 -04:00
c6d3d9673b Update show.html.erb 2016-08-03 21:15:03 -04:00
3f5334a92d Update show.html.erb 2016-08-03 21:14:25 -04:00
bde7b83752 Update show.html.erb 2016-08-03 21:13:40 -04:00
c788e5724a Update show.html.erb 2016-08-03 21:12:54 -04:00
295cd12f9d Update show.html.erb 2016-08-03 21:11:57 -04:00
4a432481d9 Update show.html.erb 2016-08-03 21:11:05 -04:00
4a37d83694 Update show.html.erb 2016-08-03 21:09:15 -04:00
15a2a16379 Update show.html.erb 2016-08-03 21:08:42 -04:00
18fc7a6c8c Update vehicles_controller.rb 2016-08-03 21:02:45 -04:00
7aba8cdce3 Update qbo_invoice.rb 2016-08-03 16:40:05 -04:00
382e6675f1 Update qbo_invoice.rb 2016-08-03 16:39:07 -04:00
116d6896f4 Update qbo_invoice.rb 2016-08-03 16:38:09 -04:00
c9ced52112 Update qbo_invoice.rb 2016-08-03 16:36:50 -04:00
01b4bb4e53 Update qbo_invoice.rb 2016-08-03 16:35:04 -04:00
a266da2cd7 Update qbo_invoice.rb 2016-08-03 16:33:38 -04:00
578e7ba807 Update qbo_invoice.rb 2016-08-03 16:32:52 -04:00
b923e15d46 Update qbo_invoice.rb 2016-08-03 16:31:17 -04:00
1310d1e63e Update qbo_invoice.rb 2016-08-03 16:27:30 -04:00
a8e1e8429c Update qbo_invoice.rb 2016-08-03 16:25:33 -04:00
1b54b40f6c Update qbo_invoice.rb 2016-08-03 16:22:44 -04:00
6d7530922d Update qbo_invoice.rb 2016-08-03 16:20:26 -04:00
23698986b1 Update qbo_invoice.rb 2016-08-03 16:15:50 -04:00
1b4c377940 Update _details.html.erb 2016-08-01 22:35:12 -04:00
d33c0c9aa5 Update _details.html.erb 2016-08-01 22:34:38 -04:00
09d8c0024f Update _details.html.erb 2016-08-01 22:33:32 -04:00
06e827fff8 Version bump 0.1.0 2016-08-01 22:30:47 -04:00
b1844689df Update qbo_controller.rb 2016-08-01 22:29:53 -04:00
a4263a92ca Update issues_show_hook_listener.rb 2016-08-01 22:20:57 -04:00
14cc251809 Update Gemfile 2016-08-01 21:56:17 -04:00
471e8f3398 Update qbo_controller.rb 2016-08-01 21:56:00 -04:00
dadbda62c6 Update qbo_controller.rb 2016-08-01 21:55:30 -04:00
df47efe816 Update qbo_controller.rb 2016-08-01 21:54:31 -04:00
03cc6943a3 Update Gemfile 2016-08-01 21:51:04 -04:00
6f0163ce7d Update qbo_controller.rb 2016-08-01 21:49:17 -04:00
91110adad5 Update qbo_controller.rb 2016-08-01 21:47:30 -04:00
c2f48d0277 Update qbo_controller.rb 2016-08-01 21:41:47 -04:00
06344b6498 Update qbo_controller.rb 2016-08-01 21:34:14 -04:00
4ff2b2bdc6 Update _settings.html.erb 2016-08-01 21:28:15 -04:00
a71dd310fe Update issues_show_hook_listener.rb 2016-08-01 21:24:22 -04:00
90da7a5d74 Update issues_show_hook_listener.rb 2016-08-01 21:23:15 -04:00
6505f54c7f Update issues_show_hook_listener.rb 2016-08-01 21:22:31 -04:00
c4a488e5a7 Update issues_show_hook_listener.rb 2016-08-01 21:21:41 -04:00
71817f5ca8 Update issues_show_hook_listener.rb 2016-08-01 21:18:31 -04:00
24 changed files with 365 additions and 73 deletions

View File

@@ -0,0 +1,51 @@
#The MIT License (MIT)
#
#Copyright (c) 2016 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 PaymentsController < ApplicationController
unloadable
include AuthHelper
before_filter :require_user
def new
@payment = Payment.new
@customers = Customer.all
@accounts = Qbo.get_base(:account).service.query("SELECT Id, Name FROM Account WHERE AccountType = 'Bank' ")
@payment_methods = Qbo.get_base(:payment_method).service.all
end
def create
@payment = Payment.new(params[:payment])
if @payment.save
flash[:notice] = "Payment Saved"
redirect_to Customer.find_by_id(@payment.customer_id)
else
flash[:error] = @payment.errors.full_messages.to_sentence
redirect_to new_customer_path
end
end
private
def only_one_non_zero?( array )
found_non_zero = false
array.each do |val|
if val!=0
return false if found_non_zero
found_non_zero = true
end
end
found_non_zero
end
end

View File

@@ -11,6 +11,8 @@
class QboController < ApplicationController
unloadable
require 'openssl'
include AuthHelper
before_filter :require_user, :except => :qbo_webhook
@@ -64,41 +66,52 @@ class QboController < ApplicationController
# Quickbooks Webhook Callback
def qbo_webhook
if request.headers['Content-Type'] == 'application/json'
data = JSON.parse(request.body.read)
else
# application/x-www-form-urlencoded
data = params.as_json
end
# Process the information
entities = data['eventNotifications'][0]['dataChangeEvent']['entities']
entities.each do |entity|
id = entity['id'].to_i
name = entity['name']
# TODO rename all other models!
name.prepend("Qbo") if not name.eql? "Customer"
# Magicly initialize the correct class
obj = name.constantize
# for merge events
obj.delete(entity['deletedId']) if entity['deletedId']
#Check to see if we are deleting a record
if entity['operation'].eql? "Delete"
obj.delete(id)
#if not then update!
# check the payload
signature = request.headers['intuit-signature']
key = Setting.plugin_redmine_qbo['settingsWebhookToken']
data = request.body.read
hash = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
# proceed if the request is good
if hash.eql? signature
if request.headers['content-type'] == 'application/json'
data = JSON.parse(data)
else
obj.sync_by_id(id)
# application/x-www-form-urlencoded
data = params.as_json
end
# Process the information
entities = data['eventNotifications'][0]['dataChangeEvent']['entities']
entities.each do |entity|
id = entity['id'].to_i
name = entity['name']
# TODO rename all other models!
name.prepend("Qbo") if not name.eql? "Customer"
# Magicly initialize the correct class
obj = name.constantize
# for merge events
obj.destroy(entity['deletedId']) if entity['deletedId']
#Check to see if we are deleting a record
if entity['operation'].eql? "Delete"
obj.destroy(id)
#if not then update!
else
obj.sync_by_id(id)
end
end
# Record that last time we updated
Qbo.update_time_stamp
# The webhook doesn't require a response but let's make sure we don't send anything
render :nothing => true
else
render nothing: true, status: 400
end
# Record that last time we updated
Qbo.update_time_stamp
# The webhook doesn't require a response but let's make sure we don't send anything
render :nothing => true
end
#

View File

@@ -18,6 +18,14 @@ class VehiclesController < ApplicationController
# display a list of all vehicles
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]
@vehicles = Vehicle.search(params[:search]).paginate(:page => params[:page])
if only_one_non_zero?(@vehicles)
@@ -30,6 +38,7 @@ class VehiclesController < ApplicationController
def new
@vehicle = Vehicle.new
@customers = Customer.all.order(:name)
@customer = params[:customer_id] if params[:customer_id]
end
# create a new vehicle
@@ -92,6 +101,15 @@ class VehiclesController < ApplicationController
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
def only_one_non_zero?( array )

View File

@@ -142,7 +142,18 @@ class Customer < ActiveRecord::Base
# Searchs the database for a customer by name
def self.search(search)
where("name LIKE ?", "%#{search}%").order(:name)
customers = where("name LIKE ?", "%#{search}%")
#if customers.empty?
# service = Qbo.get_base(:customer).service
# results = service.query("Select Id From Customer Where PrimaryPhone LIKE '%#{search}%' AND Mobile LIKE '%#{search}%'")
# results.each do |customer|
# customers << Customer.find_by_id(customer.id)
# end
#end
return customers.order(:name)
end
# proforms a bruteforce sync operation

37
app/models/payment.rb Normal file
View File

@@ -0,0 +1,37 @@
#The MIT License (MIT)
#
#Copyright (c) 2016 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 Payment
unloadable
include ActiveModel::Model
attr_accessor :errors, :customer_id, :account_id, :payment_method_id, :total_amount
validates_presence_of :customer_id, :account_id, :payment_method_id, :total_amount
validates :total_amount, numericality: true
def save
payment = Quickbooks::Model::Payment.new
payment.customer_id = @customer_id.to_i
payment.deposit_to_account_id = @account_id.to_i
payment.payment_method_id = @payment_method_id.to_i
payment.total = @total_amount
Qbo.get_base(:payment).service.update(payment)
end
def save!
save
end
# Dummy stub to make validtions happy.
def update_attribute
end
end

View File

@@ -46,11 +46,23 @@ class QboInvoice < ActiveRecord::Base
end
def self.sync_by_id(id)
#update the information in the database
invoice = get_base.service.fetch_by_id(id)
qbo_invoice = find_or_create_by(id: invoice.id)
qbo_invoice.doc_number = invoice.doc_number
qbo_invoice.id = invoice.id
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
def self.update(id)

View File

@@ -72,7 +72,7 @@ class Vehicle < ActiveRecord::Base
# Force Upper Case for VIN numbers
def vin=(val)
# The to_s is in case you get nil/non-string
write_attribute(:vin, val.to_s.upcase)
write_attribute(:vin, val.to_s.scan(/^[A-Za-z0-9]+$/).join.upcase)
end
# search for a vin

View File

@@ -12,12 +12,37 @@
<tr>
<th>Primary Phone</th>
<td><%= customer.primary_phone %></td>
<td><%= number_to_phone(customer.primary_phone.gsub(/[^\d]/, '').to_i, area_code: true) if customer.primary_phone %></td>
</tr>
<tr>
<th>Mobile Phone</th>
<td><%= customer.mobile_phone %></td>
<td><%= number_to_phone(customer.mobile_phone.gsub(/[^\d]/, '').to_i, area_code: true) if customer.mobile_phone %></td>
</tr>
<tr>
<th>Bill Address</th>
<td><%= customer.billing_address %></td>
</tr>
<tr>
<th>Shipping Address</th>
<td><%= customer.shipping_address %></td>
</tr>
<tr>
<th>Issues</th>
<td><%= customer.issues.count %></td>
</tr>
<tr>
<th>Account Balance</th>
<td>$<%= customer.balance %></td>
</tr>
<tr>
<th>Balance With Jobs</th>
<td>$<%= customer.balance_with_jobs %></td>
</tr>
<tr>
@@ -26,12 +51,6 @@
</tr>
<tr>
<th>Issues</th>
<td><%= customer.issues.count %></td>
</tr>
<tr>
<td/>
<td>
<%= button_to "Edit Customer", edit_customer_path(customer), method: :get%>
</td>

View File

@@ -3,19 +3,17 @@
<%= form_tag(customers_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search Customers" %>
<%= submit_tag "Search" %>
<%= button_to "New Customer", new_customer_path, method: :get %>
<% end %>
<br/>
<% if @customers.present? %>
<br/>
<% @customers.each do |c| %>
<div class="row">
<div class="span6 columns">
<%= link_to c, customer_path(c.id) %>
<br/>
<% @customers.each do |c| %>
<div class="row">
<div class="span6 columns">
<%= link_to c, customer_path(c.id) %>
</div>
</div>
</div>
<% end %>
<% end %>
<div class="actions">
<%= will_paginate @customers %>
@@ -26,5 +24,5 @@
<% end %>
<div>
<b>Last Sync: </b> <%= Qbo.last_sync %>
<%= Customer.count %> Customers - <b>Last Sync: </b> <%= Qbo.last_sync %>
</div>

View File

@@ -1,7 +1,12 @@
<h1>Customer #<%= @customer.id %></h1>
<br/>
<h2>Details:</h2>
<%= render :partial => 'customers/details', locals: {customer: @customer} %>
<br/>
<h2>Vehicles:</h2>
<%= render :partial => 'vehicles/list' %>
<%= button_to "New Vehicle", new_customer_vehicle_path(@customer), method: :get %>
<br/>
<br/>
<h2>Issues:</h2>
<%= render :partial => 'issues/list_simple', locals: {issues: @issues} %>

View File

@@ -0,0 +1,42 @@
<div class="row">
<div class="span6 columns">
<fieldset>
<%= form_for @payment do |f| %>
<div class="clearfix">
Customer:
<div class="input">
<%= f.collection_select :customer_id, @customers, :id, :name, include_blank: true, :selected => @customer, :required => true%>
</div>
</div>
<div class="clearfix">
Deposit to Account:
<div class="input">
<%= f.collection_select :account_id, @accounts, :id, :name, include_blank: true, :selected => @account, :required => true%>
</div>
</div>
<div class="clearfix">
Payment Method:
<div class="input">
<%= f.collection_select :payment_method_id, @payment_methods, :id, :name, include_blank: true, :selected => @payment_method, :required => true%>
</div>
</div>
<div class="clearfix">
Amount:
<div class="input">
<%= f.number_field :total_amount %>
</div>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
</fieldset>
</div>
</div>

View File

@@ -0,0 +1,3 @@
<h1>New Payment</h1>
<br/>
<%= render :partial => 'payments/form' %>

View File

@@ -46,6 +46,15 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_au
name="settings[settingsOAuthConsumerSecret]" >
</td>
</tr>
<tr>
<th>Intuit QBO Webhook Token</th>
<td>
<input type="text" style="width:350px" id="settingsWebhookToken"
value="<%= settings['settingsWebhookToken'] %>"
name="settings[settingsWebhookToken]" >
</td>
</tr>
<tr>
<th>Token Expires At</th>
@@ -63,6 +72,36 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_au
<br/>
Note: You need to authenticate after saving your key and secret above
<br/>
<br/>
<!-- this will display a button that the user clicks to start the flow -->
<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>

View File

@@ -3,7 +3,7 @@
<tr>
<th>Customer</th>
<td><%= vehicle.customer.name %></td>
<td><%= link_to vehicle.customer.name, customer_path(vehicle.customer) %></td>
</tr>
<tr>

View File

@@ -41,18 +41,14 @@
<div class="clearfix">
Notes:
<div class="input">
<p>
<%= link_to_function content_tag(:span, l(:button_edit), :class => 'icon icon-edit'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @vehicle.new_record? %>
<p>
<%= content_tag 'span', :id => "issue_description_and_toolbar", :style => (@vehicle.new_record? ? nil : 'display:none') do %>
<%= f.text_area :notes,
<%= f.text_area :notes,
:cols => 60,
:rows => 10,
:accesskey => accesskey(:edit),
:class => 'wiki-edit',
:no_label => true %>
<% end %>
</p>
<%= wikitoolbar_for 'issue_description' %>
</div>
</div>

View File

@@ -16,8 +16,6 @@
</div>
<br/>
<% end %>
<br/>
<div class="actions">
<%= will_paginate @vehicles %>

View File

@@ -0,0 +1 @@
<option value="<%= vehicle.id %>"><%= vehicle.to_s.titleize %></option>

View File

@@ -2,9 +2,8 @@
<br/>
<%= form_tag(vehicles_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search Vehicles by VIN" %>
<%= submit_tag "Search" %>
<%= button_to "New Vehicle", new_vehicle_path, method: :get %>
<%= text_field_tag :search, params[:search], placeholder: "Search Vehicles by VIN" %>
<%= submit_tag "Search" %>
<% end %>
<%= render :partial => 'vehicles/list' %>

View File

@@ -0,0 +1 @@
$("#issue_vehicles_id").empty().append("<%= escape_javascript(render(:partial => @vehicles)) %>")

View 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!")

View File

@@ -8,17 +8,35 @@
#
#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.
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
#
# Main Quickbooks landing page
get 'qbo', :to=> 'qbo#index'
#authentication
get 'qbo/authenticate', :to => 'qbo#authenticate'
get 'qbo/oauth_callback', :to => 'qbo#oauth_callback'
#manual sync
get 'qbo/sync', :to => 'qbo#sync'
# Estimate & Invoice PDF
get 'qbo/estimate/:id', :to => 'estimate#show', as: :estimate
get 'qbo/invoice/:id', :to => 'invoice#show', as: :invoice
#payments
#get 'qbo/payments', :to => 'payments#new'
#post 'qbo/payments', :to => 'payments#create'
resources :payments
#webhook
post 'qbo/webhook', :to => 'qbo#qbo_webhook'
#ajax
get "update_vehicles" => 'vehicles#update_vehicles', as: 'update_vehicles'
# Nest Vehicles under customers
resources :customers do
resources :vehicles
end
#allow for just vehicles too
resources :vehicles
resources :customers

16
init.rb
View File

@@ -25,7 +25,7 @@ Redmine::Plugin.register :redmine_qbo do
name 'Redmine Quickbooks Online plugin'
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'
version '0.0.8'
version '0.3.0'
url 'https://github.com/rickbarrette/redmine_qbo'
author_url 'http://rickbarrette.org'
settings :default => {'empty' => true}, :partial => 'qbo/settings'
@@ -46,8 +46,16 @@ Redmine::Plugin.register :redmine_qbo do
WillPaginate.per_page = 10
# Register QBO top menu item
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, :qbo, { :controller => :qbo, :action => :index }, :caption => 'Quickbooks', :if => Proc.new { User.current.admin? }
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? }
menu :application_menu, :new_payment, { :controller => :payments, :action => :new }, :caption => 'New Payment', :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 => :new_issue, :param => :project_id
permission :payments, { :payments => [:index, :new] }, :public => false
menu :project_menu, :payments, { :controller => 'payments', :action => 'new' }, :caption => 'New Payment', :after => :customers, :param => :project_id
end

View File

@@ -10,6 +10,11 @@
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
# Show a dropdown for quickbooks contacts
def view_issues_form_details_bottom(context={})

View File

@@ -50,6 +50,8 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
#do nothing
end
split_vin = vin.scan(/.{1,9}/) if vin
return "
<div class=\"attributes\">
@@ -82,7 +84,7 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
<div class=\"vehicle_vin attribute\">
<div class=\"label\"><span>VIN</span>:</div>
<div class=\"value\">#{vin.gsub(/(.{9})/, '\1 ') if vin}</div>
<div class=\"value\">#{split_vin[0] if split_vin}<b>#{split_vin[1] if split_vin}</b></div>
</div>
<div class=\"vehicle_notes attribute\">