Link to: header | tables
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CWagesBreakdownTable
This class manages payroll wages breakdown tables for the Goldenseal accounting software,
payroll software and small business
management software.
It's a table showing employee wages for one pay period. Used in Payroll Records,
which are the heart of the Goldenseal payroll software.
SUPERCLASS = CTransactionBreakdownTable Source Code
/*********************************************************************************
RecalcBreakdownRow
recalculate the given row
*********************************************************************************/
CMoney CWagesBreakdownTable::RecalcBreakdownRow(const TableIndexT row, const TagType /*changedCol*/)
{
CMoney totalDue(0,0), baseRate, OTRate, OTHrs, hours;
// calculate the total due amount
TableIndexT col = GetMemberCol(tag_pay);
if (col)
{
if (IsChecked(row, col))
{
baseRate = GetMemberColMoney(row, tag_wagerateamount);
hours = GetMemberColMoney(row, tag_timeused);
OTRate = GetMemberColMoney(row, tag_overtimerate);
OTHrs = GetMemberColMoney(row, tag_overtimehours);
totalDue = (hours - OTHrs) * baseRate + OTHrs * OTRate;
}
SetMemberColMoney(row, tag_amount, totalDue);
}
return totalDue;
}
/*********************************************************************************
FillFromHoursArray TCS 4/27/00
fill in data from an array of labor hours id's. This is used to fill in
payroll record breakdowns, when the breakdown is switched
*********************************************************************************/
void CWagesBreakdownTable::FillFromHoursArray(TLaborHoursArray *itemArray)
{
// sanity check
TCS_FailNILMsg(itemArray, TCS_GetErrString(errID_BadArray));
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
// get number of table rows
SetNumRows(itemArray->GetCount(), cDontRedraw);
// ok, walk through each hours item and fill in the table
TLaborHoursArrayIterator iterator(*itemArray);
SLaborHoursInfo itemInfo;
TableIndexT row;
CTextString jobName, workDone;
CDate date;
SMemberInfo memberInfo;
// loop through each item in the array
while (iterator.Next(itemInfo))
{
row = iterator.GetCurrentIndex();
// fetch the labor hours record
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
CLaborLog *laborLog = TCS_SAFE_CAST(gDBFile->GetOneObject(id_LaborHours, itemInfo.id),
CLaborLog);
TCS_FailNILMsg(laborLog, TCS_GetErrString(errID_BadTransaction));
DB_ObjectWatcher watcher(laborLog);
// get scads of info from the labor hours record
TCS_ASSERTMsg(laborLog->GetMemberValue(tag_name, type_cstring, &workDone),
TCS_GetValueErrString(tag_name));
TCS_ASSERTMsg(laborLog->GetMemberValue(tag_jobname, type_cstring, &jobName),
TCS_GetValueErrString(tag_jobname));
date = laborLog->GetDate();
// loop through each table column and fill in data
for (TableIndexT col = 1; col <= LastCol(); col++)
{
TCS_TRY
{
// based on the member type, set the cell value
// from the object data
TCS_ASSERTMsg(GetColMemberInfo(col, &memberInfo),
TCS_GetErrString(errID_BadColumn));
switch (memberInfo.tag)
{
case tag_pay:
SetCellText(row, col, itemInfo.pay ? cCheckMarkString : "");
break;
//case tag_id:
case tag_transactid:
SetCellText(row, col, itemInfo.id);
break;
case tag_jobname:
SetCellText(row, col, jobName);
break;
case tag_date:
SetCellText(row, col, date.GetCString());
break;
case tag_name:
SetCellText(row, col, workDone);
break;
case tag_wagerateamount:
SetCellText(row, col, itemInfo.wageRateAmount.GetCurrencyString());
break;
case tag_timeused:
if (itemInfo.isBonus) // TCS 12/24/02
SetCellText(row, col, cOneString);
else
SetCellText(row, col, itemInfo.baseHours.GetNumberString());
break;
case tag_daysworked:
SetCellText(row, col, itemInfo.daysWorked.GetNumberString());
break;
case tag_overtimerate:
SetCellText(row, col, itemInfo.overtimeRate.GetCurrencyString());
break;
case tag_overtimehours:
SetCellText(row, col, itemInfo.overtimeHrs.GetCurrencyString());
break;
case tag_amount:
SetCellText(row, col, itemInfo.totalDueAmount.GetCurrencyString());
break;
default:
TCS_DebugAlert(CTextString("Oops, missing value for table column tag") +
TCS_GetTagMessage(memberInfo.tag));
SetCellText(row, col, "");
break;
}
}
TCS_CATCH
{ // catch the assertion so other fields can be written
}
}
}
Refresh();
}
|