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

Accounting Transfers (Source Code)

Link to: header | transactions directory

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

Comments

CTransfer

This class manages basic accounting transfers in the Goldenseal accounting software,
estimating software, project management software and construction accounting software.

Each record is a transfer between two accounts.
This is an abstract class for several different transfer types-- Cash
Transfers, Job Cost Transfers, Chargebacks etc.

SUPERCLASS = CTransaction

Constructor

/*********************************************************************************
constructor
*********************************************************************************/
CTransfer::CTransfer()
{
mSecondAccountClass = 0; // subclasses should always overrride
mSecondAccount = 0;
mAmount = 0;
mTransferPadding = 0;
}

Source Code

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

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

CTransfer *src = TCS_SAFE_CAST(source, CTransfer);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));

TCS_BlockMove(&src->mSecondAccount, &mSecondAccount, cCopyFileLength);
}/*********************************************************************************

GetMemberValue

return the value of the member with the given tag

*********************************************************************************/
Boolean CTransfer::GetMemberValue(const TagType aTag, const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_secondaccount:
return ConvertObjectIDMember(mSecondAccount, mSecondAccountClass, aValue, aType);
break;

case tag_secondaccountclass:
return ConvertEnumMember(mSecondAccountClass, MENU_AccountClasses, aValue, aType);
break;

case tag_amount:
return ConvertMember(&mAmount, type_money, aValue, aType);
break;

case tag_secondaccountfullname: // TCS 10/31/02
case tag_secondaccountaddress:
case tag_secondaccountphone:
case tag_secondaccountemail:
return true;
break;
{
CTextString outString;

if (IS_TURTLE_CLASS_ID(mSecondAccountClass))
{
DB_PersistentObject *account = gDBFile->GetOneObject(mSecondAccountClass, mSecondAccount);

if (account)
{
DB_ObjectWatcher watcher(account);

if (aTag == tag_secondaccountfullname)
outString = account->GetFullName();
else if (aTag == tag_secondaccountaddress)
account->GetMemberValue(tag_address, type_cstring, &outString);
else if (aTag == tag_secondaccountphone)
account->GetMemberValue(tag_telephone, type_cstring, &outString);
else if (aTag == tag_secondaccountemail)
account->GetMemberValue(tag_email, type_cstring, &outString);
}
}

return ConvertMember(&outString, type_cstring, aValue, aType);
}
break;

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

SetMemberValue

set the value of the member with the given tag

*********************************************************************************/
Boolean CTransfer::SetMemberValue(const TagType aTag, const TagType aType,
const void *aValue)
{
switch (aTag)
{
case tag_secondaccount:
return ConvertDataToObjectID(aValue, aType, &mSecondAccount, mSecondAccountClass);
break;

case tag_secondaccountclass:
return ConvertMember(aValue, aType, &mSecondAccountClass, type_objclass);
break;

case tag_amount:
return ConvertMember(aValue, aType, &mAmount, type_money);
break;

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

ReadObject

read the persistent object's data in from a stream
*********************************************************************************/
void CTransfer::ReadObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));

CNeoDebugImport checker(aStream, this); // TCS 2/24/00

THE_SUPERCLASS::ReadObject(aStream, aTag);

if (!IsIOValid()) // TCS 2/5/02
return;

/// aStream->ReadChunk(&mSecondAccount, cFileLength);

mSecondAccount = aStream->ReadID(); // mfs_sa rev 20feb2k3

mAmount.ReadFromStream(aStream);

mSecondAccountClass = aStream->ReadChar();
mTransferPadding = aStream->ReadChar();
}/*********************************************************************************

WriteObject

write the persistent object's data to a stream
*********************************************************************************/
void CTransfer::WriteObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));

CNeoDebugExport checker(aStream, this);

THE_SUPERCLASS::WriteObject(aStream, aTag);

/// aStream->WriteChunk(&mSecondAccount, cFileLength);

aStream->WriteID(mSecondAccount); // mfs_sa rev 20feb2k3

mAmount.WriteToStream(aStream);

aStream->WriteChar(mSecondAccountClass);
aStream->WriteChar(mTransferPadding);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

PostNewRecord TCS 11/20/03

post info for a new record
*********************************************************************************/
void CTransfer::PostNewRecord(const UInt8 creationType)
{
PostUseCount(mSecondAccountClass, mSecondAccount);

// let the superclass do any posting
THE_SUPERCLASS::PostNewRecord(creationType);
}
/*********************************************************************************

PostDeletion TCS 11/20/03

post info from a deleted record
*********************************************************************************/
void CTransfer::PostDeletion(const Boolean postAudit)
{
PostUseCount(mSecondAccountClass, mSecondAccount, cRemoveItem);

// let the superclass do any posting
THE_SUPERCLASS::PostDeletion(postAudit);
}
/*********************************************************************************

PostRecordChanging TCS 11/20/03

a record will be changing. Post the change.
*********************************************************************************/
void CTransfer::PostRecordChanging(const Boolean accountChanging, const Boolean jobChanging)
{
PostUseCount(mSecondAccountClass, mSecondAccount, cRemoveItem);

THE_SUPERCLASS::PostRecordChanging(accountChanging, jobChanging);
}
/*********************************************************************************

PostRecordChanged TCS 11/20/03

a record has changed. Post it.
*********************************************************************************/
void CTransfer::PostRecordChanged(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
PostUseCount(mSecondAccountClass, mSecondAccount);

THE_SUPERCLASS::PostRecordChanged(oldAmount, accountChanged, jobChanged);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

VerifyImport

return whether a record can be imported
*********************************************************************************/
SInt32 CTransfer::VerifyImport()
{
if (HasVoidStatus()) // TCS 5/1/01
return import_OK;

if (!NeedsSecondAccountValue()) // TCS 9/6/01
return THE_SUPERCLASS::VerifyImport();

if (mSecondAccount && IS_TURTLE_CLASS_ID(mSecondAccountClass))
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));

// make sure the referenced account really exists
if (gDBFile->ObjectExists(mSecondAccountClass, mSecondAccount))
return THE_SUPERCLASS::VerifyImport();
else
return import_Fatal;
}
else
return import_Fatal;
}
/*********************************************************************************

FillDataReport TCS 9/6/02

fill in a diagnostic table that shows data field values.

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

FillFieldObjectIDRow(table, stream, tag_secondaccount, mSecondAccount, mSecondAccountClass);

FillFieldTagRow(table, stream, tag_amount, cMoneySize, mAmount.GetCurrencyString());

FillFieldEnumRow(table, stream, tag_secondaccountclass, mSecondAccountClass, MENU_AccountClasses);
FillFieldStockRow(table, stream, stockID_Padding, cCharSize, SInt32(mTransferPadding));
}