Skip to content

Commit

Permalink
Merge pull request #288 from dhanasingh/dev
Browse files Browse the repository at this point in the history
ERPmine v4.7
  • Loading branch information
Mohanraj1996 authored Apr 18, 2023
2 parents f4b8776 + 44ad731 commit 9382a9d
Show file tree
Hide file tree
Showing 88 changed files with 2,614 additions and 473 deletions.
46 changes: 26 additions & 20 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ This Plugin has the following modules:
Log Material and Asset Entries
Stock and Asset Report

* *Survey*
Create Project, Account, Contact, User and General survey
Recursive survey
Survey Responses
Survey Result

* *Dashboards*
Clock in users
Expense for issues
Lead generation vs conversion
Invoice vs Payment
Assets
Profit and loss

For more information on features, please refer to the user guide

http://erpmine.org/attachments/download/115/ERPmine-User-Guide_v4.5.pdf
Expand Down Expand Up @@ -95,30 +109,22 @@ For more information on features, please refer to the user guide

rake redmine:plugins:migrate NAME=redmine_wktime VERSION=0 RAILS_ENV=production

=== Release Notes for v4.6
=== Release Notes for v4.7

* *Features*
- Allow default choice for Check box and Radio button type survey questions.
- Change Item Dropdown list based on invoice type.
- Create a page to assemble inventory items.
- Does not allow admins to edit their own clock records.
- Allow customization of salary type at the user level.
- Add configuration for amount in words.
- Add tax number field for Account module.
- Display consumed Material list in issue detail page.
- Include a "New Row" link below the table as well.
- Allow old users in the Referred By list.
- Auto populate the Approved leaves in empty timesheets.
- Change Rating field into a dropdown in interview page.
- Add an interview type dropdown.
- Add Sales Quote module.
- Add "activity type" column in Generate Invoice popup page.
- Add language support for Portuguese.

* *Bug* *fixes*
- Auto populate the holiday description also in timesheet.
- Format all pages Edit/Delete URLs.
- Issues are not loaded When clicking issue logger.
- Display the current date clock records only.
- The interview page displays the wrong menu selection.
- The translation of some labels is wrong in some languages.
- Save Custom query issue in spent time filter.
- Add validation for available quantity in material log page.
- Compatibility error with PostGIS database.
- Make Custom fields editable in the timesheet page.
- Remove the deprecated rss_key.
- The CRM Contacts dropdown is not populating in one scenario.

We would like to thank Agilex Cyber Management Solutions for partially sponsored this release.

=== Customization

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/wkaccount_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class WkaccountController < WkcrmController

include WkaccountprojectHelper
include WksalesquoteHelper
before_action :require_login

def index
Expand Down Expand Up @@ -99,6 +100,7 @@ def edit
set_filter_session
@accountproject = formPagination(accountProjctList)
@accountEntry = WkAccount.find(params[:account_id])
@invoiceEntries = formPagination(salesQuoteList(params[:account_id], 'WkAccount'))
end
respond_to do |format|
format.html do
Expand Down
28 changes: 13 additions & 15 deletions app/controllers/wkaccountproject_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def destroy
end


def setLimitAndOffset
def setLimitAndOffset
if api_request?
@offset, @limit = api_offset_and_limit
if !params[:limit].blank?
Expand All @@ -165,26 +165,20 @@ def formPagination(entries)
end

def account_project_permission
project_id = params[:project_id]
params[:project_id] = (Project.all).first.identifier if params[:project_id].blank?
contact_id = params[:contact_id].blank? ? nil : WkCrmContact.where(:id => params[:contact_id])
contact_id = (contact_id.first).id unless contact_id.blank?
account_id = params[:account_id].blank? ? nil : WkAccount.where(:id => params[:account_id])
account_id = (account_id.first).id unless account_id.blank?

if !showCRMModule
contact = WkCrmContact.where(id: params[:contact_id]).first
account = WkAccount.where(id: params[:account_id]).first
lead = WkLead.where(id: params[:lead_id]).first

if params[:id].blank? && ((params[:contact_id].present? && contact.blank?) || (params[:account_id].present? && account.blank?) || (params[:lead_id].present? && lead.blank?))
render_403
return false
elsif project_id.blank? && contact_id.blank? && account_id.blank?
render_404
return false
elsif !params[:project_id].blank?
elsif params[:project_id].present?
find_project_by_project_id
end
end

def check_account_proj_module_permission
if params[:contact_id].blank? && params[:account_id].blank? && !params[:project_id].blank? && !User.current.allowed_to?(:view_accounts, @project)
if !showCRMModule || (@project.present? && !User.current.allowed_to?(:view_accounts, @project))
render_403
return false
end
Expand Down Expand Up @@ -214,7 +208,11 @@ def additionalAccountType
end

def set_filter_session
filters = [:contact_id, :account_id, :polymorphic_filter]
filters = [:contact_id, :account_id, :polymorphic_filter, :lead_id]
super(filters, {:project_id => params[:project_id]})
end

def addLeadDD
true
end
end
14 changes: 14 additions & 0 deletions app/controllers/wkbase_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,18 @@ def updateWkuserVal
def loadPurchaseDD
false
end

def addLeadDD
false
end

def redirect_controller
if ['wklead', 'wkcrmaccount', 'wkcrmcontact'].include?controller_name
'wksalesquote'
elsif ['wkrfq'].include?controller_name
'wkquote'
else
controller_name
end
end
end
36 changes: 19 additions & 17 deletions app/controllers/wkcontact_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class WkcontactController < WkcrmController
unloadable
include WkaccountprojectHelper
include WksalesquoteHelper

def index
sort_init 'updated_at', 'desc'
Expand Down Expand Up @@ -45,14 +46,14 @@ def index
else
wkcontact = wkcontact.joins("LEFT OUTER JOIN wk_leads ON wk_crm_contacts.id = wk_leads.contact_id").where(:contact_type => getContactType, wk_leads: { status: ['C', nil] }).where(:account_id => accountId).where("LOWER(wk_crm_contacts.first_name) like LOWER(?) OR LOWER(wk_crm_contacts.last_name) like LOWER(?)", "%#{contactName}%", "%#{contactName}%")
end

elsif contactName.blank? && !accountId.blank?
if accountId == 'AA'
wkcontact = wkcontact.joins("LEFT OUTER JOIN wk_leads ON wk_crm_contacts.id = wk_leads.contact_id").where(:contact_type => getContactType, wk_leads: { status: ['C', nil] }).where.not(:account_id => nil)
else
wkcontact = wkcontact.joins("LEFT OUTER JOIN wk_leads ON wk_crm_contacts.id = wk_leads.contact_id").where(:contact_type => getContactType, wk_leads: { status: ['C', nil] }).where(:account_id => accountId)
end

elsif !contactName.blank? && accountId.blank?
wkcontact = wkcontact.joins("LEFT OUTER JOIN wk_leads ON wk_crm_contacts.id = wk_leads.contact_id").where(:contact_type => getContactType, wk_leads: { status: ['C', nil] }).where(:account_id => nil).where("LOWER(wk_crm_contacts.first_name) like LOWER(?) OR LOWER(wk_crm_contacts.last_name) like LOWER(?)", "%#{contactName}%", "%#{contactName}%")
else
Expand All @@ -73,8 +74,8 @@ def index
end
format.csv do
headers = { name: l(:field_name), acc_name: l(:label_account_name), location: l(:label_location), title: l(:field_title), email: l(:field_mail), phone: l(:label_work_phone), assignee: l(:field_assigned_to), modified: l(:label_modified) }
data = wkcontact.map do |e|
{name: e.name, acc_name: (e&.account&.name || ''), location: (e&.location&.name || ''), title: (e&.title || ''), email: (e&.address&.email || ''), phone: (e&.address&.work_phone || ''), assignee: (e&.assigned_user&.name(:firstname_lastname) || ''), modified: e.updated_at.localtime.strftime("%Y-%m-%d") }
data = wkcontact.map do |e|
{name: e.name, acc_name: (e&.account&.name || ''), location: (e&.location&.name || ''), title: (e&.title || ''), email: (e&.address&.email || ''), phone: (e&.address&.work_phone || ''), assignee: (e&.assigned_user&.name(:firstname_lastname) || ''), modified: e.updated_at.localtime.strftime("%Y-%m-%d") }
end
respond_to do |format|
format.csv {
Expand All @@ -86,21 +87,22 @@ def index
end

def edit
@conEditEntry = nil
@conEditEntry = nil
unless params[:contact_id].blank?
set_filter_session
@accountproject = formPagination(accountProjctList)
@conEditEntry = WkCrmContact.find(params[:contact_id])
@invoiceEntries = formPagination(salesQuoteList(params[:contact_id], 'WkCrmContact'))
end

respond_to do |format|
format.html {
format.html {
render :layout => !request.xhr?
}
format.api
end
end

def update
wkContact = contactSave
errorMsg = wkContact.errors.full_messages.join("<br>")
Expand All @@ -117,14 +119,14 @@ def update
format.api{
if errorMsg.blank?
render :plain => errorMsg, :layout => nil
else
@error_messages = errorMsg.split('\n')
else
@error_messages = errorMsg.split('\n')
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil
end
}
end
end

def destroy
contact = WkCrmContact.find(params[:contact_id].to_i)
if contact.destroy
Expand All @@ -135,19 +137,19 @@ def destroy
end
redirect_back_or_default :action => 'index', :tab => params[:tab]
end

def set_filter_session
filters = [:contactname, :account_id, :location_id]
super(filters)
end

def formPagination(entries)
@entry_count = entries.count
setLimitAndOffset()
@contact = entries.limit(@limit).offset(@offset)
end
def setLimitAndOffset

def setLimitAndOffset
if api_request?
@offset, @limit = api_offset_and_limit
if !params[:limit].blank?
Expand All @@ -160,13 +162,13 @@ def setLimitAndOffset
@entry_pages = Paginator.new @entry_count, per_page_option, params['page']
@limit = @entry_pages.per_page
@offset = @entry_pages.offset
end
end
end

def getAccountLbl
l(:field_account)
end

def contactLbl
l(:label_contact_plural)
end
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/wkcrm_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def getActRelatedIds
if params[:related_type] == "WkOpportunity"
relatedId = WkOpportunity.all.order(:name)
elsif params[:related_type] == "WkLead"
relatedId = WkLead.includes(:contact).where.not(:status => 'C').order("wk_crm_contacts.first_name, wk_crm_contacts.last_name")
relatedId = WkLead.includes(:contact).where.not(:status => 'C').where('wk_crm_contacts.contact_type' => 'C').order("wk_crm_contacts.first_name, wk_crm_contacts.last_name")
elsif params[:related_type] == "WkCrmContact"
#relatedId = WkCrmContact.includes(:lead).where(wk_leads: { status: ['C', nil] }).where(:contact_type => params[:contact_type]).order(:first_name, :last_name)
hookType = call_hook(:additional_type)
Expand Down Expand Up @@ -263,4 +263,16 @@ def get_plural_activity_label
def get_activity_label
l(:label_new_activity)
end

def getLabelInvNum
l(:label_quote_number)
end

def getDateLbl
l(:label_quote_date)
end

def isInvPaymentLink
false
end
end
42 changes: 13 additions & 29 deletions app/controllers/wkinvoice_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,13 @@

class WkinvoiceController < WkorderentityController

accept_api_auth :index, :edit, :update, :getInvProj, :getAccountProjIds
accept_api_auth :index, :edit, :update, :getInvProj, :getAccountProjIds, :export
@@invmutex = Mutex.new

def newOrderEntity(parentId, parentType)
newInvoice(parentId, parentType)
end

def newInvoice(parentId, parentType)
invoiceFreq = getInvFreqAndFreqStart
invIntervals = getIntervals(params[:start_date].to_date, params[:end_date].to_date, invoiceFreq["frequency"], invoiceFreq["start"], true, false)
if !params[:project_id].blank? && params[:project_id] != '0'
@projectsDD = Project.where(:id => params[:project_id].to_i).pluck(:name, :id)
@issuesDD = Issue.where(:project_id => params[:project_id].to_i).pluck(:subject, :id)
setTempEntity(invIntervals[0][0], invIntervals[0][1], parentId, parentType, params[:populate_items], params[:project_id])
elsif (!params[:project_id].blank? && params[:project_id] == '0') || params[:isAccBilling] == "true"
accountProjects = WkAccountProject.where(:parent_type => parentType, :parent_id => parentId.to_i)
unless accountProjects.blank?
@projectsDD = accountProjects[0].parent.projects.pluck(:name, :id)
setTempEntity(invIntervals[0][0], invIntervals[0][1], parentId, parentType, params[:populate_items], params[:project_id])
else
client = parentType.constantize.find(parentId)
flash[:error] = l(:warn_billable_project_not_configured, :name => client.name)
redirect_to :action => 'new'
end
else
flash[:error] = l(:warning_select_project)
redirect_to :action => 'new'
end
setupNewInvoice(parentId, parentType, invIntervals[0][0], invIntervals[0][1])
end

def saveOrderInvoice(parentId, parentType, projectId, invDate, invoicePeriod, isgenerate, getInvoiceType)
Expand Down Expand Up @@ -386,20 +365,21 @@ def generateTimeEntries
lastArray = invIntervals.length - 1
todate = invIntervals[lastArray][1]
timeEntries = WkInvoiceItem.getGenerateEntries(todate.to_date, fromDate.to_date, parent_id, parent_type, params[:projectID], TimeEntry, "time_entries")
data1 = timeEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), proj_name: e&.project&.name, subject: e.issue.to_s, usr_name: e.user.name, spent_on: e.spent_on, hours: e.hours}}
listHeader1 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), user: l(:label_user), date: l(:label_date), hour: l(:field_hours) }

data1 = timeEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), proj_name: e&.project&.name, subject: e.issue.to_s, usr_name: e&.user&.name, activity: e&.activity.to_s, spent_on: e.spent_on, hours: e.hours}}
listHeader1 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), user: l(:label_user), activity: l(:label_activity_type), date: l(:label_date), hour: l(:field_hours) }

materialEntries = WkInvoiceItem.getGenerateEntries(todate.to_date, fromDate.to_date, parent_id, parent_type, params[:projectID], WkMaterialEntry, "wk_material_entries")
data2 = materialEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), project: e&.project&.name, issue: e.issue.to_s, spent_on: e.spent_on, product: e.inventory_item&.product_item&.product&.name, selling_price: e.currency.to_s+" "+e.selling_price.to_s, quantity: e.quantity }}
listHeader2 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), date: l(:label_date), product_name: l(:label_product), selling_price: l(:label_selling_price), quantity: l(:field_quantity)}
data2 = materialEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), project: e&.project&.name, issue: e.issue.to_s, activity: e&.activity.to_s, spent_on: e.spent_on, product: e.inventory_item&.product_item&.product&.name, selling_price: e.currency.to_s+" "+e.selling_price.to_s, quantity: e.quantity }}
listHeader2 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), activity: l(:label_activity_type), date: l(:label_date), product_name: l(:label_product), selling_price: l(:label_selling_price), quantity: l(:field_quantity)}

schudleEntries = WkInvoiceItem.getFcItems(invIntervals[0][0].to_date, todate.to_date, params[:projectID], parent_id, parent_type)
data3 = schudleEntries.map{|e| { acc_name: (e&.name || e&.c_name), project: e&.project&.name, issue: e&.milestone.to_s, spent_on: e.bill_date, amount: e&.currency+" "+e&.amount.to_s}}
listHeader3 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), date: l(:label_date), amount: l(:field_amount)}

listHeader4 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), user: l(:label_user), date: l(:label_date), amount: l(:field_amount)}
listHeader4 = { acc_cont_name: l(:field_account), project_name: l(:label_project), issue: l(:label_invoice_name), user: l(:label_user), activity: l(:label_activity_type), date: l(:label_date), amount: l(:field_amount)}
expenseEntries = WkInvoiceItem.getGenerateEntries(todate.to_date, fromDate.to_date, parent_id, parent_type, params[:projectID], WkExpenseEntry, "wk_expense_entries")
data4 = expenseEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), proj_name: e&.project&.name, subject: e.issue.to_s, usr_name: e.user&.name, spent_on: e.spent_on, amount: e&.currency+" "+e&.amount.to_s}}
data4 = expenseEntries.map{|e| {id: e.id, acc_name: (e&.name || e&.c_name), proj_name: e&.project&.name, subject: e.issue.to_s, usr_name: e.user&.name, activity: e&.activity.to_s, spent_on: e.spent_on, amount: e&.currency+" "+e&.amount.to_s}}

data = []
data << {data: data1, header: listHeader1, type: "time_entries", title: l(:label_select_time_entries)} if data1.length > 0
Expand Down Expand Up @@ -454,4 +434,8 @@ def isInvoiceController
def addExpenseType
true
end

def showQuantityPopup
true
end
end
8 changes: 7 additions & 1 deletion app/controllers/wklead_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class WkleadController < WkcrmController
unloadable
include WktimeHelper
include WkleadHelper
include WkaccountprojectHelper
include WksalesquoteHelper
accept_api_auth :index, :edit, :update

def index
Expand Down Expand Up @@ -87,7 +89,11 @@ def show

def edit
@lead = nil
@lead = WkLead.find(params[:lead_id]) unless params[:lead_id].blank?
if params[:lead_id].present?
@lead = WkLead.find(params[:lead_id])
@accountproject = formPagination(accountProjctList)
@invoiceEntries = formPagination(salesQuoteList(params[:lead_id], 'WkLead'))
end
@lead
end

Expand Down
Loading

0 comments on commit 9382a9d

Please sign in to comment.