Accounting Software
Small Business Software Estimating Software
Construction Estimating SoftwareBookkeeping SoftwareInventory SoftwareInventory Control SoftwareInventory Tracking SoftwareInventory Management SoftwareBusiness Management Software

Employee Account Viewers (Source Code)

Link to: header | record viewer directory

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

Comments

CEmployeeAccountViewer

This class manages employee accounts for the Goldenseal accounting software,
small business management software, payroll software and
construction estimating software.

a viewer for employee accounts. It's the most crowded account layout,
with wage rates, job cost rates and billing rates, plus scads of payroll info
(wage schedule, tax package, vacation package, benefit package, deductions,
exemptions etc).

SUPERCLASS = CAccountViewer

Constructor

/*********************************************************************************
constructor
*********************************************************************************/
CEmployeeAccountViewer::CEmployeeAccountViewer(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo)
: CAccountViewer(inPaneInfo, inViewInfo)
{
}

Source Code

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

FinishUpdatingFields split TCS 4/17/00

Finish prep work after updating fields from an object, but before displaying them

*********************************************************************************/
void CEmployeeAccountViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);

// format the wage amount field
// note that we always update the value if it's changed
FormatWageField(tag_wageamount, GetFieldValue(tag_wagerate), true);

// set enablement of the 'view contacts' buttons TCS 10/30/02
UpdateContactButton(id_LaborHours, button_viewhours); // TCS 11/24/02
UpdateContactButton(id_PayrollRecord, button_viewpayroll);
}
/*********************************************************************************

HandleCVChanged

Handle a changed value in a clairvoyant field. Some frequently-used fields are
handled here. Subclasses can override to handle their own cv fields.

*********************************************************************************/
void CEmployeeAccountViewer::HandleCVChanged(CTCS_CVField *cvField)
{
// sanity check
TCS_FailNILMsg(cvField, TCS_GetErrString(errID_BadClairvoyant));
DBid value = cvField->GetValue();

// what we need to do depends on which cv changed
switch (cvField->GetPaneID())
{
case tag_wagerate:
FormatWageField(tag_wageamount, value, true);
break;

default:
break;
}
// also let the superclass have a chance
THE_SUPERCLASS::HandleCVChanged(cvField);

}
/*********************************************************************************

HandleDBButtonClicked TCS 11/24/02

a button in the layout was clicked.

*********************************************************************************/
void CEmployeeAccountViewer::HandleDBButtonClicked(const TagType btnID)
{
if (btnID == button_viewhours || btnID == button_viewpayroll)
{
DB_Account *account = TCS_SAFE_CAST(mCurrViewerObject, DB_Account);
TCS_FailNILMsg(account, TCS_GetErrString(errID_BadObject));

TObjectIDArray contactArray;

if (btnID == button_viewhours)
{
account->FetchMeetingArray(id_LaborHours, contactArray);
if (contactArray.GetCount() > 0)
DB_Editor::ShowEditorArray(id_LaborHours, contactArray, cShowLastRecord);
}
else
{
account->FetchMeetingArray(id_PayrollRecord, contactArray);
if (contactArray.GetCount() > 0)
DB_Editor::ShowEditorArray(id_PayrollRecord, contactArray, cShowLastRecord);
}

}
else
THE_SUPERCLASS::HandleDBButtonClicked(btnID);
}
#if CAN_USE_MARK
#pragma mark -
#endif/*********************************************************************************

FormatWageField

format the display of a wage rate amount field. TCS disabled 9/14/98, looks
like we may want to keep field enabled

*********************************************************************************/
void CEmployeeAccountViewer::FormatWageField(const TagType fieldTag, const DBid rateID,
const Boolean updateValue)
{
CMoney rateValue = 0;
Boolean enableIt = false;

if (rateID)
enableIt = FetchVariableWage(rateID, rateValue);

SetFieldEnabled(fieldTag, enableIt, cSetItalic); // rev TCS 7/18/00

if (!enableIt && updateValue)
SetFieldMoneyValue(fieldTag, rateValue);
}
/*********************************************************************************
FetchVariableWage

return whether a wage rate is variable, and fetch the current rate

**********************************************************************************/
Boolean CEmployeeAccountViewer::FetchVariableWage(const DBid rateID, CMoney &rateValue)
{
if (rateID)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_FailNILMsg(mCurrViewerObject, TCS_GetErrString(errID_BadObject));

DBid accountClass = mCurrViewerObject->GetDBClassID();

CWageSchedule *rate = TCS_SAFE_CAST(gDBFile->GetOneObject(id_WageSchedule,
rateID), CWageSchedule);
if (rate) // we found a rate, so it can decide whether there's a variable rate
{
DB_ObjectWatcher watcher(rate);
rateValue = rate->GetBaseWage();

return rate->HasVariableRate();
}
} // if no wage rate, then we allow entry into rate field
return true;
}
/*********************************************************************************

FormatRateField

format the display of a job cost or billing rate amount field

*********************************************************************************/
void CEmployeeAccountViewer::FormatRateField(const TagType fieldTag, const DBid rateID,
const Boolean updateValue)
{
if (rateID)
{
CMoney rateValue;
UInt8 calcMethod = FetchCalcMethod(rateID, rateValue);
SetFieldEnabled(fieldTag, calcMethod == rate_Variable);

switch (calcMethod)
{
case rate_Variable:
break;

case rate_Dollar:
if (updateValue)
SetFieldMoneyValue(fieldTag, rateValue);
break;

case rate_Net:
case rate_NetPlusPercent:
SetFieldCString(fieldTag, TCS_GetStockString(stockID_NetCost));
break;

case rate_Pay:
case rate_PayPlusPercent:
SetFieldCString(fieldTag, TCS_GetStockString(stockID_GrossCost));
break;

default:
TCS_DebugAlert("Oops, bad case in CEmployeeAccountViewer::FormatRateField!");
break;
}
}
else
{
SetFieldEnabled(fieldTag, false);

if (updateValue) // rev TCS 7/18/00
SetFieldMoneyValue(fieldTag, 0);
}
}
/*********************************************************************************
FetchCalcMethod renamed TCS 4/23/03

fetch the calculation method fir this employee's wage and fill in the rate amount

**********************************************************************************/
UInt8 CEmployeeAccountViewer::FetchCalcMethod(const DBid rateID, CMoney &rateValue)
{
if (rateID)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_FailNILMsg(mCurrViewerObject, TCS_GetErrString(errID_BadObject));

DBid accountClass = mCurrViewerObject->GetDBClassID();

CLaborBillingRate *rate = TCS_SAFE_CAST(gDBFile->GetOneObject(id_LaborBillingRate,
rateID), CLaborBillingRate);
if (rate) // we found a rate, so it can decide whether there's a variable rate
{
DB_ObjectWatcher watcher(rate);
rateValue = rate->GetRate();

return rate->GetCalcMethod();
}
} // if no rate, then we'll not allow entry into variable rate field
rateValue = 0;

return rate_Dollar;
}