SQL Series 1000060

Set Calculations and Values on the Target Application Record

A series of SQL Scripts that completes all calculations - totaling Values and Applying Pain / Gain Stages.

 

SQL Identifier

Notes and Comments

SQL 1000060 - 1

Set details for all Schemes fo Scheme Target Price, Final Account and Variation (Pain / Gain) to zero..

SQL 1000060 - 1

SQL 1000060 - 2

Set Scheme Target Prices for all schemes in to column PCCostN4Price.  Prices taken from Scheme SPS Table and includes Inflation Uplifts (no Fees Uplift).

SQL 1000060 - 2

SQL 1000060 - 3

Set Scheme Final Account Costs for all schemes that have been Final Accounted in to column PCCostN4FinalAccount.  Costs taken from Scheme SPS Table tblPIFPriceCostCompare (LPMSO).

SQL 1000060 - 3

SQL 1000060 - 4

Set the DCP Flag for All Schemes that come under DCP Costs range.  Normally this is set earlier - but added here in the case when it is the FIRST occurrence of Costs in any Application.

SQL 1000060 - 4

SQL 1000060 - 5

Sets the Scheme Is costed flag for all prime Schemes.  These range 210000 to 259999, 270000 to 299999, 410000 to 499999.  This used later to pick out Pain / Gain schemes.

SQL 1000060 - 5

SQL 1000060 - 6

Set the Final Account Cost in to PCCostN4Base for schemes that have been final accounted - and are schemes subject to Pain / Gain.  This overrides the Costs taken from the standard live Cost Tables.

SQL 1000060 - 6

SQL 1000060 - 7

Set the Previous Period Costs for N1, N2, N3, N4, N99 where the Last Period flag equals the (Current Period - )1- i.e. already is the previous period and no Fees Uplift is set.  This seeds the records.

SQL 1000060 - 7

SQL 1000060 - 8

Set the Contract Fees Uplift percentage - IMPORTANT.  This sets from [tbsSettings].

SQL 1000060 - 8

SQL 1000060 - 9

Establish the Difference between Cost Target Price for all Pain / Gain subjected schemes.

SQL 1000060 - 9

SQL 1000060 - 10

Establish the Pain Gain element within 20% Variation for all Pain / Gain subjected schemes.

SQL 1000060 - 10

SQL 1000060 - 11

Establish the Pain Gain element for over 20% Variation for all Pain / Gain subjected schemes.

SQL 1000060 - 11

SQL 1000060 - 12

Set the overall Pain / Gain figure for under 20% variation - for all Pain / Gain subjected schemes.

SQL 1000060 - 12

SQL 1000060 - 13

Calculate all Application To Date Totals - N1, N2, N3, N4, N99 and Application To Date.

SQL 1000060 - 13

SQL 1000060 - 14

Calculate all Application Current Period Totals - N1, N2, N3, N4, N99 - Schemes with Costs in Current Period processed.

SQL 1000060 - 14

SQL 1000060 - 15

Set Flag on Final Account to 'TRUE' as these are now all calculated.

SQL 1000060 - 15

 SQL 1000060 - 16

Calculate all Application Current Period Totals - N99 - Schemes with Costs in Current Period processed.

SQL 1000060 - 16