diff --git a/Application.cfc b/Application.cfc index 074b84c..39eac9e 100644 --- a/Application.cfc +++ b/Application.cfc @@ -99,7 +99,7 @@ - + diff --git a/deal.cfm b/deal.cfm index 515f891..7fe55aa 100644 --- a/deal.cfm +++ b/deal.cfm @@ -21,7 +21,7 @@ - + @@ -44,15 +44,37 @@ s(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) + ), + component as (select siv.deal as deal_uids, siv.type, (siv.cnt*(100-COALESCE(siv.discount,0))/100*p.price*p.cnt*(100-COALESCE(p.discount,0))) as param_cost + from elma.deals_services siv + join elma.service_parametrs p on (p.__id = ANY(siv.params)) ) + select k.__name as contragent ,k.id_klienta as wz + ,k.__index as contragent_index ,d."_plannedDueDate" as _plannedDueDate + ,d."__createdAt" + ,d."__index" as deal_index ,s.status ,s.probability_pc + ,c.__name as owner + ,(select sum(param_cost) + from component + where d.__id = ANY(component.deal_uids) AND component.type IN (1) + ) as install + ,(select sum(param_cost) + from component + where d.__id = ANY(component.deal_uids) AND component.type IN (2) + ) as periodical + ,(select sum(param_cost) + from component + where d.__id = ANY(component.deal_uids) AND component.type IN (3) + ) as metered from elma.deals d left outer join elma.companies k on (d._companies=k.__id) + left outer join elma.comp_users_ext c on (d._owner=c.__id) left outer join s on (d.__status_status=s.status_id) where d.__id= @@ -89,7 +111,10 @@
__id
-
#d.__id#
+
+ #d.__id# + index:#qDecoration.deal_index# +
@@ -102,12 +127,15 @@
#qDecoration.contragent# #qDecoration.wz# + index:#qDecoration.contragent_index#
_plannedDueDate
-
#qDecoration._plannedDueDate#
+
#dateFormat(qDecoration._plannedDueDate,'YYYY-MM-DD')# + Паразитное поле, не использовать в расчетах +
@@ -145,7 +173,32 @@
dt_load
-
#d.dt_load#
+
#dateTimeFormat(d.dt_load,"yyyy-MM-dd HH:nn:ss.SSSZ")#
+
+ +
+
__createdAt
+
#dateFormat(qDecoration.__createdAt,"YYYY-MM-DD")#
+
+ +
+
Ответственный
+
#qDecoration.owner#
+
+ +
+
Инсталл
+
#numFmt(qDecoration.install,2)#
+
+ +
+
Ежемес
+
#numFmt(qDecoration.periodical,2)#
+
+ +
+
Тарифицируемые
+
#numFmt(qDecoration.metered,2)#
diff --git a/deal_ls.cfm b/deal_ls.cfm index 9bf6ab6..68df423 100644 --- a/deal_ls.cfm +++ b/deal_ls.cfm @@ -27,18 +27,26 @@ select d.__id + d.__index d.__name d._companies + d."__createdAt" as __createdAt k.__name as contragent k.id_klienta as wz d.__status_status s.status s.probability_pc - + c.__name as owner + a.__name as additional_agreement + g.__name as contract + g.date_of_aggrement as dt_contract from elma.deals d left outer join elma.companies k on (d._companies=k.__id) left outer join status s on (d.__status_status=s.status_id) + left outer join elma.comp_users_ext c on (d._owner=c.__id) + left outer join elma.additional_agreements a on (d.__id=a.deal_uid) + left outer join elma.aggrements g on (a.contract_uid = g.__id) where 1=1 order by @@ -103,14 +111,19 @@ select count(*) as cnt from elma.deals d where 1=1 - + - + - + - - + + + + + + + diff --git a/util/builder.pg.cfm b/util/builder.pg.cfm index acf95fb..12f9b68 100644 --- a/util/builder.pg.cfm +++ b/util/builder.pg.cfm @@ -103,6 +103,7 @@ AND o.table_schema= +добавить сюда еще выполнение селекта, чтобы почитать данные