<?php
declare(strict_types = 1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241006121120 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql(
'create view report_total_or_installments_amount_per_year_and_student as
select p.faculty,
p.index_no,
p.current_semester as semester,
concat(s.first_name, \' \', s.last_name) as full_name,
e.academic_year AS academic_year,
sp.name as study_program,
case
when t.title = \'U cjelosti\' or t.title = \'Uplata u cjelosti\' then \'Uplata u cjelosti\'
else \'Rate\' end AS payment_type,
SUM(CASE WHEN t.payed_on IS NOT NULL THEN t.amount ELSE 0 END) AS amount,
case
when m.covered = 1 then m.title
else \'\' end AS sponsored
from students s
left join profiles p on s.id = p.student_id
left join enrollment_events e on e.profile_id = p.id
left join tuition_modality_templates m on e.tuition_modality_template_id = m.id
left join tuition_installments t on t.enrollment_id = e.id
left join study_programmes sp on sp.id = p.study_programme_id
where e.academic_year is not null
and e.tuition_modality_template_id is not null
group by p.faculty, p.index_no, s.first_name, s.last_name, e.academic_year, sp.name, payment_type, sponsored,
p.current_semester
order by p.faculty, e.academic_year, sp.name, p.index_no;');
}
public function down(Schema $schema): void
{
$this->addSql('DROP VIEW report_total_or_installments_amount_per_year_and_student');
}
}