pricing model
This commit is contained in:
+82
-6
@@ -31,6 +31,7 @@
|
||||
<d:param field="agreement" type="varchar" size="255" preprocessor=#cleanInput# init=#qInitVersion.next_version#/>
|
||||
<d:param field="dt_agreement" type="timestamp" format="yyyy-MM-dd" init=#Now()#/>
|
||||
<d:param field="is_actual" type="bit" init="0" default="0"/>
|
||||
<d:param field="deal_uid" type="guid" skipInsert skipUpdate/>
|
||||
<d:param field="descr" type="varchar" preprocessor=#plain2HtmClean#/>
|
||||
|
||||
<d:param field="creator_id" type="integer" value="#request.usr_id#" skipUpdate/>
|
||||
@@ -113,6 +114,13 @@
|
||||
<div class="td">
|
||||
#d.agreement_version# (некорректный нейминг, в одном месте версией называется номер, а в другом сущность, и это отразилось в именовании таблиц и полей)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Ключ сделки</div>
|
||||
<div class="td">
|
||||
#d.deal_uid#
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
@@ -181,6 +189,8 @@
|
||||
iv.specification_item_uid
|
||||
,iv.agreement_version /*лучше читается, когда все одинаково берется из резалтсета*/
|
||||
,i.svc_id
|
||||
,i.pricing_model_id
|
||||
,p.pricing_model_short
|
||||
,svc.svc
|
||||
,svc.code
|
||||
,iv.specification_item_version /*it is printable name not number*/
|
||||
@@ -195,12 +205,48 @@
|
||||
,d.dt_contract
|
||||
,d.contragent_id
|
||||
,k.contragent
|
||||
,ver.agreement_version as prev_version
|
||||
,ver.price as prev_price
|
||||
,ver.quantity as prev_quantity
|
||||
,ver.dt_from as prev_dt_from
|
||||
,ver.dt_to as prev_dt_to
|
||||
,case when ver.agreement_version IS NULL then 'new' else 'change' end as change_type /*удалить услугу нельзя, можно только завершить ее оказание (после этого в более поздних версиях она должна стать незаметной)*/
|
||||
,COALESCE(iv.price*iv.quantity,0) - COALESCE(ver.price*ver.quantity,0) as cost_diff
|
||||
|
||||
from specification_item_version iv
|
||||
join specification_item i on (iv.specification_item_uid=i.specification_item_uid)
|
||||
join pricing_model p on (i.pricing_model_id=p.pricing_model_id)
|
||||
join specification s on (i.specification_id=s.specification_id)
|
||||
join contract d on (s.contract_id=d.contract_id)
|
||||
join contragent k on (d.contragent_id=k.contragent_id)
|
||||
left outer join svc on (i.svc_id=svc.svc_id)
|
||||
left outer join (select
|
||||
siv.agreement_version
|
||||
,siv.specification_item_uid
|
||||
,a.agreement
|
||||
,a.contract_id
|
||||
,a.dt_agreement
|
||||
,a.is_actual
|
||||
,siv.specification_item_version
|
||||
,siv.quantity
|
||||
,siv.price
|
||||
,siv.dt_from
|
||||
,siv.dt_to
|
||||
,ii1.specification_id
|
||||
from specification_item_version siv
|
||||
join specification_item ii1 on (siv.specification_item_uid=ii1.specification_item_uid)
|
||||
join specification is1 on (ii1.specification_id=is1.specification_id)
|
||||
join agreement a on (siv.agreement_version=a.agreement_version AND is1.contract_id=a.contract_id)
|
||||
where a.agreement_version = (select max(iiv.agreement_version)
|
||||
from specification_item_version iiv
|
||||
join specification_item ii on (iiv.specification_item_uid=ii.specification_item_uid)
|
||||
join specification isp on (ii.specification_id=isp.specification_id)
|
||||
join agreement ia on (isp.contract_id=ia.contract_id AND iiv.agreement_version=ia.agreement_version)
|
||||
where iiv.specification_item_uid=siv.specification_item_uid
|
||||
AND ia.is_actual
|
||||
AND ia.agreement_version < <cfqueryparam cfsqltype="cf_sql_integer" value="#d.agreement_version#"/>
|
||||
)
|
||||
) ver on (iv.specification_item_uid=ver.specification_item_uid AND ver.specification_id=s.specification_id)
|
||||
where s.contract_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contract_id#"/>
|
||||
AND iv.agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.agreement_version#"/>
|
||||
order by i.specification_id
|
||||
@@ -215,17 +261,32 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Спецификация</th>
|
||||
<th>Специф-я</th>
|
||||
<th>Договор</th>
|
||||
<th>Контрагент</th>
|
||||
<th>Стабильный ключ строки</th>
|
||||
<th>Услуга</th>
|
||||
<th>Модель</th>
|
||||
<th>Код услуги</th>
|
||||
<th>Имя для печати</th>
|
||||
|
||||
<th>Дата с</th>
|
||||
<th>Дата по</th>
|
||||
<th>Кол-во</th>
|
||||
<th>Цена</th>
|
||||
<th>Цена</th>
|
||||
|
||||
<th> </th>
|
||||
|
||||
<th>Прошлая версия</th>
|
||||
|
||||
<th>Прошлая дата с</th>
|
||||
<th>Прошлая дата по</th>
|
||||
<th>Прошлое кол-во</th>
|
||||
<th>Прошлая цена</th>
|
||||
|
||||
<th>Изменение</th>
|
||||
<th>Прибавка стоимости</th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -245,12 +306,26 @@
|
||||
<td>
|
||||
<a href="svc.cfm?svc_id=#svc_id#&#tr.fwx#">#svc#</a>
|
||||
</td>
|
||||
<td class="c">#pricing_model_short#</td>
|
||||
<td>#code#</td>
|
||||
<td>#specification_item_version#</td>
|
||||
<td>#dateFormat(dt_from,'DD.MM.YYYY')#</td>
|
||||
<td>#dateFormat(dt_to,'DD.MM.YYYY')#</td>
|
||||
<td>#quantity#</td>
|
||||
<td>#price#</td>
|
||||
|
||||
<td class="c">#dateFormat(dt_from,'DD.MM.YYYY')#</td>
|
||||
<td class="c">#dateFormat(dt_to,'DD.MM.YYYY')#</td>
|
||||
<td class="r">#quantity#</td>
|
||||
<td class="r">#price#</td>
|
||||
|
||||
<td></td>
|
||||
|
||||
<td class="c"><a href="specification_item_version.cfm?specification_item_uid=#specification_item_uid#&agreement_version=#prev_version#&#tr.fwx#">#prev_version#</a></td>
|
||||
<td class="c">#dateFormat(prev_dt_from,'DD.MM.YYYY')#</td>
|
||||
<td class="c">#dateFormat(prev_dt_to,'DD.MM.YYYY')#</td>
|
||||
<td class="r">#prev_quantity#</td>
|
||||
<td class="r">#prev_price#</td>
|
||||
|
||||
<td class="c">#change_type#</td>
|
||||
<td class="r">#cost_diff#</td>
|
||||
|
||||
<td class="c">
|
||||
<cfif pageInfo.writePermitted()>
|
||||
<a href="specification_item_version_del.cfm?specification_item_uid=#specification_item_uid#&agreement_version=#agreement_version#&#tr.fwx#" class="del"></a>
|
||||
@@ -259,6 +334,7 @@
|
||||
</tr>
|
||||
</cfoutput>
|
||||
</table>
|
||||
Может быть, сюда для ясности добавить не измененые строки спецификаций?
|
||||
|
||||
</cfif>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user