26

(34 replies, posted in Modules Add-on's)

It should not be terribly difficult to add a new calculation type to what I already have set up. Check out the post above where I listed the calculation functions I have made. If the tiered rate function will work, that would be great. Otherwise, perhaps you could write a new function using these as a model. I'll put it in there.

I am making progress on this, but I'm a slow coder so it's still going to be a little while.

27

(34 replies, posted in Modules Add-on's)

I'm sure that is a great explanation - it looks quite thorough - but it went right over my head. I probably should not be the person making this module, but I want to get away from quickbooks. I'll do my best.

28

(34 replies, posted in Modules Add-on's)

Asro,
So far, we're on the same page.
I haven't implemented a scheduling system, but I have allowed for different pay frequencies per employee.

I have not set up the pay types yet. I just have salary/hourly options to test this as I build. There has to be some basis for the calculations, right? The system has to know that hourly rates (including overtime, etc) and piecework are calculated as pay per unit. Salary is a yearly figure. Commission, tips, bonus, etc are lump sum payments. Given these basic types of calculations (pay per unit, yearly sum, lump sum), the user could set up different pay types and rates. I was planning to eventually connect the salesperson commission tracking to this payroll setup.

I have avoided as much as possible any set tax definitions. There shouldn't be anything in here that is country specific. I have different functions to handle different types of calculations (as I mentioned in the first post). Here they are:

//complex tiered percentage calculation
//--------------------------------------------------------------------------------------------
function calculate_tiered($gross, $tiered_array, $allowances, $per_allowance, $payfreq){
  //$tiered_array is an array of thresholds => percentages as annual figures
  //returns the amount of tax owed
  
  //get the allowance for this pay period
  $allowance = ($allowances * $per_allowance)/$payfreq;

  $net = $gross - $allowance;

  $tax = 0;
  $last_threshold = 0;
  foreach($tiered_array as $threshold => $percent){
    //convert the annual figures to pay period figures
    $period_threshold = round($threshold/$payfreq, 0);//round to whole dollars (per IRS tables)
    //compare pay to each threshold and calculate tax accordingly
    if ($net <= $period_threshold){
      $tax += round(($net-$last_threshold)*$percent/100, 2);
      break;
    } else {
      $tax += round(($period_threshold-$last_threshold)*$percent/100, 2);
    }
    $last_threshold = $period_threshold;
  }

  return $tax;
}

//advanced percentage calculation with a threshold
//--------------------------------------------------------------------------------------------
function calculate_adv_percent($gross, $rate_array, $ytd){
  //$rate_array is an array of 1 threshold => percentage
  $threshold = key($rate_array);
  $percent = current($rate_array);

  //have we met the threshold?
  if ($ytd < $threshold){
    //will this paycheck push us over the threshold?
    if ($ytd + $gross >= $threshold){
      //yes, only calculate tax on the remaining amount
      $tax = round(($threshold - $ytd)*$percent/100, 2);
    } else {
      //no, calculate tax on the entire amount
      $tax = round($gross*$percent/100, 2);
    }
  } else {
    //threshold met, no more tax owed
    $tax = 0;
  }
  return $tax;
}

//simple percentage calculation
//--------------------------------------------------------------------------------------------
function calculate_percent($gross, $percent){
  $percent = current($percent);//$percent comes in as an array as with the other calculators
  $tax = round($gross*$percent/100, 2);
  return $tax;
}

I don't quite understand what you mean by attribute tables. Please explain this more.

As for holding totals, I would like to insert paychecks as journal entries. Should there be a separate table just for paycheck journal entries?

You've not been discouraging at all. I really appreciate the feedback.

29

(2 replies, posted in Setup)

Thank you.

30

(34 replies, posted in Modules Add-on's)

I hope it is helpful. So far, you have been the only person to respond.

Joshua

31

(2 replies, posted in Setup)

Good day,

Just to be sure, is this still the way to handle tax payments? https://frontaccounting.com/fawiki/index.php?n=Main.TaxSystem
That is, transferring to an accrual account and making the payment from there instead of directly from the tax account?

The wiki post is two years old and I just wanted to make sure nothing has changed about this process in the meantime.

Thank you,
-Joshua

32

(34 replies, posted in Modules Add-on's)

I've created some simple calculation functions and I've been able to figure the various payroll amounts correctly. I could use some help in posting the values to the GL. It looks like the Bank Account Payment Entry is using a cart to handle entries, but I'm not seeing how they are posted. Any help is appreciated.

Thank you,
-Joshua

33

(34 replies, posted in Modules Add-on's)

I've started the process payroll form and I'd like to get some feedback.
I'd like to be able to select the employees to pay, but I don't know how to check whether they have been selected and then send only those employees to the calculation page. If there's a better way to do this, I'm open.

Here's what I have so far:

<?php
/*
  Paycheck.php
  Begin to process paychecks
    list employees, enter hours, set pay period
    submit for calculation and review
*/

/////////////////////////////////////////////////////
//Includes
/////////////////////////////////////////////////////
$page_security = 'SA_PAYROLL';
$path_to_root="../..";

include($path_to_root . "/includes/session.inc");
add_access_extensions();

$js = "";
if ($use_popup_windows)
    $js .= get_js_open_window(900, 500);
if ($use_date_picker)
    $js .= get_js_date_picker();

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");


/////////////////////////////////////////////////////
//Functions
/////////////////////////////////////////////////////

function payperiod_settings(){

  start_outer_table(TABLESTYLE2);
  table_section(1);
  date_row("Pay Period Ends:", 'PayPeriodEnd');
  date_row("Check date:", "CheckDate");

  table_section(2);
  bank_accounts_list_row("Bank Account:", "BankAccount");
  end_outer_table(1);
}

//--------------------------------------------------------------------------------------------
function get_employees(){
  //get all active employees
  $sql = "SELECT emp_id, emp_name, emp_paytype FROM ".TB_PREF."employees WHERE inactive = 0";

  $result = db_query($sql, "The employee table is inaccessible");

  return $result;
}

//--------------------------------------------------------------------------------------------
//display the list of employees
function list_employees($list){

    start_table(TABLESTYLE, "width=60%");

    $th = array(("check"),_("Name"), _("Hours"), _("Salary"));//add columns for commission, overtime, etc
    table_header($th);

      $k = 0;
      while ($myrow = db_fetch($list)){
      alt_table_row_color($k);
      check_cells(null, "check".$myrow["emp_id"], '', '', '', "width=15 align=center");//select employees to pay
      label_cell($myrow["emp_name"]);

      if ($myrow['emp_paytype'] == 'hr'){
        text_cells(null, 'hours'.$myrow["emp_id"], "get_last_hours()", 8, 4);//pre-fill this with hours from last paycheck?
      } else {
        echo "<td></td>";//blank cell for non hourly employees
      }

      if ($myrow['emp_paytype'] == 'sal'){
        text_cells(null, 'salary'.$myrow["emp_id"], null, 8, 4);//show something?
      } else {
        echo "<td></td>";//blank cell for non salaried employees
      }

      end_row();
      }

    end_table(1);

    div_start('controls');
    submit_center('submit', _("Proceed"), true, '', 'default');
    div_end();

}

//--------------------------------------------------------------------------------------------
function get_last_hours($id){
  //
}

//--------------------------------------------------------------------------------------------
function can_process(){
  //is at least one employee checked?
  
  //do all the checked hourly employees have positive hours listed?

  return true;
}

//--------------------------------------------------------------------------------------------
function handle_submit(){

  if (!can_process())
    return;

  //hand off to calculation/review page

}


/////////////////////////////////////////////////////
//Page Flow
/////////////////////////////////////////////////////
page("Enter Paycheck Information");

//display top table with date, check, and account info
payperiod_settings();


//display bottom table with employee info
$result = get_employees();
if (!$result)
  display_notification("There are no employees to pay.");
else
  list_employees($result);


end_page();

?>  
 

34

(34 replies, posted in Modules Add-on's)

One specific question I have is how to integrate the payroll into the current bank transaction (check writing) form, and being able to see all the taxes/deductions itemized.

All ideas coveted.

35

(34 replies, posted in Modules Add-on's)

I am in the process of migrating away from quickbooks to Frontaccounting. My quickbooks software (Pro 2009) is going to cripple its payroll function as of May 31, so I'm trying to build a simple payroll module for FA and get everything moved over before then. So far, I've combed through the core code and I've gotten as far as building an employee database table with an input/edit form on the front end. Woohoo!

My idea is to make the payroll system fairly agnostic. As I see it, US payroll uses three types of calculations:
Tiered percentage -
percent witheld based on certain income levels with allowances for household members (ie. income tax witholding)

Limited percentage -
percentage taken up a certain yearly limit (ie Unemployment Tax)

Straight percentage -
simple percentage of gross pay (ie Medicare)

So, I'm thinking of having a form to input these different levels and percentages and run the calculations based on that.

I'm looking for ideas, best practices, help in implementation, etc. I'll be submitting this to the community when I get it working.

36

(10 replies, posted in Wish List)

Here also is some info from Consolibyte, the group that put this web connector together: http://wiki.consolibyte.com/wiki/doku.php/quickbooks_integration_php_consolibyte_sqlmirror

It looks like it is possible to do a full(?) mirror of qb data to mysql.

37

(10 replies, posted in Wish List)

I am currently in the process of migrating away from quickbooks. I will be working on finding some way to get as much as I can out of our current system. Janusz, any help in this regard would be very much appreciated.
In addition to the qodbc, I
Also found this web connector written in PHP:
https://idnforums.intuit.com/messageview.aspx?catid=56&threadid=13858&forumid=1

It looks promising.