097 column offset fixed, unneedeed cols commented out, gaussian round partly mv to hsql
This commit is contained in:
+1
-1
@@ -89,7 +89,7 @@
|
|||||||
|
|
||||||
<!--- global settings --->
|
<!--- global settings --->
|
||||||
<!--- *************************************************************************************************** --->
|
<!--- *************************************************************************************************** --->
|
||||||
<cfset request.APP_VERSION="0.00.096"/> <!--- *********************************************************** --->
|
<cfset request.APP_VERSION="0.00.097"/> <!--- *********************************************************** --->
|
||||||
<!--- *************************************************************************************************** --->
|
<!--- *************************************************************************************************** --->
|
||||||
<cfset request.STAND=getStand()/>
|
<cfset request.STAND=getStand()/>
|
||||||
<cfset request.RECORDS_PER_PAGE=500/>
|
<cfset request.RECORDS_PER_PAGE=500/>
|
||||||
|
|||||||
@@ -81,7 +81,8 @@
|
|||||||
siv.hash as line_key
|
siv.hash as line_key
|
||||||
,siv.date_nop as serviceStart,
|
,siv.date_nop as serviceStart,
|
||||||
siv.date_end as serviceEnd,
|
siv.date_end as serviceEnd,
|
||||||
siv.discount as service_discount, siv.cnt as service_quantity
|
siv.discount as service_discount,
|
||||||
|
siv.cnt as service_quantity
|
||||||
/*,p.__name as line_key*/, p.ed_izm, p.name as component, p.type, p.cnt*coalesce(siv.cnt,1) as component_quantity,
|
/*,p.__name as line_key*/, p.ed_izm, p.name as component, p.type, p.cnt*coalesce(siv.cnt,1) as component_quantity,
|
||||||
aa.__name as additional_agreement, aa.__id::text as additional_agreement_uid
|
aa.__name as additional_agreement, aa.__id::text as additional_agreement_uid
|
||||||
--, aa.is_actual
|
--, aa.is_actual
|
||||||
@@ -91,6 +92,7 @@
|
|||||||
--,ft.free_tier
|
--,ft.free_tier
|
||||||
,s.probability_pc
|
,s.probability_pc
|
||||||
,siv.__id::text as siv_uid
|
,siv.__id::text as siv_uid
|
||||||
|
,coalesce(siv.cnt*(100.-siv.discount)/100.*p.price*(100.-p.discount)/100., 0.) as discounted_price
|
||||||
from elma.deals d
|
from elma.deals d
|
||||||
JOIN STATUS s ON (d.__status_status = s.status_id)
|
JOIN STATUS s ON (d.__status_status = s.status_id)
|
||||||
join elma.deals_services siv on (d.__id=ANY(siv.deal))
|
join elma.deals_services siv on (d.__id=ANY(siv.deal))
|
||||||
@@ -544,9 +546,10 @@ WITH
|
|||||||
max(component_quantity) as component_quantity,
|
max(component_quantity) as component_quantity,
|
||||||
max(service_quantity) as service_quantity,
|
max(service_quantity) as service_quantity,
|
||||||
max(service_discount) as service_discount,
|
max(service_discount) as service_discount,
|
||||||
|
max(discounted_price) as discounted_price,
|
||||||
max(type) as type,
|
max(type) as type,
|
||||||
max(ed_izm) as ed_izm,
|
max(ed_izm) as ed_izm,
|
||||||
max(coalesce(service_quantity*(100.-service_discount)/100.*price*(100.-component_discount)/100., 0.)) as discounted_price,
|
--max(coalesce(service_quantity*(100.-service_discount)/100.*price*(100.-component_discount)/100., 0.)) as discounted_price,
|
||||||
max(serviceStart) as serviceStart,
|
max(serviceStart) as serviceStart,
|
||||||
max(serviceEnd) as serviceEnd,
|
max(serviceEnd) as serviceEnd,
|
||||||
max(line_key) as line_key,
|
max(line_key) as line_key,
|
||||||
@@ -579,15 +582,25 @@ SELECT
|
|||||||
<d:field title="SKU code по специф.">s.sku_code as sku_code</d:field><!--- без суффикса --->
|
<d:field title="SKU code по специф.">s.sku_code as sku_code</d:field><!--- без суффикса --->
|
||||||
<d:field title="Кол-во компонента по спец." cfSqlType="CF_SQL_NUMERIC">s.component_quantity</d:field>
|
<d:field title="Кол-во компонента по спец." cfSqlType="CF_SQL_NUMERIC">s.component_quantity</d:field>
|
||||||
<d:field title="Кол-во сервиса по спец." cfSqlType="CF_SQL_NUMERIC">s.service_quantity</d:field>
|
<d:field title="Кол-во сервиса по спец." cfSqlType="CF_SQL_NUMERIC">s.service_quantity</d:field>
|
||||||
<d:field title="Скидка на сервис" cfSqlType="CF_SQL_NUMERIC">s.service_discount</d:field>
|
<!--- <d:field title="Скидка на сервис" cfSqlType="CF_SQL_NUMERIC">s.service_discount</d:field> --->
|
||||||
<d:field title="Тип по спец.">s.type</d:field>
|
<d:field title="Тип по спец.">s.type</d:field>
|
||||||
<d:field title="Ед.изм.">s.ed_izm</d:field>
|
<d:field title="Ед.изм.">s.ed_izm</d:field>
|
||||||
<d:field title="Цена &##8381; с НДС" cfSqlType="CF_SQL_NUMERIC">coalesce(s.service_quantity*(100.-s.service_discount)/100.*s.price*(100.-s.component_discount)/100., 0.) as discounted_price</d:field>
|
<d:field title="Цена &##8381; с НДС" cfSqlType="CF_SQL_NUMERIC">
|
||||||
|
CASE
|
||||||
|
-- Isolate the 3rd decimal place using MOD instead of %
|
||||||
|
WHEN ABS(MOD(TRUNCATE(s.discounted_price * 1000, 0), 10)) = 5
|
||||||
|
AND ABS(MOD(TRUNCATE(s.discounted_price * 100, 0), 2)) = 0
|
||||||
|
-- If it's a perfect .xx5 tie and the 2nd digit is EVEN, shave off the 5
|
||||||
|
THEN TRUNCATE(s.discounted_price, 2)
|
||||||
|
-- In all other cases, standard mathematical rounding applies safely
|
||||||
|
ELSE ROUND(s.discounted_price, 2)
|
||||||
|
END as discounted_price
|
||||||
|
</d:field>
|
||||||
<d:field title="Дата НОУ" cfSqlType="CF_SQL_TIMESTAMP">s.serviceStart</d:field>
|
<d:field title="Дата НОУ" cfSqlType="CF_SQL_TIMESTAMP">s.serviceStart</d:field>
|
||||||
<d:field title="Дата оконч." cfSqlType="CF_SQL_TIMESTAMP">s.serviceEnd</d:field>
|
<d:field title="Дата оконч." cfSqlType="CF_SQL_TIMESTAMP">s.serviceEnd</d:field>
|
||||||
<d:field title="Ключ строки">s.line_key</d:field>
|
<d:field title="Ключ строки">s.line_key</d:field>
|
||||||
<d:field title="Цена с НДС" cfSqlType="CF_SQL_NUMERIC">s.price</d:field>
|
<!--- <d:field title="Цена с НДС до скидки" cfSqlType="CF_SQL_NUMERIC">s.price</d:field> --->
|
||||||
<d:field title="Скидка % на компонент" cfSqlType="CF_SQL_NUMERIC">s.component_discount</d:field>
|
<!--- <d:field title="Скидка % на компонент" cfSqlType="CF_SQL_NUMERIC">s.component_discount</d:field> --->
|
||||||
<d:field title="Договор">s.contract</d:field>
|
<d:field title="Договор">s.contract</d:field>
|
||||||
<d:field title="contract_uid">s.contract_uid</d:field>
|
<d:field title="contract_uid">s.contract_uid</d:field>
|
||||||
<d:field title="Допник">s.additional_agreement</d:field>
|
<d:field title="Допник">s.additional_agreement</d:field>
|
||||||
@@ -604,7 +617,7 @@ SELECT
|
|||||||
<d:field>m.dimension1</d:field>
|
<d:field>m.dimension1</d:field>
|
||||||
<d:field title="Ед.изм.">m.unit</d:field>
|
<d:field title="Ед.изм.">m.unit</d:field>
|
||||||
<d:field title="Сырая метрика" cfSqlType="CF_SQL_NUMERIC">m.raw_metric</d:field>
|
<d:field title="Сырая метрика" cfSqlType="CF_SQL_NUMERIC">m.raw_metric</d:field>
|
||||||
<d:field title="Приведенная метрика" cfSqlType="CF_SQL_NUMERIC">m.metric</d:field>
|
<d:field title="Приведенная метрика" cfSqlType="CF_SQL_NUMERIC">round(m.metric,3) as metric</d:field>
|
||||||
|
|
||||||
<d:field title="Free Tier" cfSqlType="CF_SQL_NUMERIC">coalesce(ft.free_tier,0) as free_tier</d:field>
|
<d:field title="Free Tier" cfSqlType="CF_SQL_NUMERIC">coalesce(ft.free_tier,0) as free_tier</d:field>
|
||||||
|
|
||||||
@@ -726,7 +739,7 @@ S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load,
|
|||||||
<th width="5%">Кол-во метр.</th>
|
<th width="5%">Кол-во метр.</th>
|
||||||
<th width="5%">Free Tier.</th>
|
<th width="5%">Free Tier.</th>
|
||||||
<th width="5%">Опл. объем</th>
|
<th width="5%">Опл. объем</th>
|
||||||
<th width="3%">Ед.изм.</th>
|
<th width="2%">Ед.изм.</th>
|
||||||
<th width="3%">Цена ₽ со скид., с НДС</th>
|
<th width="3%">Цена ₽ со скид., с НДС</th>
|
||||||
<th width="3%">Стоимость ₽ с НДС</th>
|
<th width="3%">Стоимость ₽ с НДС</th>
|
||||||
|
|
||||||
@@ -749,9 +762,9 @@ S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load,
|
|||||||
<td width="3%">Цена ₽ до ск. с НДС</td>
|
<td width="3%">Цена ₽ до ск. с НДС</td>
|
||||||
<td width="3%">Цена ₽ co ск. с НДС без окр.</td>
|
<td width="3%">Цена ₽ co ск. с НДС без окр.</td>
|
||||||
<td width="3%">Кол-во сервиса</td>
|
<td width="3%">Кол-во сервиса</td>
|
||||||
<td width="3%">Скидка на сервис</td>
|
<!--- <td width="3%">Скидка на сервис</td> --->
|
||||||
<td width="3%">Кол-во комп-та</td>
|
<td width="3%">Кол-во комп-та</td>
|
||||||
<td width="3%">Скидка на комп-т %</td>
|
<!--- <td width="3%">Скидка на комп-т %</td> --->
|
||||||
|
|
||||||
<!--- <td width="5%">Договор</td>
|
<!--- <td width="5%">Договор</td>
|
||||||
<td width="10%">Допник</td> --->
|
<td width="10%">Допник</td> --->
|
||||||
@@ -816,11 +829,12 @@ S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load,
|
|||||||
<td>#m_code#</td>
|
<td>#m_code#</td>
|
||||||
<td>#dimension1#</td>
|
<td>#dimension1#</td>
|
||||||
|
|
||||||
<td class="r" style="padding:0 1em;">#request.roundSafe(metric,3)#</td>
|
<td class="r" style="padding:0 1em;">#metric#</td>
|
||||||
<td class="r"><!--- #free_tier# ---></td>
|
<td class="r"><!--- #free_tier# ---></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td style="font-size:90%;">#unit# <cfif len(ed_izm)>[#ed_izm#]</cfif></td><!--- #len(unit)?unit:'['& ed_izm &']'# --->
|
<td class="c" style="font-size:80%;">#unit# <cfif len(ed_izm)>[#ed_izm#]</cfif></td><!--- #len(unit)?unit:'['& ed_izm &']'# --->
|
||||||
<td class="r">#gaussianRound(discounted_price,2)#</td>
|
<!--- <td class="r">#gaussianRound(discounted_price,2)#</td> --->
|
||||||
|
<td class="r">#discounted_price#</td>
|
||||||
<td class="r"></td>
|
<td class="r"></td>
|
||||||
|
|
||||||
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
|
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
|
||||||
@@ -836,16 +850,16 @@ S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load,
|
|||||||
<td class="r">#dateFormat(serviceEnd,'YYYY-MM-DD')#</td>
|
<td class="r">#dateFormat(serviceEnd,'YYYY-MM-DD')#</td>
|
||||||
|
|
||||||
<!--- <td class="r">#line_key#</td> --->
|
<!--- <td class="r">#line_key#</td> --->
|
||||||
<td class="r" style="color:##bbb">#request.roundSafe(raw_metric,3)#</td>
|
<td class="r" style="color:##bbb">#raw_metric#</td>
|
||||||
<td class="r">#request.roundSafe(metric,3)#</td>
|
<td class="r">#metric#</td>
|
||||||
|
|
||||||
<!--- сырые исходные данные без округлений --->
|
<!--- сырые исходные данные без округлений --->
|
||||||
<td class="r">#price#</td>
|
<!--- <td class="r">#price#</td> --->
|
||||||
<td class="r">#discounted_price#</td><!--- style="word-wrap:break-word" --->
|
<td class="r">#discounted_price#</td><!--- style="word-wrap:break-word" --->
|
||||||
<td class="r">#service_quantity#</td>
|
<td class="r">#service_quantity#</td>
|
||||||
<td class="r">#service_discount#</td>
|
<!--- <td class="r">#service_discount#</td> --->
|
||||||
<td class="r">#component_quantity#</td>
|
<td class="r">#component_quantity#</td>
|
||||||
<td class="r">#component_discount#</td>
|
<!--- <td class="r">#component_discount#</td> --->
|
||||||
|
|
||||||
<!--- <td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#contract#</a></td>
|
<!--- <td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#contract#</a></td>
|
||||||
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td> --->
|
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td> --->
|
||||||
@@ -866,7 +880,7 @@ S3 операции и трафик: <b<cfif datediff("h",qS3OpsTrfAge.dt_load,
|
|||||||
<td class="b c">#unit# <cfif len(ed_izm)>[#ed_izm#]</cfif></td>
|
<td class="b c">#unit# <cfif len(ed_izm)>[#ed_izm#]</cfif></td>
|
||||||
<td class="b r">#current_price#</td>
|
<td class="b r">#current_price#</td>
|
||||||
<td class="b r">#gaussianRoundSafe(cost_dimension_1,2)#</td>
|
<td class="b r">#gaussianRoundSafe(cost_dimension_1,2)#</td>
|
||||||
<td colspan="8"></td>
|
<td colspan="7"></td>
|
||||||
<td class="b r" title="сумма корректна, если нет замножения строк из-за наличия PAYG и FIX по одному артикулу">#request.roundSafe(accum_metric_dimension_1_all,3)#<!--- #final_metric_dimension_1_all# ---></td>
|
<td class="b r" title="сумма корректна, если нет замножения строк из-за наличия PAYG и FIX по одному артикулу">#request.roundSafe(accum_metric_dimension_1_all,3)#<!--- #final_metric_dimension_1_all# ---></td>
|
||||||
<td colspan="100"></td>
|
<td colspan="100"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user