Link to: header | record viewer
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CMarkupSystemViewer
This class manages markups for the Goldenseal accounting software,
small business management software, construction
project management software and
construction estimating software.
It's a viewer for markups on sales and project work. A markup system calculates
markup on different types of work, using simple percentage markup or retail style
markup (1 / 1 - percent). Prices can be rounded or trimmed to a 'retail' price.
Part of the Goldenseal accounting software and point of sale software.
SUPERCLASS = DB_RecordViewer
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CMarkupSystemViewer::CMarkupSystemViewer(const SPaneInfo &inPaneInfo,
const SViewInfo &inViewInfo)
: DB_RecordViewer(inPaneInfo, inViewInfo)
{
}
Source Code
/*********************************************************************************
FinishUpdatingFields split TCS 4/17/00
Finish prep work after updating fields from an object, but before displaying them
*********************************************************************************/
void CMarkupSystemViewer::FinishUpdatingFields(const UInt8 creationMethod,
DB_PersistentObject *viewerObject)
{
// the superclass handles basic field updating
THE_SUPERCLASS::FinishUpdatingFields(creationMethod, viewerObject);
// now set the visiblity of markup fields
EnableMarkupField(tag_resalemarkup, tag_resalemarkuptype, tag_resalerounding);
EnableMarkupField(tag_reducedmarkup, tag_reducedmarkuptype, tag_reducedrounding);
EnableMarkupField(tag_projectmarkup, tag_projectmarkuptype, tag_projectrounding);
EnableMarkupField(tag_componentmarkup, tag_componentmarkuptype, tag_componentrounding);
EnableMarkupField(tag_inventorymarkup, tag_inventorymarkuptype, tag_inventoryrounding);
FormatRestockingCharge(GetPopupValue(tag_restockingchargetype)); // TCS 10/31/02
}
/*********************************************************************************
IsReadyToUpdateObject TCS 5/28/03
are we ready to close this item? We now give a warning for manual pricing
since it can cause difficult tech problems if users don't realize its implications
*********************************************************************************/
UInt8 CMarkupSystemViewer::IsReadyToUpdateObject(const UInt8 saveSource)
{
// let the superclass deal with it first
UInt8 results = THE_SUPERCLASS::IsReadyToUpdateObject(saveSource);
if (results != save_success)
return results;
if (GetPopupValue(tag_resalemarkuptype) == markup_manual ||
GetPopupValue(tag_reducedmarkuptype) == markup_manual ||
GetPopupValue(tag_projectmarkuptype) == markup_manual ||
GetPopupValue(tag_componentmarkuptype) == markup_manual ||
GetPopupValue(tag_inventorymarkuptype) == markup_manual)
{
if (TCS_OKCancelDialog(TCS_GetMsgString(msgID_RUSureManualPricing)))
return save_success;
else
return save_notready;
}
else
return save_success;
}
/*********************************************************************************
FinishObjectUpdate 8/3/01
If we've just changed a markup system, we need to ask and possibly update
all cost items and assemblies that use this markup
*********************************************************************************/
void CMarkupSystemViewer::FinishObjectUpdate(const UInt8 /*saveSource*/)
{
if (IsNewRecord())
return;
if (!TCS_YesNoDialog(TCS_GetMsgString(msgID_RecalcAllMarkups)))
return;
CUnitCost::UpdateAllUnitCosts(GetCurrentViewerObjectID()); // rev TCS 6/6/03
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
HandlePopupChanged
a cv field or popup has changed, act accordingly
*********************************************************************************/
void CMarkupSystemViewer::HandlePopupChanged(CTCS_StdPopupMenu *popupMenu)
{
// sanity check
TCS_FailNILMsg(popupMenu, TCS_GetErrString(errID_BadPopup));
// now process the popup
switch (popupMenu->GetPaneID())
{
case tag_resalemarkuptype:
EnableMarkupField(tag_resalemarkup, tag_resalemarkuptype, tag_resalerounding);
break;
case tag_reducedmarkuptype:
EnableMarkupField(tag_reducedmarkup, tag_reducedmarkuptype, tag_reducedrounding);
break;
case tag_projectmarkuptype:
EnableMarkupField(tag_projectmarkup, tag_projectmarkuptype, tag_projectrounding);
break;
case tag_componentmarkuptype:
EnableMarkupField(tag_componentmarkup, tag_componentmarkuptype, tag_componentrounding);
break;
case tag_inventorymarkuptype: // TCS 11/16/01
EnableMarkupField(tag_inventorymarkup, tag_inventorymarkuptype, tag_inventoryrounding);
break;
case tag_restockingchargetype: // TCS 10/31/02
FormatRestockingCharge(popupMenu->GetValue());
break;
default:
break;
}
// be sure to pass it along
THE_SUPERCLASS::HandlePopupChanged(popupMenu);
}
/*********************************************************************************
EnableMarkupField
enable/disable a markup field according to the markup type settings
*********************************************************************************/
void CMarkupSystemViewer::EnableMarkupField(const TagType fieldTag, const TagType calcTag,
const TagType roundingTag)
{
CMoney zeroPercent = 0;
if (FieldExists(calcTag)) // rev TCS 5/18/00
{
UInt8 setting = GetFieldValue(calcTag);
Boolean hasValue = (setting == markup_retail ||
setting == markup_simple ||
setting == markup_fixedaddition);
// set field enablement
SetFieldEnabled(fieldTag, hasValue);
SetCVFieldEnabled(roundingTag,(setting != markup_notavailable)); // bugfix TCS 1/27/00
// set field type
if (hasValue)
{
if (setting == markup_fixedaddition) // rev TCS 2/14/02
SetFieldType(fieldTag, fieldtype_money);
else
SetFieldType(fieldTag, fieldtype_percent);
}
else
{
SetFieldCString(fieldTag, zeroPercent.GetPercentString());
}
// forbid retail markups over 99%
if (setting == markup_retail)
{
CTextString markupString;
if (GetFieldCString(fieldTag, &markupString))
{
CMoney markup(markupString);
if (markup >= 100)
{
TCS_InfoAlert(TCS_GetMsgString(msgID_MarkupTooHigh));
CMoney ninetyNine = 99;
SetFieldCString(fieldTag, ninetyNine.GetPercentString());
}
}
}
}
}
/*********************************************************************************
FormatRestockingCharge TCS 10/31/02
format the restocking charge field
*********************************************************************************/
void CMarkupSystemViewer::FormatRestockingCharge(const SInt32 payType)
{
if (payType == calc_dollars)
SetFieldType(tag_restockingcharge, fieldtype_money);
else
SetFieldType(tag_restockingcharge, fieldtype_percent);
}
|