Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CEquipmentAccountViewer
This class manages equipment accounts for the Goldenseal accounting software,
small business management software, construction
project management software and
construction estimating software.
It's a viewer for equipment accounts, which help
with equipment
tracking .
The viewer includes
job costing and billing rates, plus depreciation
and other details.
SUPERCLASS = CAccountViewer
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CEquipmentAccountViewer::CEquipmentAccountViewer(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 CEquipmentAccountViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
TCS_FailNILMsg(viewerObject, TCS_GetErrString(errID_BadObject));
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
// set up the estimate field
PrepareEstimateField(id_EquipmentAccount, viewerObject->GetDBID()); // TCS 1/3/02
// if there's a rental rate field, set enablement of rental amount
// note that we always update the value if it's changed
DBid rateID = GetFieldValue(tag_rentalrate);
FormatRentalRateField(tag_rentalamount, rateID, true);
UpdateContactButton(id_EquipmentHours, button_viewhours); // TCS 11/24/02
}
/*********************************************************************************
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 CEquipmentAccountViewer::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_rentalrate:
FormatRentalRateField(tag_rentalamount, 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 CEquipmentAccountViewer::HandleDBButtonClicked(const TagType btnID)
{
if (btnID == button_viewhours)
{
DB_Account *account = TCS_SAFE_CAST(mCurrViewerObject, DB_Account);
TCS_FailNILMsg(account, TCS_GetErrString(errID_BadObject));
TObjectIDArray contactArray;
account->FetchMeetingArray(id_EquipmentHours, contactArray);
if (contactArray.GetCount() > 0)
{
DB_Editor::ShowEditorArray(id_EquipmentHours, contactArray, cShowLastRecord);
}
}
else
THE_SUPERCLASS::HandleDBButtonClicked(btnID);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FetchVariableBillingRate renamed TCS 4/23/03
return whether a billing rate is variable, and fetch the current rate
**********************************************************************************/
Boolean CEquipmentAccountViewer::FetchVariableBillingRate(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();
CEquipBillingRate *rate = TCS_SAFE_CAST(gDBFile->GetOneObject(id_EquipBillingRate,
rateID), CEquipBillingRate);
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->HasVariableRate();
}
} // if no rate, then we'll not allow entry into variable rate field
rateValue = 0;
return false;
}
/*********************************************************************************
FormatRentalRateField TCS 7/18/00
format the display of the equipment rental amount field.
*********************************************************************************/
void CEquipmentAccountViewer::FormatRentalRateField(const TagType fieldTag, const DBid rateID,
const Boolean updateValue)
{
CMoney rateValue = 0;
Boolean enableIt = false;
if (rateID)
enableIt = FetchVariableRentalRate(rateID, rateValue);
SetFieldEnabled(fieldTag, enableIt, cSetItalic);
if (!enableIt && updateValue)
SetFieldMoneyValue(fieldTag, rateValue);
}
/*********************************************************************************
FetchVariableRentalRate TCS 7/18/00
return whether a wage rate is variable, and fetch the current rate
**********************************************************************************/
Boolean CEquipmentAccountViewer::FetchVariableRentalRate(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();
CEquipRentalRate *rate = TCS_SAFE_CAST(gDBFile->GetOneObject(id_EquipRentalRate,
rateID), CEquipRentalRate);
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->HasVariableRate();
}
} // if no rate, then we'll not allow entry into variable rate field
rateValue = 0;
return false;
}
|