using Microsoft.Dynamics.Platform.Integration.Office;
class DaxExpenseJournalClass extends DocuTemplateRegistrationBase implements LedgerIJournalExcelTemplate
{
// resource that contains xlsx file.
private const DocuTemplateName ExcelTemplateName = resourceStr(DaxExpenseJournal);
// lines Data Entity
private const EntityName LineEntityName = tableStr(ExpenseJournalLineEntity);
private const FieldName LineEntityJournalNum = fieldStr(ExpenseJournalLineEntity, JournalBatchNumber);
private const FieldName LineEntityDataAreaId = fieldStr(ExpenseJournalLineEntity, dataAreaId);
private const FieldName HeaderEntityName = tableStr(ExpenseJournalHeaderEntity);
private const FieldName HeaderEntityJournalNum = fieldStr(ExpenseJournalHeaderEntity, JournalBatchNumber);
// header Data Entity.
private const FieldName HeaderEntityDataAreaId = fieldStr(ExpenseJournalHeaderEntity, dataAreaId);
public void registerTemplates()
{
this.addTemplate(OfficeAppApplicationType::Excel,
ExcelTemplateName,
ExcelTemplateName,
"Dax Expense Journal",
"Dax Expense Journal",
NoYes::No,
NoYes::No);
}
public boolean isJournalTypeSupported(LedgerJournalType _ledgerJournalType)
{
// only daily journals are supported in this template.
return _ledgerJournalType == LedgerJournalType::Cost;
}
public DocuTemplateName documentTemplateName()
{
return ExcelTemplateName;
}
public Set supportedAccountTypes()
{
// Set with supported account types.
Set accountSetTypes = new Set(Types::Integer);
accountSetTypes.add(LedgerJournalACType::Project);
accountSetTypes.add(LedgerJournalACType::Ledger);
return accountSetTypes;
}
public Set supportedOffsetAccountTypes()
{
// Set with supported offset account types.
Set offsetAccountTypeSet = new Set(Types::Integer);
offsetAccountTypeSet.add(LedgerJournalACType::Ledger);
return offsetAccountTypeSet;
}
public boolean validateJournalForTemplate(LedgerJournalTable _ledgerJournalTable)
{
return LedgerJournalExcelTemplate::validateJournalForTemplate(_ledgerJournalTable, this);
}
public EntityName headerEntityName()
{
return HeaderEntityName;
}
public EntityName lineEntityName()
{
return LineEntityName;
}
public FieldName headerJournalBatchNumberFieldName()
{
return HeaderEntityJournalNum;
}
public FieldName headerDataAreaFieldName()
{
return HeaderEntityDataAreaId;
}
public FieldName lineJournalBatchNumberFieldName()
{
return LineEntityJournalNum;
}
public FieldName lineDataAreaFieldName()
{
return LineEntityDataAreaId;
}
public FilterCollectionNode appendHeaderEntityFilters(FilterCollectionNode _headerFilter, ExportToExcelFilterTreeBuilder _headerFilterBuilder)
{
return _headerFilter;
}
/// <summary>
/// Filter the vouchers which are having accounttype as Project and offset account as Ledger
/// </summary>
/// <param name = "_lineFilter"></param>
/// <param name = "_lineFilterBuilder"></param>
/// <returns></returns>
public FilterCollectionNode appendLineEntityFilters(FilterCollectionNode _lineFilter, ExportToExcelFilterTreeBuilder _lineFilterBuilder)
{
// creates excel filter to show only lines that have Bank account type
// and Ledger offset account type
FilterCollectionNode lineFilter = _lineFilterBuilder.and(
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntity, AccountType), LedgerJournalACType::Project),
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntity, OffsetAccountType), LedgerJournalACType::Ledger));
return _lineFilterBuilder.and(_lineFilter, lineFilter);
}
public void applyCustomTrimming(Excel.IWorkbookManager _templateManaer, Excel.WorkbookSettingsManager _settingsManager, LedgerJournalTable _ledgerJournalTable)
{
}
}
.....................
A custom template is added to form.
No comments:
Post a Comment