mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Added comments to clearify methods
This commit is contained in:
@@ -35,14 +35,20 @@ class CustomersController < ApplicationController
|
|||||||
|
|
||||||
autocomplete :customer, :name, :full => true, :extra_data => [:id]
|
autocomplete :customer, :name, :full => true, :extra_data => [:id]
|
||||||
|
|
||||||
|
# getter method for a customer's vehicles
|
||||||
|
# TODO: move into customer model
|
||||||
def filter_vehicles_by_customer
|
def filter_vehicles_by_customer
|
||||||
@filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer])
|
@filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# getter method for a customer's invoices
|
||||||
|
# TODO: move into customer model
|
||||||
def filter_invoices_by_customer
|
def filter_invoices_by_customer
|
||||||
@filtered_invoices = QboInvoice.all.where(customer_id: params[:selected_customer])
|
@filtered_invoices = QboInvoice.all.where(customer_id: params[:selected_customer])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# getter method for a customer's estimates
|
||||||
|
# TODO: move into customer model
|
||||||
def filter_estimates_by_customer
|
def filter_estimates_by_customer
|
||||||
@filtered_estimates = QboEstimate.all.where(customer_id: params[:selected_customer])
|
@filtered_estimates = QboEstimate.all.where(customer_id: params[:selected_customer])
|
||||||
end
|
end
|
||||||
@@ -57,10 +63,12 @@ class CustomersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# initialize a new customer
|
||||||
def new
|
def new
|
||||||
@customer = Customer.new
|
@customer = Customer.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# create a new customer
|
||||||
def create
|
def create
|
||||||
@customer = Customer.new(params[:customer])
|
@customer = Customer.new(params[:customer])
|
||||||
if @customer.save
|
if @customer.save
|
||||||
@@ -108,6 +116,7 @@ class CustomersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# delete a customer
|
||||||
def destroy
|
def destroy
|
||||||
begin
|
begin
|
||||||
Customer.find_by_id(params[:id]).destroy
|
Customer.find_by_id(params[:id]).destroy
|
||||||
@@ -118,7 +127,7 @@ class CustomersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Customer view for an issue
|
# displays an issue for a customer with a provided security CustomerToken
|
||||||
def view
|
def view
|
||||||
|
|
||||||
User.current = User.find_by lastname: 'Anonymous'
|
User.current = User.find_by lastname: 'Anonymous'
|
||||||
@@ -153,14 +162,18 @@ class CustomersController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# redmine permission - add customers
|
||||||
def add_customer
|
def add_customer
|
||||||
global_check_permission(:add_customers)
|
global_check_permission(:add_customers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# redmine permission - view customers
|
||||||
def view_customer
|
def view_customer
|
||||||
global_check_permission(:view_customers)
|
global_check_permission(:view_customers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# checks to see if there is only one item in an array
|
||||||
|
# @return true if array only has one item
|
||||||
def only_one_non_zero?( array )
|
def only_one_non_zero?( array )
|
||||||
found_non_zero = false
|
found_non_zero = false
|
||||||
array.each do |val|
|
array.each do |val|
|
||||||
|
|||||||
Reference in New Issue
Block a user