Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CTaxTableViewer
This class manages payroll tax tables for the Goldenseal accounting software,
payroll software and small business
management software.
It's a viewer for payroll tax tables. This handles the to/from columns.
Generally users won't need to do much with payroll tax tables, since we provide
them for import.
Source Code
/*********************************************************************************
GetReadyToUpdateFields split TCS 4/17/00
Do prep work before updating fields
*********************************************************************************/
void CTaxTableViewer::GetReadyToUpdateFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadViewer));
// we first need to set cv class id TCS 5/21/99
DBClass accountClass = 0;
viewerObject->GetMemberValue(tag_firsttype, type_objclass, &accountClass);
//FormatTaxItemField(accountClass);
// the superclass handles basic field updating
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 CTaxTableViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
// set up the table with to/from values
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_withholdtable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
table->SetToColumn(CTaxTable::col_to); // TCS 3/6/00
table->SetFromColumn(CTaxTable::col_from);
table->FillToFromValues();
// set up visibility and format of amount fields
SetAmountEnabled(tag_firstamount, GetPopupValue(tag_firsttype));
SetAmountEnabled(tag_secondamount, GetPopupValue(tag_secondtype));
SetAmountEnabled(tag_thirdamount, GetPopupValue(tag_thirdtype));
SetAmountEnabled(tag_fourthamount, GetPopupValue(tag_fourthtype));
SetAmountEnabled(tag_fifthamount, GetPopupValue(tag_fifthtype)); // TCS 4/24/00
Boolean hasTax = (GetPopupValue(tag_firsttype) != tax_nothing); // TCS rev 5/18/99
// set visibility of min/max checkboxes TCS 11/22/98
SetFieldVisible(tag_hasmaximum, hasTax);
SetFieldVisible(tag_hasminimum, hasTax);
//FormatTaxItemField(GetPopupValue(tag_firsttype));
SetFieldVisible(tag_subtractfromtable1, GetPopupValue(tag_firsttype) != tax_nothing);
SetFieldVisible(tag_subtractfromtable2, GetPopupValue(tag_secondtype) != tax_nothing);
SetFieldVisible(tag_subtractfromtable3, GetPopupValue(tag_thirdtype) != tax_nothing);
SetFieldVisible(tag_subtractfromtable4, GetPopupValue(tag_fourthtype) != tax_nothing);
SetFieldVisible(tag_subtractfromtable5, GetPopupValue(tag_fifthtype) != tax_nothing);
// set visibility of min/max amounts
SetFieldVisible(tag_maximum, hasTax && GetCheckboxValue(tag_hasmaximum));
SetFieldVisible(tag_minimum, hasTax && GetCheckboxValue(tag_hasminimum));
}
/*********************************************************************************
HandlePopupChanged
a popup menu has been clicked, act accordingly
*********************************************************************************/
void CTaxTableViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
UInt8 value = popupMenu->GetValue();
switch (popupMenu->GetPaneID())
{
case tag_firsttype:
SetAmountEnabled(tag_firstamount, value);
SetFieldVisible(tag_hasmaximum, value != tax_nothing);
SetFieldVisible(tag_hasminimum, value != tax_nothing);
//FormatTaxItemField(value);
SetFieldVisible(tag_subtractfromtable1, value != tax_nothing);
SetFieldVisible(tag_maximum, value != tax_nothing && GetCheckboxValue(tag_hasmaximum));
SetFieldVisible(tag_minimum, value != tax_nothing && GetCheckboxValue(tag_hasminimum));
break;
case tag_secondtype:
SetAmountEnabled(tag_secondamount, value);
SetFieldVisible(tag_subtractfromtable2, value != tax_nothing);
break;
case tag_thirdtype:
SetAmountEnabled(tag_thirdamount, value);
SetFieldVisible(tag_subtractfromtable3, value != tax_nothing);
break;
case tag_fourthtype:
SetAmountEnabled(tag_fourthamount, value);
SetFieldVisible(tag_subtractfromtable4, value != tax_nothing);
break;
case tag_fifthtype: // TCS 4/24/00
SetAmountEnabled(tag_fifthamount, value);
SetFieldVisible(tag_subtractfromtable5, value != tax_nothing);
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}/*********************************************************************************
HandleCheckboxClicked
handle a checkbox click
*********************************************************************************/
void CTaxTableViewer::HandleCheckboxClicked(CTCS_StdCheckbox *checkbox)
{
TCS_FailNILMsg(checkbox, TCS_GetErrString(errID_BadCheckbox));
Boolean value = checkbox->GetValue();
switch (checkbox->GetPaneID())
{
case tag_hasmaximum:
SetFieldVisible(tag_maximum, value);
break;
case tag_hasminimum:
SetFieldVisible(tag_minimum, value);
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleCheckboxClicked(checkbox);
}
/******************************************************************************
ListenToMessage
Responds to a message v1.28, 01-30-96, 12-30-96
*******************************************************************************/
void CTaxTableViewer::ListenToMessage(MessageT inMessage, void *ioParam)
{
switch (inMessage)
{
case msg_TableEditCellChanged:
case msg_TableCVCellChanged:
{ // find the tax table
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_withholdtable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
// was a to value changed?
table->ValidateToFromValues();
}
break;
case msg_TableNewRow :
{ // find the tax table
CToFromTable *table =
TCS_SAFE_CAST(FindPaneByID(tag_withholdtable), CToFromTable);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadObject));
// fill in some values
table->FillToFromValues();
}
break;
}
// Always call inherited method
THE_SUPERCLASS::ListenToMessage(inMessage, ioParam);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/******************************************************************************
FormatTaxItemField TCS 5/19/99 removed 5/1/00
format the tax item field
*******************************************************************************/
/*void CTaxTableViewer::FormatTaxItemField(const UInt8 type)
{
switch (type)
{
case tax_taxitem:
SetCVFieldVisible(tag_taxitem, true);
SetCVClassID(tag_taxitem, id_TaxItem);
break;
case tax_taxcalculation:
SetCVFieldVisible(tag_taxitem, true);
SetCVClassID(tag_taxitem, id_CalcPayroll);
break;
case tax_summation:
SetCVFieldVisible(tag_taxitem, true);
SetCVClassID(tag_taxitem, id_CalcSummation);
break;
default:
SetCVFieldVisible(tag_taxitem, false);
break;
}
}*/
/******************************************************************************
SetAmountEnabled
set the enablement of an amount field
*******************************************************************************/
void CTaxTableViewer::SetAmountEnabled(const TagType tag, const SInt32 type)
{
switch (type)
{
case tax_federaldollar:
case tax_statedollar:
case tax_localdollar:
case tax_otherdollar: // TCS 5/1/00
case tax_nothing:
case tax_taxitem:
case tax_taxcalculation:
case tax_summation:
SetFieldVisible(tag, false);
break;
default:
SetFieldVisible(tag, true);
break;
}
if (type == tax_percent)
SetFieldType(tag, fieldtype_percent);
else
SetFieldType(tag, fieldtype_emoney);
}
|