Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CTaxItemViewer
This class manages payroll tax items for the Goldenseal accounting software,
payroll software and small business
management software.
It's a viewer for payroll tax items. This is the data entry window for
employee withholding, employer taxes and other payroll taxes.
SUPERCLASS = DB_RecordViewer
Source Code
/*********************************************************************************
GetReadyToUpdateFields TCS 10/4/02
Do prep work before updating fields
*********************************************************************************/
void CTaxItemViewer::GetReadyToUpdateFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// we need to prep the paid to cv BEFORE update
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 CTaxItemViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
FormatCalcMethod(GetPopupValue(tag_calcmethod));
FormatAdjustment(GetPopupValue(tag_firsttype), tag_firstamount);
FormatAdjustment(GetPopupValue(tag_secondtype), tag_secondamount);
FormatSubtractFrom(GetPopupValue(tag_basedon));
}
/*********************************************************************************
HandlePopupChanged
a popup menu has been clicked, act accordingly
*********************************************************************************/
void CTaxItemViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
SInt32 value = popupMenu->GetValue();
switch (popupMenu->GetPaneID())
{
case tag_calcmethod:
FormatCalcMethod(value, true);
break;
case tag_firsttype:
FormatAdjustment(value, tag_firstamount);
break;
case tag_secondtype:
FormatAdjustment(value, tag_secondamount);
break;
case tag_paidtoclass:
SetCVClassID(tag_paidto, value, cEraseValue);
break;
case tag_basedon:
FormatSubtractFrom(value);
break;
default:
break;
}
// we always let the superclass have a crack
THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FormatCalcMethod
format the fields associated with calculation method
*********************************************************************************/
void CTaxItemViewer::FormatCalcMethod(const UInt8 taxType, const Boolean updateNow)
{
switch (taxType) // rev TCS 8/13/00
{
case tax_taxtable:
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, false);
SetCVFieldVisible(tag_thirdtable, false);
SetCVFieldVisible(tag_fourthtable, false);
SetCVFieldVisible(tag_fifthtable, false);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_TaxTable));
break;
case tax_maritaltables:
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, true);
SetCVFieldVisible(tag_thirdtable, true);
SetCVFieldVisible(tag_fourthtable, true);
SetCVFieldVisible(tag_fifthtable, true);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_MarriedTable));
SetFieldTitle(tag_secondtable, TCS_GetStockString(stockID_SingleTable));
SetFieldTitle(tag_thirdtable, TCS_GetStockString(stockID_DualIncomeTable));
SetFieldTitle(tag_fourthtable, TCS_GetStockString(stockID_HeadOfHouseTable));
SetFieldTitle(tag_fifthtable, TCS_GetStockString(stockID_OtherTable));
break;
case tax_doubletables:
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, true);
SetCVFieldVisible(tag_thirdtable, false);
SetCVFieldVisible(tag_fourthtable, false);
SetCVFieldVisible(tag_fifthtable, false);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_TaxTable));
SetFieldTitle(tag_secondtable, TCS_GetStockString(stockID_DeductionTable));
break;
case tax_tripletables:
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, true);
SetCVFieldVisible(tag_thirdtable, true);
SetCVFieldVisible(tag_fourthtable, false);
SetCVFieldVisible(tag_fifthtable, false);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_TaxTable));
SetFieldTitle(tag_secondtable, TCS_GetStockString(stockID_DeductionTable));
SetFieldTitle(tag_thirdtable, TCS_GetStockString(stockID_CreditTable));
break;
case tax_canadafedtable: // note the alt. order of titles
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, true);
SetCVFieldVisible(tag_thirdtable, true);
SetCVFieldVisible(tag_fourthtable, false);
SetCVFieldVisible(tag_fifthtable, false);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_SurtaxTable));
SetFieldTitle(tag_secondtable, TCS_GetStockString(stockID_TaxTable));
SetFieldTitle(tag_thirdtable, TCS_GetStockString(stockID_CreditTable));
break;
case tax_canadaprovtable:
SetCVFieldVisible(tag_taxtable, true);
SetCVFieldVisible(tag_secondtable, true);
SetCVFieldVisible(tag_thirdtable, true);
SetCVFieldVisible(tag_fourthtable, true);
SetCVFieldVisible(tag_fifthtable, true);
SetFieldTitle(tag_taxtable, TCS_GetStockString(stockID_SurtaxTable));
SetFieldTitle(tag_secondtable, TCS_GetStockString(stockID_TaxTable));
SetFieldTitle(tag_thirdtable, TCS_GetStockString(stockID_CreditTable));
SetFieldTitle(tag_fourthtable, TCS_GetStockString(stockID_FourthTable));
SetFieldTitle(tag_fifthtable, TCS_GetStockString(stockID_FifthTable));
break;
default: // others don't use tables
SetCVFieldVisible(tag_taxtable, false);
SetCVFieldVisible(tag_secondtable, false);
SetCVFieldVisible(tag_thirdtable, false);
SetCVFieldVisible(tag_fourthtable, false);
SetCVFieldVisible(tag_fifthtable, false);
break;
}
// set up the amount field
if (taxType == tax_dollars || taxType == tax_percent)
{
SetFieldVisible(tag_amount, true);
SetFieldType(tag_amount, taxType == tax_percent ?
fieldtype_percent : fieldtype_emoney); // rev TCS 12/13/99
if (updateNow) // TCS 1/7/02
{
CMoney value = GetFieldMoneyValue(tag_amount);
if (taxType == tax_dollars)
SetFieldCString(tag_amount, value.GetCurrencyString());
else
SetFieldCString(tag_amount, value.GetPercentString());
}
}
else
{
SetFieldVisible(tag_amount, false);
}
// set up other fields
if (taxType == tax_catcomprate || taxType == tax_cattaxrate) // TCS 3/1/99
{
FormatSubtractFrom(tax_wagesgross);
SetFieldValue(tag_firsttype, tax_nothing);
SetFieldEnabled(tag_firsttype, false);
SetFieldVisible(tag_firstamount, false);
SetFieldValue(tag_secondtype, tax_nothing);
SetFieldEnabled(tag_secondtype, false);
SetFieldVisible(tag_secondamount, false);
}
else
{
SetFieldEnabled(tag_basedon, true);
SetFieldEnabled(tag_firsttype, true);
FormatAdjustment(GetPopupValue(tag_firsttype), tag_firstamount);
SetFieldEnabled(tag_secondtype, true);
FormatAdjustment(GetPopupValue(tag_secondtype), tag_secondamount);
}
switch (taxType) // TCS 10/21/02
{
case tax_percent:
case tax_taxtable:
case tax_maritaltables:
case tax_doubletables:
case tax_tripletables:
case tax_canadafedtable:
case tax_canadaprovtable:
case tax_compercent:
case tax_disabilitypercent:
case tax_otherpercent:
FormatBasedOn(true);
SetFieldEnabled(tag_basedon, true);
break;
case tax_catcomprate:
case tax_cattaxrate:
FormatBasedOn(true);
SetPopupValue(tag_basedon, tax_wagesgross);
SetFieldEnabled(tag_basedon, false);
break;
case tax_dollars:
case tax_federaldollar:
case tax_statedollar:
case tax_localdollar:
case tax_otherdollar:
FormatBasedOn(false);
SetFieldEnabled(tag_basedon, true);
break;
default:
break;
}
}
/*********************************************************************************
FormatBasedOn TCS 10/21/02
format the 'based on' field
*********************************************************************************/
void CTaxItemViewer::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
format the 'subtract from' field
*********************************************************************************/
void CTaxItemViewer::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);
}
/*********************************************************************************
FormatAdjustment
format the fields associated with an adjustment
*********************************************************************************/
void CTaxItemViewer::FormatAdjustment(const UInt8 adjustType, const TagType tag)
{
switch (adjustType)
{
case tax_nothing:
case tax_federaldollar:
case tax_statedollar:
case tax_localdollar:
case tax_otherdollar:
case tax_compercent:
case tax_disabilitypercent:
case tax_otherpercent:
SetFieldVisible(tag, false);
break;
case tax_constant:
SetFieldVisible(tag, true);
SetFieldType(tag, fieldtype_number);
break;
case tax_percent:
SetFieldVisible(tag, true);
SetFieldType(tag, fieldtype_percent);
break;
case tax_federalallow: // rev TCS 5/21/99, 11/24/99
case tax_stateallow:
case tax_localallow:
case tax_otherallow:
SetFieldVisible(tag, true);
SetFieldType(tag, fieldtype_emoney);
break;
case tax_dollars:
case tax_maxbase:
case tax_minbase:
case tax_maxresult:
case tax_minresult:
case tax_annualmaxbase:
case tax_annualmaxtax:
SetFieldVisible(tag, true);
SetFieldType(tag, fieldtype_emoney);
break;
default:
TCS_DebugAlert("Oops, bad case in CTaxItemViewer::FormatAdjustment!");
break;
}
}
|