Personal tools
You are here: Home Blog

Latest Blog

Latest informal news and updates on the company, including our open source releases, training and development experiences with Plone, Zope3 and more.

Customizing P4A.Calendar (and the Power of collections and Views)

Posted by Khairil Yusof at Feb 15, 2010 02:27 PM |
Filed under: Plone

In current versions of Plone, it is quite easy to extend existing features for various uses cases. One of the most powerful features is saved searches (called Collections), which provides end users to easily generate their own results based on different criteria.

This is then combined with end user selectable views, which are easily added via Zope3 views by developers. You can imagine the possibilities for the content manager:

  • Thumbnail views based on tags
  • News listings
  • Blog listings
  • Table lists
  • Calendar Views

The last one is very useful for Intranets, since a lot of content are events based. For example, a standard Leave content form would have start and end dates. If we register them as Event types, they can be treated as such (beauty of component based architecture). So if if have a collection of all Leave forms that are in workflow state "Approved", you can then have auto generated calendar views of when people are on leave. By department, by team (pick users), by type eg. sick, or annual etc.

The most powerful of these calendar views is p4a.plonecalendar that provides folders and collections with Day, Week, Monthly and list views of event type items. dateable.chronos is the view package which provides standard views.

Plone views are based on Zope Page Templates (ZPT), that provides a very powerful XHTML compliant template system. Once you get a hang of it, it's quite easy to create your own custom views, often with extra fields that are not part of the default views. For example, our Leave form, maybe you want to show what type of leave it is, or even the name of the person.

Customizing Month views

This is relatively easy (thanks to Kagesenshi) who helped me figure out how to access objects directly. dateable.chronos by default only show's titles and mouseovers only show title and date. So usually you want to show more information. For events, probably you want to show the location.

In your browser folder of your theme or customization package, add the following in your configure.zcml:

<browser:page
 name="month.html"
 for="dateable.chronos.interfaces.ICalendarEnhanced"
 permission="dateable.chronos.ViewContent"
 class="dateable.chronos.browser.month.MonthView"
 template="month.pt"
 layer=".interfaces.IThemeSpecific"
 />

And copy over the month.pt template from dateble.chronos browser directory.

When it begins the loop, you can define the event object like so:

...

<a href="#" tal:attributes="href dayurl"><span tal:content="day/day" /></a>
<tal:block repeat="display
python:view.getOccurrenceDisplays(day)">

<tal:block tal:define="event_obj display/event/context/getObject;
                       start_time

...

The important part is "event_obj display/event/context/getObject;. This allows us to access object values that are not provided by the default display brains object (which is a sort of metadata object, not the real object). This was probably done by the original authors to speed up things and reduce memory usage. By accessing the object directly in this case, if our "event" object is not standard, we can access whatever fields/attributes we want. For example, location:

<a tal:attributes="href display/url"
    tal:condition="display/viewable">
     <tal:block replace="event_obj/title" />
     <span class="location"
         tal:content="event_obj/location |
         nothing" />
     <span class="location" tal:content="event_obj/mission_event_location
     | nothing" />
</a>

Customizing event lists

This is slightly different, because there is no single events.pt view, but the past and list attribute views refer to a class, which then refer to the template. So in order to register your own template, you're going to need to subclass and override the template attribute to point to your own custom one.

First lets register this view and class in configure.zcml:

<browser:page
name="list.html"
for="dateable.chronos.interfaces.ICalendarEnhanced"
permission="dateable.chronos.ViewContent"
class=".events.MyOwnEventListingView"
attribute="upcomingEvents"
layer=".interfaces.IThemeSpecific"
/>

<browser:page
name="past.html"
for="dateable.chronos.interfaces.ICalendarEnhanced"
permission="dateable.chronos.ViewContent"
class=".events.MyOwnEventListingView"
attribute="pastEvents"
layer=".interfaces.IThemeSpecific"
/>

Notice in this case, that class=".events.MyOwnEventListingView". It's basically saying use MyOwnEventListingView in the events.py file. You can change the filename and classes to whatever you like (or even register some additional types of listing views).

You'll then need to copy events.pt from dateable.chronos, to have a template to customize. And you'll need to create an events.py file like this:

from dateable.chronos.browser.month import MonthView as BaseMonthView
from dateable.chronos.browser.month import cmp_occurrence
from dateable.chronos.browser.events import EventListingView
import calendar
import datetime
from dateable import kalends

try:
    from Products.Five.browser.pagetemplatefile import \
         ZopeTwoPageTemplateFile as PageTemplateFile
except ImportError:
    from zope.pagetemplate.pagetemplatefile import PageTemplateFile

class MyOwnEventListingView (EventListingView):
    """
    """

    eventlist = PageTemplateFile('events.pt')

It's not too different from the original, we just need to be more specific about classes we import. By subclassing EventListingView we only need to only worry about the attributes and methods we are going to override. We only need to specify the new eventlist template here.

The only difference between month view is that instead of display, the attribute that you need to access your event objects is finding the loop for events and defining event_obj with event/event/context/getObject;

Don't forget that when you do zcml (configure.zcml) changes, you'll need to rebuild buildout or add the appropriate zcml entries in parts/instance/etc/package-includes before the templates and classes are picked up. Once they are, you don't need to restart instances for template changes.

Finally p4a.plonecalendar does some monkeypatching, so make sure that in your buidlout.cfg that your theme or customization package is below that of p4a.plonecalendar or you'll get some errors about some views not being available.

GnuCash: Salary, EPF and SOCSO

GnuCash: Salary, EPF and SOCSO

Posted by Khairil Yusof at Jan 20, 2010 09:10 PM |
Filed under: GNUCash

We use GnuCash for our small business accounting needs. So far it does the job well, including managing payroll. It treats payroll as accounting items so at this time it doesn't scale well if you have a lot of employees. For small business with say 5-10 employees, once you've set up the splits, it's quick using the duplicate feature at the end of each month to process everybody's monthly checks complete with compulsory EPF (superannuation) and SOCSO (workers insurance) payments.

Here's how you set it up to pay your employee for a Malaysian business. The on-line manual provides enough information for you to understand what you need to do.

Basically you need to have:

  • Basic Salary
  • Pay Net Salary (Your pay check basically, after EPF/SOCSO deductions + allowances)
  • Other allowances (It's good to separate these out as some are tax deductable. We have communications and child care allowances.)
  • EPF Employee Contribution
  • EPF Employer Contribution
  • SOCSO Employer Contribution
  • SOCSO Employee Contribution

The accounts you need to have are:

  • Assets
    • Current Account
  • Liability
    The company has to pay the relevant government agencies these amounts:
    • EPF Employer Contribution
    • EPF Employee Contribution
    • SOCSO Employer Contribution
    • SOCSO Employee Contribution
  • Expenses
    These are expenses on top of the salary for the company. The employee deductions are reflected in their net salary, it's sort of an expense/investment for them but does not need to be reflected in company accounts.
    • EPF Employer Contribution
    • SOCSO Employer Contribution
    • Payroll
      • Base Salary
      • Allowances (and other financial benefits)

I tend to do the entries in the current account, since that's where all the money is going in and out. So the entry with splits looks like this for an employee who earns basic salary of RM3,000 with a communications allowance. It's a bit weird with splits, in that the headings don't change if you're in the current account, so it's not obvious for example whether it's an increase or decrease for liability and expense accounts. It will show correctly if you view the entry in the Liabilities account (which is reversed). The good thing is that being a double entry system, all of this has to balance even for the split totals. If you get an imbalance, there is something wrong somewhere such as an expense in the wrong column or wrong value. This also applies to the other accounts, and you can check whether the right amounts have been paid to the respective agencies.

Date Description
Account Deposit Withdrawal
1/1/10
Abu Salary January 2010
   
  Base Salary
Expenses:Payroll:Base Salary
3,000.00  
  Employer EPF Contribution
Expenses:EPF:Employer Contribution
360.00  
  Employer SOCSO Contribution
Expenses:SOCSO:Employer Contribution
51.65  
  Communications Allowance
Expenses:Payroll:Online Services
250.00  
  Net Salary
Assets:Current Account
  2,995.25
  Employee EPF Contribution
Liabilities:EPF:Employee Contribution
  240
  Employer EPF Contribution
Liabilities:EPF:Employer Contribution   360

SOCSO Employer Contribution
Liabilities:SOCSO:Employer Contribution

51.65

SOCSO Employee Contribution
Liabilities:SOCSO:Employee Contribution

14.75

Notes:

  • EPF Contributions are based on current rates of 12% Employer and 8% Employee from base salary.
  • SOCSO Contributions are based on fixed current rates for RM3,000/mo and above.

Both of these government agencies are extremely friendly and helpful to small businesses. If you have any questions, they're more than willing to help. They also have booklets and such to guide you when you first register.

You only need to set this once. Later you can just duplicate the entry for existing employee, and adjust for a new one.

The only missing thing is a pay slip, which is often needed in Malaysia to prove income for employees applying for loans and such. Currently doing this with OpenOffice.org spreadsheet, another essential FOSS desktop application a business needs.

 

Booting up

Booting up

Posted by Khairil Yusof at Jan 20, 2010 09:50 AM |
Filed under: Community
We seem to be rather quiet lately since FOSS.my 2009. That's because we have been working hard at booting up Inigo. We wanted to prove that it's viable to run a Malaysian IT company that values employee contributions, life balance between work and family, and community values both social and technical. Luckily for us, MySQL AB has already done this at an international scale, and their founders have been keen to share their knowledge and experiences. We have then adapted this model for Malaysia. We are also using only free and open source software to do all our work, including administrative and financial work. Where it is lacking, we file/fix bugs, provide input or write our own. We're still learning and adapting, and will continue to share our experiences with others here.

Services and Solutions

With the updated the website, you should now be able to find quickly all the services and solutions we provide. We specialize in Plone, but do contact us if you have specific development and training needs, especially for large organizations with multiple departments. We're also familiar with working remotely supporting clients in Bangkok, New Delhi and Incheon.

FOSS Community

Although we're not doing enough yet in terms of upstream participation, we try to do our best with sending patches, documentation and modules. Here are some of our Plone contributions:

All of our shared code is available locally for developers as reference: https://dev.inigo-tech.com/svn/base.

A more flexible FOSS only working environment also allows us to contribute to other projects in our individual capacity.

Not known by many, but we also host and maintain community sites and projects on our servers:

We hope we can continue to improve and do well this year, which would mean we can be more supportive of local and upstream communities.

 

Document Actions
Theme based on Broadcaster template by ThemeBin