oprava import/export kwh
This commit is contained in:
@@ -59,7 +59,13 @@ as $fn$
|
||||
coalesce(dt.vat_rate, 0.21) as vat_rate,
|
||||
mip.buy_raw_price_czk_kwh as buy_spot,
|
||||
mip.sell_raw_price_czk_kwh as sell_spot,
|
||||
pi.expected_cost_czk as planned_cost_czk
|
||||
pi.expected_cost_czk as planned_cost_czk,
|
||||
ems.fn_audit_grid_import_wh_for_economics(
|
||||
ai.actual_grid_import_wh, ai.actual_grid_export_wh, ai.actual_grid_power_w
|
||||
) as est_grid_import_wh,
|
||||
ems.fn_audit_grid_export_wh_for_economics(
|
||||
ai.actual_grid_import_wh, ai.actual_grid_export_wh, ai.actual_grid_power_w
|
||||
) as est_grid_export_wh
|
||||
from ems.audit_interval ai
|
||||
left join lateral (
|
||||
select smc_inner.*
|
||||
@@ -202,29 +208,19 @@ as $fn$
|
||||
select
|
||||
s5.site_id,
|
||||
s5.day_local,
|
||||
round(s5.est_grid_import_wh / 1000, 4) as import_kwh,
|
||||
round(s5.est_grid_export_wh / 1000, 4) as export_kwh,
|
||||
round(
|
||||
coalesce(s5.actual_grid_import_wh, greatest(s5.actual_grid_power_w, 0)::numeric / 4) / 1000,
|
||||
4
|
||||
) as import_kwh,
|
||||
round(
|
||||
coalesce(s5.actual_grid_export_wh, abs(least(s5.actual_grid_power_w, 0))::numeric / 4) / 1000,
|
||||
4
|
||||
) as export_kwh,
|
||||
round(
|
||||
coalesce(s5.actual_grid_import_wh, greatest(s5.actual_grid_power_w, 0)::numeric / 4) / 1000.0
|
||||
* coalesce(s5.buy_p, 0),
|
||||
s5.est_grid_import_wh / 1000.0 * coalesce(s5.buy_p, 0),
|
||||
4
|
||||
) as grid_import_cashflow_czk,
|
||||
round(
|
||||
coalesce(s5.actual_grid_export_wh, abs(least(s5.actual_grid_power_w, 0))::numeric / 4) / 1000.0
|
||||
* coalesce(s5.sell_p, 0),
|
||||
s5.est_grid_export_wh / 1000.0 * coalesce(s5.sell_p, 0),
|
||||
4
|
||||
) as grid_export_revenue_czk,
|
||||
round(
|
||||
coalesce(s5.actual_grid_import_wh, greatest(s5.actual_grid_power_w, 0)::numeric / 4) / 1000.0
|
||||
* coalesce(s5.buy_p, 0)
|
||||
- coalesce(s5.actual_grid_export_wh, abs(least(s5.actual_grid_power_w, 0))::numeric / 4) / 1000.0
|
||||
* coalesce(s5.sell_p, 0),
|
||||
s5.est_grid_import_wh / 1000.0 * coalesce(s5.buy_p, 0)
|
||||
- s5.est_grid_export_wh / 1000.0 * coalesce(s5.sell_p, 0),
|
||||
4
|
||||
) as dynamic_cost_czk,
|
||||
s5.green_bonus_czk,
|
||||
|
||||
Reference in New Issue
Block a user