Link to: header | transactions
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CEscrowTransaction
This class manages checking transactions for the Goldenseal accounting software,
small business management software, construction
project management software and
construction
accounting software.
Each record is an accounting transaction involving an escrow account. They are similar to other
bank transactions, but they involve an account that is neither an asset
nor a liability.
Escrow transactions cover money going in or out of a rental deposit escrow
account, or similar escrows.
SUPERCLASS = CBankTransaction
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CEscrowTransaction::CEscrowTransaction()
{
mCheckbookID = 0;
mFiller = 0;
mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}
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 CEscrowTransaction::CopyFrom(DB_PersistentObject *source, const UInt8 copyFlags)
{
THE_SUPERCLASS::CopyFrom(source, copyFlags);
CEscrowTransaction *src = TCS_SAFE_CAST(source, CEscrowTransaction);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));
TCS_BlockMove(&src->mCheckbookID, &mCheckbookID, cCopyFileLength);
}/*********************************************************************************
GetMemberValue
return the value of the member with the given tag
*********************************************************************************/
Boolean CEscrowTransaction::GetMemberValue(const TagType aTag, const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_bankaccount:
return ConvertObjectIDMember(mBankAccount, id_EscrowAccount, aValue, aType);
break;
case tag_checkbook: // TCS 12/17/00
return ConvertMember(&mCheckbookID, type_enum, aValue, aType);
break;
case tag_bankaccountclass: // this isn't a member but we still may need it
{
DBClass id = id_EscrowAccount;
return ConvertMember(&id, type_objclass, aValue, aType);
}
break;
case tag_nextcheck: // we get the next check number from the bank account
{
SInt32 refNum = 0;
CEscrowAccount *checkAccount =
TCS_SAFE_CAST(gDBFile->GetOneObject(id_EscrowAccount, mBankAccount),
CEscrowAccount);
if (checkAccount)
{
DB_ObjectWatcher watcher(checkAccount);
refNum = checkAccount->PeekNextCheckNumber(mConditions);
}
return ConvertMember(&refNum, type_long, aValue, aType);
}
break;
default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
SetMemberValue
set the value of the member with the given tag
*********************************************************************************/
Boolean CEscrowTransaction::SetMemberValue(const TagType aTag, const TagType aType,
const void *aValue)
{
switch (aTag)
{
case tag_bankaccount:
return ConvertDataToObjectID(aValue, aType, &mBankAccount, id_EscrowAccount);
break;
case tag_checkbook: // TCS 12/17/00
return ConvertMember(aValue, aType, &mCheckbookID, type_enum);
break;
default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}
/*********************************************************************************
ReadObject
read the persistent object's data in from a stream
*********************************************************************************/
void CEscrowTransaction::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;
mCheckbookID = aStream->ReadChar(); // mfs_sa 20feb2k3
mFiller = aStream->ReadChar();
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 CEscrowTransaction::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(mCheckbookID); // mfs_sa 20feb2k3
aStream->WriteChar(mFiller);
aStream->WriteEndSafetyTag(mEndSafetyTag, this);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FillBreakdownsFromVendorStruct TCS 10/7/02
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 CEscrowTransaction::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 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 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 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;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FillDataReport TCS 9/6/02
fill in a diagnostic table that shows data field values.
*********************************************************************************/
void CEscrowTransaction::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);
FillFieldTagRow(table, stream, tag_checkbook, cCharSize, SInt32(mCheckbookID));
FillFieldStockRow(table, stream, stockID_Padding, cCharSize, SInt32(mFiller));
FillEndSafetyTag(table, stream, mEndSafetyTag);
}
|