This example shows how to exclude some item categories from cost or revenue budget control.
For cost budget control :
Create an extension class of SourceDocumentLineState class
[ExtensionOf(classStr(SourceDocumentLineState))]
final class Al0SourceDocumentLineState_Extension
{
/// <summary>
/// Extension method
/// </summary>
/// <returns></returns>
protected boolean validatePostTransition()
{
//Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN
//Excluding some Project Categories from Project Budget calculation
boolean ret;
ProjParameters projParameters = ProjParameters::find();
if(projParameters.Al0DisableBudgetControl == NoYes::Yes)
{
PurchLine al0PurchLine;
Al0ProjBudgetCalculationExcludedCategoriesCost al0ProjBudgetCalculationExcludedCategoriesCost;
Common al0CurrentImplementation = processor.parmCurrentImplementation();
if(al0CurrentImplementation is PurchLine)
{
al0PurchLine = al0CurrentImplementation as PurchLine;
}
else if(al0CurrentImplementation is VendInvoiceInfoLine)
{
VendInvoiceInfoLine vendInvoiceInfoLine = al0CurrentImplementation as VendInvoiceInfoLine;
al0PurchLine = PurchLine::findRecId(vendInvoiceInfoLine.PurchLineRecId);
}
ProjCategoryId al0ProjCategoryId = al0PurchLine.ProjCategoryId;
al0ProjBudgetCalculationExcludedCategoriesCost = Al0ProjBudgetCalculationExcludedCategoriesCost::findExcludedCategory(al0ProjCategoryId, al0PurchLine.ProjId);
if(al0ProjBudgetCalculationExcludedCategoriesCost)
{
isBudgetUpdateRequired = false;
}
}
ret = next validatePostTransition();
return ret;
//Al0_0266_ProjBudgetExcludedCategoryItm - END
}
}

For Revenue budget control :
Create an extension class of ProjBudgetTransactionManager class
[ExtensionOf(classStr(ProjBudgetTransactionManager))]
final class Al0ProjBudgetTransactionManager_Extension
{
/// <summary>
/// Extension method for adjustBudgetDecrement
/// </summary>
/// <param name = "_projBudgetTransactionLine"></param>
/// <param name = "_projTable"></param>
/// <returns></returns>
protected boolean adjustBudgetDecrement(ProjBudgetTransactionLine _projBudgetTransactionLine, ProjTable _projTable)
{
//Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN
//Excluding some Project Categories from Project Budget calculation
Al0ProjBudgetCalculationExcludedCategoriesRevenue al0ProjBudgetCalculationExcludedCategoriesRevenue;
ProjCategoryId al0ProjCategoryId = _projBudgetTransactionLine.categoryId();
al0ProjBudgetCalculationExcludedCategoriesRevenue = Al0ProjBudgetCalculationExcludedCategoriesRevenue::findExcludedCategory(al0ProjCategoryId, _projBudgetTransactionLine.ProjId());
if(al0ProjBudgetCalculationExcludedCategoriesRevenue)
{
_projTable.UseBudgeting = false;
}
boolean ret = next adjustBudgetDecrement(_projBudgetTransactionLine, _projTable);
return ret;
//Al0_0266_ProjBudgetExcludedCategoryItm - END
}
/// <summary>
/// Extension method for adjustBudgetIncrementIsBudgetDefined
/// </summary>
/// <param name = "_projBudgetTransactionLine"></param>
/// <param name = "_projTable"></param>
/// <returns></returns>
protected boolean adjustBudgetIncrementIsBudgetDefined(ProjBudgetTransactionLine _projBudgetTransactionLine, ProjTable _projTable)
{
boolean ret = true;
ret = next adjustBudgetIncrementIsBudgetDefined(_projBudgetTransactionLine, _projTable);
//Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN
//Excluding some Project Categories from Project Budget calculation
ProjParameters projParameters = ProjParameters::find();
if(projParameters.Al0DisableBudgetControl == NoYes::Yes)
{
Al0ProjBudgetCalculationExcludedCategoriesRevenue al0ProjBudgetCalculationExcludedCategoriesRevenue;
ProjCategoryId al0ProjCategoryId = _projBudgetTransactionLine.categoryId();
al0ProjBudgetCalculationExcludedCategoriesRevenue = Al0ProjBudgetCalculationExcludedCategoriesRevenue::findExcludedCategory(al0ProjCategoryId, _projBudgetTransactionLine.ProjId());
if(al0ProjBudgetCalculationExcludedCategoriesRevenue)
{
ret = false;
}
}
//Al0_0266_ProjBudgetExcludedCategoryItm - END
return ret;
}
}

Create an extension class of CostControlPostingItemSalesOrder class
[ExtensionOf(classStr(CostControlPostingItemSalesOrder))]
final class Al0CostControlPostingItemSalesOrder_Extension
{
/// <summary>
/// Extension method for mustUpdateBudget
/// </summary>
/// <param name = "_costAmount"></param>
/// <param name = "_salesAmount"></param>
/// <returns></returns>
public boolean mustUpdateBudget(AmountCur _costAmount, AmountCur _salesAmount)
{
//Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN
//Excluding some Project Categories from Project Budget calculation
boolean ret = next mustUpdateBudget(_costAmount, _salesAmount);
ProjParameters projParameters = ProjParameters::find();
if(projParameters.Al0DisableBudgetControl == NoYes::Yes)
{
if(buffer is SalesLine)
{
Al0ProjBudgetCalculationExcludedCategoriesRevenue al0ProjBudgetCalculationExcludedCategoriesRevenue;
SalesLine al0SalesLine = buffer as SalesLine;
ProjCategoryId al0ProjCategoryId = al0SalesLine.ProjCategoryId;
al0ProjBudgetCalculationExcludedCategoriesRevenue = Al0ProjBudgetCalculationExcludedCategoriesRevenue::findExcludedCategory(al0ProjCategoryId, al0SalesLine.ProjId);
if(al0ProjBudgetCalculationExcludedCategoriesRevenue)
{
ret = false;
}
}
}
return ret;
//Al0_0266_ProjBudgetExcludedCategoryItm - END
}
}
Leave a comment