Link to: header | transactions
directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
CPurchase
This class manages material purchases for the Goldenseal accounting software,
small business management software, construction
project management software and
construction
accounting software.
Each record is a purchase transaction, for purchases made from vendors. This class handles
credit card, cash, billed and all other types of purchases.
We use purchases for accounts payable, job costing and time & materials billing.
Purchases also add to inventory.
This is one of the most common transactions used in the Goldenseal job costing
software, inventory software and accounting software.
SUPERCLASS = CExpenseTransaction
Constructor
/*********************************************************************************
constructor
*********************************************************************************/
CMaterialPurchase::CMaterialPurchase()
{
mMainAccountClass = id_MaterialAccount;
mPaymentMethod = method_billed;
mBillingDate.SetToToday();
mPaymentTerms = 0; // TCS bugfix 9/6/01
mPurchasePadding = 0;
mCheckbookNumber = 0;
mSkipUpdating = false;
mWithholdingRate = 0;
mWithholdingAmount = 0;
mRetainageAmount = 0;
mCurrency = 0; // TCS 12/10/03
mForeignAmount = 0;
#if TCS_EST_ONLY
mStatus = status_PriceUpdateOnly;
#endif
mMatEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}
Source Code
/*********************************************************************************
GetFileLength
return the file length to reserve for this object
*********************************************************************************/
NeoSize CMaterialPurchase::GetFileLength(const CNeoFormat *aFormat) const
{
NeoSize baseLength = THE_SUPERCLASS::GetFileLength(aFormat) +
mOneTimeVendorName.FileLength(cFullNameTextLen) +
mInvoiceNum.FileLength(cMenuTextLen); // TCS 3/14/00 moved 5/30/02
// subclasses don't include the validation tag TCS 9/8/02
NeoVersion version = GetVersion();
if (version == 1)
{
if (GetDBClassID() == id_MaterialPurchase)
return baseLength + cFileLength;
else
return baseLength + cParentFileLength;
}
else // TCS 12/10/03
{
if (GetDBClassID() == id_MaterialPurchase)
return baseLength + cFileLength2;
else
return baseLength + cParentFileLength2;
}
}
/*********************************************************************************
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 CMaterialPurchase::CopyFrom(DB_PersistentObject *source, const UInt8 copyFlags)
{
THE_SUPERCLASS::CopyFrom(source, copyFlags);
CMaterialPurchase *src = TCS_SAFE_CAST(source, CMaterialPurchase);
TCS_FailNILMsg(src, TCS_GetErrString(errID_BadRecord));
// copy the strings
mOneTimeVendorName = src->mOneTimeVendorName;
mInvoiceNum = src->mInvoiceNum;
TCS_BlockMove(&src->mPaymentTerms, &mPaymentTerms, cCopyFileLength);
}/*********************************************************************************
GetMemberValue
return the value of the member with the given tag
*********************************************************************************/
Boolean CMaterialPurchase::GetMemberValue(const TagType aTag, const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_paymentterm: // the details field
return ConvertObjectIDMember(mPaymentTerms, GetPaymentDetailsClass(GetPaymentMethod()),
aValue, aType);
break;
case tag_withholdingrate: // TCS 7/24/02
return ConvertObjectIDMember(mWithholdingRate, id_VendorWithholding, aValue, aType);
break;
case tag_currency: // TCS 12/10/03
return ConvertObjectIDMember(mCurrency, id_Currency, aValue, aType);
break;
case tag_status:
return ConvertEnumMember(mStatus, MENU_PurchaseStatus, aValue, aType);
break;
case tag_paymentmethod:
return ConvertEnumMember(mPaymentMethod, MENU_PurchasePaymentMethods, aValue, aType);
break;
case tag_withholdingamount: // TCS 7/24/02
return ConvertMember(&mWithholdingAmount, type_money, aValue, aType);
break;
case tag_retainage: // TCS 9/25/02
return ConvertMember(&mRetainageAmount, type_money, aValue, aType);
break;
case tag_foreignamount: // TCS 12/10/03
return ConvertMember(&mForeignAmount, type_money, aValue, aType);
break;
case tag_billingdate:
return ConvertMember(&mBillingDate, type_date, aValue, aType);
break;
case tag_onetimename: // TCS 8/17/00
if (mUseOneTimeName)
return ConvertMember(&mOneTimeVendorName, type_cstring, aValue, aType);
else if (mMainAccount && mMainAccountClass)
{ // rev TCS 4/14/01
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_PersistentObject *source = gDBFile->GetOneObject(mMainAccountClass, mMainAccount);
CTextString itemName;
if (source)
{
DB_ObjectWatcher watcher(source);
itemName = source->GetFullName();
if (!itemName.Length())
itemName = source->GetName();
}
return ConvertMember(&itemName, type_cstring, aValue, aType);
}
else
return true; // TCS 10/27/00
break;
case tag_invoicenum: // TCS 11/24/97
return ConvertMember(&mInvoiceNum, type_cstring, aValue, aType);
break;
case tag_onetimeitem: // TCS 8/17/00
return ConvertBitFieldMember(mUseOneTimeName, aValue, aType);
break;
case tag_skipupdating: // TCS 11/1/01
return ConvertBitFieldMember(mSkipUpdating, aValue, aType);
break;
default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
SetMemberValue
set the value of the member with the given tag
*********************************************************************************/
Boolean CMaterialPurchase::SetMemberValue(const TagType aTag, const TagType aType,
const void *aValue)
{
switch (aTag)
{
case tag_paymentterm: // the details field
return ConvertDataToObjectID(aValue, aType, &mPaymentTerms,
GetPaymentDetailsClass(GetPaymentMethod()));
break;
case tag_withholdingrate: // TCS 7/24/02
return ConvertDataToObjectID(aValue, aType, &mWithholdingRate, id_VendorWithholding);
break;
case tag_currency: // TCS 12/10/03
return ConvertDataToObjectID(aValue, aType, &mCurrency, id_Currency);
break;
case tag_paymentmethod:
return ConvertMember(aValue, aType, &mPaymentMethod, type_enum);
break;
case tag_withholdingamount: // TCS 7/24/02
return ConvertMember(aValue, aType, &mWithholdingAmount, type_money);
break;
case tag_retainage: // TCS 9/25/02
return ConvertMember(aValue, aType, &mRetainageAmount, type_money);
break;
case tag_foreignamount: // TCS 12/10/03
return ConvertMember(aValue, aType, &mForeignAmount, type_money);
break;
case tag_billingdate: // TCS 1/3/02
return ConvertMember(aValue, aType, &mBillingDate, type_date);
break;
case tag_onetimename: // TCS 8/17/00
if (mUseOneTimeName)
return SafeConvertString(aValue, aType, &mOneTimeVendorName);
else
{
if (IsInDatabase()) // TCS 5/31/00
{
TCS_TokenErrorAlert(errID_BadLengthChange, DB_ClassDescriptor::GetClassName(GetDBClassID()));
return false;
}
else
{
mOneTimeVendorName.MakeNull();
return true;
}
}
break;
case tag_invoicenum:
return SafeConvertString(aValue, aType, &mInvoiceNum);
break;
case tag_onetimeitem: // TCS 8/17/00
mUseOneTimeName = ConvertDataToBitField(aValue, aType);
return true;
break;
case tag_skipupdating: // TCS 11/1/01
mSkipUpdating = ConvertDataToBitField(aValue, aType);
return true;
break;
default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
ReadObject
read the persistent object's data in from a stream
*********************************************************************************/
void CMaterialPurchase::ReadObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
Boolean isMaterial = (GetDBClassID() == id_MaterialPurchase);
CNeoDebugImport checker(aStream, this, isMaterial); // TCS 2/24/00
THE_SUPERCLASS::ReadObject(aStream, aTag);
if (!IsIOValid()) // TCS 2/5/02
return;
NeoVersion version = GetVersion();
ReadTextFromStream(aStream, &mOneTimeVendorName);
ReadTextFromStream(aStream, &mInvoiceNum);
mPaymentTerms = aStream->ReadID(); // mfs_sa 20feb2k3
mWithholdingRate = aStream->ReadID();
mPaymentMethod = aStream->ReadChar();
*((UInt8*)&mPaymentMethod + sizeof(mPaymentMethod)) = aStream->ReadBits(2); // --Bitfield
mWithholdingAmount.ReadFromStream(aStream);
mRetainageAmount.ReadFromStream(aStream);
mBillingDate.ReadFromStream(aStream);
if (version > 1) // TCS 12/10/03
{
mCurrency = aStream->ReadID();
mForeignAmount.ReadFromStream(aStream);
}
// subclasses don't read safety tag
if (isMaterial)
mMatEndSafetyTag = aStream->ReadEndSafetyTag(this);
if (!IsValidEndTag(mMatEndSafetyTag)) // TCS 9/8/02
ReportDamagedObject(GetDBClassID(), GetDBID());
}
/*********************************************************************************
WriteObject
write the persistent object's data to a stream
*********************************************************************************/
void CMaterialPurchase::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(mMatEndSafetyTag))
{
ReportDamagedObject(GetDBClassID(), GetDBID());
mMatEndSafetyTag = tag_endsafetytag; // TCS 11/26/02
}
Boolean isMaterial = (GetDBClassID() == id_MaterialPurchase);
CNeoDebugExport checker(aStream, this, isMaterial);
THE_SUPERCLASS::WriteObject(aStream, aTag);
NeoVersion version = GetVersion();
WriteTextToStream(aStream, mOneTimeVendorName, cFullNameTextLen); // removed -1 TCS 2/28/00
WriteTextToStream(aStream, mInvoiceNum, cMenuTextLen);
aStream->WriteID(mPaymentTerms); // mfs_sa 20feb2k3
aStream->WriteID(mWithholdingRate);
aStream->WriteChar(mPaymentMethod);
aStream->WriteChar(*((UInt8*)&mPaymentMethod + sizeof(mPaymentMethod))); // --Bitfield
mWithholdingAmount.WriteToStream(aStream);
mRetainageAmount.WriteToStream(aStream);
mBillingDate.WriteToStream(aStream);
if (version > 1) // TCS 12/10/03
{
aStream->WriteID(mCurrency);
mForeignAmount.WriteToStream(aStream);
}
// subclasses don't write safety tag
if (isMaterial)
aStream->WriteEndSafetyTag(mMatEndSafetyTag, this);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
FinishNonViewerCreate TCS 9/6/01
fill in values after creation from an AFW drag
*********************************************************************************/
void CMaterialPurchase::FinishNonViewerCreate()
{
// let the superclass do its stuff
THE_SUPERCLASS::FinishNonViewerCreate();
DB_Account *account =
TCS_SAFE_CAST(gDBFile->GetOneObject(mMainAccountClass, mMainAccount), DB_Account);
if (account)
{ // there is an account, so we can proceed
DB_ObjectWatcher watcher(account);
// fetch payment term from the account
if (!mPaymentTerms)
account->GetMemberValue(tag_paymentterm, type_objectid, &mPaymentTerms);
// fetch tax rate from the account
if (!mTaxRate)
account->GetMemberValue(tag_taxrate, type_objectid, &mTaxRate);
}
}
/*********************************************************************************
ShouldBePaid rev TCS 5/5/00, 5/19/00
return whether this invoice should be included in lists of bills to pay
*********************************************************************************/
Boolean CMaterialPurchase::ShouldBePaid() const
{
return HasOpenStatus() || mStatus == status_TandMBilled;
}
/*********************************************************************************
GetAmountUnpaid TCS 10/28/99
return the amount unpaid
*********************************************************************************/
CMoney CMaterialPurchase::GetAmountUnpaid() const
{
if (GetPaymentMethod() == method_billed)
return GetAmountDue();
else
return 0; // rev TCS 5/19/00
}
/*********************************************************************************
GetAccountingAmount TCS 10/4/02
for taxes, use the vendor withholding amount
*********************************************************************************/
CMoney CMaterialPurchase::GetAccountingAmount(const Boolean removeIt, const UInt8 type) const
{
if (type == virtual_unpaidtax)
{
if (removeIt)
return -GetWithholdingAmount();
else
return GetWithholdingAmount();
}
else
{
if (removeIt)
return -GetAmount();
else
return GetAmount();
}
}
/*********************************************************************************
GetJobCostAmount TCS 10/8/02
for job costs, we check prefs setting on whether to use the adjusted amount
*********************************************************************************/
CMoney CMaterialPurchase::GetJobCostAmount() const
{
if (GetPrefsBoolean(id_ExpensePrefs, tag_includeadjustments))
return GetAdjustedAmount();
else
return GetAmount();
}
/*********************************************************************************
GetWithholdingDeduction TCS 9/16/03
get the amount of vendor withholding to deduct from the amount due to this
vendor.
For the gross withholding amount, use GetWithholdingAmount.
*********************************************************************************/
CMoney CMaterialPurchase::GetWithholdingDeduction() const
{
CVendorWithholding *withholding =
TCS_SAFE_CAST(gDBFile->GetOneObject(id_VendorWithholding, mWithholdingRate),
CVendorWithholding);
if (withholding)
{
DB_ObjectWatcher watcher (withholding);
if (withholding->IsDeducted())
return mWithholdingAmount;
else
return 0;
}
else if (mWithholdingRate)
ReportMissingObject(id_VendorWithholding, mWithholdingRate);
return 0;
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
PostNewRecord TCS 11/21/03
post info for a new record. Note that most new record posting happens via
PostRecordActivated.
*********************************************************************************/
void CMaterialPurchase::PostNewRecord(const UInt8 creationType)
{
PostUseCount(id_VendorPaymentTerm, mPaymentTerms);
PostUseCount(id_VendorWithholding, mWithholdingRate);
// let the superclass do any posting
THE_SUPERCLASS::PostNewRecord(creationType);
}
/*********************************************************************************
PostDeletion TCS 11/21/03
post info from a deleted record. Note that most posting happens via
PostRecordCancelled.
*********************************************************************************/
void CMaterialPurchase::PostDeletion(const Boolean postAudit)
{
PostUseCount(id_VendorPaymentTerm, mPaymentTerms, cRemoveItem);
PostUseCount(id_VendorWithholding, mWithholdingRate, cRemoveItem);
// let the superclass do any posting
THE_SUPERCLASS::PostDeletion(postAudit);
}
/*********************************************************************************
PostRecordActivated TCS 10/17/99
post info from a transaction that is newly created or activated. We may need to create
a bank payment for the purchase
*********************************************************************************/
void CMaterialPurchase::PostRecordActivated(const UInt8 creationType)
{
// let the superclass do any posting first TCS changed order 1/23/01
THE_SUPERCLASS::PostRecordActivated(creationType);
PostVendorWithholding(); // TCS 10/4/02
PostRetainage(); // TCS 10/9/02
gDBFile->UpdateEarlyLateDates(mBillingDate); // TCS 1/3/03
// we may need to create an instant payment transaction
if (NeedsPurchaseOffset(mPaymentMethod)) // rev TCS 11/30/99, 10/25/00
{
SetIsInstantPayment(true); // TCS rev 2/9/01
if (!WasJustImported())
CreateOffsetTransaction();
}
}
/*********************************************************************************
PostNewVoidRecord TCS 9/24/02
a void transaction was created. If it was 'pricing only' we still need
to do some posting
*********************************************************************************/
void CMaterialPurchase::PostNewVoidRecord(const UInt8 creationType)
{
if (GetStatus() == status_PriceUpdateOnly)
PostBreakdownsActivated(mBreakdownArray, mBreakdownClassID, creationType);
THE_SUPERCLASS::PostNewVoidRecord(creationType);
}
/*********************************************************************************
PostRecordCancelled TCS 10/17/99
post info from a voided or deleted transaction
*********************************************************************************/
void CMaterialPurchase::PostRecordCancelled(const UInt8 cancelType)
{
/*if (NeedsPurchaseOffset(mPaymentMethod)) // removed TCS 10/25/00
{
CancelOffsetTransaction(cancelType);
}*/
PostVendorWithholding(cRemoveItem); // TCS 10/4/02
PostRetainage(cRemoveItem); // TCS 10/9/02
// let the superclass do any posting
THE_SUPERCLASS::PostRecordCancelled(cancelType);
}
/*********************************************************************************
PostVoidRecordDeleted TCS 9/24/02
a void record was deleted. If it was 'pricing only' we still need to post
*********************************************************************************/
void CMaterialPurchase::PostVoidRecordDeleted()
{
if (GetStatus() == status_PriceUpdateOnly)
PostBreakdownsCancelled(mBreakdownArray, mBreakdownClassID, record_deletevoid);
THE_SUPERCLASS::PostVoidRecordDeleted();
}
/*********************************************************************************
PostRecordChanging TCS 10/17/99
a record will be changing. Post the change.
*********************************************************************************/
void CMaterialPurchase::PostRecordChanging(const Boolean accountChanging, const Boolean jobChanging)
{
PostVendorWithholding(cRemoveItem); // TCS 10/4/02
PostRetainage(cRemoveItem); // TCS 10/9/02
PostUseCount(id_VendorPaymentTerm, mPaymentTerms, cRemoveItem); // TCS 11/21/03
PostUseCount(id_VendorWithholding, mWithholdingRate, cRemoveItem);
THE_SUPERCLASS::PostRecordChanging(accountChanging, jobChanging);
}
/*********************************************************************************
PostVoidRecordChanging TCS 9/24/02
a void record will be changing. Post the change.
*********************************************************************************/
void CMaterialPurchase::PostVoidRecordChanging(const Boolean accountChanging, const Boolean jobChanging,
const UInt8 startingStatus, const UInt8 finalStatus)
{
if (GetStatus() == status_PriceUpdateOnly)
PostBreakdownsCancelled(mBreakdownArray, mBreakdownClassID, record_deletevoid);
PostUseCount(id_VendorPaymentTerm, mPaymentTerms, cRemoveItem); // TCS 11/21/03
PostUseCount(id_VendorWithholding, mWithholdingRate, cRemoveItem);
THE_SUPERCLASS::PostVoidRecordChanging(accountChanging, jobChanging, startingStatus, finalStatus);
}
/*********************************************************************************
PostRecordChanged TCS 10/17/99
a record has changed. Post it.
*********************************************************************************/
void CMaterialPurchase::PostRecordChanged(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
if (NeedsPurchaseOffset(mPaymentMethod) && !WasJustImported()) // rev TCS 10/25/00, 2/14/01
{
SetIsInstantPayment(true); // TCS rev 2/9/01
CreateOffsetTransaction();
}
PostVendorWithholding(); // TCS 10/4/02
PostRetainage(); // TCS 10/9/02
gDBFile->UpdateEarlyLateDates(mBillingDate); // TCS 1/3/03
PostUseCount(id_VendorPaymentTerm, mPaymentTerms); // TCS 11/21/03
PostUseCount(id_VendorWithholding, mWithholdingRate);
THE_SUPERCLASS::PostRecordChanged(oldAmount, accountChanged, jobChanged);
}
/*********************************************************************************
PostRecordChangedRemotely TCS 7/15/03
a record has changed from a remote update. Post it. We don't do purchase
offsets
*********************************************************************************/
void CMaterialPurchase::PostRecordChangedRemotely(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
PostVendorWithholding(); // TCS 10/4/02
PostRetainage(); // TCS 10/9/02
gDBFile->UpdateEarlyLateDates(mBillingDate); // TCS 1/3/03
THE_SUPERCLASS::PostRecordChanged(oldAmount, accountChanged, jobChanged);
}
/*********************************************************************************
PostVoidRecordChanged TCS 9/24/02
a void record has changed. Post it. We still need to do breakdown posting
so prices will update.
*********************************************************************************/
void CMaterialPurchase::PostVoidRecordChanged(const CMoney &oldAmount, const Boolean accountChanged,
const Boolean jobChanged)
{
if (GetStatus() == status_PriceUpdateOnly)
PostBreakdownsActivated(mBreakdownArray, mBreakdownClassID, record_voidtojobcost);
PostUseCount(id_VendorPaymentTerm, mPaymentTerms); // TCS 11/21/03
PostUseCount(id_VendorWithholding, mWithholdingRate);
THE_SUPERCLASS::PostVoidRecordChanged(oldAmount, accountChanged, jobChanged);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
PostVendorWithholding TCS 10/4/02
post vendor withholding
*********************************************************************************/
void CMaterialPurchase::PostVendorWithholding(const Boolean removeItem)
{
DBClass paytoClass = id_OtherCostAccount;
DBid payToID = 0, taxAccountID = account_UnpaidVendorWithholding;
if (mWithholdingRate) // rev TCS 1/19/01
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
CVendorWithholding *withholdRate =
TCS_SAFE_CAST(gDBFile->GetOneObject(id_VendorWithholding, mWithholdingRate),
CVendorWithholding);
if (withholdRate)
{
if (!withholdRate->IsPostedToAgency())
return;
DB_ObjectWatcher watcher(withholdRate);
paytoClass = withholdRate->GetPaidToClass(); // rev TCS 10/4/02
payToID = withholdRate->GetPaidToAccount();
taxAccountID = withholdRate->GetExpenseAccount();
// check the validity
if (!CUtilityAccount::IsValidAccount(taxAccountID, virtual_unpaidtax))
{
taxAccountID = account_UnpaidVendorWithholding;
withholdRate->SetUtilityAccount(taxAccountID);
withholdRate->MakeDirty();
}
}
else
ReportMissingObject(id_VendorWithholding, mWithholdingRate);
}
if (payToID)
{
DB_Account *payToAccount =
TCS_SAFE_CAST(gDBFile->GetOneObject(paytoClass, payToID),
DB_Account);
if (payToAccount)
{
DB_ObjectWatcher accountWatcher(payToAccount);
payToAccount->AddToUnpaidVendorWithholdingArray(GetDBClassID(), GetDBID(), removeItem);
}
else
ReportMissingObject(paytoClass, payToID);
}
// also add to the virtual account TCS 11/10/00 rev TCS 11/21/00 rev 12/11/00
CUtilityAccount::AddToBothArrays(taxAccountID, this, removeItem);
}
/*********************************************************************************
PostRetainage TCS 10/9/02
post retainage withheld or paid
*********************************************************************************/
void CMaterialPurchase::PostRetainage(const Boolean removeItem)
{
if (mRetainageAmount.IsZero() && mConditions != condition_Retainage)
return;
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_PersistentObject *costAccount =
gDBFile->GetOneObject(GetMainAccountClass(), GetMainAccountID());
if (costAccount)
{
DB_ObjectWatcher watcher (costAccount);
if (mConditions == condition_Retainage)
costAccount->HandleRetainage(GetDBClassID(), GetDBID(), -mAmount, removeItem);
else
costAccount->HandleRetainage(GetDBClassID(), GetDBID(), mRetainageAmount, removeItem);
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
HandlePaymentCancelled TCS 10/25/00, rev 2/9/01
deal with a payment that has been cancelled. We set the payment terms to billed,
since this item is still due.
This was formerly handled via HandlePaymentMade but that caused problems, since
it was posted during any change, not just payment cancellation or deletion.
*********************************************************************************/
void CMaterialPurchase::HandlePaymentCancelled()
{
UInt8 saveSuccess = PrepareViewerDisplay();
if (GetPaymentMethod() != method_billed)
{
SetPaymentMethod(method_billed);
// we also need to fill in payment terms TCS 11/14/00
DB_Account *account = TCS_SAFE_CAST(gDBFile->GetOneObject(GetMainAccountClass(), mMainAccount),
DB_Account);
if (account)
{
DB_ObjectWatcher watcher(account);
mPaymentTerms = account->GetPaymentTerm();
}
if (!mPaymentTerms)
mPaymentTerms = gDBFile->GetFirstObjectID(id_VendorPaymentTerm);
}
UpdateViewerDisplay(saveSuccess);
}
/*********************************************************************************
HandleDateChanged TCS 3/1/02
the date has changed from 'replace all' or other remote action. We need
to recalc the billing date
*********************************************************************************/
void CMaterialPurchase::HandleDateChanged()
{
mBillingDate = CalculateBillingDate(id_VendorPaymentTerm, mPaymentTerms, mDate);
MakeDirty();
}
/*********************************************************************************
HandleTaxesPaid TCS 10/7/02
handle payment of sales tax for this item.
*********************************************************************************/
void CMaterialPurchase::HandleTaxesPaid(const DBClass /*sourceClass*/, const DBid /*sourceID*/,
const Boolean removeItem)
{
// We can just use the basic tax posting code, but reversed.
PostVendorWithholding(!removeItem);
}
/*********************************************************************************
FinishBreakdownUpdate TCS 11/1/01
we fill in the 'on sale' status for item breakdowns. We don't assert since
category breakdowns don't store a value.
*********************************************************************************/
void CMaterialPurchase::FinishBreakdownUpdate(CBreakdownEntry *breakdown, CBreakdownTable */*table*/)
{
TCS_FailNILMsg(breakdown, TCS_GetErrString(errID_BadBreakdown));
Boolean skipUpdating = mSkipUpdating;
breakdown->SetMemberValue(tag_skipupdating, type_boolean, &skipUpdating);
}
/*********************************************************************************
FillDataReport TCS 9/6/02
fill in a diagnostic table that shows data field values.
*********************************************************************************/
void CMaterialPurchase::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();
FillFieldStringRow(table, stream, tag_onetimename, mOneTimeVendorName);
FillFieldStringRow(table, stream, tag_invoicenum, mInvoiceNum);
FillFieldObjectIDRow(table, stream, tag_paymentterm, mPaymentTerms, id_VendorPaymentTerm);
FillFieldObjectIDRow(table, stream, tag_withholdingrate, mWithholdingRate, id_VendorWithholding);
FillFieldEnumRow(table, stream, tag_paymentmethod, mPaymentMethod, MENU_PurchasePaymentMethods);
FillFieldBitRow(table, stream, "mUseOneTimeName", mUseOneTimeName, true);
FillFieldBitRow(table, stream, "mSkipUpdating", mSkipUpdating);
FillFieldStockRow(table, stream, stockID_Padding, -6, SInt32(mPurchasePadding));
FillFieldTagRow(table, stream, tag_withholdingamount, cMoneySize, mWithholdingAmount.GetCurrencyString());
FillFieldTagRow(table, stream, tag_retainage, cMoneySize, mRetainageAmount.GetCurrencyString());
FillFieldTagRow(table, stream, tag_billingdate, cDateSize, mBillingDate.GetCString());
if (version > 1) // TCS 12/10/03
{
FillFieldObjectIDRow(table, stream, tag_currency, mCurrency, id_Currency);
FillFieldTagRow(table, stream, tag_foreignamount, cMoneySize, mForeignAmount.GetCurrencyString());
}
if (GetDBClassID() == id_MaterialPurchase)
{
FillEndSafetyTag(table, stream, mMatEndSafetyTag);
}
}
|