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

Transactions (Source Code)

Link to: header | source code | source 3 | source 4 | transactions directory

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

Source Code

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

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

SetMainAccount

set the main (dest) account to the given account
*********************************************************************************/
void CTransaction::SetMainAccount(DB_Account *dest)
{
if (dest)
{
SetMainAccountID(dest->GetDBID());
SetMainAccountClass(dest->GetDBClassID());
}
else
{
SetMainAccountID(0);
SetMainAccountClass(0);
}
}
/*********************************************************************************

SetMainAccountID

set the dest account to the given account ID
*********************************************************************************/
void CTransaction::SetMainAccountID(const DBid id)
{
mMainAccount = id;
}
/*********************************************************************************

SetStatus TCS 7/13/99

set the value of the status member, if available. We override since we
may need to update transaction arrays so cv menus will work right

*********************************************************************************/
void CTransaction::SetStatus(const UInt8 inValue)
{
// let the superclass do its stuff
THE_SUPERCLASS::SetStatus(inValue);

// then update menu arrays. We skip it for a brand
// new record, though, to reduce the chance that we'll have
// a menu array entry for a record that isn't saved TCS rev 10/14/03
if (HasBeenPosted())
DB_ListManager::ChangeMenuStatus(this);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetMainAccountName

return the name of the main account TCS 9/10/98
*********************************************************************************/
CTextString CTransaction::GetMainAccountName() const
{
if (mMainAccount && mMainAccountClass)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_PersistentObject *account = gDBFile->GetOneObject(mMainAccountClass, mMainAccount);
if (account)
{
DB_ObjectWatcher watcher(account);
return account->GetName();
}
}
// if we get this far, we don't have a name so just return blank
return cEmptyString;
}
/*********************************************************************************

GetMenuName TCS 9/8/99

return the name used for listing in menus. The default is to use the basic
name if available. Otherwise we build it from the class name and reference number

Note that subclasses should override this only if some other method is used
to fill in a menu name when the name field is blank
*********************************************************************************/
CTextString CTransaction::GetMenuName() const
{
CTextString menuName = GetName();
if (!menuName.Length())
{
menuName = DB_ClassDescriptor::GetClassName(GetDBClassID());
menuName.AppendNumber(mReferenceNum); // rev TCS 1/29/01
}

return menuName;
}
/*********************************************************************************

GetLayoutIDFromClassID (static)

return the layout id that is used for the given breakdown type.

NOTE- the conversion the other way is in CBreakdownTransaction::GetClassIDFromLayoutID
*********************************************************************************/
ResIDT CTransaction::GetLayoutIDFromClassID(const DBid classID,
const UInt8 breakdown,
const SInt32 formType)
{
// a few transaction classes have a fixed set of breakdowns TCS 12/10/03
switch (classID)
{
case id_Assembly:
case id_Inspection:
case id_BillingStatement:
case id_Manufacture:
return DB_Layout::GetLayoutIDForForm(classID, formType);
break;

default:
break;
}

// for other transaction classes, we need to look at the breakdown
// to know which layout to use.
switch (breakdown)
{
case breakdown_none:
case breakdown_assembly: // bugfix TCS 4/25/01
return DB_Layout::GetLayoutIDForForm(classID, formType);
break;
case breakdown_longform:
return DB_Layout::GetLayoutIDForForm(classID, form_long);
break;

case breakdown_register:
return DB_Layout::GetLayoutIDForForm(classID, form_register);
break;

case breakdown_shortform:
return DB_Layout::GetLayoutIDForForm(classID, form_short);
break;

// Note that for breakdown transactions, we show the breakdown layout whether it's
// a long form or short form. We need to do that, otherwise short form changes
// will zap all the breakdowns.
case breakdown_estcategory:
case breakdown_costcategory:
case breakdown_salecategory:
case breakdown_laborcategory:
return classID + cCatBreakdownBaseID;
break;

case breakdown_estitem:
case breakdown_costitem:
case breakdown_saleitem:
case breakdown_laboritem:
case breakdown_inventoryitem:
return classID + cItemBreakdownBaseID;
break;

case breakdown_purchase:
return classID + cPurchaseBreakdownBaseID;
break;

case breakdown_rental:
return classID + cRentalBreakdownBaseID;
break;

case breakdown_commission:
return classID + cCommishBreakdownBaseID; // TCS 3/30/99
break;

case breakdown_wages:
return classID + cWageBreakdownBaseID;
break;

case breakdown_deduction:
return classID + cDeductionBreakdownBaseID;
break;

case breakdown_employertax:
return classID + cEmpTaxBreakdownBaseID;
break;

case breakdown_categorytax:
return classID + cCatTaxBreakdownBaseID;
break;

case breakdown_benefit:
return classID + cBenefitBreakdownBaseID;
break;

case breakdown_vacation:
return classID + cVacationBreakdownBaseID;
break;

case breakdown_draw:
return classID + cDrawBreakdownBaseID;
break;

case breakdown_payment:
return classID + cPaymentBreakdownBaseID;
break;

case breakdown_payrollrecord:
return classID + cPayrollBreakdownBaseID;
break;

case breakdown_progress:
return classID + cProgressBreakdownBaseID;
break;

case breakdown_timeandmaterials:
return classID + cTandMBreakdownBaseID;
break;

case breakdown_allowance:
return classID + cAllowBreakdownBaseID;
break;

case breakdown_changeorder:
return classID + cCOBreakdownBaseID;
break;
case breakdown_payrolltax: // TCS 6/21/99
return classID + cTaxPaymentBreakdownBaseID;
break;
case breakdown_salestax: // TCS 2/12/01
return classID + cSalesTaxBreakdownBaseID;
break;
case breakdown_vendorwithholding: // TCS 10/7/02
return classID + cVendorWithholdBreakdownBaseID;
break;

default: // rev TCS 3/20/99
TCS_DebugAlert("Oops, invalid breakdown type in CTransaction::GetLayoutIDFromClassID!");
return DB_Layout::GetLayoutIDForForm(classID, form_long);
break;
}
}
/*********************************************************************************

GetClassIDFromLayoutID

return the class id from a layout used for a given breakdown type

NOTE- the conversion the other way is in CTransaction::GetLayoutIDFromClassID
*********************************************************************************/
DBid CTransaction::GetClassIDFromLayoutID(const ResIDT layoutID,
const UInt8 breakdown)
{
switch (breakdown)
{
case breakdown_none:
return layoutID - cNoneBreakdownBaseID;
break;

case breakdown_estcategory:
case breakdown_costcategory:
case breakdown_salecategory:
case breakdown_laborcategory:
return layoutID - cCatBreakdownBaseID;
break;

case breakdown_estitem:
case breakdown_costitem:
case breakdown_saleitem:
case breakdown_laboritem:
case breakdown_inventoryitem:
return layoutID - cItemBreakdownBaseID;
break;

case breakdown_purchase:
return layoutID - cPurchaseBreakdownBaseID;
break;

case breakdown_rental:
return layoutID - cRentalBreakdownBaseID;
break;

case breakdown_wages:
return layoutID - cWageBreakdownBaseID;
break;

case breakdown_commission: // TCS 12/17/99
return layoutID - cCommishBreakdownBaseID;
break;

case breakdown_employertax:
return layoutID - cEmpTaxBreakdownBaseID;
break;

case breakdown_categorytax:
return layoutID - cCatTaxBreakdownBaseID;
break;

case breakdown_deduction:
return layoutID - cDeductionBreakdownBaseID;
break;

case breakdown_benefit:
return layoutID - cBenefitBreakdownBaseID;
break;

case breakdown_vacation:
return layoutID - cVacationBreakdownBaseID;
break;

case breakdown_draw:
return layoutID - cDrawBreakdownBaseID;
break;

case breakdown_payment:
return layoutID - cPaymentBreakdownBaseID;
break;

case breakdown_payrollrecord:
return layoutID - cPayrollBreakdownBaseID;
break;

case breakdown_progress:
return layoutID - cProgressBreakdownBaseID;
break;

case breakdown_timeandmaterials:
return layoutID - cTandMBreakdownBaseID;
break;

case breakdown_allowance:
return layoutID - cAllowBreakdownBaseID;
break;

case breakdown_changeorder:
return layoutID - cCOBreakdownBaseID;
break;

case breakdown_payrolltax: // TCS 6/21/99
return layoutID - cTaxPaymentBreakdownBaseID;
break;

case breakdown_salestax: // TCS 2/12/01
return layoutID - cSalesTaxBreakdownBaseID;
break;

case breakdown_vendorwithholding: // TCS 10/7/02
return layoutID - cVendorWithholdBreakdownBaseID;
break;

default:
return 0;
break;
}
}
/*********************************************************************************

GetEnumMenuID TCS 7/8/99

return the id of the menu used for the given tag

*********************************************************************************/
ResIDT CTransaction::GetEnumMenuID(const TagType tag, const Boolean importing) const
{
// first check the static method, for tags that don't come from MEMB definitions
ResIDT menuID = GetAccountMenuID(GetDBClassID(), tag);

if (menuID)
return menuID;
else // if no special menu, we can use the normal method to fetch menu id
return THE_SUPERCLASS::GetEnumMenuID(tag, importing);
}
/*********************************************************************************

GetAccountMenuID (static) TCS 7/8/99

return the id of the menu used for the given tag and class id. This code
assigns menu id's to a few tags that aren't set in MEMB resources.

*********************************************************************************/
ResIDT CTransaction::GetAccountMenuID(const DBid classID, const TagType tag)
{
switch (tag)
{
case tag_mainaccountclass:
case tag_secondaccountclass:
switch (classID)
{
case id_AddressBook:
case id_Appointment:
case id_ContactLog:
case id_DocumentLog:
case id_InfoLog:
case id_Policy:
case id_Prospect:
case id_ToDoList:
return MENU_MeetingAccountTypes;
break;

case id_Contract:
return MENU_ContractAccountTypes;
break;

case id_AssetTransfer: // TCS 4/30/99
if (tag == tag_mainaccountclass)
return MENU_AssetTransferTypes;
else
return MENU_ExpenseJobTypes;
break;

case id_CashTransfer:
return MENU_CashTransferTypes;
break;

case id_CashTransaction: // should only get here for reports
case id_CheckingTransaction: // since CBankTransaction overrides
case id_CreditCardTransaction: // perhaps we should use a custom menu
case id_EscrowTransaction: // that includes all possible items?
case id_InvestmentTransaction:
case id_LoanTransaction:
case id_SavingsTransaction:
return MENU_BankCheckAccountTypes;
break;

case id_BankCheck: // TCS 6/19/99
case id_BankPayment:
return MENU_BankCheckAccountTypes;
break;

case id_BankDeposit:
return MENU_BankDepositAccountTypes;
break;

case id_BankTransferIn:
return MENU_BankTransferInAccountTypes;
break;

case id_BankTransferOut:
return MENU_BankTransferOutAccountTypes;
break;

case id_BillingRecord:
return MENU_BillingAccountTypes;
break;

case id_Estimate:
return MENU_EstimateAccountTypes;
break;

case id_PaymentReceipt:
return MENU_PaymentReceiptAccountTypes;
break;

case id_InventoryUsed:
case id_MaterialPurchase:
case id_OtherCost:
case id_Bid:
return MENU_BidAccountTypes;
break;

case id_PurchaseWorkOrder:
case id_ProblemLog: // moved TCS 4/18/99
return MENU_POAccountTypes;
break;

case id_Chargeback:
return MENU_ChargebackAccountTypes;
break;

case id_CostTransfer:
return MENU_ExpenseJobTypes;
break;

case id_EquityTransfer:
return MENU_OwnerEquityAccountTypes;
break;

case id_InventoryTransfer:
return MENU_InventoryAccountTypes;
break;
}
break;

case tag_jobclass:
switch (classID)
{
case id_Bid:
return MENU_BidJobTypes;
break;

case id_InventoryUsed: // TCS 3/4/04
return MENU_InventoryUsedJobTypes;
break;

default:
return MENU_ExpenseJobTypes;
break;
}
break;

default:
break;
}
// if we got this far there is no special menu being used
return 0;
}
/*********************************************************************************

GetJobCostClass

get the cost class for a transaction or account TCS 9/10/98

*********************************************************************************/
UInt8 CTransaction::GetJobCostClass() const
{
// the cost class is usually based on the main account class
return GetJobCostArea(mMainAccountClass);
}
/*********************************************************************************

GetJobCostArea (static) TCS 9/10/98 rev TCS 7/29/99
renamed TCS 9/18/02

get the cost class for a transaction or account. This is generally based on
the main account class

*********************************************************************************/
UInt8 CTransaction::GetJobCostArea(const DBid inClass)
{
// the cost class is usually based on the main account class
switch (inClass)
{
case id_EquipmentAccount:
case id_EquipmentHours:
return costtype_equipment;
break;

case id_EmployeeAccount:
case id_LaborHours:
return costtype_labor;
break;

case id_InventoryAccount:
case id_InventoryUsed:
case id_MaterialAccount:
case id_MaterialPurchase:
return costtype_material;
break;

case id_SubcontractorAccount:
case id_SubcontractorLog:
return costtype_subcontractor;
break;

case id_OtherCostAccount:
case id_OtherCost:
case condition_OtherCharge: // TCS 4/16/01
case condition_InterestOut:
return costtype_other;
break;

case id_BillingRecord:
case id_PaymentReceipt:
case id_CustomerAccount:
case id_ProjectAccount:
case condition_OtherCredit: // TCS 4/16/01
case condition_InterestIn:
case filter_cashsalesbybranch: // TCS 4/17/01
case filter_cashsalesbydate:
case filter_billedsales:
case filter_billedprojects:
case filter_rentals:
return costtype_income;
break;

case id_OverheadAccount:
return costtype_overhead;
break;

default:
TCS_DebugAlert("Oops, bad case in CTransaction::GetJobCostClass!");
return 0;
break;
}
}
/*********************************************************************************

GetRefNumString TCS 2/20/01

return the reference number as a string.
*********************************************************************************/
CTextString CTransaction::GetRefNumString() const
{
CTextString outString = CNumbering::RefNumberToString(GetDBClassID(), mReferenceNum);
return outString;
}