You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
843 lines
56 KiB
843 lines
56 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title> |
|
Module: Validations::Sales::FinancialValidations |
|
|
|
— Documentation by YARD 0.9.36 |
|
|
|
</title> |
|
|
|
<link rel="stylesheet" href="../../css/style.css" type="text/css" /> |
|
|
|
<link rel="stylesheet" href="../../css/common.css" type="text/css" /> |
|
|
|
<script type="text/javascript"> |
|
pathId = "Validations::Sales::FinancialValidations"; |
|
relpath = '../../'; |
|
</script> |
|
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script> |
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script> |
|
|
|
|
|
</head> |
|
<body> |
|
<div class="nav_wrap"> |
|
<iframe id="nav" src="../../class_list.html?1"></iframe> |
|
<div id="resizer"></div> |
|
</div> |
|
|
|
<div id="main" tabindex="-1"> |
|
<div id="header"> |
|
<div id="menu"> |
|
|
|
<a href="../../_index.html">Index (F)</a> » |
|
<span class='title'>Validations</span> » <span class='title'>Sales</span> |
|
» |
|
<span class="title">FinancialValidations</span> |
|
|
|
</div> |
|
|
|
<div id="search"> |
|
|
|
<a class="full_list_link" id="class_list_link" |
|
href="../../class_list.html"> |
|
|
|
<svg width="24" height="24"> |
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect> |
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect> |
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect> |
|
</svg> |
|
</a> |
|
|
|
</div> |
|
<div class="clear"></div> |
|
</div> |
|
|
|
<div id="content"><h1>Module: Validations::Sales::FinancialValidations |
|
|
|
|
|
|
|
</h1> |
|
<div class="box_info"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dl> |
|
<dt>Defined in:</dt> |
|
<dd>sales/financial_validations.rb</dd> |
|
</dl> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2> |
|
Instance Method Summary |
|
<small><a href="#" class="summary_toggle">collapse</a></small> |
|
</h2> |
|
|
|
<ul class="summary"> |
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_child_income-instance_method" title="#validate_child_income (instance method)">#<strong>validate_child_income</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_combined_income-instance_method" title="#validate_combined_income (instance method)">#<strong>validate_combined_income</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_equity_in_range_for_year_and_type-instance_method" title="#validate_equity_in_range_for_year_and_type (instance method)">#<strong>validate_equity_in_range_for_year_and_type</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_equity_less_than_staircase_difference-instance_method" title="#validate_equity_less_than_staircase_difference (instance method)">#<strong>validate_equity_less_than_staircase_difference</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_income1-instance_method" title="#validate_income1 (instance method)">#<strong>validate_income1</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'> |
|
<p>Validations methods need to be called ‘validate_<page_name>’ to run on model save or ‘validate_’ to run on submit as well.</p> |
|
</div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_income2-instance_method" title="#validate_income2 (instance method)">#<strong>validate_income2</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_monthly_leasehold_charges-instance_method" title="#validate_monthly_leasehold_charges (instance method)">#<strong>validate_monthly_leasehold_charges</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_mortgage-instance_method" title="#validate_mortgage (instance method)">#<strong>validate_mortgage</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_percentage_bought_at_least_threshold-instance_method" title="#validate_percentage_bought_at_least_threshold (instance method)">#<strong>validate_percentage_bought_at_least_threshold</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_percentage_bought_not_equal_percentage_owned-instance_method" title="#validate_percentage_bought_not_equal_percentage_owned (instance method)">#<strong>validate_percentage_bought_not_equal_percentage_owned</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
<li class="public "> |
|
<span class="summary_signature"> |
|
|
|
<a href="#validate_percentage_bought_not_greater_than_percentage_owned-instance_method" title="#validate_percentage_bought_not_greater_than_percentage_owned (instance method)">#<strong>validate_percentage_bought_not_greater_than_percentage_owned</strong>(record) ⇒ Object </a> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span> |
|
|
|
</li> |
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list"> |
|
<h2>Instance Method Details</h2> |
|
|
|
|
|
<div class="method_details first"> |
|
<h3 class="signature first" id="validate_child_income-instance_method"> |
|
|
|
#<strong>validate_child_income</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 80</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_child_income'>validate_child_income</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_ecstat2'>ecstat2</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span><span class='period'>.</span><span class='id identifier rubyid_positive?'>positive?</span> <span class='op'>&&</span> <span class='id identifier rubyid_is_economic_status_child?'>is_economic_status_child?</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_ecstat2'>ecstat2</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_start_date'>start_date</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span> <span class='op'>>=</span> <span class='int'>2023</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:ecstat2</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.child_has_income</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:income2</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.child_has_income</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_combined_income-instance_method"> |
|
|
|
#<strong>validate_combined_income</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 27</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_combined_income'>validate_combined_income</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income1'>income1</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_la'>la</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_shared_ownership_scheme?'>shared_ownership_scheme?</span> |
|
|
|
<span class='id identifier rubyid_combined_income'>combined_income</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income1'>income1</span> <span class='op'>+</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span> <span class='op'>=</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>income1</span><span class='words_sep'> </span><span class='tstring_content'>income2</span><span class='words_sep'> </span><span class='tstring_content'>ownershipsch</span><span class='words_sep'> </span><span class='tstring_content'>uprn</span><span class='words_sep'> </span><span class='tstring_content'>la</span><span class='words_sep'> </span><span class='tstring_content'>postcode_full</span><span class='tstring_end'>]</span></span> |
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_london_property?'>london_property?</span> <span class='op'>&&</span> <span class='id identifier rubyid_combined_income'>combined_income</span> <span class='op'>></span> <span class='int'>90_000</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:over_combined_hard_max_for_london</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.combined_over_hard_max_for_london</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_property_not_in_london?'>property_not_in_london?</span> <span class='op'>&&</span> <span class='id identifier rubyid_combined_income'>combined_income</span> <span class='op'>></span> <span class='int'>80_000</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:over_combined_hard_max_for_outside_london</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.combined_over_hard_max_for_outside_london</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_equity_in_range_for_year_and_type-instance_method"> |
|
|
|
#<strong>validate_equity_in_range_for_year_and_type</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 89</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_equity_in_range_for_year_and_type'>validate_equity_in_range_for_year_and_type</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_collection_start_year'>collection_start_year</span> |
|
|
|
<span class='id identifier rubyid_ranges'>ranges</span> <span class='op'>=</span> <span class='const'>EQUITY_RANGES_BY_YEAR</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_collection_start_year'>collection_start_year</span><span class='comma'>,</span> <span class='const'>DEFAULT_EQUITY_RANGES</span><span class='rparen'>)</span> |
|
|
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid_range'>range</span> <span class='op'>=</span> <span class='id identifier rubyid_ranges'>ranges</span><span class='lbracket'>[</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span><span class='rparen'>)</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span> <span class='op'><</span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:type</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.under_min</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>min_equity:</span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:equity</span><span class='comma'>,</span> <span class='symbol'>:under_min</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.under_min</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>min_equity:</span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span><span class='rparen'>)</span> |
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span> <span class='op'>></span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:type</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.over_max</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>max_equity:</span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:equity</span><span class='comma'>,</span> <span class='symbol'>:over_max</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.over_max</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>max_equity:</span> <span class='id identifier rubyid_range'>range</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_equity_less_than_staircase_difference-instance_method"> |
|
|
|
#<strong>validate_equity_less_than_staircase_difference</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 105</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_equity_less_than_staircase_difference'>validate_equity_less_than_staircase_difference</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_saledate'>saledate</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_start_year_after_2024?'>start_year_after_2024?</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span> <span class='op'>></span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> <span class='op'>-</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> |
|
<span class='id identifier rubyid_formatted_equity'>formatted_equity</span> <span class='op'>=</span> <span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%g</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_equity'>equity</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:equity</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.over_stairowned_minus_stairbought</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>equity:</span> <span class='id identifier rubyid_formatted_equity'>formatted_equity</span><span class='comma'>,</span> <span class='label'>staircase_difference:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> <span class='op'>-</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span><span class='comma'>,</span> <span class='label'>buyer_owns:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_joint_purchase?'>joint_purchase?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyers own</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyer owns</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairowned</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.over_stairowned_minus_stairbought</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>equity:</span> <span class='id identifier rubyid_formatted_equity'>formatted_equity</span><span class='comma'>,</span> <span class='label'>staircase_difference:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> <span class='op'>-</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span><span class='comma'>,</span> <span class='label'>buyer_owns:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_joint_purchase?'>joint_purchase?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyers own</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyer owns</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairbought</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.equity.over_stairowned_minus_stairbought</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>equity:</span> <span class='id identifier rubyid_formatted_equity'>formatted_equity</span><span class='comma'>,</span> <span class='label'>staircase_difference:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> <span class='op'>-</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span><span class='comma'>,</span> <span class='label'>buyer_owns:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_joint_purchase?'>joint_purchase?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyers own</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyer owns</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_income1-instance_method"> |
|
|
|
#<strong>validate_income1</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring"> |
|
<div class="discussion"> |
|
|
|
<p>Validations methods need to be called ‘validate_<page_name>’ to run on model save or ‘validate_’ to run on submit as well</p> |
|
|
|
|
|
</div> |
|
</div> |
|
<div class="tags"> |
|
|
|
|
|
</div><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 5</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_income1'>validate_income1</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income1'>income1</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_la'>la</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_shared_ownership_scheme?'>shared_ownership_scheme?</span> |
|
|
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span> <span class='op'>=</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>income1</span><span class='words_sep'> </span><span class='tstring_content'>ownershipsch</span><span class='words_sep'> </span><span class='tstring_content'>uprn</span><span class='words_sep'> </span><span class='tstring_content'>la</span><span class='words_sep'> </span><span class='tstring_content'>postcode_full</span><span class='tstring_end'>]</span></span> |
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_london_property?'>london_property?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income1'>income1</span><span class='period'>.</span><span class='id identifier rubyid_between?'>between?</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>90_000</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:outside_london_income_range</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.outside_london_income_range</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_property_not_in_london?'>property_not_in_london?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income1'>income1</span><span class='period'>.</span><span class='id identifier rubyid_between?'>between?</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>80_000</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:outside_non_london_income_range</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.outside_non_london_income_range</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_income2-instance_method"> |
|
|
|
#<strong>validate_income2</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 16</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_income2'>validate_income2</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_la'>la</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_shared_ownership_scheme?'>shared_ownership_scheme?</span> |
|
|
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span> <span class='op'>=</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>income2</span><span class='words_sep'> </span><span class='tstring_content'>ownershipsch</span><span class='words_sep'> </span><span class='tstring_content'>uprn</span><span class='words_sep'> </span><span class='tstring_content'>la</span><span class='words_sep'> </span><span class='tstring_content'>postcode_full</span><span class='tstring_end'>]</span></span> |
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_london_property?'>london_property?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span><span class='period'>.</span><span class='id identifier rubyid_between?'>between?</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>90_000</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:outside_london_income_range</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.outside_london_income_range</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>elsif</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_property_not_in_london?'>property_not_in_london?</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_income2'>income2</span><span class='period'>.</span><span class='id identifier rubyid_between?'>between?</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>80_000</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_relevant_fields'>relevant_fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='id identifier rubyid_field'>field</span><span class='comma'>,</span> <span class='symbol'>:outside_non_london_income_range</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.income.outside_non_london_income_range</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_monthly_leasehold_charges-instance_method"> |
|
|
|
#<strong>validate_monthly_leasehold_charges</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
43 |
|
44 |
|
45</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 43</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_monthly_leasehold_charges'>validate_monthly_leasehold_charges</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:mscharge</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.monthly_leasehold_charges.not_zero</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_mscharge'>mscharge</span><span class='op'>&.</span><span class='id identifier rubyid_zero?'>zero?</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_mortgage-instance_method"> |
|
|
|
#<strong>validate_mortgage</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
39 |
|
40 |
|
41</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 39</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_mortgage'>validate_mortgage</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:mortgage</span><span class='comma'>,</span> <span class='symbol'>:cannot_be_0</span><span class='comma'>,</span> <span class='label'>message:</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.mortgage</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_mortgage_used?'>mortgage_used?</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_mortgage'>mortgage</span><span class='op'>&.</span><span class='id identifier rubyid_zero?'>zero?</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_percentage_bought_at_least_threshold-instance_method"> |
|
|
|
#<strong>validate_percentage_bought_at_least_threshold</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 65</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_percentage_bought_at_least_threshold'>validate_percentage_bought_at_least_threshold</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> |
|
|
|
<span class='id identifier rubyid_threshold'>threshold</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='lbracket'>[</span><span class='int'>2</span><span class='comma'>,</span> <span class='int'>16</span><span class='comma'>,</span> <span class='int'>18</span><span class='comma'>,</span> <span class='int'>24</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> |
|
<span class='int'>10</span> |
|
<span class='kw'>else</span> |
|
<span class='int'>1</span> |
|
<span class='kw'>end</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_threshold'>threshold</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'><</span> <span class='id identifier rubyid_threshold'>threshold</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairbought</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.staircasing.percentage_bought_must_be_at_least_threshold</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>threshold:</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:type</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.setup.type.percentage_bought_must_be_at_least_threshold</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>threshold:</span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_percentage_bought_not_equal_percentage_owned-instance_method"> |
|
|
|
#<strong>validate_percentage_bought_not_equal_percentage_owned</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 55</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_percentage_bought_not_equal_percentage_owned'>validate_percentage_bought_not_equal_percentage_owned</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_saledate'>saledate</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_start_year_after_2024?'>start_year_after_2024?</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>==</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairbought</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.staircasing.percentage_bought_equal_percentage_owned</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>stairbought:</span> <span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%g</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>stairowned:</span> <span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%g</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span><span class='rparen'>)</span><span class='rparen'>)</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairowned</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.staircasing.percentage_bought_equal_percentage_owned</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>stairbought:</span> <span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%g</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='label'>stairowned:</span> <span class='id identifier rubyid_sprintf'>sprintf</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%g</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span><span class='rparen'>)</span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
<div class="method_details "> |
|
<h3 class="signature " id="validate_percentage_bought_not_greater_than_percentage_owned-instance_method"> |
|
|
|
#<strong>validate_percentage_bought_not_greater_than_percentage_owned</strong>(record) ⇒ <tt>Object</tt> |
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code"> |
|
<tr> |
|
<td> |
|
<pre class="lines"> |
|
|
|
|
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53</pre> |
|
</td> |
|
<td> |
|
<pre class="code"><span class="info file"># File 'sales/financial_validations.rb', line 47</span> |
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_percentage_bought_not_greater_than_percentage_owned'>validate_percentage_bought_not_greater_than_percentage_owned</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> |
|
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>&&</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> |
|
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairbought'>stairbought</span> <span class='op'>></span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_stairowned'>stairowned</span> |
|
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='symbol'>:stairowned</span><span class='comma'>,</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>buyer_now_owns:</span> <span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_joint_purchase?'>joint_purchase?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyers now own</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>buyer now owns</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> |
|
<span class='kw'>end</span> |
|
<span class='kw'>end</span></pre> |
|
</td> |
|
</tr> |
|
</table> |
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div id="footer"> |
|
Generated on Thu Apr 18 11:36:47 2024 by |
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> |
|
0.9.36 (ruby-3.1.4). |
|
</div> |
|
|
|
</div> |
|
</body> |
|
</html> |