Kakitangan CLI for Malaysian Users

Md. Minhazul Haque - Aug 20 '19 - - Dev Community

Hello everyone, it's Minhaz. This is my first post in dev.to.

For the last 2 months, I have been working with a command line version of Kakitangan is an online HR Software for Malaysian businesses that helps handle payroll, claims, benefits, leave and more.

The project can be found at mdminhazulhaque/kakitangan-cli

Why CLI Version?

You can ask me why I made this CLI version although they have a nice web and mobile version. Well, people like me prefer CLI than GUI. Also, I wanted to learn how Python module works. So I decided to turn this into a pet project.

How To Use It?

I am currently working to distribute this via setuptools. Before that, you can download the repo and execute the kakitangan.py as the main file. The default commands are given below.

$ kakitangan.py --help
Usage: kakitangan.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  aboutme      Shows personal information as Kakitangan user
  colleagues   Shows colleagues' leaves
  holidays     Shows holidays
  loadleaves   Fetches all calendar information from Kakitangan server
  login        Login and save authorization token in disk
  logout       Logs out by clearing authorization token from disk
  myleaves     Shows user's leaves
  myleavestat  The user's leave statistics
Enter fullscreen mode Exit fullscreen mode

First, you have to log in, right? You have to pass the username/email via -u option. The password will be prompted and will be invisible as you type it. The password can also be passed via -p option but I tell you not to do so. Your password will be stored in .bash_history which would be a serious security issue.

$ kakitangan.py login -u john.doe@dream.job
Password: **********
Login success

$ kakitangan.py login -u john.doe@dream.job -p 1234567890
Login success
Enter fullscreen mode Exit fullscreen mode

If your password is correct and you have an internet connection, you are supposed to see the Login success message. Use the aboutme option to see your basic info.

$ kakitangan.py aboutme
---------------------  -------------------------------
Email                  john.doe@dream.job
Official Full Name     John Doe
Nationality            Bangladesh
Highest Qualification  Bachelors Degree
SOCSO Account          1234567890
Bank Account           1234567890
Bank Account Type      saving
Bank Account Name      AABBCCDD
Income Tax Account     1234567890
Salary                 1234567890
Preferred Name         John
Sex                    Male
Marital Status         married
Active                 True
Birth Date             1994-01-23
Phone                  1234567890
NRIC Number            1234567890
Passport Number        BB12345678
Employee ID            1000
Joined                 1970-01-01
Manager                boss@dream.job
Position               DevOps
Department             Tech
Location               Kuala Lumpur
---------------------  -------------------------------
Enter fullscreen mode Exit fullscreen mode

That's enough for you I guess. Let's move to the leave calendar which is the best feature of Kakitangan. Before executing any calendar related command, you have to download the full calendar from Kakitangan server. loadleaves option will do it for you.

$ kakitangan.py loadleaves
Updated leave database
Enter fullscreen mode Exit fullscreen mode

After doing so, you will find 3 new JSON files in ~/.config/kakitangan-cli named load_calendar.json, load_colleagues.json and load_holiday_event.json. This 3 calendar holds data for yourself, your colleagues, and holidays respectively.

Now you are ready to get your colleagues' leave summary. The colleagues command takes several parameters.

Usage: kakitangan.py colleagues [OPTIONS]

  Shows colleagues' leaves

Options:
  -a, --all          Show past leaves also
  -t, --today        Show leaves only on today
  -u, --untill TEXT  Show leaves upto date
  -s, --since TEXT   Show leaves from date
  -d, --date TEXT    Show leaves on specific date
  --help             Show this message and exit.
Enter fullscreen mode Exit fullscreen mode

By default, it will show leaves AFTER the current date. You can see all leaves with -a parameter.

$ kakitangan.py colleagues
---------------  --------------
2019-06-03  Abdul Doe (Annual)
            Alice Begum (Marriage Leave)
2019-06-04  Abdul Doe (CarryForward)
            Charlie Ahmed (Annual)
            Foo Bin Bar (Annual)
            Alice Begum (Sick)
2019-06-10  Foo Bin Bar (Sick)
            Bob Mia (Birthday Leave)
2019-06-11  Bob Mia (Sick)
2019-06-12  Bob Mia (Sick)
2019-06-13  Bob Mia (Annual)
2019-06-14  Clara Khatun (Annual)
            Bob Mia (Annual)
2019-06-15  Clara Khatun (CarryForward)
2019-06-16  Clara Khatun (CarryForward)
2019-06-17  Clara Khatun (Annual)
            Bob Mia (Replacement)
2019-06-18  Bob Mia (Annual)
---------------  --------------
Enter fullscreen mode Exit fullscreen mode

It is possible to see who are on leave on a specific date. Just pass the date in YYYY-MM-DD format with -d parameter.

$ kakitangan.py colleagues -d 2019-06-10
---------------  -----------
2019-06-10  Foo Bin Bar (Sick)
            Bob Mia (Birthday Leave)
---------------  -----------
Enter fullscreen mode Exit fullscreen mode

You might want to filter colleagues within specific date range. Just use the -s (since) and -u (until) parameter.

$ kakitangan.py colleagues -s 2019-06-15 -u 2019-06-17
---------------  ------------
2019-06-15  Clara Khatun (Annual)
2019-06-16  Clara Khatun (Annual)
2019-06-17  Clara Khatun (Annual)
            Bob Mia (Annual)
---------------  ------------
Enter fullscreen mode Exit fullscreen mode

Similar to the leave calendar, you can check your holidays too. Use the holidays option for this purpose.

$ kakitangan.py holidays 
---------------  ----------------------------
2019-06-05  Hari Raya Aidilfitri
2019-06-06  Hari Raya Aidilfitri Holiday
2019-08-11  Hari Raya Haji
2019-08-12  Hari Raya Haji
2019-08-31  Merdeka Day
2019-09-01  Awal Muharram
2019-09-02  Awal Muharram
2019-09-09  Agong's Birthday
2019-09-16  Malaysia Day
2019-10-27  Deepavali
2019-10-28  Deepavali
2019-11-09  Prophet Muhammad's birthday
2019-12-25  Christmas
---------------  ----------------------------
Enter fullscreen mode Exit fullscreen mode

As I said earlier, filtering hides old leaves/events. So you have to pass -a to see full holiday list.

$ kakitangan.py holidays -a
---------------  ---------------------------------------------------------
2015-01-01  New Year
2015-01-02  New Year
2015-01-03  New Year
...
2017-06-25  Hari Raya Aidilfitri
2017-06-26  Hari Raya Aidilfitri
2017-06-27  Hari Raya Aidilfitri
...
2019-10-27  Deepavali
2019-10-28  Deepavali
2019-11-09  Prophet Muhammad's birthday
2019-12-25  Christmas
---------------  ---------------------------------------------------------
Enter fullscreen mode Exit fullscreen mode

Okay, you want to check your own leaves, right? You can! Use myleaves with -a parameter if you want to see the old leaves too.

$ kakitangan.py myleaves -a
---------------  -----------
2019-02-28  Sick
2019-03-12  Sick
2019-03-21  Annual
2019-05-17  Annual (PM)
2019-05-21  Annual
2019-05-22  Annual
2019-05-23  Annual
2019-05-24  Annual
---------------  -----------
Enter fullscreen mode Exit fullscreen mode

If you need to know your leave statistics, I have added a command named myleavestat.

$ kakitangan.py myleavestat
----------------------------  -----------------
Compassionate            10/10
Annual                   25/50 (25 used)
Sick                     15/30 (15 used)
Paternity                10/10
Hospitalization          30/60 (30 used)
Replacement              1/1
Birthday Leave           1/1
Annual Leave Additional  5/5
CarryForward             5/5
Unpaid Leave             10/10
Bonus Leave              1/1
Exam/Study Leave         5/5
----------------------------  -----------------
Enter fullscreen mode Exit fullscreen mode

Going back home? Don't want anyone to sneak into your Kakitangan account? You can log out anytime. It's easy.

$ kakitangan.py logout
Confirm logout? [Y/N]: Y
Logged out
Enter fullscreen mode Exit fullscreen mode

Please review, post issues, star or commit changes. Thanks.

. . .