Link to: header | lists directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CVendorWithholding
This class manages vendor withholding for the Goldenseal accounting software,
construction estimating software, project
management software and business management software.
a deduction that is withheld from vendors, and paid to a tax agency. In the
US this is used for backup withholding (rare) and for sales/use tax on items
purchased out of state. Vendor withholding taxes are common in some foreign
countries (e.g. Latin America).
This class also handles credits against sales tax-- for Canada GST and similar
VAT taxes in other countries.
SUPERCLASS = DB_DescribedPersistent
Constructor
/*********************************************************************************
default constructor
*********************************************************************************/
CVendorWithholding::CVendorWithholding()
{
mCalculationMethod = calc_paytoagency;
mVendorSpareByte = 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 CVendorWithholding::CopyFrom(DB_PersistentObject *source, const UInt8 copyFlags)
{
THE_SUPERCLASS::CopyFrom(source, copyFlags);
CVendorWithholding *src = TCS_SAFE_CAST(source, CVendorWithholding);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));
mCalculationMethod = src->mCalculationMethod;
}
/*********************************************************************************
GetFileLength TCS 8/16/00
return the file length used by this object
*********************************************************************************/
NeoSize CVendorWithholding::GetFileLength(const CNeoFormat *aFormat) const
{
NeoVersion version = GetVersion();
if (version > 1)
return THE_SUPERCLASS::GetFileLength(aFormat) + cFileLength2;
else
return THE_SUPERCLASS::GetFileLength(aFormat) + cFileLength;
}
/*********************************************************************************
GetMemberValue
return the value of the member with the given tag
*********************************************************************************/
Boolean CVendorWithholding::GetMemberValue(const NeoTag aTag, const NeoTag aType,
void *aValue) const
{
switch (aTag)
{
case tag_calcmethod: // TCS 9/15/03
return ConvertEnumMember(mCalculationMethod, MENU_VendorWithholdTypes, aValue, aType);
break;
default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}
/*********************************************************************************
SetMemberValue
set the value of the member with the given tag
*********************************************************************************/
Boolean CVendorWithholding::SetMemberValue(const NeoTag aTag, const NeoTag aType,
const void *aValue)
{
switch (aTag)
{
case tag_calcmethod: // TCS 9/15/03
return ConvertMember(aValue, aType, &mCalculationMethod, type_enum);
break;
default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}
/*********************************************************************************
ReadObject
read the persistent object's data in from a stream
*********************************************************************************/
void CVendorWithholding::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;
NeoVersion version = GetVersion(); // TCS 8/7/03
if (version > 1)
{
mCalculationMethod = aStream->ReadChar(); // TCS rev 9/15/03
mVendorSpareByte = aStream->ReadChar();
}
mEndSafetyTag = aStream->ReadEndSafetyTag(this); // mfs_sa rev 20feb2k3
// validate the object end marker TCS 9/8/02
if (!IsValidEndTag(mEndSafetyTag))
ReportDamagedObject(GetDBClassID(), GetDBID());
}
/*********************************************************************************
WriteObject
write the persistent object's data to a stream
*********************************************************************************/
void CVendorWithholding::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);
NeoVersion version = GetVersion(); // TCS 8/7/03
if (version > 1)
{
aStream->WriteChar(mCalculationMethod); // TCS rev 9/15/03
aStream->WriteChar(mVendorSpareByte);
}
aStream->WriteEndSafetyTag(mEndSafetyTag, this); // mfs_sa rev 20feb2k3
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
GetTableColInfo
return information about table columns
*********************************************************************************/
Boolean CVendorWithholding::CVendorWithholding_Desc::GetTableColInfo(const TagType tag,
const TableIndexT col,
STableColInfo *colInfo)
{
if (tag == tag_SalesTaxTable)
{ // it's the tax table
colInfo->colData = 0;
switch (col)
{
case col_item:
TCS_BufferFromText(colInfo->colName,
TCS_GetStockString(stockID_Item), cTableColNameLength);
colInfo->colType = coltype_edit;
colInfo->fieldType = fieldtype_string;
return true;
break;
case col_percent:
TCS_BufferFromText(colInfo->colName,
TCS_GetStockString(stockID_Percentage), cTableColNameLength);
colInfo->colType = coltype_edit;
colInfo->fieldType = fieldtype_percent;
return true;
break;
default:
return false;
break;
}
}
else
return false;
}
/*********************************************************************************
CalculateWithholdingAmount rev TCS 10/5/02
return the withholding amount for this tax.
*********************************************************************************/
CMoney CVendorWithholding::CalculateWithholdingAmount(const CMoney &price) const
{
CMoney amount = price * mRate.GetPercentDecimal();
amount += mAddAmount;
amount = amount.GetRoundedValue(mRoundingType);
if (mCalculationMethod == calc_agencycredit) // TCS 9/15/03
return -amount;
else
return amount;
}
/*********************************************************************************
IsDeducted 9/15/03
do we deduct this item from purchase amounts?
*********************************************************************************/
Boolean CVendorWithholding::IsDeducted() const
{
switch (mCalculationMethod)
{
case calc_retainage:
case calc_deductandpay:
return true;
break;
case calc_paytoagency:
case calc_agencycredit:
default:
return false;
break;
}
}
/*********************************************************************************
IsPostedToAgency 9/15/03
do we post this item to tax accounts?
*********************************************************************************/
Boolean CVendorWithholding::IsPostedToAgency() const
{
switch (mCalculationMethod)
{
case calc_deductandpay:
case calc_paytoagency:
case calc_agencycredit:
return true;
break;
case calc_retainage:
default:
return false;
break;
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FillDataReport TCS 9/7/02
fill in a diagnostic table that shows data field values.
*********************************************************************************/
void CVendorWithholding::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);
NeoVersion version = GetVersion();
if (version > 1) // TCS 8/7/03
{
FillFieldEnumRow(table, stream, tag_calcmethod, mCalculationMethod, MENU_VendorWithholdTypes);
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mVendorSpareByte));
}
FillEndSafetyTag(table, stream, mEndSafetyTag);
}
|