Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CProjectPTViewer
This class manages project payment terms for the Goldenseal accounting software,
small business management software, construction
project management software and
construction estimating software.
It's a viewer for project payment terms. Setup for project billing in
Goldenseal project management software
SUPERCLASS = CPaymentTermViewer
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CProjectPTViewer::CProjectPTViewer(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo)
: THE_SUPERCLASS(inPaneInfo, inViewInfo)
{
}
Source Code
/*********************************************************************************
FinishUpdatingFields split TCS 4/17/00
Finish prep work after updating fields from an object, but before displaying them
*********************************************************************************/
void CProjectPTViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
// format the mgmt fee type field
UInt8 managementFeeType;
TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadObject));
TCS_ASSERTMsg(viewerObject->GetMemberValue(tag_managefeetype,
type_enum, &managementFeeType),
TCS_GetErrString(errID_BadValue));
FormatManagementFeeField(managementFeeType);
}
/*********************************************************************************
HandlePopupChanged
a popup menu has been clicked, act accordingly
*********************************************************************************/
void CProjectPTViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
switch (popupMenu->GetPaneID())
{
case tag_managefeetype:
FormatManagementFeeField(popupMenu->GetValue());
break;
/*case tag_paytype:
FormatTandMFields(popupMenu->GetValue());
break;*/
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}
/*********************************************************************************
HandleCheckboxClicked TCS 10/16/02
handle a checkbox click
*********************************************************************************/
void CProjectPTViewer::HandleCheckboxClicked(CTCS_StdCheckbox *checkbox)
{
TCS_FailNILMsg(checkbox, TCS_GetErrString(errID_BadCheckbox));
Boolean value = checkbox->GetValue();
switch (checkbox->GetPaneID())
{
case tag_multiplemarkups:
FormatManagementFeeEnabled(value, GetPopupValue(tag_managefeetype));
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleCheckboxClicked(checkbox);
}
/*********************************************************************************
HandleEditChanged TCS 10/16/02
an editfield has changed, act accordingly
*********************************************************************************/
void CProjectPTViewer::HandleEditChanged(CTCS_EditField *editField)
{
TCS_FailNILMsg(editField, TCS_GetErrString(errID_BadField));
switch (editField->GetPaneID())
{
case tag_managefeematerials:
if (!GetCheckboxValue(tag_multiplemarkups))
{
FormatManagementFeeEnabled(false, GetPopupValue(tag_managefeetype));
}
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandleEditChanged(editField);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FormatManagementFeeField
format the mgmt fee fields as dollar or percent based on the setting
*********************************************************************************/
void CProjectPTViewer::FormatManagementFeeField(const UInt8 feeType)
{
if (feeType == calc_dollars)
{
SetFieldType(tag_managefeematerials, fieldtype_money);
SetFieldType(tag_managefeelabor, fieldtype_money); // TCS 10/15/02
SetFieldType(tag_managefeeequipment, fieldtype_money);
SetFieldType(tag_managefeesubs, fieldtype_money);
SetFieldType(tag_managefeeothers, fieldtype_money);
SetFieldEnabled(tag_multiplemarkups, false); // TCS 10/16/02
SetFieldValue(tag_multiplemarkups, false);
}
else
{
SetFieldType(tag_managefeematerials, fieldtype_percent);
SetFieldType(tag_managefeelabor, fieldtype_percent); // TCS 10/15/02
SetFieldType(tag_managefeeequipment, fieldtype_percent);
SetFieldType(tag_managefeesubs, fieldtype_percent);
SetFieldType(tag_managefeeothers, fieldtype_percent);
SetFieldEnabled(tag_multiplemarkups, true); // TCS 10/16/02
}
FormatManagementFeeEnabled(GetCheckboxValue(tag_multiplemarkups), feeType);
}
/*********************************************************************************
FormatManagementFeeEnabled TCS 10/16/02
format the mgmt fee field enablement
*********************************************************************************/
void CProjectPTViewer::FormatManagementFeeEnabled(const Boolean useMultiples,
const UInt8 feeType)
{
// set the field title, since the logic is different TCS 11/13/02
if (useMultiples && feeType == calc_percent)
SetFieldTitle(tag_managefeematerials, TCS_GetStockString(stockID_Materials));
else
SetFieldTitle(tag_managefeematerials, TCS_GetStockString(stockID_AllItems));
// if we are not using multiple markups, let's fill in some
// "sensible" values in the unused fields. Note that we always do
// this, even when loading an existing record. Normally we don't
// bother with that, but the extra markup fields are new, and
// older records have values which aren't "sensible".
if (feeType == calc_dollars)
{
// for flat markup, we make the unused items zero,
// since we'll only use the one amount.
CMoney zero = 0;
SetFieldMoneyValue(tag_managefeelabor, zero);
SetFieldMoneyValue(tag_managefeeequipment, zero);
SetFieldMoneyValue(tag_managefeesubs, zero);
SetFieldMoneyValue(tag_managefeeothers, zero);
SetFieldEnabled(tag_managefeelabor, false);
SetFieldEnabled(tag_managefeeequipment, false);
SetFieldEnabled(tag_managefeesubs, false);
SetFieldEnabled(tag_managefeeothers, false);
return;
}
else if (!useMultiples)
{
// for percent markup, we make them all the same, since
// that's how the math will work
CMoney matMarkup = GetFieldMoneyValue(tag_managefeematerials);
SetFieldPercentValue(tag_managefeelabor, matMarkup);
SetFieldPercentValue(tag_managefeeequipment, matMarkup);
SetFieldPercentValue(tag_managefeesubs, matMarkup);
SetFieldPercentValue(tag_managefeeothers, matMarkup);
}
// also set the field enablement
SetFieldEnabled(tag_managefeelabor, useMultiples);
SetFieldEnabled(tag_managefeeequipment, useMultiples);
SetFieldEnabled(tag_managefeesubs, useMultiples);
SetFieldEnabled(tag_managefeeothers, useMultiples);
}
|