[ExtensionOf(classstr(CustAccountStatementExtContract))]
final class DDDCustAccountStatementExtContract_Extension
{
public boolean checkChild;
[
DataMemberAttribute('CheckChild'),
SysOperationLabelAttribute(literalStr("Check Child")),
SysOperationHelpTextAttribute(literalStr("Check Child"))
]
public boolean parmCheckChild(boolean _checkChild = checkChild)
{
checkChild= _checkChild;
return checkChild;
}
}
-----------------------------------------------*******************----------------------------
[ExtensionOf(classStr(CustAccountStatementExtDP))]
final class DDDCustAccountStatementExtDP_Extension
{
protected void mapCustAccountStatementExtTmpToNewTempTableInstance(CustAccountStatementExtDPTmpTableCopyMapBuilder _copyMapBuilder)
{
next mapCustAccountStatementExtTmpToNewTempTableInstance(_copyMapBuilder);
_copyMapBuilder.addFieldToMap(fieldNum(CustAccountStatementExtTmp, ChildAccount));
_copyMapBuilder.addFieldToMap(fieldNum(CustAccountStatementExtTmp, ChildName));
_copyMapBuilder.addFieldToMap(fieldNum(CustAccountStatementExtTmp, TextRef));
_copyMapBuilder.addFieldToMap(fieldNum(CustAccountStatementExtTmp, DDDIsParentAccount));
}
}
------------------------------------------*******************---------------------------
class DDDPrintMgmtDocTypeHandlerExt
{
[SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
{
switch(_docType)
{
case PrintMgmtDocumentType::CustAccountStatement:
_result.result(ssrsReportStr(DDDCustAccountStatementExtChild, Report));
break;
}
}
}
---------------------------------------------*****-------------------------------------
[ExtensionOf(classstr(CustAccountStatementExtUIBuilder))]
final class DDDCustAccountStatementExtUIBuilder_Extension
{
private boolean includeChildTransactions;
private DialogField includeChildTransactionsField;
public DialogField checkParentChildField;
public DialogGroup checkParentChildGrp;
public void build()
{
next build();
checkParentChildGrp = dialog.addGroup("@DDDLabelFile:DDDParentChild");
checkParentChildField = this.addDialogField(methodStr(CustAccountStatementExtContract, parmCheckParentChild), contract);
}
public void getFromDialog()
{
contract.parmCheckParentChild(checkParentChildField.value());
next getFromDialog();
}
}
-----------------------------------------------------------------************----------------------
/// <summary>
/// CustAccountStatementExtController extension
/// </summary>
[ExtensionOf(classstr(CustAccountStatementExtController))]
final class DDDCustAccountStatementExtController_Extension
{
public boolean checkParentChild;
public static boolean checkparentchildMain;
public real childrenBalance;
public CustTrans custTransGlobal;
public TmpCustVendTransOpen tmpOpenGlobal;
protected void runPrintMgmt()
{
next runPrintMgmt();
checkParentChild = this.parmContract().parmCheckParentChild();
}
protected void populateCustAccountStatementExtTmp(int _custCurrencyIndex)
{
LedgerJournalTrans ledgerJournalTransLoc;
select ledgerJournalTransLoc
where ledgerJournalTransLoc.CustTransId == currentTrans.Recid;
next populateCustAccountStatementExtTmp(_custCurrencyIndex);
custAccountStatementExtTmp.TextRef = ledgerJournalTransLoc.TextRef;
DDDCustParentChild custParentChildLoc;
select firstonly custParentChildLoc
where custParentChildLoc.ParentAccount == CustTable::find(custAccountStatementExtTmp.CustTable_AccountNum).RecId;
if(custParentChildLoc.RecId)
{
custAccountStatementExtTmp.DDDIsParentAccount = NoYes::Yes;
}
}
protected boolean processCustPre(CustTable _cust, int _numberOfCustProcessed)
{
boolean ret;
DDDCustParentChild custParentChild;
CustTable custLoc;
checkParentChild = this.parmContract().parmCheckParentChild();
checkparentchildMain = checkParentChild;
if(checkParentChild)
{
while select custParentChild
where custParentChild.ParentAccount == _cust.RecId
{
custLoc = CustTable::find(custParentChild.ChildAccount);
childrenBalance += custLoc.openBalanceCur(dateNull(), statementStartDate-1, statementEndDate);
}
}
ret = next processCustPre(_cust, _numberOfCustProcessed);
return ret;
}
protected void insertCustAccountStatementExtTmp(int _custCurrencyIndex)
{
if(checkParentChild)
{
if(_custCurrencyIndex == 1)
{
if(childrenBalance > 0)
{
openingBalance += childrenBalance;
custBalanceCur[1] += childrenBalance;
}
}
}
next insertCustAccountStatementExtTmp(_custCurrencyIndex);
}
protected void printClosingBalance()
{
DDDCustParentChild custParentChild1;
CustTable custLoc1;
CustTrans custTransLoc;
if(checkParentChild)
{
while select custParentChild1
where custParentChild1.ParentAccount == currentCust.RecId
{
if(custParentChild1)
{
//custLoc1 = CustTable::find(custParentChild1.ChildAccount);
while select custTransLoc
where custTransLoc.AccountNum == custParentChild1.ChildAccount // Date condition will add
{
if(custTransLoc)
{
this.processChildTrans(custTransLoc);
}
}
}
}
}
next printClosingBalance();
}
protected void processChildTrans(CustTrans _trans)
{
//tmpCustVendTransOpen tmpCustVendTransOpen;
AmountCur transAmount;
int currencyIndex;
changecompany(_trans.company())
{
_trans.resetAmountsToDate(statementEndDate);
if (!this.includeOnStatement(_trans))
{
return;
}
custTransCount++;
// update the global transaction
currentTrans = _trans;
// set up for the payment schedule
//tmpCustVendTransOpen = CustAccountStatementExtController::getTmpCustVendTransOpen(currentTrans, this.parmContract().parmToDate(), onlyOpen);
CustVendTransDetails detail = new CustVendTransDetails(_trans, this.parmContract().parmToDate());
tmpCustVendTransOpen = detail.tmpCustVendTransOpen(this.parmContract().parmOnlyOpen());
tmpOpenGlobal = tmpCustVendTransOpen;
select count(RecId), minOf(DueDate) from tmpOpenGlobal;
numberOfTransOpen = int642int(tmpCustVendTransOpen.RecId);
// Checking the number of open transactions and payment schedule parameter
if (numberOfTransOpen == 1 || (numberOfTransOpen > 1 && !printPaymentSchedule))
{
// this seems to do nothing
if (printPaymentSchedule)
{
select firstonly tmpOpenGlobal;
}
else
{
select minOf(DueDate) from tmpOpenGlobal;
}
transHeading = true;
}
// Open transactions
if (onlyOpen)
{
transAmount = _trans.remainAmountCur();
}
else
{
transAmount = _trans.AmountCur;
}
// add to the cust balance
currencyIndex = conFind(custCurrencyList, _trans.CurrencyCode);
if (currencyIndex == 0)
{
currencyIndex = this.addCustCurrency(_trans.CurrencyCode);
}
this.setCustBalanceCur(currencyIndex, transAmount);
// add to the statement balance
currencyIndex = conFind(statementCurrencyList, _trans.CurrencyCode);
Debug::assert(currencyIndex != 0);
statementBalanceCur[currencyIndex] += transAmount;
// put the transaction on the report
cust_Trans = true;
this.insertChildCustAccountStatementExtTmp(0);
cust_Trans = false;
if (numberOfTransOpen > 1 && printPaymentSchedule)
{
// print multiple transactions for the payment schedule
while select tmpOpenGlobal
order by DueDate
{
vendTransOpen = true;
this.insertChildCustAccountStatementExtTmp(0);
vendTransOpen = false;
if (specifyDueToDate)
{
this.tmpCustVendTransDetail();
}
}
}
else if (specifyDueToDate)
{
if (numberOfTransOpen > 1)
{
while select tmpOpenGlobal
order by DueDate
{
this.tmpCustVendTransDetail();
}
}
else if (_trans.remainAmountCur() != 0) // this seems to do nothing
{
// Show only open trans as due per
//this.tmpCustVendTrans();
this.initTmpCustVendTrans();
tmpCustVendTrans.insert();
}
}
}
}
protected void insertChildCustAccountStatementExtTmp(int _custCurrencyIndex)
{
str TabName;
this.populateChildCustAccountStatementExtTmp(_custCurrencyIndex);
custAccountStatementExtTmp.insert();
TabName = custAccountStatementExtTmp.getPhysicalTableName();
createdTransactionId = custAccountStatementExtTmp.CreatedTransactionId;
}
protected void populateChildCustAccountStatementExtTmp(int _custCurrencyIndex)
{
LedgerJournalTrans ledgerJournalTransLoc;
select ledgerJournalTransLoc
where ledgerJournalTransLoc.CustTransId == currentTrans.Recid;
// CustTrans - Transactions
if (cust_Trans)
{
custAccountStatementExtTmp.FlagMainData = 19;
custAccountStatementExtTmp.CustTrans_TransDate = currentTrans.TransDate;
custAccountStatementExtTmp.CustTrans_Invoice = currentTrans.Invoice;
custAccountStatementExtTmp.CustTrans_Voucher = currentTrans.Voucher;
custAccountStatementExtTmp.CustTrans_DataAreaId = currentTrans.DataAreaId;
custAccountStatementExtTmp.CustTrans_Txt = currentTrans.Txt;
custAccountStatementExtTmp.CustTrans_DueDate = tmpCustVendTransOpen.DueDate;
custAccountStatementExtTmp.DueDateTxt = syslabel::labelId2String(literalStr("@SYS78137"),languageId);
custAccountStatementExtTmp.CustTrans_markForPaymentSchedule = this.markForPaymentScheduleChild();
custAccountStatementExtTmp.CustTrans_CurrencyCode = currentTrans.CurrencyCode;
custAccountStatementExtTmp.CustTrans_Debit = this.amountCurDebitChild();
custAccountStatementExtTmp.CustTrans_Credit = this.amountCurCreditChild();
custAccountStatementExtTmp.CustTrans_Balance = this.custBalanceChild(currentTrans.CurrencyCode);
custAccountStatementExtTmp.ChildAccount = currentTrans.AccountNum;
custAccountStatementExtTmp.ChildName = CustTable::find(currentTrans.AccountNum).name();
custAccountStatementExtTmp.TextRef = ledgerJournalTransLoc.TextRef;
}
// TmpCustVendTransOpen - OpenTransactions
if (vendTransOpen)
{
custAccountStatementExtTmp.FlagMainData = 20;
custAccountStatementExtTmp.CustTransOpen_DueDate = tmpCustVendTransOpen.DueDate;
custAccountStatementExtTmp.CustTransOpen_AmountCur = tmpCustVendTransOpen.AmountCur;
custAccountStatementExtTmp.ChildAccount = currentTrans.AccountNum;
custAccountStatementExtTmp.ChildName = CustTable::find(currentTrans.AccountNum).name();
custAccountStatementExtTmp.TextRef = ledgerJournalTransLoc.TextRef;
}
}
private AmountCur amountCurCreditChild()
{
AmountCur amount = onlyOpen ? currentTrans.remainAmountCur() : currentTrans.AmountCur;
return amount < 0 ? amount : 0;
}
public AmountCur amountCurDebitChild()
{
AmountCur amount = onlyOpen ? currentTrans.remainAmountCur() : currentTrans.AmountCur;
return amount > 0 ? amount : 0;
}
private AmountCur custBalanceChild(CurrencyCode _currencyCode)
{
int currencyPosition = conFind(custCurrencyList, _currencyCode);
return currencyPosition == 0 ? 0 : custBalanceCur[currencyPosition];
}
public str markForPaymentScheduleChild()
{
if (numberOfTransOpen > 1 && !printPaymentSchedule)
{
markForPaymentSchedulePrinted = true;
return '*';
}
return '';
}
private static container getSelectedCompanyListChild(Query _query, CompanyId _company)
{
container queryCompanyRange;
container queryCompanyRangeList;
container selectedCompanyList = conNull();
container sharedCompanyList;
boolean isShared;
int i;
#Define.CompanyPosition(1)
#Define.IsMarkedPosition(2)
if (isConfigurationkeyEnabled(configurationKeyNum(CustCentralizedCustStatement)))
{
// this retrieves the company range specified by the user on the statement dialog
queryCompanyRangeList = _query.getCompanyRange();
sharedCompanyList = CustVendOpenTransManager::findSharedServiceCompanies(_company);
// include only valid companies in the company list
for (i = 1; i <= conLen(queryCompanyRangeList); i++)
{
queryCompanyRange = conPeek(queryCompanyRangeList, i);
isShared = conFind(sharedCompanyList, conPeek(queryCompanyRange, #CompanyPosition)) != 0;
if (conPeek(queryCompanyRange, #IsMarkedPosition) && isShared)
{
selectedCompanyList += conPeek(queryCompanyRange, #CompanyPosition);
}
}
}
else
{
selectedCompanyList += _company;
}
return selectedCompanyList;
}
}
Thanks for your post. It gave me some idea on the report
ReplyDelete