V10 ResourcesReference
ResourcesReference
Reference
Back | List of Articles

How to report employee monthly changes using the API?

Last changed in 02/12/2020

The Human Resources module of PRIMAVERA ERP includes features that provides organizations with greater speed and efficiency in the management of their human resources.

For example, you can manage changes to your employees' data, such as recording absences, overtime, salaries and deductions.

In this article, we use the project available from GitHub to demonstrate how we can create monthly changes through the API available in ERP V10.

Monthly Changes

The type of monthly changes in this example is the absence records, which is intended to record an employee's absences.

This process is particularly important if the system is configured to include this data for processing the employee's salary.

To record an absence for an employee, follow these steps:

Step 1 - Add the reference to the Human Resources module

Create a project in Visual Studio and add the reference to the Human Resources API:

  • RhpBE100
  • IRhpBS100

Step 2 - Add the "RhpBE100" namespace

To make it easier to read the code, add the API's HR namespace.

using RhpBE100;

Step 3 - Validate if the Absence exists

You can only report employee absences that exist in the absence table.

To avoid insertion errors, in this step we first validate if the absence exists.

RhpBEFalta absenceType = PriEngine.Engine.RecursosHumanos.Faltas.Edita(txtAbsence.Text);
if (absenceType != null)
{
  //You can enter the absence
}
else
  MessageBox.Show("The Absence type does not exist.");

Step 4 - Create the absence record object with the necessary information

RhpBECadastroFalta absenceRecords = new RhpBECadastroFalta
{
    CalculoFalta = absenceType.CalculoFaltaDias,
    Horas = absenceType.Horas,
    DescontaRem = absenceType.DescontaRemuneracoes != 0,
    Falta = txtAbsence.Text.ToUpper(),
    Data = dtDate.Value.Date,
    Observacoes = txtRemarks.Text,
    Funcionario = txtEmployee.Text.ToUpper(),
    ExcluiProc = chkExcludeProc.Checked,
    ExcluiEstat = chkExcludeStatistics.Checked,
    Tempo = (float)nupDuration.Value,
    Origem = (byte)OrigemDados.origemVBA
};

Step 5 - Create the Absence record

You need to check if the absence associated with the employee already exists on the specified date before entering it.

If it already exists, the system updates the existing absence data, otherwise it will report a new absence with the entered data.

if (PriEngine.Engine.RecursosHumanos.CadastroFaltas.Existe(absenceRecords.Funcionario, absenceRecords.Data, absenceRecords.Falta))
{
    MessageBox.Show($"The absence {absenceRecords.Falta} already exists for Employee { absenceRecords.Funcionario} on day {absenceRecords.Data}.");
}
else
{
    PriEngine.Engine.RecursosHumanos.CadastroFaltas.Actualiza(absenceRecords);
    MessageBox.Show("Writing carried out successfully.");
    this.Close();
}
Bookmark or share this article
Esta página foi útil?
Obrigado pelo seu voto.

login para deixar a sua opinião.

Obrigado pelo seu feedback. Iremos analisá-lo para continuarmos a melhorar!
Artigos Relacionados
Características das entidades e serviços Conceito de integração Conceito de extensibilidade Como registar projetos de extensibilidade? Boas práticas de organização de projetos de integração
Últimos Artigos Vistos
How to retrieve inventory values using SQL statements?