Adding a Payroll calculator

Derek Atkins warlord at MIT.EDU
Wed Nov 2 09:05:07 EST 2005


Jay Scherrer <jay at scherrer.com> writes:

>> >  gnc_numeric     workday;
>> >  gnc_numeric     rate;
>> >    gnc_numeric     type;         /* employeeType */
>> >    gnc_numeric     overTimeRate; /* employeeOverTimeRate */
>> 
>> technically, gnc_numeric is the wrong type for all but the 'rate'.
>> the workday and type should be an enum, or a string.
>> 
> I think Derek was using the numeric workday for date arithmetic. However
> Employee_type should be char * but Employee_overTimeRate should remain a
> number.

Actually, now that I look back again (remember, I /am/ Derek ;)
I was ysing the numeric workday in order to handle fractions of
days (or fractions of hours).  But of course this really only
makes sense for a 'default' -- you still need to track actual
hours.  I'll also note that "overTimeRate" is still a "rate" ;)
I meant the workday and the type..

>> > struct +gncBusiness
>> > {
>> > char *          id;
>> > char *          businessName;   /* Name */
>> > char *          businessType;   /* sole-proprieter, partnership, LLC  */
>> > char *          businessCatagory;/* LandI or IRS listing*/
>> > }
>> 
>> There is no 'gncBusiness' object.  This should all go into the QofBook
>> where it belongs.
>> 
> I was looking for that. In what directory is QofBook located under
> gnucash/src/ ? 

  engine

But you don't want to look there.  The information is stored in the
QofBook KVP in the File->Properties hierarchy.  See the business
prefs:

  src/business/business-utils/business-prefs.scm

> We probably could create member functions something like this function I
> had created for calculating 2001 income taxes using perl. This should
> not be to difficult to convert to "c". It's just a bunch if statements. 
>
> Example: scheduleY1()
>
> This example is used for calculating the income tax for someone who is
> married, filing jointly, and earns more then $100,000 according to the
> IRS 1040 2001 rates. 
>
> variables: 
> [$line41 = wages, $line42 = Tax, scheduleY1 = member function]
> ## Status = married filing joint ##
> sub scheduleY1(){
>     my $line41 = shift;
>     if ($line41 >= 0 && $line41 <= 12000){
> 	$line42 = $line41 * .10;
>     }elsif ($line41 >= 12000 && $line41 <= 46700) {
> 	$line42 = ((($line41 - 12000)* .15) + 12000);
>     }elsif ($line41 >= 46700 && $line41 <= 112850) {
> 	$line42 = ((($line41 - 46700)* .27) + 6405);
>     }elsif ($line41 >= 112850 && $line41 <= 171950) {
> 	$line42 = ((($line41 - 112850)* .30) + 24265.50);
>     }elsif ($line41 >= 171950 && $line41 <= 307050) {
> 	$line42 = ((($line41 - 171950)* .35) + 41995.50);
>     }elsif ($line41 > 307050) {
> 	$line42 = ((($line41 - 307050)* .38.6) + 89280.50);
>     }
>     return $line42;

Um, this seems particular hard-coded and not very flexible.  It's even
WORSE if it's in C, because then the numbers aren't user-settable.
You /need/ to support this kind of configuration in a user-settable
method.  How do you propose to do that?

This is why I'm suggesting scheme, because then you can configure this
kind of "function" in scheme and users can change the values without
having to rebuild gnucash.  I'm open to other suggestions, too.  We
can certainly try to create a generalized "graduated tax" in C, but
you'd need to figure out some way to allow the user to configure that.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list