Link to: header | tables
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CDeductionBreakdownTable
This class manages payroll deduction tables for the Goldenseal accounting software,
payroll software and small business
management software.
It's a table showing employee payroll withholding or employer payroll taxes. We fill
the table via the Write Payroll command. This table appears in Payroll Records
so users can see itemized payroll deductions, as part of their use of our payroll software.
Source Code
/*********************************************************************************
RecalcBreakdownRow
recalculate the given row
*********************************************************************************/
CMoney CDeductionBreakdownTable::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, cIncludeX))
{
totalDue = GetMemberColMoney(row, tag_calcdeduction);
}
SetMemberColMoney(row, tag_amount, totalDue);
}
return totalDue;
}
/*********************************************************************************
GetColType
return the column type for the given column
*********************************************************************************/
SInt32 CDeductionBreakdownTable::GetColType(const SMemberInfo &memberInfo) const
{
switch (memberInfo.tag)
{
case tag_transactid:
return coltype_lookup;
break;
case tag_conditions:
return coltype_menulookup;
break;
case tag_amount: // TCS 10/29/99, rev 3/21/02
if (DB_PersistentObject::GetPrefsBoolean(id_ExpensePrefs, tag_allowpaychanges))
return coltype_edit;
else
return coltype_caption;
break;
case tag_baseamount: // TCS 10/29/99
case tag_yeartodate:
case tag_calcdeduction:
case tag_calculationtype:
return coltype_caption;
break;
default:
return THE_SUPERCLASS::GetColType(memberInfo);
break;
}
}
/*********************************************************************************
FillFromDeductionsArray TCS 4/28/00
fill in data from an array of deduction id's. This is used to fill in
payroll record breakdowns, when the breakdown is switched
*********************************************************************************/
void CDeductionBreakdownTable::FillFromDeductionsArray(TDeductionArray *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
TDeductionArrayIterator iterator(*itemArray);
SDeductionInfo itemInfo;
TableIndexT row = 0;
CMoney zeroValue(0,0);
CTextString itemName, rateType;
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
CTaxItem *taxItem = TCS_SAFE_CAST(gDBFile->GetOneObject(id_TaxItem, itemInfo.id),
CTaxItem);
if (taxItem)
{
DB_ObjectWatcher watcher(taxItem);
row++;
SetNumRows(row, cDontRedraw);
// get info from the tax item
TCS_ASSERTMsg(taxItem->GetMemberValue(tag_name, type_cstring, &itemName),
TCS_GetValueErrString(tag_name));
TCS_ASSERTMsg(taxItem->GetMemberValue(tag_calcmethod, type_cstring, &rateType),
TCS_GetValueErrString(tag_taxsource));
// 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:
SetCellText(row, col, rateType);
break;
case tag_conditions:
SetCVCellValue(row, col, itemInfo.conditions);
break;
case tag_rate:
SetCellText(row, col, rateType);
break;
case tag_basedon: // the step #
SetCellValue(row, col, itemInfo.basedOn);
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_calcdeduction:
SetCellText(row, col, itemInfo.deductionAmount.GetCurrencyString());
break;
case tag_yeartodate:
SetCellText(row, col, itemInfo.yearToDateAmount.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
}
}
}
else
ReportMissingObject(id_TaxItem, itemInfo.id);
}
}
Refresh();
}
/*********************************************************************************
FillFromCatDeductionsArray TCS 4/28/00
fill in data from an array of cat tax deduction id's. This is used to fill in
payroll record breakdowns, when the breakdown is switched
*********************************************************************************/
void CDeductionBreakdownTable::FillFromCatDeductionsArray(TCatTaxItemArray *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
TCatTaxItemArrayIterator iterator(*itemArray);
SCatTaxItemInfo itemInfo;
TableIndexT row = 0;
CMoney zeroValue(0,0);
CTextString itemName, rateType;
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
CTaxItem *taxItem = TCS_SAFE_CAST(gDBFile->GetOneObject(id_TaxItem, itemInfo.id),
CTaxItem);
TCS_FailNILMsg(taxItem, TCS_GetErrString(errID_BadObject));
DB_ObjectWatcher watcher(taxItem);
row++;
SetNumRows(row, cDontRedraw);
// get info from the tax item
TCS_ASSERTMsg(taxItem->GetMemberValue(tag_name, type_cstring, &itemName),
TCS_GetValueErrString(tag_name));
TCS_ASSERTMsg(taxItem->GetMemberValue(tag_calcmethod, type_cstring, &rateType),
TCS_GetValueErrString(tag_taxsource));
// 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:
SetCellText(row, col, rateType);
break;
case tag_conditions:
SetCVCellValue(row, col, itemInfo.conditions);
break;
case tag_catsystem:
SetCVCellValue(row, col, itemInfo.catSystem);
break;
case tag_category:
SetCVCellValue(row, col, itemInfo.category);
break;
case tag_subcategory:
SetCVCellValue(row, col, itemInfo.subcategory);
break;
case tag_rate: // TCS 3/28/02
if (itemInfo.isPercent)
SetCellText(row, col, itemInfo.rate.GetPercentString());
else
SetCellText(row, col, itemInfo.rate.GetCurrencyString());
break;
case tag_basedon: // the step #
SetCellValue(row, col, itemInfo.basedOn);
break;
case tag_baseamount: // may be hours or dollars
if (itemInfo.basedOn == tax_hoursstraight || itemInfo.basedOn == tax_hoursgross ||
itemInfo.basedOn == tax_daysworked)
SetCellText(row, col, itemInfo.baseAmount.GetNumberString());
else
SetCellText(row, col, itemInfo.baseAmount.GetCurrencyString());
break;
case tag_employeeamount: // TCS 10/12/00
case tag_calcdeduction: // TCS 10/23/00
SetCellText(row, col, itemInfo.employeeAmount.GetCurrencyString());
break;
case tag_employeramount: // TCS 10/12/00
SetCellText(row, col, itemInfo.employerAmount.GetCurrencyString());
break;
case tag_yeartodate:
SetCellText(row, col, itemInfo.yearToDateAmount.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();
}
|