-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor Lead Promotion Logic to Improve Separation of Concerns #1398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2008-2013 Michael Dvorkin and contributors. | ||
# | ||
# Fat Free CRM is freely distributable under the terms of MIT license. | ||
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php | ||
#------------------------------------------------------------------------------ | ||
module LeadPromotionHelper | ||
# Promote the lead by creating a contact and optional opportunity. Upon | ||
# successful promotion Lead status gets set to :converted. | ||
#---------------------------------------------------------------------------- | ||
Check noticeCode scanning / Rubocop Avoid trailing whitespace. Note
Layout/TrailingWhitespace: Trailing whitespace detected.
|
||
def promote_lead(lead, params) | ||
Check noticeCode scanning / Rubocop Use 2 spaces for indentation. Note
Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
|
||
account_params = params[:account] || {} | ||
opportunity_params = params[:opportunity] || {} | ||
|
||
Check noticeCode scanning / Rubocop Avoid trailing whitespace. Note
Layout/TrailingWhitespace: Trailing whitespace detected.
|
||
account = Account.create_or_select_for(lead, account_params) | ||
opportunity = Opportunity.create_for(lead, account, opportunity_params) | ||
contact = Contact.create_for(lead, account, opportunity, params) | ||
|
||
Check noticeCode scanning / Rubocop Avoid trailing whitespace. Note
Layout/TrailingWhitespace: Trailing whitespace detected.
|
||
[account, opportunity, contact] | ||
end | ||
end | ||
|
||
Check noticeCode scanning / Rubocop Avoid trailing whitespace. Note
Layout/TrailingWhitespace: Trailing whitespace detected.
|
Check notice
Code scanning / Rubocop
Keep indentation straight. Note