function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rodrigo Soares 13Rodrigo Soares 13 

Creating a VisualPage to view Finance Controller

Hi, Good Morning!
Can somenone help me for this please?
I need to develop a VisualForce page similar below called Finance Vision (that is a SObj):
Example for visualForce page

This table have conditions:
1. Only create the Finance Vision if Master Object (Project__c) has created Revenues__c and AlocationPeriod__c
2. I Need that has a Button on Project__c layout to create and update this Finance Vision
3. This data Informations are allowed in others SObjects (getting by apex methods and formula)


At the moment, my code is that:
 

public void gerarPlanejamentoFinanceiro(List<Projeto__c> listProjeto, List<PeriodoAlocacao__c> listPeriodoAlocacao, List<Faturamento__c> listFaturamento)
    {

		Set<Id> setIdProjeto = new Set<Id>();
		Set<Id> setIdPeriodoAlocacao = new Set<Id>();
		Set<Id> setIdFaturamento = new Set<Id>();


		//Salva os Ids dos projetos existentes
		for(Projeto__c projeto : listProjeto)
		{
			setIdProjeto.add((Id)projeto);

			for(PeriodoAlocacao__c periodo: listPeriodoAlocacao)
							{
				setIdPeriodoAlocacao.add((Id)projeto.periodo);
			}

			for(Faturamento__c faturamento : listFaturamento)
			{
				setIdFaturamento.add((Id)projeto.faturamento);
			}
		}

		List<VisaoFinanceira__c> listVisaoFinanceira= new List<VisaoFinanceira__c>();

		for(Projeto__c projeto : listProjeto)
		{

			if(setIdFaturamento == null || setIdFaturamento.isEmpty() || setIdPeriodoAlocacao == null || setIdPeriodoAlocacao.isEmpty())
			{
				projeto.addError('Não há Faturamento ou Alocação cadastrada neste projeto!');
				break;
			}
				
			for(Integer i=0; i<projeto.NumeroMesesProjeto__c; i++)
			{
			
				VisaoFinanceira__c vf = new VisaoFinanceira__c();

				vf.Projeto__c = projeto.Projeto__c;
				vf.DataInicio__c = projeto.Inicio__c;
				
				if (DataInicio__c.Month() == System.today().Month()) 
					vf.Status__c = 'Em Andamento';

				else if(DataInicio__c.Month() < System.today().Month())
					vf.Status__c = 'Real';
				else
					vf.Status__c = 'Planejado';


				listVisaoFinanceira.add(vf);
			}
		}

		insert listVisaoFinanceira;
	}