Link to: header | transactions
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
This class manages equipment hours for the Goldenseal accounting software,
time tracking software, construction
project management software and
construction
accounting software.
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CEquipmentLog::CEquipmentLog()
{
mStatus = status_Entered;
mSpareByte = 0;
mMainAccountClass = id_EquipmentAccount;
//mJobCosted = mTMBilled = mPartTMBilled = false;
mBeenPaid = true; // start out paid since no pmt needed TCS 5/18/00
mEmployee = 0;
mTMBillingRate = mJobCostRate = 0;
mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}
Source Code
/*********************************************************************************
GetFileLength rev TCS 3/6/01
return the file length used by this object
*********************************************************************************/
NeoSize CEquipmentLog::GetFileLength(const CNeoFormat *aFormat) const
{
return THE_SUPERCLASS::GetFileLength(aFormat) + cFileLength;
}/*********************************************************************************
CopyFrom
copy the data members from the passed object. This is used to implement
duplicate. source should be an object of the same class as this object
*********************************************************************************/
void CEquipmentLog::CopyFrom(DB_PersistentObject *source, const UInt8 copyFlags)
{
THE_SUPERCLASS::CopyFrom(source, copyFlags);
CEquipmentLog *src = TCS_SAFE_CAST(source, CEquipmentLog);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));
TCS_BlockMove(&src->mStatus, &mStatus, cCopyFileLength);
if (HasLockedStatus()) // TCS 2/2/99
mStatus = GetStarterStatus(); // rev TCS 3/8/00
}/*********************************************************************************
GetMemberValue
return the value of the member with the given tag
*********************************************************************************/
Boolean CEquipmentLog::GetMemberValue(const TagType aTag, const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_billingrate:
return ConvertObjectIDMember(mTMBillingRate, id_EquipBillingRate, aValue, aType);
break;
case tag_jobcostrate:
return ConvertObjectIDMember(mJobCostRate, id_EquipBillingRate, aValue, aType);
break;
case tag_employee:
return ConvertObjectIDMember(mEmployee, id_EmployeeAccount, aValue, aType);
break;
case tag_status:
return ConvertEnumMember(mStatus, MENU_EquipmentLogStatus, aValue, aType);
break;
case tag_timeunit: // rev TCS 11/10/03
return ConvertEnumMember(mTimeUnit, MENU_EquipmentTimeUnits, aValue, aType);
break;
case tag_breakdown:
return ConvertEnumMember(mBreakdownType, MENU_TimeCatItemBreakdown, aValue, aType);
break;
case tag_actualequipment: // for job cost item reports TCS 4/15/02
return ConvertMember(&mJobCostAmount, type_money, aValue, aType);
break;
case tag_billingamount: // the billing amount is the same as regular amount
return ConvertMember(&mAmount, type_money, aValue, aType);
break;
case tag_costarea: // calculated-- for reports // TCS 7/10/02
return ConvertEnumMember(costtype_equipment, MENU_EstimateItemCostTypes, aValue, aType);
break;
default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
SetMemberValue
set the value of the member with the given tag
*********************************************************************************/
Boolean CEquipmentLog::SetMemberValue(const TagType aTag, const TagType aType,
const void *aValue)
{
switch (aTag)
{
case tag_billingrate:
return ConvertDataToObjectID(aValue, aType, &mTMBillingRate, id_EquipBillingRate);
break;
case tag_jobcostrate:
return ConvertDataToObjectID(aValue, aType, &mJobCostRate, id_EquipBillingRate);
break;
case tag_employee:
return ConvertDataToObjectID(aValue, aType, &mEmployee, id_EmployeeAccount);
break;
case tag_status:
return ConvertMember(aValue, aType, &mStatus, type_enum);
break;
default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
ReadObject
read the persistent object's data in from a stream
*********************************************************************************/
void CEquipmentLog::ReadObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
CNeoDebugImport checker(aStream, this, cCheckTooSmall); // TCS 2/24/00
THE_SUPERCLASS::ReadObject(aStream, aTag);
if (!IsIOValid()) // TCS 2/5/02
return;
/// aStream->ReadChunk(&mStatus, cFileLength);
mStatus = aStream->ReadChar(); // mfs_sa rev 20feb2k3
mSpareByte = aStream->ReadChar();
mEmployee = aStream->ReadID();
mTMBillingRate = aStream->ReadID();
mJobCostRate = aStream->ReadID();
mEndSafetyTag = aStream->ReadEndSafetyTag(this);
if (!IsValidEndTag(mEndSafetyTag)) // TCS 9/8/02
ReportDamagedObject(GetDBClassID(), GetDBID());
}
/*********************************************************************************
WriteObject
write the persistent object's data to a stream
*********************************************************************************/
void CEquipmentLog::WriteObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
// make sure we have valid data to write TCS 9/8/02
if (!IsValidEndTag(mEndSafetyTag))
{
ReportDamagedObject(GetDBClassID(), GetDBID());
mEndSafetyTag = tag_endsafetytag; // TCS 11/26/02
}
CNeoDebugExport checker(aStream, this, cCheckTooSmall);
THE_SUPERCLASS::WriteObject(aStream, aTag);
aStream->WriteChar(mStatus); // mfs_sa rev 20feb2k3
aStream->WriteChar(mSpareByte);
aStream->WriteID(mEmployee);
aStream->WriteID(mTMBillingRate);
aStream->WriteID(mJobCostRate);
aStream->WriteEndSafetyTag(mEndSafetyTag, this);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FinishViewerCreate TCS 1/19/04
fill in values after creation
*********************************************************************************/
void CEquipmentLog::FinishViewerCreate()
{
// let the superclass do its stuff
THE_SUPERCLASS::FinishViewerCreate();
// for labor-only, fill in the employee ID
if (gDBFile->LaborHoursOnly())
{
mEmployee = gDBFile->GetEmployeeID();
}
}
/*********************************************************************************
FinishNonViewerCreate rev TCS 9/29/02
fill in values after creation from an AFW drag
*********************************************************************************/
void CEquipmentLog::FinishNonViewerCreate()
{
// let the superclass do its stuff
THE_SUPERCLASS::FinishNonViewerCreate();
// for labor-only, fill in the employee ID TCS 1/19/04
if (gDBFile->LaborHoursOnly())
{
mEmployee = gDBFile->GetEmployeeID();
}
// the reference number must always be equal to the object id
mReferenceNum = GetDBID();
CEquipmentAccount *account =
TCS_SAFE_CAST(gDBFile->GetOneObject(id_EquipmentAccount, mMainAccount),
CEquipmentAccount);
if (account)
{ // there is an account, so we can proceed
DB_ObjectWatcher watcher(account);
// update the billing rate field
if (!mTMBillingRate)
{
account->GetMemberValue(tag_billingrate, type_objectid, &mTMBillingRate);
}
// update the job cost rate field
if (!mJobCostRate)
{
account->GetMemberValue(tag_jobcostrate, type_objectid, &mJobCostRate);
}
// no need to set billing amount or t&m amount, since both start at zero
mTimeUnit = account->GetTimeUnit(); // TCS 1/20/04
}
}
/*********************************************************************************
FinishTemplateCreate TCS 8/17/01
fill in values after creation from a template or recurring transaction.
We might as well recalculate billing rate, since it may have changed.
*********************************************************************************/
void CEquipmentLog::FinishTemplateCreate()
{
// let the superclass do its stuff
THE_SUPERCLASS::FinishTemplateCreate();
// for labor-only, fill in the employee ID TCS 1/19/04
if (gDBFile->LaborHoursOnly())
{
mEmployee = gDBFile->GetEmployeeID();
}
// calculate the t&m billing amount
mAmount = CalculateTMBillingAmount(id_EquipmentHours, mTimeUsed, mMainAccount,
mTimeUnit, mTMBillingRate, mAmount, 0);
}
/*********************************************************************************
FinishImportCreate TCS 8/11/99
fill in values after creation from an import
*********************************************************************************/
void CEquipmentLog::FinishImportCreate()
{
// let the superclass do its stuff
THE_SUPERCLASS::FinishImportCreate();
// we used to recalc the wage amount and billing amount, but that causes
// problems if rate has changed. TCS removed 9/29/02
}
/*********************************************************************************
FinishBreakdownUpdate TCS 4/17/01 rev 2/22/02 rev 1/25/03 removed 6/10/03 rev 2/18/04
If there is no cost area column, we fill in the cost area
*********************************************************************************/
void CEquipmentLog::FinishBreakdownUpdate(CBreakdownEntry *breakdown, CBreakdownTable *table)
{
TCS_FailNILMsg(breakdown, TCS_GetErrString(errID_BadBreakdown));
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
if (!table->HasColumn(tag_costarea))
{
UInt8 costArea = costtype_equipment;
breakdown->SetMemberValue(tag_costarea, type_enum, &costArea);
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
PostNewRecord TCS 11/20/03
post info for a new record
*********************************************************************************/
void CEquipmentLog::PostNewRecord(const UInt8 creationType)
{
PostUseCount(id_EmployeeAccount, mEmployee);
PostUseCount(id_EquipBillingRate, mTMBillingRate);
PostUseCount(id_EquipBillingRate, mJobCostRate);
// let the superclass do any posting
THE_SUPERCLASS::PostNewRecord(creationType);
}
/*********************************************************************************
PostDeletion TCS 11/20/03
post info from a deleted record
*********************************************************************************/
void CEquipmentLog::PostDeletion(const Boolean postAudit)
{
PostUseCount(id_EmployeeAccount, mEmployee, cRemoveItem);
PostUseCount(id_EquipBillingRate, mTMBillingRate, cRemoveItem);
PostUseCount(id_EquipBillingRate, mJobCostRate, cRemoveItem);
// let the superclass do any posting
THE_SUPERCLASS::PostDeletion(postAudit);
}
/*********************************************************************************
PostRecordActivated TCS 12/4/99
post info from a newly created or activated transaction record
*********************************************************************************/
void CEquipmentLog::PostRecordActivated(const UInt8 creationType)
{
// update account balances
if (creationType != record_jobcosttoactive) // rev TCS 12/17/99
PostEquipmentIncome(GetJobCostAmount());
// let the superclass do any posting
THE_SUPERCLASS::PostRecordActivated(creationType);
}
/*********************************************************************************
PostRecordCancelled TCS 12/4/99
post info from a deleted or voided transaction record
*********************************************************************************/
void CEquipmentLog::PostRecordCancelled(const UInt8 cancelType)
{
// update account balances
if (cancelType != record_activetojobcost) // rev TCS 12/17/99
PostEquipmentIncome(-GetJobCostAmount(), cRemoveItem);
// let the superclass do any posting
THE_SUPERCLASS::PostRecordCancelled(cancelType);
}
/*********************************************************************************
PostRecordChanging TCS 12/4/99
a record will be changing. Post the change.
*********************************************************************************/
void CEquipmentLog::PostRecordChanging(const Boolean accountChanging, const Boolean jobChanging)
{
PostEquipmentIncome(-GetJobCostAmount(), cRemoveItem);
PostUseCount(id_EmployeeAccount, mEmployee, cRemoveItem); // TCS 11/20/03
PostUseCount(id_EquipBillingRate, mTMBillingRate, cRemoveItem);
PostUseCount(id_EquipBillingRate, mJobCostRate, cRemoveItem);
// let the superclass do any posting
THE_SUPERCLASS::PostRecordChanging(accountChanging, jobChanging);
}
/*********************************************************************************
PostVoidRecordChanging TCS 12/17/99
a void record will be changing. Post the change.
*********************************************************************************/
void CEquipmentLog::PostVoidRecordChanging(const Boolean accountChanging, const Boolean jobChanging,
const UInt8 startingStatus, const UInt8 finalStatus)
{
if (startingStatus == status_JobCostOnly)
PostEquipmentIncome(-GetJobCostAmount(), cRemoveItem);
PostUseCount(id_EmployeeAccount, mEmployee, cRemoveItem); // TCS 11/20/03
PostUseCount(id_EquipBillingRate, mTMBillingRate, cRemoveItem);
PostUseCount(id_EquipBillingRate, mJobCostRate, cRemoveItem);
THE_SUPERCLASS::PostVoidRecordChanging(accountChanging, jobChanging, startingStatus, finalStatus);
}
/*********************************************************************************
PostRecordChanged TCS 12/4/99
a record has changed. Post it.
*********************************************************************************/
void CEquipmentLog::PostRecordChanged(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
PostEquipmentIncome(GetJobCostAmount());
PostUseCount(id_EmployeeAccount, mEmployee); // TCS 11/20/03
PostUseCount(id_EquipBillingRate, mTMBillingRate);
PostUseCount(id_EquipBillingRate, mJobCostRate);
// let the superclass do any posting
THE_SUPERCLASS::PostRecordChanged(oldAmount, accountChanged, jobChanged);
}
/*********************************************************************************
PostVoidRecordChanged TCS 9/24/02
a void record has changed. Post it.
*********************************************************************************/
void CEquipmentLog::PostVoidRecordChanged(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
if (GetStatus() == status_JobCostOnly)
PostEquipmentIncome(GetJobCostAmount());
PostUseCount(id_EmployeeAccount, mEmployee); // TCS 11/20/03
PostUseCount(id_EquipBillingRate, mTMBillingRate);
PostUseCount(id_EquipBillingRate, mJobCostRate);
THE_SUPERCLASS::PostVoidRecordChanged(oldAmount, accountChanged, jobChanged);
}
/*********************************************************************************
PostRecordVoided TCS 12/17/99
a record has changed from active to inactive status. Post the change.
*********************************************************************************/
void CEquipmentLog::PostRecordVoided(const Boolean accountChanged, const Boolean jobChanged,
const UInt8 startStatus, const UInt8 finalStatus)
{
if (finalStatus == status_JobCostOnly)
PostEquipmentIncome(GetJobCostAmount());
THE_SUPERCLASS::PostRecordVoided(accountChanged, jobChanged, startStatus, finalStatus);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
PostEquipmentIncome TCS 12/4/99
post income to the equipment account
*********************************************************************************/
void CEquipmentLog::PostEquipmentIncome(const CMoney &changeAmount, const Boolean /*removeItem*/)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_Account *account = nil;
if (mMainAccount)
{
account = TCS_SAFE_CAST(gDBFile->GetOneObject(mMainAccountClass,
mMainAccount), DB_Account);
}
if (account)
{
DB_ObjectWatcher watcher(account);
// adjust the balance
account->AddIncome(changeAmount);
}
}
/*********************************************************************************
HandleTandMBilling TCS 9/7/99 rev TCS 5/5/00
deal with a billing event. We override since there are no payments
*********************************************************************************/
void CEquipmentLog::HandleTandMBilling(const DBid /*billID*/, const Boolean removeItem)
{
UInt8 saveType = PrepareViewerDisplay(); // TCS 8/22/00 rev TCS 10/23/00
if (removeItem)
SetToStarterStatus();
else
SetStatus(status_TandMBilled);
// update the display TCS 3/21/00
UpdateViewerDisplay(saveType);
}
/*********************************************************************************
HandlePaymentMade TCS 5/1/00
deal with a payment that has been made for this item. We override, since
we don't need to handle payments, period.
*********************************************************************************/
void CEquipmentLog::HandlePaymentMade(const CMoney &/*inAmount*/, const UInt8 /*sourceClass*/,
const DBid /*sourceID*/, const UInt8 /*transactionType*/, const Boolean /*removeItem*/)
{
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FillDataReport TCS 9/6/02
fill in a diagnostic table that shows data field values.
*********************************************************************************/
void CEquipmentLog::FillDataReport(CTCS_Table *table, CNeoStream *stream) const
{
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
TCS_FailNILMsg(stream, TCS_GetErrString(errID_BadStream));
THE_SUPERCLASS::FillDataReport(table, stream);
FillFieldEnumRow(table, stream, tag_status, mStatus, MENU_EquipmentLogStatus);
FillFieldStockRow(table, stream, stockID_Padding, cCharSize, SInt32(mSpareByte));
FillFieldObjectIDRow(table, stream, tag_employee, mEmployee, id_EmployeeAccount);
FillFieldObjectIDRow(table, stream, tag_billingrate, mTMBillingRate, id_EquipBillingRate);
FillFieldObjectIDRow(table, stream, tag_jobcostrate, mJobCostRate, id_EquipBillingRate);
FillEndSafetyTag(table, stream, mEndSafetyTag);
}
|