How to report employee monthly changes using the API?
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. 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: Step 2 - Add the "RhpBE100" namespace To make it easier to read the code, add the API's HR namespace. 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. Step 4 - Create the absence record object with the necessary information 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.Monthly Changes
using RhpBE100;
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.");
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
};
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();
}
login para deixar a sua opinião.