Accounting Software
Small Business Software Estimating Software
Time Tracking SoftwareTime Management SoftwareTime Billing SoftwareProject Management SoftwareBookkeeping SoftwareContact Management SoftwareBusiness Management Software

Rental Payment Terms (Source Code)

Link to: header | lists directory

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

Comments

CRentalPaymentTerm

Payment terms for property rentals. This class handles tenant rent
payments. It's useful for any property manager, whether they own
property or manage it for others.

This class manages property rental payment terms for the Goldenseal accounting software,
property management software and rental property management software.

Related class: CPropertyTerms handles billing for property management
services provided to a property owner.

SUPERCLASS = CPaymentTerm

Constructor

/*********************************************************************************
default constructor
*********************************************************************************/
CRentalPaymentTerm::CRentalPaymentTerm()
{
mDiscountPeriodType = date_daysbeforedue;

mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}

Source Code

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

ReadObject

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

mEndSafetyTag = aStream->ReadEndSafetyTag(this); // mfs_sa rev 20feb2k3

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

WriteObject

write the persistent object's data to a stream
*********************************************************************************/
void CRentalPaymentTerm::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->WriteEndSafetyTag(mEndSafetyTag, this); // mfs_sa rev 20feb2k3

}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetTableColInfo

return information about table columns
*********************************************************************************/
Boolean CRentalPaymentTerm::CRentalPT_Desc::GetTableColInfo(const TagType tag,
const TableIndexT col,
STableColInfo *colInfo)
{
if (tag == tag_rentaldatetable)
{
switch (col)
{
case col_date:
colInfo->colType = coltype_caption;
colInfo->fieldType = fieldtype_date;
colInfo->colData = 0;
TCS_BufferFromText(colInfo->colName, CDate::ThisYearString() +
TCS_GetStockString(stockID_BillingDates), cTableColNameLength);
return true;
break;

default:
return false;
break;
}
}
else
return false;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

GetStartingAmount TCS 3/26/02

return the amount of the first rent payment, which may be partial
*********************************************************************************/
CMoney CRentalPaymentTerm::GetStartingAmount(const CMoney baseAmount, const CDate leaseStart)
{
CDate fullTermStart = GetPeriodStart(leaseStart);
CDate fullTermEnd = GetPeriodClose(leaseStart);


return baseAmount;
}
/*********************************************************************************

GetClosingAmount TCS 3/26/02

return the amount of the final rent payment, which may be partial
*********************************************************************************/
CMoney CRentalPaymentTerm::GetClosingAmount(const CMoney baseAmount, const CDate /*leaseEnd*/)
{
return baseAmount;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FillBasicRents TCS 3/26/02

fill in monthly rents for the rental period between the two dates

*********************************************************************************/
Boolean CRentalPaymentTerm::FillBasicRents(SLeaseInfo &leaseInfo, const CMoney baseAmount,
const CDate leaseStart, const CDate leaseEnd,
const CDate cutoffDate, const CMoney startAmount,
const CMoney endAmount, const Boolean /*isMonthToMonth*/)
{
TCS_FailNILMsg(leaseInfo.rentArray, TCS_GetErrString(errID_BadArray));

Boolean success = false;
SRentalInfo rentInfo;
CLease::InitializeRentalInfo(rentInfo);

CDate fullRentStart = GetPeriodClose(leaseStart);
fullRentStart.AddDays(1);

if (fullRentStart.IsAfter(leaseStart))
{
rentInfo.rentPeriod++;

// we start with a partial rental period
rentInfo.rentPeriodStart = leaseStart;
rentInfo.rentPeriodEnd = fullRentStart;
rentInfo.rentPeriodEnd.AddDays(-1);
rentInfo.type = condition_StartingRent;
rentInfo.amount = startAmount;

if (rentInfo.rentPeriodStart.IsBefore(cutoffDate))
{
rentInfo.bill = cPayNow;
rentInfo.totalDueAmount = rentInfo.amount;
leaseInfo.currentAmount += rentInfo.amount;
}
else
{
rentInfo.bill = cDontPayNow;
rentInfo.totalDueAmount = 0;
}

leaseInfo.rentArray->Append(rentInfo);
success = true;
}

rentInfo.rentPeriodStart = fullRentStart;
rentInfo.rentPeriodEnd = GetPeriodClose(fullRentStart);
rentInfo.type = condition_BasicRent;
rentInfo.amount = baseAmount;

Boolean stillLooking = true; // TCS 1/16/03

// fill in basic rent periods
while (rentInfo.rentPeriodEnd.IsBefore(leaseEnd) && stillLooking)
{
rentInfo.rentPeriod++;

if (rentInfo.rentPeriodStart.IsBefore(cutoffDate))
{
rentInfo.bill = cPayNow;
rentInfo.totalDueAmount = rentInfo.amount;
leaseInfo.currentAmount += rentInfo.amount;
}
else
{
rentInfo.bill = cDontPayNow;
rentInfo.totalDueAmount = 0;
}

// append the rent to the array
leaseInfo.rentArray->Append(rentInfo);
success = true;

// stop at the lease end or the cutoff date
if (leaseEnd.IsValidDate() || rentInfo.rentPeriodEnd.IsBefore(cutoffDate))
{
// move ahead by one rent period
rentInfo.rentPeriodStart = rentInfo.rentPeriodEnd;
rentInfo.rentPeriodStart.AddDays(1);
rentInfo.rentPeriodEnd = GetPeriodClose(rentInfo.rentPeriodStart);
}
else
stillLooking = false; // TCS 1/16/03
}

// do we have a partial month at the end?
if (rentInfo.rentPeriodStart.IsBefore(leaseEnd) &&
rentInfo.rentPeriodEnd.IsAfter(leaseEnd) && stillLooking)
{
rentInfo.rentPeriod++;

if (rentInfo.rentPeriodStart.IsBefore(cutoffDate))
{
rentInfo.bill = cPayNow;
rentInfo.totalDueAmount = rentInfo.amount;
leaseInfo.currentAmount += rentInfo.amount;
}
else
{
rentInfo.bill = cDontPayNow;
rentInfo.totalDueAmount = 0;
}

rentInfo.rentPeriodEnd = leaseEnd;
rentInfo.type = condition_ClosingRent;
rentInfo.amount = endAmount;

leaseInfo.rentArray->Append(rentInfo);
success = true;
}

return success;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FillDataReport TCS 9/7/02

fill in a diagnostic table that shows data field values.

*********************************************************************************/
void CRentalPaymentTerm::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, mEndSafetyTag);
}