Загрузка данных


union all
  -- Перераспределение: списание без кредитового счета
  select
    s.id,
    t.effective_date,
    -t.value,
    ot.short_name
  from back_office.transaction t
    join back_office.operation o
      on o.id = t.operation_id
    join back_office.operation_type ot
      on ot.id = o.operation_type_id
      and ot.code = 'REDISTRIBUTION'
    join back_office.account da
      on da.id = t.debit_account_id
    join ourpension.sharer s
      on s.id = da.owner_sharer_id
      and s.id = $P{sharer_id}
  where o.approved is not null
    and o.deleted is null
    and t.credit_account_id is null
    and t.effective_date <= $P{d2}