pricing model
This commit is contained in:
parent
13cc175dc3
commit
b4aa34d24a
@ -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>
|
||||
|
||||
|
@ -8,6 +8,31 @@
|
||||
|
||||
|
||||
<!---<cftry>--->
|
||||
<!--- "dealId" : "018c687b-3700-5503-ae2a-4dfa85ea2cca",
|
||||
"dealName" : "№566 1С и терм.сервер",
|
||||
"contragentInn" : "7751265941",
|
||||
"contragentId" : "b6c95829-5397-497e-b80f-2b86495a2a54",
|
||||
"dealType" : "New sale",
|
||||
"arr" : [ {
|
||||
"price" : 50000.004,
|
||||
"sum" : 50000.004,
|
||||
"area" : "Размещение в ЦОД",
|
||||
"abstractService" : "Аренда стойко-места",
|
||||
"staticId" : "20231214T193205277",
|
||||
"code" : "colo.rack.0-f",
|
||||
"modifier" : "",
|
||||
"isActual" : true,
|
||||
"type" : "3",
|
||||
"modifierCode" : "none",
|
||||
"abstractServiceCode" : "Аренда стойко-места",
|
||||
"dateStartProvision" : "",
|
||||
"dateEndProvision" : "",
|
||||
"componentsName" : "Аренда стойко-места",
|
||||
"unit" : "шт.",
|
||||
"quantity" : 1,
|
||||
"priceWoDiscount" : 50000.004,
|
||||
"discount" : 0,
|
||||
"change" : "new" --->
|
||||
|
||||
<cfquery name="qRead" datasource="#request.DS#">
|
||||
select
|
||||
|
@ -14,6 +14,8 @@ create table measure (
|
||||
,dt_created timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà çàïèñè
|
||||
,dt_updated timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà ïîñëåäíåé ìîäèôèêàöèè
|
||||
);
|
||||
ALTER TABLE measure OWNER TO dbo;
|
||||
|
||||
insert into measure (measure, measure_short) values ('øòóêà','øò.');
|
||||
insert into measure (measure, measure_short) values ('êèëîâàòò','êÂò');
|
||||
insert into measure (measure, measure_short) values ('êèëîâàòò-÷àñ','êÂò-÷');
|
||||
@ -22,6 +24,28 @@ insert into measure (measure, measure_short) values ('
|
||||
insert into measure (measure, measure_short) values ('10000 øò.','10òûñ.øò.');
|
||||
|
||||
|
||||
drop table if exists pricing_model;
|
||||
create table pricing_model (
|
||||
pricing_model_id int PRIMARY KEY NOT NULL
|
||||
,pricing_model varchar(255) NOT NULL
|
||||
,pricing_model_short varchar(255) NOT NULL -- ýòî íå êîä, à êîðîòêîå íàçâàíèå
|
||||
,pricing_model_code char(1) NOT NULL -- ñóôôèêñ
|
||||
,descr text NULL
|
||||
|
||||
,creator_id int NULL
|
||||
,updater_id int NULL
|
||||
,dt_created timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà çàïèñè
|
||||
,dt_updated timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà ïîñëåäíåé ìîäèôèêàöèè
|
||||
);
|
||||
insert into pricing_model (pricing_model_id, pricing_model, pricing_model_short, pricing_model_code, descr)
|
||||
values (1, 'Îäíîêðàòíàÿ', 'install', 'i', 'Îäíîêðàòíàÿ èëè èíñòàëëÿöèîííàÿ óñëóãà');
|
||||
insert into pricing_model (pricing_model_id, pricing_model, pricing_model_short, pricing_model_code, descr)
|
||||
values (2, 'Ôèêñèðîâàííàÿ', 'fix', 'f', 'Ôèêñèðîâàííàÿ ðåãóëÿðíàÿ îïëàòà çà îïðåäåëåííûé îáúåì (êâîòó), ÷àñòî allocation èëè reservation. Êàê ïðàâèëî, åæåìåñÿ÷íûé ïëàòåæ, èíîãäà ïîêâàðòàëüíûé, âîçìîæíû è äðóãèå. Allocation íå ýêâèâàëåíòíî Fix.');
|
||||
insert into pricing_model (pricing_model_id, pricing_model, pricing_model_short, pricing_model_code, descr)
|
||||
values (3, 'Ïî ïîòðåáëåíèþ', 'metered', 'm','Îïëàòà ïî ôàêòó ïîòðåáëåíèÿ, metered, PAYG');
|
||||
ALTER TABLE pricing_model OWNER TO dbo;
|
||||
|
||||
|
||||
drop table if exists contragent CASCADE;
|
||||
create table contragent (
|
||||
contragent_id int GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY
|
||||
@ -126,6 +150,7 @@ create table specification_item (
|
||||
specification_item_uid uuid NOT NULL PRIMARY KEY DEFAULT gen_random_uuid() -- êëþ÷ ñòðîêè
|
||||
,specification_id int NOT NULL --FK
|
||||
,svc_id int NOT NULL --immutable
|
||||
,pricing_model_id int NOT NULL --immutable
|
||||
|
||||
,creator_id int NULL
|
||||
,updater_id int NULL
|
||||
@ -133,6 +158,7 @@ create table specification_item (
|
||||
,dt_updated timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà ïîñëåäíåé ìîäèôèêàöèè
|
||||
);
|
||||
ALTER TABLE specification_item OWNER TO dbo;
|
||||
--ALTER TABLE specification_item ADD pricing_model_id int NOT NULL default 2;
|
||||
|
||||
-- âåðñèÿ ñòðîêè ñïåöèôèêàöèè (âåðñèîííîñòü áåðåòñÿ îò ñïåêè)
|
||||
drop table if exists specification_item_version CASCADE;
|
||||
@ -151,8 +177,10 @@ create table specification_item_version (
|
||||
,dt_created timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà çàïèñè
|
||||
,dt_updated timestamp NOT NULL default CURRENT_TIMESTAMP -- äàòà ïîñëåäíåé ìîäèôèêàöèè
|
||||
,CONSTRAINT PK_specification_item_version PRIMARY KEY (specification_item_uid, agreement_version)
|
||||
,CONSTRAINT CK_specification_item_version_dt CHECK NOT(dt_from IS NULL AND dt_to IS NULL)
|
||||
);
|
||||
ALTER TABLE specification_item OWNER TO dbo;
|
||||
-- ALTER TABLE specification_item_version ADD CONSTRAINT CK_specification_item_version_dt CHECK(NOT(dt_from IS NULL AND dt_to IS NULL));
|
||||
|
||||
-- ïàðàìåòð (êîìïîíåíò) ñîáñòâåííîé âåðñèîííîñòè íå èìååò, ïðè ñîçäàíèè íîâîé âåðñèè ñòðîêè êëîíèðóåòñÿ
|
||||
drop table if exists specification_item_param CASCADE;
|
||||
|
@ -7,6 +7,7 @@ join agreement a on (s.contract_id=a.contract_id AND siv.agreement_version=a.agr
|
||||
Теперь дифференциальный вариант. Для каждого варианта строки можно найти предыдущий (если он есть) и с ним сравнивать.
|
||||
Нужно ли добавить типы экземпляров инсталл и пейг? С пейгом чтобы получить дифф, нужно количество - иначе мы можем дифф только на цену. Если мы хотим брать во внимание дату НОУ, то без количества разницу в стоимости мы не получим.
|
||||
Как вообще учитывать дату в диффе? Или никак, просто передавать.
|
||||
*** Вероятно, dt_from или dt_to должны быть заполнены (check)
|
||||
|
||||
16:12 12.06.2025
|
||||
Предлагается использовать конечную дату только для завершения действия всей строки спеки. Тогда ее просто убрать из версии? Некорректно, она же возникает в какой-то версии.
|
||||
|
@ -153,8 +153,9 @@
|
||||
,svc.code
|
||||
,s.specification_id
|
||||
,s.contract_id
|
||||
<!--- ,i.price*i.quantity as cost --->
|
||||
<!--- ,(select count(*) from svc_param sp where sp.svc_id=i.svc_id) as svc_param_count --->
|
||||
,i.pricing_model_id
|
||||
,p.pricing_model_short
|
||||
|
||||
,(select siv.agreement_version from specification_item_version siv
|
||||
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
|
||||
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
|
||||
@ -193,6 +194,7 @@
|
||||
order by siv.agreement_version desc limit 1) as dt_to
|
||||
,(select count(*) from specification_item_version siv where siv.specification_item_uid=i.specification_item_uid) as item_version_count
|
||||
from specification_item i
|
||||
join pricing_model p on (i.pricing_model_id=p.pricing_model_id)
|
||||
join specification s on (i.specification_id=s.specification_id)
|
||||
--left outer join ()
|
||||
left outer join svc on (i.svc_id=svc.svc_id)
|
||||
@ -220,6 +222,7 @@
|
||||
<th></th>
|
||||
<th>Ключ строки</th>
|
||||
<th>Услуга</th>
|
||||
<th>Модель</th>
|
||||
<th>Код услуги</th>
|
||||
<th>Версий</th>
|
||||
<th> </th>
|
||||
@ -241,6 +244,7 @@
|
||||
</td>
|
||||
<td>#specification_item_uid#</td>
|
||||
<td>#svc#</td>
|
||||
<td class="c">#pricing_model_short#</td>
|
||||
<td>#code#</td>
|
||||
<td class="c">#item_version_count#</td>
|
||||
<td class="c"></td>
|
||||
|
@ -21,6 +21,7 @@
|
||||
<d:param field="specification_item_uid" type="guid" key autoincrement/>
|
||||
<d:param field="specification_id" type="integer" required/>
|
||||
<d:param field="svc_id" type="integer" required/>
|
||||
<d:param field="pricing_model_id" type="integer" required/>
|
||||
<!--- <d:param field="specification_item" type="varchar" size="1023" preprocessor=#cleanInput#/> можно было оставить здесь, но мигрировали в версию --->
|
||||
|
||||
<d:param field="creator_id" type="integer" value="#request.usr_id#" skipUpdate/>
|
||||
@ -126,7 +127,31 @@
|
||||
displayf="##code## ##svc##"
|
||||
empty=""
|
||||
class=""
|
||||
onchange="submit();"
|
||||
/>
|
||||
<!--- <cfif d.svc_id GT 0>
|
||||
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="svc" id=#d.svc_id# fwx=#tr.fwx#/>
|
||||
</cfif> --->
|
||||
при наличии версий предлагается исключить изменение
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tr">
|
||||
<div class="th">Модель тарификации</div>
|
||||
<div class="td">
|
||||
<cfquery name="qList" datasource="#request.DS#">
|
||||
select s.pricing_model_id, s.pricing_model, s.pricing_model_short
|
||||
from pricing_model s
|
||||
order by 2
|
||||
</cfquery>
|
||||
<c:combo
|
||||
query=#qList#
|
||||
combo="pricing_model_id"
|
||||
id="pricing_model_id"
|
||||
key="pricing_model_id"
|
||||
selected="#d.pricing_model_id#"
|
||||
displayf="##pricing_model_short## [##pricing_model_id##] ##pricing_model##"
|
||||
empty=""
|
||||
class=""
|
||||
/>
|
||||
<!--- <cfif d.svc_id GT 0>
|
||||
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="svc" id=#d.svc_id# fwx=#tr.fwx#/>
|
||||
|
@ -78,11 +78,14 @@
|
||||
,s.specification_id, s.specification, s.contract_id
|
||||
,d.contract, d.dt_contract, d.contragent_id
|
||||
,k.contragent
|
||||
,i.pricing_model_id, p.pricing_model, p.pricing_model_short
|
||||
|
||||
from specification_item i
|
||||
left join specification s on (i.specification_id=s.specification_id)
|
||||
left join contract d on (s.contract_id=d.contract_id)
|
||||
left join contragent k on (d.contragent_id=k.contragent_id)
|
||||
left join svc v on (i.svc_id=v.svc_id)
|
||||
left join pricing_model p on (i.pricing_model_id=p.pricing_model_id)
|
||||
where i.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.specification_item_uid#" null=#!IsValid('guid',d.specification_item_uid)#/>
|
||||
</cfquery>
|
||||
|
||||
@ -137,6 +140,7 @@
|
||||
|
||||
<layout:detail_line title="Услуга">
|
||||
<a href="svc.cfm?svc_id=#qSpecificationItem.svc_id#&#tr.fwx#">#qSpecificationItem.svc# [#qSpecificationItem.svc_id#]</a>
|
||||
#qSpecificationItem.pricing_model_short# (#qSpecificationItem.pricing_model#)
|
||||
</layout:detail_line>
|
||||
|
||||
<!--- <layout:detail_line title="Версия">#d.agreement_version# (версия-номер соглашения)</layout:detail_line> --->
|
||||
|
@ -195,6 +195,8 @@
|
||||
,svc.svc_id
|
||||
,svc.svc
|
||||
,svc.code
|
||||
,i.pricing_model_id
|
||||
,p.pricing_model_short
|
||||
,s.specification_id
|
||||
,s.contract_id
|
||||
,(select count(*) from specification_item_version siv where siv.specification_item_uid=i.specification_item_uid) as item_version_count
|
||||
@ -209,6 +211,7 @@
|
||||
,ver.dt_from
|
||||
,ver.dt_to
|
||||
from specification_item i
|
||||
join pricing_model p on (i.pricing_model_id=p.pricing_model_id)
|
||||
join specification s on (i.specification_id=s.specification_id)
|
||||
join (select
|
||||
siv.agreement_version
|
||||
@ -238,7 +241,7 @@
|
||||
<!--- </cfif> --->
|
||||
AND ia.agreement_version <= <cfqueryparam cfsqltype="cf_sql_integer" value="#agreement_version#"/>
|
||||
)
|
||||
) ver on (i.specification_item_uid=ver.specification_item_uid AND s.contract_id=ver.contract_id AND ver.specification_id=s.specification_id)
|
||||
) ver on (i.specification_item_uid=ver.specification_item_uid /*AND s.contract_id=ver.contract_id*/ AND ver.specification_id=s.specification_id)
|
||||
|
||||
left outer join svc on (i.svc_id=svc.svc_id)
|
||||
where i.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.specification_id#"/>
|
||||
@ -267,6 +270,7 @@
|
||||
<th></th>
|
||||
<th>Ключ строки</th>
|
||||
<th>Услуга</th>
|
||||
<th>Модель</th>
|
||||
<th>Код услуги</th>
|
||||
<th>Версий</th>
|
||||
<th> </th>
|
||||
@ -288,6 +292,7 @@
|
||||
</td>
|
||||
<td>#specification_item_uid#</td>
|
||||
<td>#svc#</td>
|
||||
<td class="c">#pricing_model_short#</td>
|
||||
<td>#code#</td>
|
||||
<td class="c">#item_version_count#</td>
|
||||
<td class="c"></td>
|
||||
|
Loading…
Reference in New Issue
Block a user