Accounting Software
Small Business Software Estimating Software
Time Tracking SoftwareTime Management SoftwareTime Billing SoftwareContact Management SoftwareCustomer Management SoftwareProject Management SoftwareBusiness Management Software

Commissions Table (Source Code)

Link to: header | tables directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CCommishBreakdownTable

This class manages payroll commissions tables for the Goldenseal accounting software,
payroll software and small business management software.

It's a table showing employee commissions earned. We fill the table from sales rep info
in sales transactions and billing record, via the Write Payroll command. This is included
in payroll income, along with regular hourly wages or salary.

SUPERCLASS = CTransactionBreakdownTable

Source Code

/*********************************************************************************

GetColType TCS 6/9/02

return the column type for the given column

*********************************************************************************/
SInt32 CCommishBreakdownTable::GetColType(const SMemberInfo &memberInfo) const
{
switch (memberInfo.tag)
{
case tag_mainaccountfullname:
case tag_commissionpercent:
case tag_commissionamount:
case tag_baseamount:
return coltype_caption;
break;

default:
return THE_SUPERCLASS::GetColType(memberInfo);
break;
}
}
/*********************************************************************************

RecalcBreakdownRow rev TCS 6/8/02

recalculate the given row

*********************************************************************************/
CMoney CCommishBreakdownTable::RecalcBreakdownRow(const TableIndexT row, const TagType /*changedCol*/)
{
CMoney totalDue = 0;

// calculate the total due amount
TableIndexT col = GetMemberCol(tag_pay);
if (col)
{
if (IsChecked(row, col))
totalDue = GetMemberColMoney(row, tag_commissionamount);
else
totalDue = 0;

SetMemberColMoney(row, tag_amount, totalDue);
}

return totalDue;
}
/*********************************************************************************

FillFromCommissionsArray TCS 6/8/02

fill in data from an array of labor hours id's
*********************************************************************************/
void CCommishBreakdownTable::FillFromCommissionsArray(TCommissionArray *itemArray)
{
// sanity check
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_FailNILMsg(itemArray, TCS_GetErrString(errID_BadArray));


// get number of table rows
SetNumRows(itemArray->GetCount(), cDontRedraw);

// ok, walk through each hours item and fill in the table
TCommissionArrayIterator iterator(*itemArray);
SCommissionInfo itemInfo;
TableIndexT row;

CTextString itemName, accountName;
CDate date;
SMemberInfo memberInfo;

// loop through each item in the array
while (iterator.Next(itemInfo))
{
row = iterator.GetCurrentIndex();

// fetch the commission source record
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));

DB_PersistentObject *source = gDBFile->GetOneObject(itemInfo.classID, itemInfo.id);
TCS_FailNILMsg(source, TCS_GetErrString(errID_BadTransaction));

DB_ObjectWatcher watcher(source);

// get info from the source record
itemName = source->GetMenuName();
accountName = source->GetFullName();
date = source->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_transactiontype:
if (itemInfo.classID == id_ProjectAccount)
SetCellText(row, col, TCS_GetStockString(stockID_Project));
else
SetCellText(row, col, DB_ClassDescriptor::GetClassName(itemInfo.classID));
break;

case tag_date:
SetCellText(row, col, date.GetCString());
break;

case tag_mainaccountfullname:
SetCellText(row, col, accountName);
break;

case tag_menuname:
SetCellText(row, col, itemName);
break;

case tag_baseamount:
SetCellText(row, col, itemInfo.baseAmount.GetCurrencyString());
break;

case tag_commissionpercent:
SetCellText(row, col, itemInfo.percentage.GetPercentString());
break;

case tag_commissionamount:
SetCellText(row, col, itemInfo.commissionAmount.GetCurrencyString());
break;

case tag_prevpaid:
SetCellText(row, col, itemInfo.prevPaidAmount.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();
}