fix(finance): cast derived revenue parameters
This commit is contained in:
parent
88804a0eea
commit
1007f929c2
1 changed files with 5 additions and 3 deletions
|
|
@ -649,11 +649,13 @@ async function refreshRevenueMetric(
|
|||
`INSERT INTO staff_daily_metrics
|
||||
(id, tenant_id, org_unit_id, business_date, metric_key, value,
|
||||
currency_code, source, recorded_by)
|
||||
SELECT $1, $2, $3, $4, 'revenue_minor',
|
||||
SELECT $1::varchar(26), $2::varchar(26), $3::varchar(26), $4::date, 'revenue_minor',
|
||||
COALESCE(SUM(value) FILTER (WHERE metric_key LIKE 'income\\_%' ESCAPE '\\'), 0),
|
||||
'RUB', 'module', $5
|
||||
'RUB', 'module', $5::varchar(26)
|
||||
FROM staff_daily_metrics
|
||||
WHERE tenant_id = $2 AND org_unit_id = $3 AND business_date = $4
|
||||
WHERE tenant_id = $2::varchar(26)
|
||||
AND org_unit_id = $3::varchar(26)
|
||||
AND business_date = $4::date
|
||||
ON CONFLICT (tenant_id, org_unit_id, business_date, metric_key)
|
||||
DO UPDATE SET value = EXCLUDED.value, source = 'module',
|
||||
recorded_by = EXCLUDED.recorded_by, updated_at = now()`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue