Link to: header | tables
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CBenefitBreakdownTable
This class manages general breakdown tables for the Goldenseal accounting software,
payroll software and small business
management software.
It's a table showing employee benefits in a payroll record. We generate this from
employee benefit packages in the Write Payroll command. Each line shows
one benefit item (such as pension plan, health insurance coverage, tool allowances
or mileage). Note that paid vacations and holidays are handled separately.
SUPERCLASS = CTransactionBreakdownTable Source Code
/*********************************************************************************
RecalcBreakdownRow TCS 4/7/00
recalculate the given row
*********************************************************************************/
CMoney CBenefitBreakdownTable::RecalcBreakdownRow(const TableIndexT row, const TagType changedCol)
{
// if the amount col has been edited, we don't recalc, just return entered value TCS 10/29/99
if (changedCol == tag_amount)
{
return GetMemberColMoney(row, tag_amount);
}
CMoney totalDue(0,0);
// calculate the total due amount
TableIndexT col = GetMemberCol(tag_pay);
if (col)
{
if (IsChecked(row, col))
{
totalDue = GetMemberColMoney(row, tag_calcdeduction);
}
SetMemberColMoney(row, tag_amount, totalDue);
}
return totalDue;
}
/*********************************************************************************
GetColType TCS 4/7/00
return the column type for the given column
*********************************************************************************/
SInt32 CBenefitBreakdownTable::GetColType(const SMemberInfo &memberInfo) const
{
switch (memberInfo.tag)
{
case tag_transactid:
return coltype_lookup;
break;
case tag_conditions:
case tag_calculationtype:
return coltype_menulookup;
break;
case tag_employeramount: // TCS 3/21/02
case tag_calcdeduction:
case tag_employeebenefits:
case tag_amount:
if (DB_PersistentObject::GetPrefsBoolean(id_ExpensePrefs, tag_allowpaychanges))
return coltype_edit;
else
return coltype_caption;
break;
case tag_baseamount:
case tag_yeartodate:
return coltype_caption;
break;
default:
return THE_SUPERCLASS::GetColType(memberInfo);
break;
}
}
/*********************************************************************************
FillFromDeductionsArray
fill in data from an array of deduction id's
*********************************************************************************/
void CBenefitBreakdownTable::FillFromBenefitArray(TBenefitArray *itemArray)
{
// sanity check
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_FailNILMsg(itemArray, TCS_GetErrString(errID_BadArray));
// ok, walk through each deduction item and fill in the table
TBenefitArrayIterator iterator(*itemArray);
SBenefitInfo itemInfo;
TableIndexT row = 0;
CTextString itemName;
UInt8 benefitType;
SMemberInfo memberInfo;
Boolean canChange = DB_PersistentObject::GetPrefsBoolean(id_ExpensePrefs, tag_allowpaychanges);
// loop through each item in the array
while (iterator.Next(itemInfo))
{
if (itemInfo.included) // we only list items that are included in package
{
// fetch the tax item
CBenefitItem *benefitItem = TCS_SAFE_CAST(gDBFile->GetOneObject(id_BenefitItem, itemInfo.id),
CBenefitItem);
TCS_FailNILMsg(benefitItem, TCS_GetErrString(errID_BadObject));
DB_ObjectWatcher watcher(benefitItem);
row++;
SetNumRows(row, cDontRedraw);
// get info from the tax item
TCS_ASSERTMsg(benefitItem->GetMemberValue(tag_name, type_cstring, &itemName),
TCS_GetValueErrString(tag_name));
benefitType = benefitItem->GetBenefitType();
// 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:
if (canChange)
SetCellText(row, col, itemInfo.pay ? cCheckMarkString : "");
else
SetCellText(row, col, itemInfo.pay ? cXString : ""); // TCS 10/24/02
break;
case tag_transactid:
SetCVCellValue(row, col, itemInfo.id);
break;
case tag_name:
SetCellText(row, col, itemName);
break;
case tag_calculationtype:
SetCVCellValue(row, col, benefitType);
break;
case tag_conditions:
SetCVCellValue(row, col, itemInfo.conditions);
break;
case tag_baseamount: // may be hours or dollars
if (itemInfo.basedOn)
SetCellText(row, col, itemInfo.baseAmount.GetCurrencyString());
else
SetCellText(row, col, itemInfo.baseAmount.GetNumberString());
break;
case tag_employeramount:
SetCellText(row, col, itemInfo.employerPaysAmount.GetCurrencyString());
break;
case tag_employeebenefits:
SetCellText(row, col, itemInfo.benefitAmount.GetCurrencyString());
break;
case tag_yeartodate:
SetCellText(row, col, itemInfo.yearToDateAmount.GetCurrencyString());
break;
case tag_calcdeduction:
SetCellText(row, col, itemInfo.deductionAmount.GetCurrencyString());
break;
case tag_amount:
{
CMoney netAmount = itemInfo.benefitAmount - itemInfo.deductionAmount;
SetCellText(row, col, netAmount.GetCurrencyString());
}
break;
case tag_basedon: // the step # TCS 11/1/00
SetCellValue(row, col, itemInfo.basedOn);
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();
}
|