Accounting Software
Small Business Software Estimating Software
Inventory SoftwareInventory Tracking SoftwareInventory Control SoftwareInventory Management SoftwareConstruction Management SoftwareProject Management SoftwareBusiness Management Software

Other Costs (Source Code)

Link to: header | transactions directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

COtherCost

This class manages other costs for the Goldenseal accounting software,
small business management software, construction project management software and
construction accounting software.

Each record is a cost transaction for expenses from other cost suppliers. These transactions
cover expenses for utilities, insurance, taxes and any other job costs that
aren't equipment, labor, materials or subcontractors.

Other Cost transactions are also owners of sales tax and payroll tax payment
breakdowns, to sales tax agencies and payroll tax agencies.

SUPERCLASS = CMaterialPurchase

Constructor

/*********************************************************************************
constructor
*********************************************************************************/
COtherCost::COtherCost()
{
mMainAccountClass = id_OtherCostAccount;

mOCEndSafetyTag = tag_endsafetytag;
}

Source Code

/*********************************************************************************

GetFileLength

return the file length to reserve for this object

*********************************************************************************/
NeoSize COtherCost::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 COtherCost::CopyFrom(DB_PersistentObject *source, const UInt8 copyFlags)
{
THE_SUPERCLASS::CopyFrom(source, copyFlags);

COtherCost *src = TCS_SAFE_CAST(source, COtherCost);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));
// no members to copy here
}/*********************************************************************************

GetMemberValue

return the value of the member with the given tag

*********************************************************************************/
Boolean COtherCost::GetMemberValue(const TagType aTag,
const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_breakdown: // TCS 4/3/00
return ConvertEnumMember(mBreakdownType, MENU_OtherCostBreakdown, aValue, aType);
break;

case tag_actualother: // for job cost item reports TCS 4/15/02
return ConvertMember(&mAmount, type_money, aValue, aType);
break;

case tag_actualmaterials: // for job cost item reports TCS 4/15/02
return false;
break;

case tag_costarea: // calculated-- for reports // TCS 7/10/02
return ConvertEnumMember(costtype_other, 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 COtherCost::SetMemberValue(const TagType aTag,
const TagType aType,
const void *aValue)
{
switch (aTag)
{


default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}
/*********************************************************************************

ReadObject

read the persistent object's data in from a stream
*********************************************************************************/
void COtherCost::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);

mOCEndSafetyTag = aStream->ReadEndSafetyTag(this); // TCS 9/8/02, mfs_sa 20feb2k3

if (!IsValidEndTag(mOCEndSafetyTag)) // TCS 9/8/02
ReportDamagedObject(GetDBClassID(), GetDBID());
}
/*********************************************************************************

WriteObject

write the persistent object's data to a stream
*********************************************************************************/
void COtherCost::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(mOCEndSafetyTag))
{
ReportDamagedObject(GetDBClassID(), GetDBID());
mOCEndSafetyTag = tag_endsafetytag; // TCS 11/26/02
}

CNeoDebugExport checker(aStream, this, cCheckTooSmall);
THE_SUPERCLASS::WriteObject(aStream, aTag);
aStream->WriteEndSafetyTag(mOCEndSafetyTag, this); // mfs_sa 20feb2k3
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

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 type
*********************************************************************************/
void COtherCost::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_other;
breakdown->SetMemberValue(tag_costarea, type_enum, &costArea);
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FillBreakdownsFromVendorStruct TCS 2/11/01

fill in tax payment breakdowns from the passed vendor info struct. This is
used for sales tax, payroll tax and vendor withholding payments via the
Pay Bills command.
*********************************************************************************/
void COtherCost::FillBreakdownsFromVendorStruct(SVendorInfo &vendorInfo, const UInt8 filterType)
{
// sanity check
TCS_FailNILMsg(vendorInfo.purchaseArray, TCS_GetErrString(errID_BadArray));
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
TCS_ASSERTMsg(!IsInDatabase(), TCS_GetErrString(errID_BadDatabaseChange));

UInt8 breakdownClass;

if (filterType == filter_salestax)
breakdownClass = id_SalesTaxBreakdownEntry;
else if (filterType == filter_vendorwithholding) // TCS 10/7/02
breakdownClass = id_VendorWithholdBreakdownEntry;
else
breakdownClass = id_TaxPayBreakdownEntry;

// fetch basic info
DBid ownerID = GetDBID(),
sourceID;
DBClass ownerClass = GetDBClassID(),
sourceClass;
DBid breakdownID;
SInt32 breakdownIndex,
breakdownsCompleted = 0;
CMoney oldAmount;
CTaxPaymentBreakdownEntry *entry;
Boolean isExisting = false;
DB_PersistentObject *source;
CDate date;

// walk through the items in the tax item array
TPurchaseInfoArrayIterator iterator(*(vendorInfo.purchaseArray));
SPurchaseInfo itemInfo;
while (iterator.Next(itemInfo))
{
entry = nil; // bugfix TCS 4/27/00
breakdownIndex = iterator.GetCurrentIndex();

if (mBreakdownArray.FetchItemAt(breakdownIndex, breakdownID)) // major rev TCS 4/20/00
{ // fetch an existing breakdown entry. Note that we don't
// put a watcher on it yet- that is done later on.
entry = TCS_SAFE_CAST(gDBFile->GetOneObject(breakdownClass, breakdownID),
CTaxPaymentBreakdownEntry);
if (entry)
isExisting = true;
}

if (!entry)
{ // create a new breakdown entry
entry = TCS_SAFE_CAST(gDBFile->CreateObjectFromID(breakdownClass,
flag_dontautoname), CTaxPaymentBreakdownEntry);

TCS_FailNILMsg(entry, TCS_GetErrString(errID_BadBreakdown));

entry->FinishNonViewerCreate(); // TCS 5/5/03

entry->SetCreationType(record_fromprocess); // TCS 6/25/03

// add it to the database. We watch it later TCS rev 5/1/03
gDBFile->AddObject(entry);

// add the new entry to the record
AddBreakdown(entry->GetDBID());
}
// set a watcher on the breakdown entry moved TCS 11/12/01
DB_ObjectWatcher entryWatcher(entry);

// increment the counter
breakdownsCompleted++;

// fetch the source transaction (which can be a sale or a payroll breakdown)
{
source = gDBFile->GetOneObject(itemInfo.classID, itemInfo.id);
TCS_FailNILMsg(source, TCS_GetErrString(errID_BadTransaction));

DB_ObjectWatcher sourceWatcher(source);

date = source->GetDate();
sourceID = source->GetMainAccountID(); // customer (sale) or employee (payroll)
sourceClass = source->GetMainAccountClass();
}

// update the record. We use a separate scope so the object will
// be returned to the database before it is dereferenced
{
DB_ObjectTempRemover remover (entry); // TCS 4/17/03 rev 8/26/03 TCS 10/31/03
if (remover.WasRemoved())
{
entry->SetMemberValue(tag_ownerobject, type_objectid, &ownerID);
entry->SetMemberValue(tag_ownerobjectclass, type_objclass, &ownerClass);

entry->SetMemberValue(tag_mainaccount, type_objectid, &vendorInfo.id); // TCS 8/8/01
entry->SetMemberValue(tag_mainaccountclass, type_objclass, &vendorInfo.classID); // TCS 8/8/01

entry->SetMemberValue(tag_secondaccount, type_objectid, &sourceID);
entry->SetMemberValue(tag_secondaccountclass, type_objclass, &sourceClass);

Boolean payIt = itemInfo.pay;
entry->SetMemberValue(tag_pay, type_boolean, &payIt);
entry->SetMemberValue(tag_date, type_date, &date);

entry->SetMemberValue(tag_taxtype, type_enum, &itemInfo.classID);
entry->SetMemberValue(tag_transactid, type_objectid, &itemInfo.id);

entry->SetMemberValue(tag_baseamount, type_money, &itemInfo.pendingAmount);
entry->SetMemberValue(tag_calcdeduction, type_money, &itemInfo.currentAmount);
entry->SetMemberValue(tag_adjustment, type_money, &itemInfo.adjustAmount);
entry->SetMemberValue(tag_amount, type_money, &itemInfo.payingAmount);
}
}
}

// remove any excess breakdowns
RemoveExcessBreakdowns(mBreakdownArray, breakdownClass, breakdownsCompleted);

// also update the total
mAmount = vendorInfo.payingAmount;
}
/*********************************************************************************

FillTaxPaymentReport TCS 4/19/02 rev 11/17/02

fill in tax payment info for the given report

*********************************************************************************/
void COtherCost::FillTaxPaymentReport(TTwoLevelArray *breakdownArray, const SReportInfo &reportInfo)
{
if (mDate.IsAfter(reportInfo.startDate) && mDate.IsBefore(reportInfo.endDate) && !HasVoidStatus())
{
TObjectIDArrayIterator iterator(mBreakdownArray);
DBid breakdownID, taxID, accountID;
CTaxPaymentBreakdownEntry *entry = nil;

while (iterator.Next(breakdownID))
{
entry = TCS_SAFE_CAST(gDBFile->GetOneObject(id_TaxPayBreakdownEntry, breakdownID),
CTaxPaymentBreakdownEntry);

if (entry)
{
DB_ObjectWatcher watcher (entry);
taxID = entry->GetTaxID();
accountID = entry->GetSecondAccountID();

entry->FillDoubleBreakdown(breakdownArray, taxID, accountID, true);
}
}
}
}
/*********************************************************************************

FillDataReport TCS 9/9/02

fill in a diagnostic table that shows data field values.

*********************************************************************************/
void COtherCost::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);

FillEndSafetyTag(table, stream, mOCEndSafetyTag);
}