Top Banner
LIBERO HR PAYROLL Developed by E-EVOLUTION Migrated by REDHUAN D. OON Version 1.1
48
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • LIBERO HR PAYROLL

    Developed by

    E-EVOLUTION

    Migrated by

    REDHUAN D. OON

    Version 1.1

  • Libero HR PayrollCore Plugin GuideA step-by-step guide for a complete Payroll cycle from master data setting right through to ac-

    counts posting and invoice payment. Well-illustrated including developer advice.

    April, 2013 written while in Krefeld, GERMANY,

    Moscow and Trans-Siberian railway, RUSSIA.

  • Cover photo is of a man-hole cover that has the coat-of-arms of Krefeld, a small

    town in Germany. You can see an image of a headless man carrying his head in one

    arm. That is the first bishop of Paris, St. Dionysius, beheaded in year 272 for his

    missionary work. He was offered to save the lives of the other condemned members

    in his mission if he can walk past them after his decapitation. According to legend,

    he did so, walking for some kilometers before succumbing, in the process saving 8.

    This man-hole lies in the middle of the cross-road of streets lined with colorful

    small shops, many with modern designs,. At one end of the street behind me, bears

    the church built in 1752 to honour his sainthood.

    - Picture taken with a Sony XPeria Go

    Krefeld is the venue of the first conference on iDempiere this month of May, which

    hails the participation for the first time of our amazing contributor, Low Heng Sin,

    who has never been to Europe and was not keen of the idea of sitting on the plane

    for 12 hours straight. However he gets the chance to come face to face for the very

    first time with Carlos Ruiz, our best and only software release master, whom he has

    been working so closely via the Internet for the last 7 years. I am here in Krefeld the

    month before to ensure that all preparations go smoothly.

    - April 8, 2013

  • sponsored by

    BANGLADESH

    RED1s THREE LAWS:Information is Free

    YOU HAVE TO KNOW

    People are NotYOU HAVE TO PAY

    Contributors are PricelessYOU HAVE TO BE

  • TABLE OF CONTENTS

    BACKGROUND 7

    INTRODUCTION 9

    Setup! 11

    Terminology 11

    Installing Libero HR plugin 12

    Alternative Pack In 14

    Role Access Update 15

    GardenWorld Sample Setup! 16

    Sample Data Script 16

    Payroll Contract (Variable Definition) 17

    Payroll Department 17

    Payroll Job 18

    Payroll Concept (Variable) 19

    Payroll Concept Catalog Window 19

    Concept Accounting Tab 21

    Concept Ordering 21

    Payroll Definition 22

    Payroll Concepts 22

    Calendar Year 23

    Generate Periods 23

    Payroll Employee Window 24

    Using the Zoom function for New Records 25

    Attribute Tab (Activity) 26

    Payroll Processing! 28

    Payroll Process Window 28

    Payroll Movement (Transactions) 30

    Generate Payroll Invoices 31

    Generate Payroll Payments 32

    Modifying Libero HR Payroll! 34

  • Modifying the Document Type in Generate Invoice 34

    Modifying the Code 36

    Doc_HRProcess Class 36

    MHRProcess Class 37

    Rule Scripts 39

    Synch With Source! 41

    Follow the BitBucket 42

    View the Diff 42

    Applying the Patch 43

    Commit and Push to Bitbucket 45

    Project Protocol ! 47

    Project Version 47

    Source Repository 47

    Project Forum for Support 47

    Contact 47

  • BACKGROUNDLibero HR Payroll is based on the original contribution by Victor Perez of e-Evolution, Mexico

    during the ADempiere project. However its documentation was mostly in Spanish which I had

    helped translated. Nevertheless, it still lacks the full HR management functionality that a modern

    Human Resource Management system possess.

    A member from another Latin-American country, Double-Click of Venezuela has brought about

    extensive improvements to include much of that, but it similarly lacks an English written guide.

    And its own Venezuelan localisation is mixed into it rendering it not easy to be generic for others

    to reuse.

    Carlos Ruiz was working with the Venezuelan team on this and I took Carlos Libero HR version

    to make it into this core plugin for iDempiere, where hopefully any other localisation can base

    themselves upon it. Originally I wanted to do so with the Venezuelan work, which I named it

    LiVE or Libero iDempiere VEnezuela project but while I was in Indonesia, our community

    member there, Edwin Ang advised me against mixing too much into a single plugin, and so I de-

    cided to fall back onto the idea of Libero HR as a core plugin. This module nevertheless bor-

    rowed item 6 from LiVE:

    1. Payroll variables that define such as Monthly Salary, Daily Wages and Overtime Pay

    2. Employee records that are associated to the payroll variables.

    3. Rules can define further how such variables are calculated as final payments.

    4. Process the payroll activity according to calendar periods resulting in transactions.

    5. Posting the transaction to Payroll accounts or Charge account.

    6. Converting the transaction to Invoice or Payment

    I have also released a still-in-progress LiVE as a further add-on that has:

    1. HR Personnel master data such as Health Benefits, Leave management, Employment

    Training, and History

    2.WithHolding Tax when generating Invoices of Employees that can withhold amounts

    payments such as for Income Tax and other statutory declarations.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 7 of 48

  • 3. Substantial reporting in Jasper Reports formats.

    While pursuing this, I have also converted Carlos Ruizs LCO WithHolding Tax into a plugin.

    You can find it under the P2 directory of my SoureForge repository:

    http://sourceforge.net/projects/red1/files/p2/WithHoldingTax/plugins

    WithHoldingTax is used in the Venezuelan LiVE sub-project because it incorporates concepts

    like Income Tax where an amount is withheld in accordance regulatory rules.

    I hope to squeeze in time to work with Double-Click to get to the bottom of LiVE, and one idea I

    posed to them was for me to go to Venezuela. Who knows.

    Thomas Bayen, getting me some cappuccino at a corner cafe in Krefeld, early April, discussing preparations about the upcoming training and conference in May. Thomas is part of a local Linux user group that is active in the German wiki of iDempiere.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 8 of 48

  • INTRODUCTIONHR Payroll is said to be a very difficult module to act as a fit-all module, because there are as many

    different rules as there are as many countries in the world. However the LiberoHR design clev-

    erly use the Rules engine in ADempiere to allow any possible rule or combination of rules to be

    crafted as rule scripts and called by HR concepts during Payroll Processing. More of this in later

    parts of this guide.

    Thus it is useful to try to reuse the framework already defined in LiberoHR. This will quite defi-

    nitely demand an extension or introduction of new table models to store regulatory information

    or lookup data to be used in the rules engine. Periodically, the Payroll Processing triggers the

    MHRProcess java class, which has methods to work with the rules to handle the standard settings

    and employees payroll records to produce respective periodic payroll transactions.

    LiberoHR, been created in Latin-America, is not labeled that intuitively as one from the English

    speaking world would expect. Thus I have made a contextual reference for its main terminology

    in the Setup section.

    I have also prepared some sample data that will use the GardenWorld client and (its about time)

    pay salary to its two hard-working employees, GardenAdmin and GardenUser. The sample data

    is for Postgres Database and can be added via a script here

    http://sourceforge.net/projects/red1/files/p2/LiVE_HR/LiberoHR_Sample_Data.sql

    The rest of this guide will go through this in detailed fashion. I have already tested the plugin to

    automatically and successfully bring in the LiberoHR module via 2Pack into the latest iDempiere

    as of this week.

    Nevertheless I welcome testers and users to report back to my forum http://red1.org/adempiere

    any hiccups they might have in order that I review them and see if anything can be done to this

    core plugin to make subsequent usage a more pleasant experience.

    However I am classifying this plugin as an alpha version which means that it is still far from been

    of any production use. I find it lacking in any ready-made rules as opposed to the LiVE plugin

    having too many rules but overly complex and married to the Venezuelan context. Learning from

    them both leaves me confidence that any real payroll system is now possible but a lot of crafting

    work is in store for a real full-fledge implementation. And we have to apply the best practice in

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 9 of 48

  • separating core code changes into model-validators and clearly designed (and English-like) rules,

    with no core code changes.

    The main reason why I insist this as an alpha version is due to the uncertain completion of a full

    circle of a payroll process right through to the disbursement of wages and final accounts settle-

    ment posting. LiberoHR originally only has Doc_HRProcess to post one set of accounts. Later

    we shall see how we attempt the full cycle with either Invoice or Payments settlement.

    This LiberoHR though usable in the limited sample example, is not fully applicable out of the box

    and require a more competent implementor or consultant developer to prepare it for usability in

    any environment. The rules usage demands some knowledge of cryptic bean-shell, SQL and Java

    code reading which can mean hours of tweaking to get it syntax-correct.

    The LiberoHR plugin is installable in both client OSGi or server OSGi of iDempiere. I have dis-

    abled a lone swing Java form class so as to free it from the 2 conflicting UIs. The LiberoHR

    plugin and its utilities (data sample, full original data dump) are housed in the same LiVE-HR

    directory for convenient location purpose.

    Peter Shepetko is from Ukraine and travelled 20 hours by train to meet me at the Moscow conference. He is a qualified engineer but due to hard life in former Soviet Union has to hold several jobs including Oracle consulting. Today he has occasional ADempiere projects and is trying to contribute a Fusion Charts add-on. We are here, outside the Kremlin and Red Square to our right.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 10 of 48

  • Setup

    Overview of HR Payroll main terminology and its usage at work.

    Terminology

    HR Concept - refers to core variables used in Payroll such as Monthly Pay, Daily or Hourly

    wages, Overtime, Loans, Benefits, Insurance, Deductions and so on.

    HR Attribute - refers to occurrence of such variables for example, monthly pay of 1,500 per

    month period for this employee, overtime wages for the period for this employee for 10 hours.

    HR Movement - refers to transactions or results once the above occurrences are processed on a

    periodic basis.

    Though the meanings on the right part of the image above is more understood in English, I am

    fond of maintaining original terminology so as not to bring about too big an impact to the sub-

    project, and look more to bringing in this infamous but basic module into iDempiere and allow

    the community to test it well but systematically.

    We shall now look at how to install this plugin before proceeding to work with some sample data.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 11 of 48

  • Installing Libero HR plugin

    Note: If you intend to use the WithHolding Tax anytime in the future it is best you install the

    WithHoldingTax plugin first due to some development dependency.

    You can download the LiberoHR plugin for immediate use in your latest iDempiere from

    http://sourceforge.net/projects/red1/files/p2/LiVE_HR/LiberoHR_plugin.jar/download

    You can check the time-stamp on this file to note that it should be at the same time as the latest

    iDempiere version as I usually test or upgrade it to work with the latest bitbucket revision of

    http://bitbucket.org/idempiere/.

    In your OSGi console of either client or server side (obtained via ss console), just key in:

    install http://downloads.sourceforge.net/project/red1/p2/LiVE_HR/LiberoHR_plugin.jar

    Alternatively you download the jar first from the URL above and do it this way (2 examples given)

    install file:/

    install file:C:/Downloads/LiberoHR_plugin.jar

    install file:/Users/Downloads/LiberoHR_plugin.jar

    The console shall reply (if the jar exists at the URI given) with a new Bundle ID. You then start it:

    ! start

    One thing to remember is that you cannot login into your instance yet as the 2Pack that will be

    triggered upon the bundle starting will check for its own client under which it was originally cre-

    ated, which is System and not . If you accidentally logged in then you have to kill

    or exit your iDempiere and launch again.

    (During the automatic PackIn process by the bundle you may not see any prompts which is only

    shown when the Preferences of your iDempiere is set to Fine. So you might see nothing happen-

    ing for a minute or two before you see the OSGi prompt again. If you cannot get the OSGi con-

    sole with ss then check your launch script to have -console before the -application argument. If

    it is not there, then add it in, and launch again. If there is a numerical value after the -console ar-

    gument, then remove that number.)

    The screenshot below will help you as a guide.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 12 of 48

  • The above screen-shot comprises of the terminal window which I executed ./adempiere-client.sh

    in my Mac OSX notebook. The iDempiere login window will appear as shown on the screen-

    shot. In this case, I have already run the install script in the terminal window and then key in ss

    to get the list of bundles. You can see that in my case LiberoHR is registered as bundle 216. (I

    repeated the install script on the last line just to show how it was done.)

    Remember that the login window is in the above state and not logged in so as not to fail the Pack

    In process which remembers the original state of the Pack Out which is the System default here.

    If you are using the Windows environment the above terminal window will also appear or you

    open the DOS prompt by running cmd from your Windows start box. The scripts used in that

    box will also be the same. There may be some difference in the slashing convention of either / or

    \ if you are installing from local file:/ as described below.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 13 of 48

  • Alternative Pack In

    If for any reason you do not wish to use the console you can PackIn the LiberoHR 2Pack manu-

    ally:

    1. Download the LiberoHR 2Pack zip from

    http://sourceforge.net/projects/red1/files/p2/LiVE_HR/LiberoHR.zip

    2. Just login as System and go to the Pack In window

    3. Create a new record

    4. Click on the Attachment icon (paper-clip icon)

    5. Select your LiberoHR.zip that you just downloaded.

    6. Click on the PackIn button and the terminal window should show the following below (if the

    Preferences Trace Level is set to Fine. Otherwise just wait for the prompt.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 14 of 48

  • Role Access Update

    Usually after PackIn of a new 2Pack zip

    file, you need to do a Role Access Update

    for the new menu to appear in full effect.

    After that you done that, you can logout

    and login again to see this on the right.

    In Moscow (April 10-14), presented at the Russian Open Source Conference (April 12) about the ideas to open up the Russian market via Free ERP. On the right is Aleksandr Ryabikof, founder of ADempiere Foundation, Russian Federation. Picture taken at the end of my interview with the Russian online Ubuntu TV.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 15 of 48

  • GardenWorld Sample Setup

    We are basing our sample case of a simplistic payroll master data setup and cycle with the already

    common GardenWorld client.

    Sample Data Script

    You can fetch this at

    http://sourceforge.net/projects/red1/files/p2/LiVE_HR/LiberoHR_Sample_Data.sql

    Follow instructions from the web about running SQL scripts in your database. We usually run

    ANT against the migration scripts directorys build.xml.

    Once that is done, you will have some sample data as shown in the following pages.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 16 of 48

  • Payroll Contract (Variable Definition)

    The Payroll Contract window is used to define the basic definition of the Variables used. In the

    above case, this variable been used to define a Monthly basis, the Net Days is set to 30. Later it

    will help generate the 12 month periods of the calendar.

    Payroll Department

    Here we recognized the two long time employees of GardenWorld as doing Compiere Support.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 17 of 48

  • Payroll Job

    We assigned a job

    called Job under the

    D e p a r t m e n t

    Compiere Support.

    After this we will

    jump ahead to the

    Concept setup and

    Definition part before returning to the HR Employee window.

    12th-14th April. Getting ready to board the Trans-Siberian train, that takes up to 6 days to reach China. I get down 2 days later at Novosibirsk, in the middle of Siberia. From there I fly directly back to Berlin. Most of my final Libero HR documentation was done and finished on board and in style, amidst Russian gibberish, beautiful sceneries and rocking bed. In fact, this photo was pasted and prepared as we speak.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 18 of 48

  • Payroll Concept (Variable)

    This is the heart of the Libero HR Payroll. The concept or variable is the core that determines

    many decisions in the system processes. Lets examine the Payroll Concept Catalog window.

    Payroll Concept Catalog Window

    In this sample data we have defined a value for Monthly Salary called CC_Salary. The Type is set

    to Concept and Column Type is Amount. There is a choice of other values such as RuleEngine

    for Type and Quantity for ColumnType.

    If the Type is RuleEngine, then under the Employee Attributes, the Rule selection will appear.

    If the ColumnType is Quantity then during Employee Attributes, the respective field will appear

    for input.

    The RuleEngine option is power for the developer in the LiberoHR framework. You can define

    virtually anything in BeanShell script how you want a value to be obtained and returned to the

    Amount or Quantity or even Text ColumnType.

    Ensure that your Employee checkbox is checked so that the record will appear in the tab below

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 19 of 48

  • for Employee. This is where we reward our GardenAdmin BP with a real salary. We are giving

    him or her $2,500 per month. You have to select that employee under the Business Partner field.

    Note also that you have to give a Valid from date that and you can set minimal and maximum val-

    ues for the salary. In the next record, you can see that GardenUser also getting a good deal.

    Below we show what will happen if a RuleEngine concept is defined instead.

    Note that the Rule combobox field appears instead.

    Next we move on to the Concept Accounting Tab.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 20 of 48

  • Concept Accounting Tab

    Here we set the default accounting elements to debit the Payroll Expense Account and credit the

    Payroll Revenue Account. Under the US Charts of Accounts they are 60990 and 22200 respec-

    tively. Note the Balancing checkbox. If it is checked it will post to both the debit and credit sides.

    If it left unchecked then it will not post to the Payroll Revenue Account but Charge account that

    you select later in Payroll Processing.

    Concept Ordering

    The Concept Ordering Tab just ensure which concept or variable is considered first in order.

    The values in there are automatically listed accordingly without you entering it. Of course you

    can edit it when needed. With this tab, we have covered all the concept setup needed.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 21 of 48

  • Payroll Definition

    Now we come to the Payroll Definition window. We can see that it is using the Payroll Contract

    called Monthly. There is a Charge field which we can use for charging another account to offset

    the debit of the Payroll.

    Here we are setting up for each variable, their effective periods. Later they are referred to by the

    Payroll Process when you are processing employees payroll during respective periods such as for

    the month of January, February and so on. But before we can do that, we still have to setup fur-

    ther. We have to define the subsequent tabs - Payroll Concepts, Year, and Periods.

    Payroll Concepts

    Here it just take the Payroll Concept (Variable) defined earlier. We set the name of this concept

    to CC_Salary to mean salary variable. We can have multiple concepts or variables, for example

    one can be for earnings, overtime, deductions, loans and leave calculations. The complex ones

    will of course refers to rules to obtain their variable figures. For monthly salary it is a fixed thing

    so it is quite simple in this example. Then the next tab we shall define the calendar year this is

    applicable and generate its calendar year periods.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 22 of 48

  • Calendar Year

    Here we define the Calendar Year and its number of periods (Quantity) and Net Days. This fol-

    lows the same Period generating model in iDempiere. Thus take note of the Start Date.

    Generate Periods

    Then we press the process button and select the HRPayroll Create Periods. Then we go to the Periods tab to view the periods generated.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 23 of 48

  • Lets now define the Payroll Employee window. It has sub tabs to handle their payroll informa-

    tion and main attribute or payroll activity such as monthly salary, earnings and deductions.

    Under the Employee checkbox, it has to be checked or else this Concepts ColumnType may not

    be correct in the next Tab.

    Payroll Employee Window

    The Payroll Employee window has the first tab that is a copy of the familiar Business Partner win-

    dow. The same with Employee tab however it has new fields that access Payroll information.

    Note that the Payroll field has a Monthly value. This is not the earlier contract that we went

    through but belonging to another data table. Right-click on it and select Zoom to see how it is

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 24 of 48

  • defined. It will pop up its un-

    derlying model window.

    We see the Payroll Definition

    record which we defined a

    while ago. It is a mandatory

    pre-requisite, but even if you

    forgot while creating new clients, you can always Zoom and resolve the needed data before cre-

    ating the Employee records.

    Using the Zoom function for New Records

    Since the fields values are already filled in from our sample data you need not do that. In the case

    where you want to create your own new employee data when you have not created a Payroll De-

    partment, below is a further example of how you use the magic Zoom button.

    The Zoom will lead you to the underlying model window for you to create your new record and

    then return to the former window and you have to right-click again to click on the ReQuery but-

    ton and the new record will appear its pull down list. Now we move to the next tab. There is noth-

    ing to do here as its values are already pre-selected. You cannot do anything because the new re-

    cord icon is greyed out. It is just read-only details from the Business Partner accounting tab.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 25 of 48

  • We move then to the next tab - Attribute.

    Attribute Tab (Activity)

    This tab is more interesting as it is the start of the business day of Libero HR Payroll. Examples

    of attributes or activity are:

    1. Monthly Salary

    2. Hourly wages

    3. Overtime wages

    4. Other earnings

    5. Statutory deductions

    6. Income tax

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 26 of 48

  • So for static information the concept will just assess the Quantity or Amount fields. But when it

    need to assign a formula in order to derive the monetary value, it can then use the RuleEngine.

    The final value will be in the periodic payroll movements (transactions).

    In other words, the Attribute is dependent on the Payroll Concept in use. If the concept is about

    salary then the attribute gives the value of the salary. If the concept is overtime hours working,

    the value is the quantity of hours worked. If it is a rule the value is what that rule script process

    returns.

    The subsequent tabs are quite self explanatory and not important for our later Payroll Process. So

    we shall leave them at that.

    Russia has among the most beautiful and tall women around. And they are very friendly despite the cultural difference to the point that we cant understand a word from each other.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 27 of 48

  • Payroll Processing

    Now we come to the fun part where we turn it on. The Payroll processing is the juggernaut of the

    Libero HR Payroll. It has two parts which is Payroll Process that creates Payroll Movements and

    post to the accounts. Then it allows generating of either Invoices or Payments.

    Payroll Process Window

    The purpose of Payroll Process is to access the Payroll Definition and iterate through its Attrib-

    ute (activities) to check if any, compute any valid concepts and rules, and generate Payroll

    Movements (Transactions) respectively.

    Click on the Payroll Process window and you see that it has only one tab with an attached process

    that sets the Payroll Definition record that you want to process. It also sets the Target Document

    Type just like in other normal documents in iDempiere. If you are using the sample data, then

    the above screen will appear. Note the other fields values. And we are assigning a Charge (in this

    case for convenience we just use Commissions Paid. This will be used to debit the accounts

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 28 of 48

  • during posting, but you have to ensure that the checkbox Balancing we described earlier is left

    unchecked. Well, with all that, we are set to go. Click on the gear icon to launch the process.

    It will show only one option which is the default from a selection. Click on that and it will show all

    the available options.

    You can select Prepare or Complete. Prepare will in itself conduct all the needed Payroll Move-

    ment processing. Complete just change the DocStatus to Complete which is important as the

    next step will be Close which allows for invoice or payment generation. This ensure separation of

    roles in the payroll process.

    The above is after a successful Complete (which made a successful Prepare). Two things hap-

    pened from here. One is the creation of Payroll Movement records, the other is accounts posting.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 29 of 48

  • From the same gear icon, you can click on it and see it has a different pull down selection menu.

    Click on Posted to view the accounting consequence. It will open up the Account-Viewer show-

    ing just the related postings.

    You can also go to the Payroll Movement tab and view the results.

    Payroll Movement (Transactions)

    Here we see two records generated, for both of Gar

    denWorld staff. They are for the first period as set dur-

    ing Payroll Process.

    Now we proceed to close the Payroll Process so that

    the staff can be issued invoice or payments. Select

    from the gear icon the close option. Now you see the

    Document Status has changed to Closed.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 30 of 48

  • Generate Payroll Invoices

    The PayNow Payroll Process we just closed can

    now be selected from the pull-down icon of the

    first parameter. If not, check the Payroll Proc-

    ess DocStatus again that it is in Closed status.

    Click on the gear icon and select Close from

    there.

    Selecting the Document Type AP Invoice.

    There is only one Document Type and it requires some extension to the available DocTypes in

    the code as well as model if required by the business practice or accountant. If you select some-

    one in Business Partner it will process only for a particular employee. If it is left blank it will

    process for everyone defined in the Payroll. After clicking on Start, we shall end up with the fol-

    lowing output.

    Now we can look at

    the Invoice (Vendor)

    window to view these.

    Note that it is made to

    the same Charge as

    defined earlier in the

    Payroll.

    The screen on the

    right is showing the

    InvoiceLine tab of

    the second Invoice

    generated for Gar-

    denUser.

    From here we can

    process this accord-

    ingly such as using

    Allocation.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 31 of 48

  • We can also look at the Account Viewer for the accounting consequence.

    We can note how the accounts now show a new double entry to credit back the Commissions

    Paid account and credit the Accounts Payable Trade. That may not be the right accounting as I

    stated earlier and may need changing. So for that I will demonstrate the meta-data configuration

    part later, to show how you can change the Document Type selection item. At this point we can

    properly close our functional demonstration of a simple Payroll cycle. There is the more dynamic

    and powerful RuleEngine but we will examine that if we get to complete the LiVE-HR add-on (if i

    get to visit Venezuela!). However I did borrow one further feature from LiVE which is the Gen-

    eratePayrollPayments. And there are some sample Rule scripts also near the end.

    Generate Payroll Payments

    The purpose is to pay salaries directly to a bank account. However this bypass Invoicing and Al-

    location function. So its a matter of business rules here.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 32 of 48

  • Call up the Payroll Payments above and begin filling it in to use it.

    After filling in and selecting the required Payroll Concept variable in the detail tab, we can then

    proceed to the Generate Payroll Payments process. Now you can access the Payroll Payment re-

    cord and start the process.

    It will then generate 2 payment records for the 2 GardenWorld staff. You can examine the new

    payments records via the Payments window.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 33 of 48

  • Modifying Libero HR Payroll

    The whole idea of Freedom Open Source Software disappears into the thin air of Siberia if we

    cannot help ourselves to the code. This is a most liberating yet demanding task even for an expe-

    rienced software developer. There is just too much new things to learn or understand. Particu-

    larly if a certain code comes from a certain origin, which is often alien to where we come from.

    Here I am rendering as much as I can from my two long months combing the codes and figuring

    out Libero HR Payroll.

    I am inviting as much attention to reuse LiberoHR to extend it until it is as famous as Oran-

    geHRM, another free application. LiVE is already a big attempt in that direction. However saying

    this means that I am admitting that there is much more to be done. Also the LiberoHR itself is

    not a completely holistic work. And it need not be. It is an early release of a core base application

    and it begs for future and frequent updates from the community. My attempt here under good

    sponsorship from SYSNOVA is to demistify LiberoHR, or Anglicized it if you will, documenting

    it sufficiently well enough for others to pick up the scent. Otherwise it will just be a vast great

    snowy desert with no use if no one is around to see it.

    M o d i f y i n g t h e Document Type in Generate Invoice

    For that we have to log

    out and login as System.

    Then look for the proc-

    ess that defines Gener-

    atePayrollInvoices.

    At the Process field

    right-click and Zoom in.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 34 of 48

  • Go to the second parameter which says Document Type. Look at the Dynamic Validation field.

    There is a value there saying, C_DocBaseType AHR. Right-click on it and Zoom in to open the

    Dynamic Validation Window.

    At the Validation code field, you can see the content, docbasetype = API. API stands for the

    Invoice Document Type. Here by changing just the type we can determine the type of Invoice we

    want to be created in the process.

    You can refer to the remarks in the Doc_ java class below. If there is more need to change or ex-

    tend the Invoice processing documents rules, it is either done via ModelValidators or creating

    a different Invoice type. It is basically a functional implementor or developers expert area.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 35 of 48

  • Modifying the Code

    There are quite some core or key code that you have to understand. In principle when you under-

    stand the main story behind the functionality of Concept to Attribute to Movement then you do

    not have much code work except creating RuleEngine scripts and making ModelValidators on the

    model classes. But there is 2 deep core classes that is in LiberoHR which is Doc_HRProcess and

    MHRProcess. We will now go through what I learnt about this two classes. But first I must thank

    Edwin Ang of Indonesia who hosted me for a week spending some time through LiberoHR and

    providing some needed tips to figure out the ends.

    Doc_HRProcess Class

    The Doc_HRProcess class is called during accounts posting of the Payroll Process. It also access

    the values as defined in MHRConcept model (the main tab of the Payroll Concept Catalog win-

    dow) such as Accounting Sign whether it is debit or credit (the usual value is debit).

    It also access the IsBalancing check from HR_Concept_Acct table to decide if the other side of

    the accounts is a Charge account instead.

    In OSGi framework which iDempiere is using this is probably the very first Doc_ accounting

    class to work outside the main base bundles. It will thus need to implement the OSGi factory

    service defined by Heng Sin. Here is the service declaration as HR_DocFactory.xml:

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 36 of 48

  • You can refer to http://www.idempiere.org and look for Heng Sins documentation for more information. My only mistake for deployment was I did not read the warning in my Eclipse IDE that says the build.properties is not committing the factory component xml. To do that I have to make an include:

    source.. = src/output.. = bin/bin.includes = META-INF/,\ .,\ plugin.xml,\ OSGI-INF/

    MHRProcess Class

    The MHRProcess class is the hardworking class that does the most during Payroll Processing.

    Action happens in prepareIt() method and the key method inside is createMovements(). We su-

    marrised that method on next page.

    private void createMovements() throws Exception{ m_scriptCtx.clear(); m_scriptCtx.put("process", this); m_scriptCtx.put("_Process", getHR_Process_ID()); m_scriptCtx.put("_Period", getHR_Period_ID()); m_scriptCtx.put("_Payroll", getHR_Payroll_ID()); m_scriptCtx.put("_Department", getHR_Department_ID());

    log.info("info data - " + " Process: " +getHR_Process_ID()+ ", Period: " +getHR_Period_ID()+ ", Payroll: " +getHR_Payroll_ID()+ ", Department: " +getHR_Department_ID()); MHRPeriod period = new MHRPeriod(getCtx(), getHR_Period_ID(), get_TrxName()); if (period != null) { m_dateFrom = period.getStartDate(); m_dateTo = period.getEndDate(); m_scriptCtx.put("_From", period.getStartDate()); m_scriptCtx.put("_To", period.getEndDate()); }

    // RE-Process, delete movement except concept type Incidence int no = DB.executeUpdateEx("DELETE FROM HR_Movement m WHERE HR_Process_ID=? AND IsRegis-tered?", new Object[]{getHR_Process_ID(), true}, get_TrxName()); log.info("HR_Movement deleted #"+ no);

    linesConcept = MHRPayrollConcept.getPayrollConcepts(this); MBPartner[] linesEmployee = MHREmployee.getEmployees(this);

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 37 of 48

  • // int count = 1; for(MBPartner bp : linesEmployee)//=============================================================== Employee { log.info("Employee " + count + " ---------------------- " + bp.getName()); count++; m_C_BPartner_ID = bp.get_ID();

    m_employee = MHREmployee.getActiveEmployee(getCtx(), m_C_BPartner_ID, get_TrxName()); m_scriptCtx.remove("_DateStart"); m_scriptCtx.remove("_DateEnd"); m_scriptCtx.remove("_Days"); m_scriptCtx.remove("_C_BPartner_ID"); m_scriptCtx.put("_DateStart", m_employee.getStartDate()); m_scriptCtx.put("_DateEnd", m_employee.getEndDate() == null ? TimeUtil.getDay(2999, 12, 31) : m_employee.getEndDate()); m_scriptCtx.put("_Days", org.compiere.util.TimeUtil.getDaysBetween(period.getStartDate(),period.getEndDate())+1); m_scriptCtx.put("_C_BPartner_ID", bp.getC_BPartner_ID()); m_movement.clear(); loadMovements(m_movement, m_C_BPartner_ID);// for(MHRPayrollConcept pc : linesConcept) // ==================================================== Concept { m_HR_Concept_ID = pc.getHR_Concept_ID(); MHRConcept concept = MHRConcept.get(getCtx(), m_HR_Concept_ID); boolean printed = pc.isPrinted() || concept.isPrinted(); MHRMovement movement = m_movement.get(concept.get_ID()); // as it's now recursive, it can happen that the concept is already generated if (movement == null) { movement = createMovementFromConcept(concept, printed); movement = m_movement.get(concept.get_ID()); } if (movement == null) { throw new AdempiereException("Concept " + concept.getValue() + " not created"); } } // concept

    // Save movements: for (MHRMovement m: m_movement.values()) { MHRConcept c = (MHRConcept) m.getHR_Concept(); if (c.isRegistered() || m.isEmpty()) { log.fine("Skip saving "+m); } else { boolean saveThisRecord =m.isPrinted() || c.isPaid() || c.isPrinted(); if (saveThisRecord) m.saveEx(); } } } // for each employee // // Save period & finish period.setProcessed(true); period.saveEx();

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 38 of 48

  • The createMovementFromConcept is where movement records are created and exe-cuteScript is carried out if a RuleEngine script is defined for it.

    Rule Scripts

    Below are some examples translated from the Spanish work of DoubleClick, Venezuela. The methods such as getConcept and getAttribute call the same in MHRProcess class. The result is returned to the ConceptType return field such as Amount or Quantity.

    R_DAILY_SALARYdouble salary = getConcept("CC_MONTHLY_SALARY");result = salary / getAttribute("C_DAY_OF_THE_MONTH");

    R_APPLY_SALARY_PERIODString sContract = getHR_Payroll().getHR_Contract().getValue();double valueReturn = 0; if (!"Vacation".equals(sContract) && !"Liquidation".equals(sContract)) { double workDays = (double) LVE_Payroll.workDays(get_TrxName(), _From, _To, _Payroll, ((Integer)getAttribute("C_REST_DAY_WEEK")).toString(), sContract); description = "Days: " + workDays; valueReturn = workDays * (getConcept("CC_MONTHLY_SALARY") / getAttrib-ute("C_DAY_OF_THE_MONTH"));}result = valueReturn;

    R_SALARY_IN_LIQUIDATIONresult = 0.0;long oneDay = 86400000;String sContract = getHR_Payroll().getHR_Contract().getValue();if ("Liquidation".equals(sContract)) { Timestamp From = getAttributeDate("A_END_DATE_LAST_MONTH_PROC",_From); From = new Timestamp(From.getTime() + oneDay); double days = LVE_Payroll.daysElapsed(From, _To); double dailySalary = ("S".equals(getAttributeString("A_SALARY_VARIABLE") )? getConcept("CC_SALARY_DAILY_VARIABLE") : (getConcept("CC_MONTHLY_SALARY") / getAttrib-ute("C_DAY_OF_THE_MONTH"))); result = (days * dailySalary) - LVE_Payroll.ExecutionOfConcepts(get_TrxName(),process,"isoption6","Y",_Payroll);}

    R_DEDUCT_DAYS_EXITnt days = 0;if (_DateEnd.after(_From) && _DateEnd.before(_To)) { days = org.compiere.util.TimeUtil.getDaysBetween(_DateEnd, _To); if (_To.getDate() == 31)

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 39 of 48

  • days--; } result = days;

    R_DEDUCT_DAYS_INCOMEint days = 0;if (_DateStart.after(_From) && _DateStart.before(_To)) { days = org.compiere.util.TimeUtil.getDaysBetween(_From, _DateStart);} result = days;

    R_SALARY_HOURString day = getConceptString("A_WORKING_HOURS");if (day == null) day = "D"; /* Default Day */double salary = getConcept("CC_MONTHLY_SALARY");double hour = getAttribute("C_DAYTIME_HOURS");if ("N".equals(day)) /* Nocturna */ hour = getAttribute("C_NIGHTIME_HOURS");if ("M".equals(day)) /* Mixed */ hour = getAttribute("C_MIXED_DAY_HOURS");description = "Day Hours " + day + "=" + hour;result = hour>0 ? (salary / getAttribute("C_DAY_OF_THE_MONTH")) / hour : 0.0;

    Russia is the largest country in the world surrounded by its strategic partners, possesses great wealth particularly its people, faces as unique a challenge as unique as its history. It has to fight backwardness, inequality, corrup-tion and overcome them fast. The mobile phone with atttendant Web access is a big help, and it be an interesting time to watch. The above is one of the many shots I took along the legendary Trans-Siberian train journey.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 40 of 48

  • Synch With Source

    I am dedicating a complete section to this topic because of its importance to ensure LiberoHR is

    synchronised with its main or best maintainer, Carlos Ruiz at his repository when he make

    changes there:

    https://bitbucket.org/CarlosRuiz_globalqss/globalqss-adempiere-hr/commits/all

    As you can see above, there are some recent changes dated 3 days ago and 4 hours ago as of today

    (April 18, 2013, 7.50am, Novosibirsk, Siberia time). I am porting these changes to my own re-

    pository at https://bitbucket.org/red1/liberohr.

    Nevertheless in future, in case I no longer am doing this, you can choose to continue to do the

    same by following the following instructions.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 41 of 48

  • Follow the BitBucket

    First you can follow the BitBucket repository so that you are aware of the changes as they occur.

    However you need not be peeking at the link above all the time. Just click on the Follow button

    on the site and you be informed by email. First you have to register at BitBucket. So do that now

    if you have not done so.

    Then click on the Follow button.

    It will change to Following indicating

    that you are following it.

    I am also following it and as shown in previous screen-shot, I can see two latest changes that I

    have to synch with. I will now do it one by one.

    View the Diff

    First I will take care of the one 3 days ago. I click on the Commit link - e851341. It will lead to a page showing what is actually change in the source.

    It displays the diff of the changes at which file within the project source.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 42 of 48

  • Applying the Patch

    I will now take the diff and apply it as a patch to my own source. To do that I click on the raw

    commit link at the top of the screen-shot. The page will show the following raw diff content.

    Here, I just select the content with my mouse, from the word diff until the end of the page.

    Then I copy it into clipboard by right-click and select copy. Then I open up an empty notepad or

    text editor to paste the contents into it. I want to make some changes to the path of the diff so that

    it fits into my Eclipse source. Notice the two lines

    --- a/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java+++ b/extension/eevolution/libero/src/main/java/org/eevolution/model/MHRProcess.java!

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 43 of 48

  • At the begining of it the path looks not aligned to my source. I want to align it to org/

    eevolution/model. So I fix that by removing the text before it so that it becomes

    --- org/eevolution/model/MHRProcess.java! Mon May 28 14:03:32 2012 -0500+++ org/eevolution/model/MHRProcess.java! Mon Apr 15 10:30:38 2013 -0500

    Then I go to my source editor panel in my Eclipse IDE and position my mouse at the exact src

    node and right-click, select Team and Apply Patch

    It will open up a window to select your clipboard as source and then the Target is at the src node I

    selected. If there is unmatched portions, I will review whether to accept, reject or replace it as a

    new file (in the case that there is too much conflicts and I decided to completely accept Carlos

    version for that file .

    After reviewing, testing that it poses no adverse impact, I will commit and then push to my bit-

    bucket.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 44 of 48

  • Commit and Push to Bitbucket

    Here above I am starting the commit to bitbucket. I make some remarks below which Edwin Ang

    reviewed telling me that his other changes do not use the best practice StringBuilder. I choose to

    ignore his other files and wrote him a message instead informing him of our opinion.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 45 of 48

  • With that commit done I can then push to my bitbucket.

    A dialog box appears where I have my credentials ready. I click on Finish and it goes in.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 46 of 48

  • Project ProtocolHere we state some reference for users, implementors and developers alike.

    Project VersionWe are basing our work on iDempiere releases and no longer on ADempiere. Or at least ADempiere 361 Final of Carlos Ruizs bitbucket.org repository. But you need to migrate to iDempiere to use this LiberoHR plugin.

    Source RepositoryAll code and database dumps are committed and uploaded to http://bitbucket.org/red1/LiberoHR/

    Project Forum for SupportSome minimal support can be given at my own forum provided its about any bugs that involved my exact work, and it is deocumented according to forum etiquette. Please participate at http://www.red1/org/adempiere.You are also welcome to report if any new update from iDempiere breaks this plugin. It is better to report early rather than late so consantly keeping track of the iDempiere project itself is advis-able.

    ContactIf you have something important to contribute or a project to discuss then email me at [email protected].

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 47 of 48

  • The friendliness of Russian folks is proven in these pho-tos. At Lenin Square in front of the Grand Opera Theatre, two local students at an English class where i gave a lecture offered to take me to a per-formance there, upon hearing I have yet to be in one. One of them is quite shy and so I offer this photo with one of them only.

    This lively young lady impressed me with her charming offer to in-troduce her famous Academe City and at the end of it escorted me safely back. After an absorbing walk of the historical scien-tific centre, and an unforgettable lunch, we stopped at the Lenin underground train station to take a photo together.

    Libero HR Payroll Core Plugin Guide

    Copyleft 2013 Redhuan D. Oon - SYSNOVA Page 48 of 48