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

Benefit Items Viewer (Source Code)

Link to: header | record viewer directory

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

Comments

CBenefitItemViewer

This class manages payroll benefit items for the Goldenseal accounting software,
payroll software and small business management software.

It's a viewer for benefit items. This sets up the window for viewing
benefit records for the Goldenseal payroll software

SUPERCLASS = DB_RecordViewer

Source Code

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

FinishCreateSelf

finish creating the viewer.

*********************************************************************************/
void CBenefitItemViewer::FinishCreateSelf()
{
// may be needed if we decide to have buttons for taxes & benefits
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetReadyToUpdateFields split TCS 4/17/00

Do prep work before updating fields

*********************************************************************************/
void CBenefitItemViewer::GetReadyToUpdateFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// set cv class id TCS added 2/25/99, rev 5/21/99
DBClass accountClass = 0;
viewerObject->GetMemberValue(tag_paidtoclass, type_objclass, &accountClass);
SetCVClassID(tag_paidto, accountClass);

THE_SUPERCLASS::GetReadyToUpdateFields(creationMethod, viewerObject);
}
/*********************************************************************************

FinishUpdatingFields split TCS 4/17/00

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

*********************************************************************************/
void CBenefitItemViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);

// format employer pay fields
SInt32 payType;
TCS_ASSERTMsg(viewerObject->GetMemberValue(tag_paytype,
type_long, &payType), TCS_GetErrString(errID_BadValue));
FormatPayFields(payType);

FormatSubtractFrom(GetPopupValue(tag_basedon));

// format min/max field enabled
SetFieldEnabled(tag_maximum, GetCheckboxValue(tag_hasmaximum));
SetFieldEnabled(tag_maxperiod, GetCheckboxValue(tag_hasmaximum));
SetFieldEnabled(tag_minimum, GetCheckboxValue(tag_hasminimum));
SetFieldEnabled(tag_minperiod, GetCheckboxValue(tag_hasminimum));
}
/*********************************************************************************

HandlePopupChanged

a popup menu has been clicked, act accordingly

*********************************************************************************/
void CBenefitItemViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
UInt8 value = popupMenu->GetValue();

TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
switch (popupMenu->GetPaneID())
{
case tag_paytype:
FormatPayFields(value, true);
break;

case tag_paidtoclass: // TCS added 2/25/99
SetCVClassID(tag_paidto, value, cEraseValue);
break;

case tag_basedon: // TCS 4/6/00
FormatSubtractFrom(value);
break;

default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}
/*********************************************************************************

HandleCheckboxClicked

handle a checkbox click

*********************************************************************************/
void CBenefitItemViewer::HandleCheckboxClicked(CTCS_StdCheckbox *checkbox)
{
TCS_FailNILMsg(checkbox, TCS_GetErrString(errID_BadCheckbox));
Boolean value = checkbox->GetValue();

switch (checkbox->GetPaneID())
{
case tag_hasmaximum:
SetFieldEnabled(tag_maximum, value);
SetFieldEnabled(tag_maxperiod, value);
break;

case tag_hasminimum:
SetFieldEnabled(tag_minimum, value);
SetFieldEnabled(tag_minperiod, value);
break;

default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleCheckboxClicked(checkbox);
}#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FormatPayFields

format the employer pays fields

*********************************************************************************/
void CBenefitItemViewer::FormatPayFields(const SInt32 payType, const Boolean updateNow)
{
if (payType == calc_dollars)
{
SetFieldType(tag_amount, fieldtype_money);
SetFieldVisible(tag_payperiod, true);
FormatBasedOn(false);
}
else
{
SetFieldType(tag_amount, fieldtype_percent);
SetFieldVisible(tag_payperiod, false);
FormatBasedOn(true);
}

if (updateNow) // TCS 1/7/02
{
CMoney value = GetFieldMoneyValue(tag_amount);

if (payType == calc_dollars)
SetFieldCString(tag_amount, value.GetCurrencyString());
else
SetFieldCString(tag_amount, value.GetPercentString());
}
}

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

FormatBasedOn TCS 10/21/02

format the 'based on' field

*********************************************************************************/
void CBenefitItemViewer::FormatBasedOn(const Boolean isPercent)
{
SetPopupCommandEnabled(tag_basedon, tax_flatrate, !isPercent);
SetPopupCommandEnabled(tag_basedon, tax_daysworked, !isPercent);
SetPopupCommandEnabled(tag_basedon, tax_daysinperiod, !isPercent);
SetPopupCommandEnabled(tag_basedon, tax_hoursgross, !isPercent);
SetPopupCommandEnabled(tag_basedon, tax_hoursstraight, !isPercent);

SetPopupCommandEnabled(tag_basedon, tax_wagesgross, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_wagesstraight, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_adjusted1, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_adjusted2, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_adjusted3, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_adjusted4, isPercent);
SetPopupCommandEnabled(tag_basedon, tax_adjusted5, isPercent);

UInt8 popupValue = GetFieldValue(tag_basedon);

switch (popupValue) // remove illogical values
{
case tax_flatrate:
case tax_daysworked:
case tax_daysinperiod:
case tax_hoursgross:
case tax_hoursstraight:
if (isPercent)
SetPopupValue(tag_basedon, tax_wagesgross);
break;

case tax_wagesgross:
case tax_wagesstraight:
case tax_adjusted1:
case tax_adjusted2:
case tax_adjusted3:
case tax_adjusted4:
case tax_adjusted5:
if (!isPercent)
SetPopupValue(tag_basedon, tax_flatrate);
break;

default:
break;
}
}

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

FormatSubtractFrom TCS 4/6/00

format the 'subtract from' field

*********************************************************************************/
void CBenefitItemViewer::FormatSubtractFrom(const UInt8 basedOn)
{
SetPopupCommandEnabled(tag_subtractfrom, tax_wagesgross, basedOn < tax_adjusted1);
SetPopupCommandEnabled(tag_subtractfrom, tax_adjusted1, basedOn < tax_adjusted2);
SetPopupCommandEnabled(tag_subtractfrom, tax_adjusted2, basedOn < tax_adjusted3);
SetPopupCommandEnabled(tag_subtractfrom, tax_adjusted3, basedOn < tax_adjusted4);
SetPopupCommandEnabled(tag_subtractfrom, tax_adjusted4, basedOn < tax_adjusted5);

if (basedOn >= tax_adjusted1 && GetPopupValue(tag_subtractfrom) < basedOn)
{
SetPopupValue(tag_subtractfrom, basedOn);
}
}