Skip to content

Commit

Permalink
Revert "#10238 - Modify report and functions."
Browse files Browse the repository at this point in the history
This reverts commit 44464a0
  • Loading branch information
dragospodariu96 committed Nov 24, 2020
1 parent 44464a0 commit 25072d5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 447 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="dev.xml"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.report.description" value=""/>
<import value="net.sf.jasperreports.engine.*"/>
<import value="java.util.*"/>
Expand Down Expand Up @@ -96,14 +96,14 @@
<field name="pricestd" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="pricestd"/>
</field>
<field name="pricepattern1" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="pricepattern1"/>
<field name="PricePattern1" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="PricePattern1"/>
</field>
<field name="altpricestd" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="altpricestd"/>
</field>
<field name="pricepattern2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="pricepattern2"/>
<field name="PricePattern2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="PricePattern2"/>
</field>
<field name="hasaltprice" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.label" value="hasaltprice"/>
Expand Down Expand Up @@ -251,7 +251,7 @@
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd.MM.yyyy").format($F{validfromplv2})]]></textFieldExpression>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd.MM.yyyy").format($F{validfromplv1})]]></textFieldExpression>
</textField>
<textField>
<reportElement key="textField-16" x="37" y="0" width="133" height="12" forecolor="#000000" uuid="ef32425f-72eb-4296-a44d-40c2cd66ed1b"/>
Expand All @@ -265,7 +265,7 @@
<textElement markup="none">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{nameplv2}]]></textFieldExpression>
<textFieldExpression><![CDATA[$F{nameplv1}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
Expand All @@ -281,7 +281,7 @@
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{Price}]]></textFieldExpression>
<textFieldExpression><![CDATA[( $F{hasaltprice} != 0 ? $R{newprice} : $R{Price})]]></textFieldExpression>
</textField>
<textField>
<reportElement key="textField-17" x="333" y="33" width="107" height="12" forecolor="#000000" uuid="70fa6b18-edb1-4cc9-9e5c-30b428399a6d"/>
Expand Down Expand Up @@ -312,15 +312,15 @@
<textFieldExpression><![CDATA[$R{P_Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement key="textField-20" x="527" y="33" width="50" height="12" forecolor="#000000" uuid="0945443b-def7-4253-a6e1-6a6d932f115c">
<reportElement key="textField-20" x="527" y="33" width="40" height="12" forecolor="#000000" uuid="0945443b-def7-4253-a6e1-6a6d932f115c">
<property name="net.sf.jasperreports.export.xls.column.hidden" value="false"/>
<printWhenExpression><![CDATA[new Boolean( $F{hasaltprice} != null
&& $F{altpricestd}.floatValue() != 0)]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{Price_New}]]></textFieldExpression>
<textFieldExpression><![CDATA[$R{oldprice}]]></textFieldExpression>
</textField>
<textField>
<reportElement key="textField-13" x="259" y="33" width="73" height="12" forecolor="#000000" uuid="9a577c3e-9c95-4400-8830-18891deb0757"/>
Expand All @@ -334,17 +334,17 @@
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{currency2}]]></textFieldExpression>
<textFieldExpression><![CDATA[$F{currency}]]></textFieldExpression>
</textField>
<textField>
<reportElement key="textField-20" x="527" y="45" width="50" height="12" forecolor="#000000" uuid="57e94297-3dbb-4465-96c1-330b0ef6c239">
<reportElement key="textField-20" x="527" y="45" width="40" height="12" forecolor="#000000" uuid="57e94297-3dbb-4465-96c1-330b0ef6c239">
<printWhenExpression><![CDATA[new Boolean( $F{hasaltprice} != null
&& $F{altpricestd}.floatValue() != 0)]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{currency}]]></textFieldExpression>
<textFieldExpression><![CDATA[$F{currency2}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
Expand Down Expand Up @@ -431,7 +431,7 @@
<textFieldExpression><![CDATA[$F{uomsymbol}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement key="textField-20" x="480" y="0" width="47" height="12" forecolor="#000000" uuid="118a78d4-035b-4396-877b-f4e9c74bf281"/>
<reportElement key="textField-20" style="StyleBOLD" x="480" y="0" width="47" height="12" forecolor="#000000" uuid="118a78d4-035b-4396-877b-f4e9c74bf281"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
Expand All @@ -442,7 +442,7 @@
<font fontName="Arial" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{pricestd}]]></textFieldExpression>
<patternExpression><![CDATA[$F{pricepattern1}]]></patternExpression>
<patternExpression><![CDATA[$F{PricePattern1}]]></patternExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement key="textField-24" mode="Transparent" x="34" y="0" width="45" height="12" forecolor="#000000" backcolor="#FFFFFF" uuid="097beb53-5e78-4dd1-9c25-efb41d796b05"/>
Expand All @@ -458,7 +458,7 @@
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement key="textField-20" style="StyleBOLD" isPrintRepeatedValues="false" mode="Transparent" x="527" y="0" width="50" height="12" forecolor="#000000" uuid="118a78d4-035b-4396-877b-f4e9c74bf281">
<reportElement key="textField-20" x="527" y="0" width="40" height="12" forecolor="#000000" uuid="118a78d4-035b-4396-877b-f4e9c74bf281">
<printWhenExpression><![CDATA[new Boolean( $F{hasaltprice} != null
&& $F{altpricestd}.floatValue() != 0)]]></printWhenExpression>
</reportElement>
Expand All @@ -468,11 +468,11 @@
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Right" markup="none">
<font fontName="Arial" size="9"/>
<textElement textAlignment="Right">
<font fontName="Arial" size="9" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{altpricestd}]]></textFieldExpression>
<patternExpression><![CDATA[$F{pricepattern2}]]></patternExpression>
<patternExpression><![CDATA[$F{PricePattern2}]]></patternExpression>
</textField>
</band>
</detail>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ WITH PriceListVersionsByValidFrom AS
plv.m_pricelist_version_id,
plv.validfrom,
plv.name,
row_number() OVER (PARTITION BY plv.c_bpartner_id ORDER BY plv.validfrom DESC, plv.m_pricelist_version_id DESC) rank
1 as rank
FROM Report.Fresh_PriceList_Version_Val_Rule plv
WHERE TRUE
AND plv.validfrom <= now()
Expand All @@ -60,15 +60,14 @@ WITH PriceListVersionsByValidFrom AS
ORDER BY TRUE,
plv.validfrom DESC,
plv.m_pricelist_version_id DESC
)
LIMIT 1)
UNION ALL
(SELECT --
plv.c_bpartner_id,
plv.m_pricelist_version_id,
plv.validfrom,
plv.name,
101 - (row_number() OVER (PARTITION BY plv.c_bpartner_id ORDER BY plv.validfrom ASC, plv.m_pricelist_version_id ASC)) rank

2 as rank
FROM Report.Fresh_PriceList_Version_Val_Rule plv
WHERE TRUE
AND plv.validfrom > now()
Expand All @@ -78,23 +77,20 @@ WITH PriceListVersionsByValidFrom AS
ORDER BY TRUE,
plv.validfrom ASC,
plv.m_pricelist_version_id ASC
)
LIMIT 1)
) t

WHERE t.rank = 1
OR t.rank = 100
),
currentAndPreviousPLV AS
(
-- implementation detail: all these sub-selects would be better implemented with a pivot. Unfortunately i cant understand how pivots work.
SELECT DISTINCT --
plvv.c_bpartner_id,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV1_ID,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV2_ID,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV1,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV2,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV1,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV2
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV1_ID,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV2_ID,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV1,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV2,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV1,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV2
FROM PriceListVersionsByValidFrom plvv
ORDER BY plvv.c_bpartner_id
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ DROP FUNCTION IF EXISTS report.Current_Vs_Next_Pricelist_Comparison_Report_With_
;

CREATE OR REPLACE FUNCTION report.Current_Vs_Next_Pricelist_Comparison_Report_With_PP_PI(p_C_BPartner_ID numeric = NULL,
p_C_BP_Group_ID numeric = NULL,
p_IsSoTrx text = 'Y',
p_AD_Language TEXT = 'en_US',
p_show_product_price_pi_flag text = 'Y')
p_C_BP_Group_ID numeric = NULL,
p_IsSoTrx text = 'Y',
p_AD_Language TEXT = 'en_US',
p_show_product_price_pi_flag text = 'Y')
RETURNS TABLE
(
bp_value text,
Expand Down Expand Up @@ -50,7 +50,7 @@ WITH PriceListVersionsByValidFrom AS
plv.m_pricelist_version_id,
plv.validfrom,
plv.name,
row_number() OVER (PARTITION BY plv.c_bpartner_id ORDER BY plv.validfrom DESC, plv.m_pricelist_version_id DESC) rank
1 as rank
FROM Report.Fresh_PriceList_Version_Val_Rule plv
WHERE TRUE
AND plv.validfrom <= now()
Expand All @@ -60,15 +60,14 @@ WITH PriceListVersionsByValidFrom AS
ORDER BY TRUE,
plv.validfrom DESC,
plv.m_pricelist_version_id DESC
)
LIMIT 1)
UNION ALL
(SELECT --
plv.c_bpartner_id,
plv.m_pricelist_version_id,
plv.validfrom,
plv.name,
101 - (row_number() OVER (PARTITION BY plv.c_bpartner_id ORDER BY plv.validfrom ASC, plv.m_pricelist_version_id ASC)) rank

2 as rank
FROM Report.Fresh_PriceList_Version_Val_Rule plv
WHERE TRUE
AND plv.validfrom > now()
Expand All @@ -78,23 +77,22 @@ WITH PriceListVersionsByValidFrom AS
ORDER BY TRUE,
plv.validfrom ASC,
plv.m_pricelist_version_id ASC
)
LIMIT 1)
) t

WHERE t.rank = 1
OR t.rank = 100
WHERE t.rank <= 2
),
currentAndPreviousPLV AS
(
-- implementation detail: all these sub-selects would be better implemented with a pivot. Unfortunately i cant understand how pivots work.
SELECT DISTINCT --
plvv.c_bpartner_id,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV1_ID,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV2_ID,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV1,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV2,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV1,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 100 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV2
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV1_ID,
(SELECT plvv2.m_pricelist_version_id FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) PLV2_ID,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV1,
(SELECT plvv2.validfrom FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) validFromPLV2,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 1 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV1,
(SELECT plvv2.name FROM PriceListVersionsByValidFrom plvv2 WHERE plvv2.rank = 2 AND plvv2.c_bpartner_id = plvv.c_bpartner_id) namePLV2
FROM PriceListVersionsByValidFrom plvv
ORDER BY plvv.c_bpartner_id
),
Expand Down

0 comments on commit 25072d5

Please sign in to comment.