029 reconciliation

This commit is contained in:
2026-03-25 14:08:34 +03:00
parent 6d06a68ad8
commit 8187db1ea3
11 changed files with 789 additions and 40 deletions
+1 -1
View File
@@ -97,7 +97,7 @@
<!--- <cfdump var=#this.datasources#/> ---> <!--- <cfdump var=#this.datasources#/> --->
<cfset request.RECORDS_PER_PAGE=500/> <cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.028"/> <cfset request.APP_VERSION="0.00.029"/>
<cfset request.STAND=getStand()/> <cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3> <cflock scope="application" type="readonly" timeout=3>
+148 -4
View File
@@ -183,13 +183,10 @@
<td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_uid#</a></td> <td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_uid#</a></td>
<td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_name#</a></td> <td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_name#</a></td>
<!--- <td class="c">
#dateFormat(dt_contract,'YYYY-MM-DD')#
</td> --->
</tr> </tr>
</cfoutput> </cfoutput>
</table> </table>
</cfif>
<br/> <br/>
Мы не показываем тут сделки, поскольку связь со сделкой у договора не прямая и не обязательная. Сделки относятся к контрагенту, а не к договору. Сделка может быть связана с договором через дополнительное соглашение (включая нулевое соглашение, по умолчанию) Мы не показываем тут сделки, поскольку связь со сделкой у договора не прямая и не обязательная. Сделки относятся к контрагенту, а не к договору. Сделка может быть связана с договором через дополнительное соглашение (включая нулевое соглашение, по умолчанию)
<!--- <cfquery name="qDeal"> <!--- <cfquery name="qDeal">
@@ -206,5 +203,152 @@
from elma.deals d limit 10 from elma.deals d limit 10
</cfquery> ---> </cfquery> --->
<!--- ----------------------------------------------------- --->
<!--- ----------------------------------------------------- --->
<!--- ----------------------------------------------------- --->
<cfquery name="qService">
with
status(status, status_id, probability_pc) as (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
)
select
siv.__id
,siv.__name
,siv.user_description
,siv.discount
,siv.cnt
,siv.modifier_code
,siv.abstractive_service_code
,siv.is_actual
,siv.type
,siv.hash
,siv.version
,siv.name_version
,siv.date_accept
,siv.__index
,siv.date_nop
,siv.date_end
,siv.is_easy
,siv.params::text
,a.__id::text as additional_agreement_uid
,a.__name as additional_agreement
,p.price
,p.cnt as p_cnt
,p.ed_izm
,p.code
,p.discount as p_discount
,p.__id as p_uid
,p.name
/*,(select
sum(siv.cnt*(100-COALESCE(siv.discount,0))/100*p.price*p.cnt*(100-COALESCE(p.discount,0))/100)
from elma.service_parametrs p
where p.__id = ANY (siv.params)
AND p."__deletedAt" IS NULL
) as line_cost
,(select count(*)
from elma.service_parametrs p
where p.__id = ANY (siv.params)
AND p."__deletedAt" IS NULL
) as param_cnt*/
,s.probability_pc
,d.__index
,d.__id as deal_uid
from elma.deals_services siv
join elma.deals d on d.__id=ANY(siv.deal)
join status s on (d.__status_status=s.status_id)
join elma.service_parametrs p ON (p.__id = ANY (siv.params) AND p."__deletedAt" IS NULL)
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
where a.contract_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
and siv.is_actual
and a.is_actual
order by siv.version::int
</cfquery>
<cfoutput>
<h4>Услуги (версии строк спецификации, только актуальные) (#qService.recordCount#) </h4>
</cfoutput>
<!--- <layout:render_query query=#qService#/> --->
<table class="worktable">
<thead>
<tr>
<th>__index</th>
<th>Код</th>
<th width="20%">user_description</th>
<th width="25%">Компоненты</th>
<th>Кол-во</th>
<th>Скидка</th>
<th width="5%">Сумма</th>
<th>type</th>
<th>is_actual</th>
<th>hash</th>
<th>version</th>
<th>name_version</th>
<th>date_accept</th>
<th>__index</th>
<th width="5%">date_nop</th>
<th width="5%">date_end</th>
<th>is_easy</th>
<th width="7%">additional_agreement</th>
</tr>
</thead>
<cfoutput query="qService" group="__index">
<tr>
<td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td>
<!--- <td class="c">#__name#</td> --->
<td class="l">
#abstractive_service_code#.#modifier_code#<!--- <cfswitch expression=#type#>
<cfcase value=1>-i</cfcase>
<cfcase value=2>-f</cfcase>
<cfcase value=3>-m</cfcase>
</cfswitch> --->
</td>
<td class="l">#user_description#</td>
<td>
<table>
<cfset cost=0/>
<cfoutput group="p_uid">
<cfif p_cnt NEQ 0>
<tr>
<td class="nw">#code#</td>
<td>#name#</td>
<td>#p_cnt#</td>
<td>#ed_izm#</td>
<td class="r nw">#nFmt(price,3)#</td>
<td class="r">#p_discount#%</td>
</tr>
<cfset cost+=price*p_cnt*(100-(isNumeric(p_discount)?p_discount:0))/100 />
</cfif>
</cfoutput>
</table>
</td>
<td class="c">#cnt#</td>
<td class="c">#discount#%</td>
<td class="r">#nFmt(cost*cnt*(100-(isNumeric(discount)?discount:0))/100)#</td>
<td class="c">#type#</td>
<td class="c">#is_actual#</td>
<td class="c">#hash#</td>
<td class="c">#version#</td>
<td class="c">#name_version#</td>
<td class="c">#date_accept#</td>
<td class="c">#__index#</td>
<td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td>
<td class="c">#dateFormat(date_end,'YYYY-MM-DD')#</td>
<td class="c">#is_easy#</td>
<!--- <td class="c">#additional_agreement_uid#</td> --->
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
</tr>
</cfoutput>
</table>
</cfif><!--- len(d.__id) --->
<layout:page section="footer"/> <layout:page section="footer"/>
+37 -23
View File
@@ -121,11 +121,10 @@
</div> </div>
</cfoutput> </cfoutput>
сюда добавить сделок, договоров и т.д.
<layout:page section="extension" closeForm="Yes"/> <layout:page section="extension" closeForm="Yes"/>
<cfif len(d.__id)> <cfif len(d.__id)>
<cfquery name="qContract"> <cfquery name="qContract">
select select
@@ -398,31 +397,29 @@
,siv.params::text ,siv.params::text
,a.__id::text as additional_agreement_uid ,a.__id::text as additional_agreement_uid
,a.__name as additional_agreement ,a.__name as additional_agreement
,(select ,p.price
sum(siv.cnt*(100-COALESCE(siv.discount,0))/100*p.price*p.cnt*(100-COALESCE(p.discount,0))/100) ,p.cnt as p_cnt
from elma.service_parametrs p ,p.ed_izm
where p.__id = ANY (siv.params) ,p.code
AND p."__deletedAt" IS NULL ,p.discount as p_discount
) as line_cost ,p.__id as p_uid
,(select count(*) ,p.name
from elma.service_parametrs p
where p.__id = ANY (siv.params)
AND p."__deletedAt" IS NULL
) as param_cnt
,s.probability_pc ,s.probability_pc
,d.__index ,d.__index
,d.__id as deal_uid ,d.__id as deal_uid
from elma.deals_services siv from elma.deals_services siv
join elma.deals d on d.__id=ANY(siv.deal) join elma.deals d on d.__id=ANY(siv.deal)
join status s on (d.__status_status=s.status_id) join status s on (d.__status_status=s.status_id)
join elma.service_parametrs p ON (p.__id = ANY (siv.params) AND p."__deletedAt" IS NULL)
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement)) left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
where d._companies=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/> where d._companies=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>
and siv.is_actual AND siv.is_actual
AND a.is_actual
order by version::int order by version::int
</cfquery> </cfquery>
<cfoutput> <cfoutput>
<h4>Услуги (версии строк спецификации, только актуальные) (#qService.recordCount#) *** здесь не учтено дублирование строк в новых версиях</h4> <h4>Услуги (версии строк спецификации, только актуальные) <!--- (#qService.recordCount#) ---></h4>
</cfoutput> </cfoutput>
<!--- <layout:render_query query=#qService#/> ---> <!--- <layout:render_query query=#qService#/> --->
@@ -431,7 +428,8 @@
<tr> <tr>
<th>__index</th> <th>__index</th>
<!--- <th>__name</th> ---> <!--- <th>__name</th> --->
<th width="12%">user_description</th> <th width="20%">user_description</th>
<th width="25%">Компоненты</th>
<th>Кол-во</th> <th>Кол-во</th>
<th>Скидка%</th> <th>Скидка%</th>
<th width="5%">Сумма</th> <th width="5%">Сумма</th>
@@ -446,19 +444,36 @@
<th width="5%">date_nop</th> <th width="5%">date_nop</th>
<th width="5%">date_end</th> <th width="5%">date_end</th>
<th>is_easy</th> <th>is_easy</th>
<th>Компонентов</th> <th width="7%">additional_agreement</th>
<th width="12%">additional_agreement</th>
</tr> </tr>
</thead> </thead>
<cfoutput query="qService"> <cfoutput query="qService" group="__index">
<tr> <tr>
<td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td> <td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td>
<!--- <td class="c">#__name#</td> ---> <!--- <td class="c">#__name#</td> --->
<td class="l">#user_description#</td> <td class="l">#user_description#</td>
<td>
<table>
<cfset cost=0/>
<cfoutput group="p_uid">
<cfif p_cnt NEQ 0>
<tr>
<td class="nw">#code#</td>
<td>#name#</td>
<td>#p_cnt#</td>
<td>#ed_izm#</td>
<td class="r nw">#nFmt(price,3)#</td>
<td class="r">#p_discount#%</td>
</tr>
<cfset cost+=price*p_cnt*(100-(isNumeric(p_discount)?p_discount:0))/100 />
</cfif>
</cfoutput>
</table>
</td>
<td class="c">#cnt#</td> <td class="c">#cnt#</td>
<td class="c">#discount#</td> <td class="c">#discount#%</td>
<td class="r">#nFmt(line_cost)#</td> <td class="r">#nFmt(cost*cnt*(100-(isNumeric(discount)?discount:0))/100)#</td>
<td class="l"> <td class="l">
#abstractive_service_code#.#modifier_code#<!--- <cfswitch expression=#type#> #abstractive_service_code#.#modifier_code#<!--- <cfswitch expression=#type#>
<cfcase value=1>-i</cfcase> <cfcase value=1>-i</cfcase>
@@ -476,7 +491,6 @@
<td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td> <td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td>
<td class="c">#dateFormat(date_end,'YYYY-MM-DD')#</td> <td class="c">#dateFormat(date_end,'YYYY-MM-DD')#</td>
<td class="c">#is_easy#</td> <td class="c">#is_easy#</td>
<td class="c">#param_cnt#</td>
<!--- <td class="c">#additional_agreement_uid#</td> ---> <!--- <td class="c">#additional_agreement_uid#</td> --->
<td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td> <td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
@@ -484,5 +498,5 @@
</cfoutput> </cfoutput>
</table> </table>
</cfif> </cfif><!--- len(d.__id) --->
<layout:page section="footer"/> <layout:page section="footer"/>
+269
View File
@@ -0,0 +1,269 @@
<cfsilent>
<cfimport prefix="m" taglib="lib"/>
<cfimport prefix="c" taglib="lib/controls"/>
<cfimport prefix="d" taglib="lib/data"/>
<cfimport prefix="layout" taglib="layout"/>
</cfsilent>
<m:prepare_ls entity="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
<cfquery name="qReconciliation">
WITH
status(status, status_id, probability_pc) as (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
),
line as (
SELECT siv.__id as siv_uid, siv.discount, siv.type as line_pricing_model_id
,siv.hash as line_key, siv.is_actual as siv_is_actual
,siv.version::numeric as line_version
,d.__index as deal_index
,d._companies
,a.index as agreement_version
,siv.date_nop::date as dt_from
,siv.date_end::date as dt_to
,siv.is_easy as is_simple
,siv.cnt -- should mutiliply
,s.probability_pc
,a.__id as agreement_uid, a.contract_uid, a.is_actual as agreement_is_actual, a.deal_uid
,d.__name as deal, d.__status_status as deal_status_id
--,c.__name as contract
,siv.user_description
,siv.params
--,(SELECT sum(p.price*p.cnt*(100.0-COALESCE(p.discount,0.0))/100.0) FROM elma.service_parametrs p WHERE(p.__id = ANY (siv.params))) as cost
FROM elma.deals_services siv
JOIN elma.deals d on (d.__id = ANY(siv.deal))
JOIN status s on (d.__status_status=s.status_id)
LEFT OUTER JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE siv.is_actual AND siv."__deletedAt" IS NULL AND d."__deletedAt" IS NULL AND a."__deletedAt" IS NULL
AND a.is_actual
AND siv.type IN (2,3)
),
component as (
SELECT
price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost
,price
,cnt
,code
,__id
FROM elma.service_parametrs
where "__deletedAt" IS NULL
),
stair as ( -- рабочая лесенка (инстансы строк, имеющие нетривиальную вероятность)
select * FROM (
SELECT *,
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt
FROM line --WHERE probability_pc > 0
) t
WHERE t.dt_from = t.running_min_dt
),
alloc as (select c."WZ" as wz
, round(sum(c."VM_RAM_Allocated")) as ram
, round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) as ram_on
, round(sum(c."VM_vCPU_count")) as cpu
, round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_vCPU_count" ELSE 0 END)) as cpu_on
from vmreports.compute c
where ts=(select max(ts) from vmreports.compute)
group by c."WZ"
),
disk_alloc as (select c."WZ" as wz
, round(sum(c."Disk_Allocated")) as disk_alloc
from vmreports.storage c
where ts=(select max(ts) from vmreports.storage)
group by c."WZ"
),
sold_ram as (SELECT
z.id_klienta as WZ, z.__name as client, z.__id as company_uid, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code LIKE 'iaas.ngc.%.ram-_'
GROUP BY z.id_klienta, z.__id, z.__name
),
sold_cpu as (SELECT
z.id_klienta as WZ, z.__name as client, z.__id as company_uid, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code LIKE 'iaas.ngc.%.vcpu-_'
GROUP BY z.id_klienta, z.__id, z.__name
),
sold_disk as (SELECT
z.id_klienta as WZ, z.__name as client, z.__id as company_uid, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code SIMILAR TO 'iaas.ngc.%.(ssd|fstssd|sata)-_'
GROUP BY z.id_klienta, z.__id, z.__name
),
deal_stat as (
select STRING_AGG(distinct deal_status_id::text,', ') as status_ids
, z.id_klienta as WZ
from line o join elma.companies z on (o._companies=z.__id)
GROUP BY z.id_klienta
)
select
r.wz as wz_sold,
r.client as client_sold, r.company_uid,
a.wz as wz_alloc,
ds.status_ids,
r.codes as ram_codes,
r.quantity as ram_sold,
a.ram as ram_alloc,
a.ram_on as ram_alloc_on,
c.codes as cpu_codes,
c.quantity as cpu_sold,
a.cpu as cpu_alloc,
a.cpu_on as cpu_alloc_on,
d.quantity as disk_sold,
da.disk_alloc,
d.codes as disk_codes
from sold_ram r
join deal_stat ds on (r.wz=ds.wz)
join sold_cpu c on (r.wz=c.wz)
left join sold_disk d on (r.wz=d.wz)
full join alloc a on (r.wz=a.wz)
left join disk_alloc da on (a.wz=da.wz)
order by 1,3
</cfquery>
<!--- QoQ does not support join syntax, at least of Lucee 5.4--->
<cfif isDefined("output_xls")>
<layout:xml qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
<cfabort/>
</cfif><cfif isDefined("output_json")>
<layout:json qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
<cfabort/>
</cfif><!---
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput>
</layout:attribute>
<layout:attribute name="controls">
<!---skip filter link, filter is not implemented--->
<!---<layout:language_switch/>--->
</layout:attribute>
</layout:page>
<!--- <cfdump var=#qReconciliation# abort=true/> --->
<cfoutput>
<!--- <form method="post" action="">
Период с <input type="text" name="dt_start" value="#dateFormat(dt_start,'YYYY-MM-DD')#"/>
по <input type="text" name="dt_finish" value="#dateFormat(dt_finish,'YYYY-MM-DD')#"/>
<input type="submit" style="cursor:pointer;"/>
<input type="submit" name="DEBUG" value="DEBUG" style="cursor:pointer;"/>
</form> --->
<!--- Часов в периоде: <b>#hours#</b> Строк в отчете: <b>#qCharge.recordCount#</b><br/>
Актуальность данных:
VCD Computing: <b>#dateFormat(qComputingAge.dt_load,'YYYY-MM-DD')# #timeFormat(qComputingAge.dt_load,'HH:MM:SS')#</b>
VCD Storage: <b>#dateFormat(qStorageAge.dt_load,'YYYY-MM-DD')# #timeFormat(qStorageAge.dt_load,'HH:MM:SS')#</b>
S3 хранение: <b>#dateFormat(qS3VolAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3VolAge.dt_load,'HH:MM:SS')#</b>
S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3OpsTrfAge.dt_load,'HH:MM:SS')#</b>
--->
<br/>
<a href="#request.thisPage#?output_xls" title="экспорт в Excel" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/xls.gif" style="vertical-align:text-bottom;"/></a>
<a href="#request.thisPage#?output_json" title="экспорт в json" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/json.svg" style="vertical-align:text-bottom;" width="13" height="13"/></a>
</cfoutput>
<table class="worktable">
<thead>
<tr>
<td width="1%"></td>
<th width="7%">WZ Elma</th>
<th width="10%">Клиент</th>
<th width="7%">WZ Cloud</th>
<th width="3%">Статусы</th>
<th width="15%">Коды RAM</th>
<th width="3%">RAM GB Elma</th>
<th width="3%">RAM Cloud</th>
<th width="3%">RAM Cloud ON</th>
<th width="15%">Коды CPU</th>
<th width="3%">CPU Elma</th>
<th width="3%">CPU Cloud</th>
<th width="3%">CPU Cloud ON</th>
<th width="15%">Коды Дисков</th>
<th width="3%">Диски GB Elma</th>
<th width="3%">Диски Cloud</th>
</tr>
</thead>
<cfoutput query="qReconciliation">
<tr>
<td></td>
<td>#wz_sold#</td>
<td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#client_sold#</a></td>
<td>#wz_alloc#</td>
<td>#status_ids#</td>
<td>#ram_codes#</td>
<td>#ram_sold#</td>
<td>#ram_alloc#</td>
<td>#ram_alloc_on#</td>
<td>#cpu_codes#</td>
<td>#cpu_sold#</td>
<td>#cpu_alloc#</td>
<td>#cpu_alloc_on#</td>
<td>#disk_codes#</td>
<td>#disk_sold#</td>
<td>#disk_alloc#</td>
</tr>
<!---
<td class="r" style="font-size:120%; padding:0 1em;">#chargeable_metric#</td>
<td class="c" style="font-size:90%;">#ed_izm#</td>
<td class="r">#discounted_price#</td>
<td class="r">#charge#</td>
<td></td>
<td>#abstract_service# #modifier#</td>
<td>#component#</td>
<td>#user_description#</td>
<td class="r">#price#</td>
<td class="r">#discount#</td>
<td class="r">#dateFormat(dt_from,'YYYY-MM-DD')#</td>
<td class="r">#dateFormat(dt_to,'YYYY-MM-DD')#</td>
<td class="r">#line_key#</td>
<td class="r" style="color:##bbb">#raw_metric#</td>
<td class="r">#metric#</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="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
</tr> --->
</cfoutput>
</table>
<!--- <cfdump var=#qCharge#/> --->
<layout:page section="footer"/>
+12
View File
@@ -14,6 +14,8 @@
<m:filterparam filter=#filter# param="wz" ftype="string" compare="LIKE%" field="k.id_klienta" default=""/> <m:filterparam filter=#filter# param="wz" ftype="string" compare="LIKE%" field="k.id_klienta" default=""/>
<m:filterparam filter=#filter# param="status_id" ftype="numeric" compare="EQ" field="d.__status_status" default=""/> <m:filterparam filter=#filter# param="status_id" ftype="numeric" compare="EQ" field="d.__status_status" default=""/>
<m:filterparam filter=#filter# param="__index" ftype="numeric" compare="EQ" field="d.__index" default=""/> <m:filterparam filter=#filter# param="__index" ftype="numeric" compare="EQ" field="d.__index" default=""/>
<m:filterparam filter=#filter# param="probability_lt" ftype="numeric" compare="LT" field="s.probability_pc" default=""/>
<m:filterparam filter=#filter# param="probability_gt" ftype="numeric" compare="GT" field="s.probability_pc" default=""/>
</m:filter_settings> </m:filter_settings>
<cfif isDefined("resetAndClose") or isDefined("saveAndClose")> <cfif isDefined("resetAndClose") or isDefined("saveAndClose")>
@@ -126,6 +128,16 @@ $(document).ready(function() {
/> />
</div> </div>
</div> </div>
<div class="tr">
<div class="th">Вероятность</div>
<div class="td">
<input type="text" name="probability_gt" value="#probability_gt#" size="3"/>
&lt; % &lt;
<input type="text" name="probability_lt" value="#probability_lt#" size="3"/>
</div>
</div>
</div><!--- detail ---> </div><!--- detail --->
добавить сюда множественный выбор статуса добавить сюда множественный выбор статуса
+5 -5
View File
@@ -150,13 +150,13 @@
<b>#nFmt(qParamCost.line_cost)#</b> по строке, с количеством и скидкой (<b>#nFmt(qParamCost.param_cost)#</b> по компонентам) <b>#nFmt(qParamCost.line_cost)#</b> по строке, с количеством и скидкой (<b>#nFmt(qParamCost.param_cost)#</b> по компонентам)
</div> </div>
</div> </div>
<!---
<div class="tr"> <div class="tr">
<div class="th">Версия</div> <div class="th">Версия</div>
<div class="td"> <div class="td">
#d.version# <i>вообще не понимаю, какой смысл вкладывается в эту цифру...</i> #d.version# <i>вообще не понимаю, какой смысл вкладывается в эту цифру...</i>
</div> </div>
</div> </div> --->
<div class="tr"> <div class="tr">
<div class="th">Версии</div> <div class="th">Версии</div>
@@ -389,8 +389,8 @@
<td class="c">#__index#</td> <td class="c">#__index#</td>
<!--- <td class="c">#__name#</td> ---> <!--- <td class="c">#__name#</td> --->
<td class="c">#type#</td> <td class="c">#type#</td>
<td class="c">#code#</td> <td>#code#</td>
<td class="c">#name#</td> <td>#name#</td>
<td class="r">#cnt#</td> <td class="r">#cnt#</td>
<td class="c">#ed_izm#</td> <td class="c">#ed_izm#</td>
<td class="r">#price#</td> <td class="r">#price#</td>
@@ -434,7 +434,7 @@
left outer join elma.deals d on (d.__id = ANY(siv.deal)) left outer join elma.deals d on (d.__id = ANY(siv.deal))
left outer join status on (d.__status_status = status.status_id) left outer join status on (d.__status_status = status.status_id)
where hash=<cfqueryparam cfsqltype="cf_sql_varchar" value=#d.hash#/> where hash=<cfqueryparam cfsqltype="cf_sql_varchar" value=#d.hash#/>
order by d.__index order by d.__index desc
</cfquery> </cfquery>
<cfquery name="qVerActual" dbtype="query"> <cfquery name="qVerActual" dbtype="query">
+144
View File
@@ -0,0 +1,144 @@
WITH
status(status, status_id, probability_pc) as (VALUES
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
),
line as (
SELECT siv.__id as siv_uid, siv.discount, siv.type as line_pricing_model_id
,siv.hash as line_key, siv.is_actual as siv_is_actual
,siv.version::numeric as line_version
,d.__index as deal_index
,d._companies
,a.index as agreement_version
,siv.date_nop::date as dt_from
,siv.date_end::date as dt_to
,siv.is_easy as is_simple
,siv.cnt -- should mutiliply
,s.probability_pc
,a.__id as agreement_uid, a.contract_uid, a.is_actual as agreement_is_actual, a.deal_uid
,d.__name as deal, d.__status_status as deal_status_id
--,c.__name as contract
,siv.user_description
,siv.params
--,(SELECT sum(p.price*p.cnt*(100.0-COALESCE(p.discount,0.0))/100.0) FROM elma.service_parametrs p WHERE(p.__id = ANY (siv.params))) as cost
FROM elma.deals_services siv
JOIN elma.deals d on (d.__id = ANY(siv.deal))
JOIN status s on (d.__status_status=s.status_id)
LEFT OUTER JOIN elma.additional_agreements a on (a.__id = ANY(siv.additional_agreement))
WHERE siv.is_actual AND siv."__deletedAt" IS NULL AND d."__deletedAt" IS NULL AND a."__deletedAt" IS NULL
AND a.is_actual
AND siv.type IN (2,3)
),
component as (
SELECT
price*cnt*(100.0-COALESCE(discount,0))/100.0 as cost
,price
,cnt
,code
,__id
FROM elma.service_parametrs
where "__deletedAt" IS NULL
),
stair as ( -- рабочая лесенка (инстансы строк, имеющие нетривиальную вероятность)
select * FROM (
SELECT *,
MIN(dt_from) OVER (PARTITION BY line_key ORDER BY deal_index desc) running_min_dt
FROM line --WHERE probability_pc > 0
) t
WHERE t.dt_from = t.running_min_dt
),
alloc as (select c."WZ" as wz
, round(sum(c."VM_RAM_Allocated")) as ram
, round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_RAM_Allocated" ELSE 0 END)) as ram_on
, round(sum(c."VM_vCPU_count")) as cpu
, round(sum(CASE WHEN "VM_is_ON" > 0 THEN c."VM_vCPU_count" ELSE 0 END)) as cpu_on
from vmreports.compute c
where ts=(select max(ts) from vmreports.compute)
group by c."WZ"
),
disk_alloc as (select c."WZ" as wz
, round(sum(c."Disk_Allocated")) as disk_alloc
from vmreports.storage c
where ts=(select max(ts) from vmreports.storage)
group by c."WZ"
),
sold_ram as (SELECT
z.id_klienta as WZ, z.__name as client, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code LIKE 'iaas.ngc.%.ram-_'
GROUP BY z.id_klienta, z.__name
),
sold_cpu as (SELECT
z.id_klienta as WZ, z.__name as client, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code LIKE 'iaas.ngc.%.vcpu-_'
GROUP BY z.id_klienta, z.__name
),
sold_disk as (SELECT
z.id_klienta as WZ, z.__name as client, round(sum(c.cnt*o.cnt)) as quantity
,count(*) as lines, STRING_AGG(c.code,', ') as codes
/*,o.line_key, o.probability_pc, dt_next, o.deal_uid, o.deal, o.agreement_uid, o.line_pricing_model_id,o.dt_from, o.dt_to*/
FROM stair o
JOIN elma.companies z on (o._companies=z.__id)
LEFT OUTER JOIN component c on (c.__id = ANY (o.params))
WHERE c.code SIMILAR TO 'iaas.ngc.%.(ssd|fstssd|sata)-_'
GROUP BY z.id_klienta, z.__name
),
deal_stat as (
select STRING_AGG(distinct deal_status_id::text,', ') as status_ids
, z.id_klienta as WZ
from line o join elma.companies z on (o._companies=z.__id)
GROUP BY z.id_klienta
)
select
r.wz as wz_sold,
r.client as client_sold,
a.wz as wz_alloc,
ds.status_ids,
r.codes as ram_codes,
r.quantity as ram_sold,
a.ram as ram_alloc,
a.ram_on as ram_alloc_on,
c.codes as cpu_codes,
c.quantity as cpu_sold,
a.cpu as cpu_alloc,
a.cpu_on as cpu_alloc_on,
d.quantity as disk_sold,
da.disk_alloc,
d.codes as disk_codes
from sold_ram r
join deal_stat ds on (r.wz=ds.wz)
join sold_cpu c on (r.wz=c.wz)
left join sold_disk d on (r.wz=d.wz)
full join alloc a on (r.wz=a.wz)
left join disk_alloc da on (a.wz=da.wz)
--where s.quantity=a.ram
order by 1,3
--select * from vmreports.compute where "WZ"='WZ01005'
--select * from vmreports.compute where "WZ"='WZ01038' AND
--select distinct "WZ" from vmreports.compute a where not exists (select * from elma.companies z where lower(trim(a."WZ"))=lower(trim(z.id_klienta)))
--select distinct "WZ" from vmreports.compute a where not exists (select * from elma.companies z where a."WZ"=z.id_klienta)
--select * from elma.companies where id_klienta='WZ00114'
--select * from vmreports.compute where "WZ"='WZ00114'
--select * from vmreports.compute where "WZ"='WZ00195'
--select d.* from elma.companies z join elma.deals d on (z.__id=d._companies) where id_klienta='WZ03378'
--select aa.* from elma.additional_agreements aa join elma.aggrements a on (aa.contract_uid=a.__id) join elma.companies z on (a.company_uid=z.__id)where id_klienta='WZ03378'
+5 -1
View File
@@ -12,15 +12,19 @@
<li class="menu-title">Реестры</li> <li class="menu-title">Реестры</li>
<c:menu_item acl="" page="deal_ls.cfm" label="Сделки"/>
<c:menu_item acl="" page="contract_ls.cfm" label="Договоры"/> <c:menu_item acl="" page="contract_ls.cfm" label="Договоры"/>
<c:menu_item acl="" page="additional_agreement_ls.cfm" label="Доп. соглашения"/> <c:menu_item acl="" page="additional_agreement_ls.cfm" label="Доп. соглашения"/>
<c:menu_item acl="" page="deal_ls.cfm" label="Сделки"/>
<c:menu_item acl="" page="vm_ls.cfm" label="VM"/>
<!--- <!---
<c:menu_item acl="" page="specification_ls.cfm" label="Спецификации"/> <c:menu_item acl="" page="specification_ls.cfm" label="Спецификации"/>
<c:menu_item acl="" page="agreement_ls.cfm" label="Сделки"/> <c:menu_item acl="" page="agreement_ls.cfm" label="Сделки"/>
<c:menu_item acl="" page="specification_item_ls.cfm" label="Экземпляры услуг"/>---> <c:menu_item acl="" page="specification_item_ls.cfm" label="Экземпляры услуг"/>--->
<li class="menu-title">Отчеты</li> <li class="menu-title">Отчеты</li>
<c:menu_item acl="" page="crm2cloud.cfm" label="CRM - Cloud"/>
<c:menu_item acl="" page="payg.cfm" label="PAYG"/> <c:menu_item acl="" page="payg.cfm" label="PAYG"/>
<!--- <c:menu_item acl="" page="detail_daily_rpt.cfm" label="Детализация по дням"/> <!--- <c:menu_item acl="" page="detail_daily_rpt.cfm" label="Детализация по дням"/>
<c:menu_item acl="" page="income_daily_rpt.cfm" label="Выручка по дням"/> <c:menu_item acl="" page="income_daily_rpt.cfm" label="Выручка по дням"/>
+1 -1
View File
@@ -1 +1 @@
<cflocation url="payg.cfm" addtoken="No"/> <cflocation url="contract_ls.cfm" addtoken="No"/>
+2 -2
View File
@@ -7,7 +7,7 @@
<cfparam name="ATTRIBUTES.closeForm" type="boolean" default="No"/> <cfparam name="ATTRIBUTES.closeForm" type="boolean" default="No"/>
<cfparam name="title" default=""/><!---заголовок страницы, отображаемый в теле например, <h1>---> <cfparam name="title" default=""/><!---заголовок страницы, отображаемый в теле например, <h1>--->
<cfparam name="pageTitle" default="PAYG"/><!---заголовок окна браузера, в теге <title>---> <cfparam name="pageTitle" default="Сверка"/><!---заголовок окна браузера, в теге <title>--->
<cfparam name="controls" default=""/> <cfparam name="controls" default=""/>
</cfsilent><cfsilent> </cfsilent><cfsilent>
@@ -126,7 +126,7 @@ select login, firstname, middlename, lastname from worker where id='#request.usr
<!--- <div style="width:20px; height:30px; margin: 5px; background: url('img/logo0.png') 0 0 no-repeat; background-size:contain; display:inline-block;"></div>---> <!--- <div style="width:20px; height:30px; margin: 5px; background: url('img/logo0.png') 0 0 no-repeat; background-size:contain; display:inline-block;"></div>--->
<div style="width:138px; height:30px; margin: 5px 0 0 5px; background: url('img/logo0.png') 0 0 no-repeat; background-size:contain; display:inline-block; -border:1px solid red;"> <div style="width:138px; height:30px; margin: 5px 0 0 5px; background: url('img/logo0.png') 0 0 no-repeat; background-size:contain; display:inline-block; -border:1px solid red;">
<p class="b r" style="color:white; margin:0 10px 10px 10px; font-size:130%;"> <p class="b r" style="color:white; margin:0 10px 10px 10px; font-size:130%;">
Отчет PAYG Сверка CRM-Cloud
</p> </p>
</div> </div>
<p style="color:lightgray; margin:10px 12px; text-align:right;"> <p style="color:lightgray; margin:10px 12px; text-align:right;">
+162
View File
@@ -0,0 +1,162 @@
<cfsilent>
<cfimport prefix="m" taglib="lib"/>
<cfimport prefix="c" taglib="lib/controls"/>
<cfimport prefix="d" taglib="lib/data"/>
<cfimport prefix="layout" taglib="layout"/>
</cfsilent>
<m:prepare_ls entity="crm2cloud" accessObject="" pageInfoOut="pageInfo" trackOut="tr"/>
<cfquery name="qVM">
select "Name", "Object_UUID", "UUID_VM",
"VDC", "Organization_UUID", "Organization", "WZ", "Cluster", "Host",
"Host_Model", "CPU_Model", "Host_CPU_Cores", "Host_CPU_Sockets", "Host_CPU_Speed", "Host_RAM",
"Host_CPU_Used", "Host_CPU_Used_Avg",
"VDC_CPU_Reserv", "VDC_CPU_Speed",
"VM_vCPU_count", "VM_CPU_Used", "VM_CPU_Used_AVG", "VM_CPU_Reserv_GHz", "VM_CPU_Reserv_perc",
"VM_RAM_Allocated", "VM_RAM_Used",
"VM_is_ON"
from vmreports.compute
where ts=(select max(ts) from vmreports.compute)
order by "WZ"
</cfquery>
<!--- <cfdump var=#qVM# abort=true/> --->
<cfif isDefined("output_xls")>
<layout:xml qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
<cfabort/>
</cfif><cfif isDefined("output_json")>
<layout:json qRead=#qCharge# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
<cfabort/>
</cfif><!---
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput><b>Сверка CRM - Cloud</b></cfoutput>
</layout:attribute>
<layout:attribute name="controls">
<!---skip filter link, filter is not implemented--->
<!---<layout:language_switch/>--->
</layout:attribute>
</layout:page>
<!--- <cfdump var=#qReconciliation# abort=true/> --->
<cfoutput>
<!--- <form method="post" action="">
Период с <input type="text" name="dt_start" value="#dateFormat(dt_start,'YYYY-MM-DD')#"/>
по <input type="text" name="dt_finish" value="#dateFormat(dt_finish,'YYYY-MM-DD')#"/>
<input type="submit" style="cursor:pointer;"/>
<input type="submit" name="DEBUG" value="DEBUG" style="cursor:pointer;"/>
</form> --->
<!--- Часов в периоде: <b>#hours#</b> Строк в отчете: <b>#qCharge.recordCount#</b><br/>
Актуальность данных:
VCD Computing: <b>#dateFormat(qComputingAge.dt_load,'YYYY-MM-DD')# #timeFormat(qComputingAge.dt_load,'HH:MM:SS')#</b>
VCD Storage: <b>#dateFormat(qStorageAge.dt_load,'YYYY-MM-DD')# #timeFormat(qStorageAge.dt_load,'HH:MM:SS')#</b>
S3 хранение: <b>#dateFormat(qS3VolAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3VolAge.dt_load,'HH:MM:SS')#</b>
S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-MM-DD')# #timeFormat(qS3OpsTrfAge.dt_load,'HH:MM:SS')#</b>
--->
<br/>
<a href="#request.thisPage#?output_xls" title="экспорт в Excel" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/xls.gif" style="vertical-align:text-bottom;"/></a>
<a href="#request.thisPage#?output_json" title="экспорт в json" style="margin-left:.5em; height:100%;" target="_blank"><img src="img/json.svg" style="vertical-align:text-bottom;" width="13" height="13"/></a>
</cfoutput>
<table class="worktable">
<thead>
<tr>
<th width="7%">WZ</th>
<th width="10%">Имя</th>
<th width="7%">Уникальное имя</th>
<th width="3%">Organization</th>
<th width="3%">VDC</th>
<th width="3%">VDC CPU Reserv</th>
<th width="3%">VDC CPU Speed GHz</th>
<th width="3%">Cluster</th>
<th width="3%">Host</th>
<th width="3%">Host Model</th>
<th width="3%">CPU Model</th>
<th width="3%">Host CPU Cores</th>
<th width="3%">Host CPU Sockets</th>
<th width="3%">Host CPU Speed GHz</th>
<th width="3%">Host RAM GB</th>
<th width="3%">Host CPU Used</th>
<th width="3%">Host CPU Used_Avg</th>
<th width="3%">VM vCPU count</th>
<th width="3%">VM CPU Used</th>
<th width="3%">VM CPU Used AVG</th>
<th width="3%">VM CPU Reserv GHz</th>
<th width="3%">VM CPU Reserv perc</th>
<th width="3%">VM RAM Allocated GB</th>
<th width="3%">VM RAM Used GB</th>
<th width="3%">VM is ON</th>
</tr>
</thead>
<cfoutput query="qVM">
<tr>
<td>#WZ#</td>
<td>#Name#</td>
<td>#UUID_VM#</td>
<td>#Organization#</td>
<td>#VDC#</td>
<td>#VDC_CPU_Reserv#</td>
<td>#VDC_CPU_Speed#</td>
<td>#qVM.Cluster#</td>
<td>#Host#</td>
<td>#Host_Model#</td>
<td>#CPU_Model#</td>
<td>#Host_CPU_Cores#</td>
<td>#Host_CPU_Sockets#</td>
<td>#round(Host_CPU_Speed,3)#</td>
<td>#Host_RAM#</td>
<td>#Host_CPU_Used#</td>
<td>#Host_CPU_Used_Avg#</td>
<td>#VM_vCPU_count#</td>
<td>#VM_CPU_Used#</td>
<td>#VM_CPU_Used_AVG#</td>
<td>#VM_CPU_Reserv_GHz#</td>
<td>#VM_CPU_Reserv_GHz#</td>
<td>#VM_CPU_Reserv_perc#</td>
<td>#VM_RAM_Allocated#</td>
<td>#VM_RAM_Used#</td>
<td>#VM_is_ON#</td>
<!--- <td><a href="contragent.cfm?__id=#company_uid#&#tr.fwx#">#client_sold#</a></td> --->
</tr>
</cfoutput>
</table>
<!--- <cfdump var=#qCharge#/> --->
<layout:page section="footer"/>