Friday, 29 March 2019

sending Email alerts in D365 (through SMTP)

class BWP_CreateEmailNotification
{
//main method testing purpose with action menu item
    static void main(Args    _args)
    {
        BWP_CreateEmailNotification     classNotification   =    new  BWP_CreateEmailNotification();
        classNotification.sendEmailNotification();
    }

    public void sendEmailNotification(BWP_BudgetRequest     _budgetRequest = null, Email    _toEmail = "")
    {
        str                     recipient, cc, subject, body;
        subject             =   "Budget adjustment Request";
        recipient           =   _toEmail;
        cc                  =   "";

        body = 'Hi,<br><br>PLease adjust the budget for following Item group.<br><br>';

        body += strFmt('<tr>  PurchId : <td>%1</td>,      ItemGroup : <td>%2</td>,      Requested date : <td>%3</td>,       Comments : <td>%4</td>  <td></tr>',
                    _budgetRequest.PurchId,
                    _budgetRequest.ItemGroupId,
                    _budgetRequest.RequstedDate,
                    _budgetRequest.Comments                 
                    );

        body += '</table><br><br>Thanks.';

        this.send(  recipient,
                    cc,
                    subject,
                    body
                 );
    }

    public void send(str recipient, str cc, str subject, str body, str fileName = '')
    {
        str                                     sender = 'Admin@botswanapost.co.bw';
        List                                    toList;
        List                                    ccList;
        ListEnumerator                          le;

        Set                                     permissionSet;
        System.Exception                        e;

        str                                     mailServer;
        int                                     mailServerPort;
        System.Net.Mail.SmtpClient              mailClient;
        System.Net.Mail.MailMessage             mailMessage;
        System.Net.Mail.MailAddress             mailFrom;
        System.Net.Mail.MailAddress             mailTo;
        System.Net.Mail.MailAddressCollection   mailToCollection;
        System.Net.Mail.MailAddressCollection   mailCCCollection;
        System.Net.Mail.AttachmentCollection    mailAttachementCollection;
        System.Net.Mail.Attachment              mailAttachment;

        try
        {
            toList = strSplit(recipient, ';');
            ccList = strSplit(cc, ';');

            permissionSet = new Set(Types::Class);
            permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
            permissionSet.add(new FileIOPermission(filename, 'rw'));
            CodeAccessPermission::assertMultiple(permissionSet);

            mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
            mailServerPort = SysEmaiLParameters::find(false).SMTPPortNumber;
            mailClient = new System.Net.Mail.SmtpClient(mailServer, mailServerPort);

            le = toList.getEnumerator();
            le.moveNext();

            mailFrom = new System.Net.Mail.MailAddress(sender);
            mailTo  = new System.Net.Mail.MailAddress(strLTrim(strRTrim(le.current())));
            mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

            mailToCollection = mailMessage.get_To();
            while (le.moveNext())
            {
                mailToCollection.Add(strLTrim(strRTrim(le.current())));
            }

            if(cc != '')
            {
                le = ccList.getEnumerator();
                mailCCCollection = mailMessage.get_CC();
                while (le.moveNext())
                {
                    mailCCCollection.Add(strLTrim(strRTrim(le.current())));
                }
            }

            mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
            mailMessage.set_Subject(subject);
            mailMessage.set_Body(body);
            mailMessage.set_IsBodyHtml(true);

            mailClient.Send(mailMessage);
            mailMessage.Dispose();

            CodeAccessPermission::revertAssert();
        }
        catch (Exception::CLRError)
        {
            e = ClrInterop::getLastException();
            while (e)
            {
                error(e.get_Message());
                e = e.get_InnerException();
            }
            CodeAccessPermission::revertAssert();
        }
    }

}

Thursday, 28 March 2019

onValidated field (table level) in D365

class BWP_FieldValidations
{
    [DataEventHandler(tableStr(PurchLine), DataEventType::ValidatedField)]
    public static void PurchLine_onValidatedField(Common sender, DataEventArgs e)
    {
        PurchLine                           purchLineLocal;
        InventTable                         inventTable, inventTableLocal;
        ItemGroupId                         itemGroupId, lineItemGroupId;
        BWBudgetDetail                      budgetDetail;
        InventItemGroupItem                 itemGroupItem;
        LineAmount                          lineAmount;
        PurchId                             purchId;
        ValidateFieldEventArgs              event           = e as ValidateFieldEventArgs;
        PurchLine                           purchLine       = sender as PurchLine;
        boolean                             result          = event.parmValidateResult();
        LineAmount                          lineSum;


        lineAmount      =   purchLine.PurchQty*purchLine.PurchPrice;
        inventTable     =   InventTable::find(purchLine.ItemId);
        itemGroupId     =   inventTable.itemGroupId();
        purchId         =   purchLine.PurchId;

        while select purchLineLocal where purchLineLocal.PurchId ==  purchId
        {
            inventTableLocal    =   InventTable::find(purchLineLocal.ItemId);
            lineItemGroupId     =   inventTableLocal.itemGroupId();
            if(lineItemGroupId  ==  itemGroupId)
            {
                lineSum  +=   purchLineLocal.LineAmount;
            }
        }
        select budgetDetail where budgetDetail.ItemGroupId == itemGroupId
            && budgetDetail.FromDate <= today()
            && budgetDetail.ToDate   >= today();
            //&& budgetDetail.DimensionDefault == purchLine.DefaultDimension
        {
            if(budgetDetail)
            {
                if (lineAmount  > (budgetDetail.amount - lineSum))
                {
                    result  =   false;
                    warning(strFmt("Actual budget : %1, Remain budget : %2, line amount : %3 (Please raise a budget adjustment request for item group - %4)", budgetDetail.Amount, (budgetDetail.amount - lineSum), lineAmount, itemGroupId));
                }
                else
                {
                    result  =   true;
                }
            }
        }
        event.parmValidateResult(result);
    }

}

Thursday, 14 March 2019

date time difference x++

public static void DateTimeDifference(Args _args)
{     
TransDateTime   dateTime_a, dateTime_b;
date            date1, date2;
int64           c;
#define.NoOfHrsInADay(24);
dateTime_a= 2018-09-26T11:59:59;
dateTime_b= 2018-09-19T08:50:50;
c = DateTimeUtil::getDifference(dateTime_a,dateTime_b);
date1 = DateTimeUtil::date(dateTime_a);
date2 = DateTimeUtil::date(dateTime_b);
c = c - (date1-date2)*(#NoOfHrsInADay)*60*60;
info(strFmt("%1 day, %2 hrs.",(date1-date2), c div 3600));
}

Tuesday, 12 March 2019

Journal lines import in d365

using System.IO;
using OfficeOpenXml;
using OfficeOpenXml.ExcelPackage;
using OfficeOpenXml.ExcelRange;
class INTC_JournalImport
{
    public static void main(Args _args)
    {
        System.IO.Stream                    stream;
        ExcelSpreadsheetName                sheeet;
        FileUploadBuild                     fileUpload;
        DialogGroup                         dlgUploadGroup;
        FileUploadBuild                     fileUploadBuild;
        FormBuildControl                    formBuildControl;
        container                           conDimValue;
        container                           conVal;
        int64                               ledgerLoc;
        str                                 dimValue;     
        FormDataSource                      ledgerJOurnalTrans_DS = _args.record().dataSource() as FormDataSource;
        ledgerjournalTrans                  ledgerJournalTrans    = ledgerJOurnalTrans_DS.cursor();
        TransDate                           postingDate;
        str                                 ledgerAccType, offsetAccType;
        LedgerJournalTransTxt               transTxt;
        MainAccountNum                      ledgerMainAccount, offsetMainAccount;
        AmountCurDebit                      amountDebit;
        AmountCurCredit                     amountCredit;
        CurrencyCode                        currencyCode;
        ExchRate                            ExchRate;
        InvoiceId                           invoiceID;
        DocumentNum                         documentNum;
        DocumentDate                        documentDate;
        DueDate                             dueDate;
        AssetTransTypeJournal               assetTransType;
        TaxGroupJournal                     taxGroup, taxItemGroup;
        Voucher                             voucher;
        NumberSeq                           numberseq;
        LineNum                             lineNum;
        int64                               ledgerDim;
        int64                               offsetLedgerDim;
        MainAccountNum                      mainAccountNum;
        int                                 hierarchyCount, offsethierarchyCount;
        int                                 hierarchyIdx, offsethierarchyIdx;
        LedgerRecId                         ledgerRecId, offsetLedgerRecId;
        LedgerJournalId                     journalNum;
     
        LedgerJournalTable                  ledgerJournalTable;
       // LedgerJournalTrans                  ledgerJOurnalTrans;
        Numbersequencetable                 numSeqTable;
        MainAccount                         mainAccount;
        LedgerJournalTrans_Asset            LedgerJournalTrans_Asset;
        RefRecId                            recordvalue, offsetrecordvalue;
        //DimensionAttribute                  dimensionAttribute;
        //DimensionAttributeValue             dimensionAttributeValue;
        //DimensionSetSegmentName             dimensionSet;
        //DimensionStorage                    dimStorage, offsetdimStorage;
        //LedgerJournalTrans_Asset            LedgerJournalTrans_Asset;
        //LedgerAccountContract               ledgerAccountContract;// = new LedgerAccountContract();
        //LedgerAccountContract               offsetledgerAccountContract;// = new LedgerAccountContract();
        //DimensionAttributeValueContract     valueContract;
        //List                                valueContracts = new List(Types::Class);

        //dimensionAttributeValueCombination  dimensionAttributeValueCombination;
        common                              loccom;
       
       
     
     
        DimensionValueName         tmpLegal_Entity, tmpOffice_Location, tmpProject_Location, tmpDepartment, tmpService_Line, tmpSub_Service_Line, tmpIndustry,
                                            tmpSub_Industry, tmpCoIndustry, tmpPartner, tmpPM_Employee, tmpProject;
     
        container                           conAttr = [ "A_LegalEntity","B_Office_Location","C_Project_Location","D_Department","E_Service_Line","F_Sub_Service_Line","H_Industry","I_Sub_Industry","J_CoIndustry","G_Partner","PM_Employee","Project"];

        Dialog                              dialog = new Dialog("Import Journal lines");

     

        dlgUploadGroup                      = dialog.addGroup("@SYS54759");
        formBuildControl                    = dialog.formBuildDesign().control(dlgUploadGroup.name());
        fileUploadBuild                     = formBuildControl.addControlEx(classstr(FileUpload), "Import");

        fileUploadBuild.style(FileUploadStyle::MinimalWithFilename);
        fileUploadBuild.fileTypesAccepted('.xlsx');

        if (dialog.run() && dialog.closedOk())
        {

            FileUpload fileUploadControl     = dialog.formRun().control(dialog.formRun().controlId('Import'));
            FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult();

            if (fileUploadResult != null && fileUploadResult.getUploadStatus())
            {
                stream = fileUploadResult.openResult();
                using (ExcelPackage Package = new ExcelPackage(stream))
                {
                    int                         rowCount, i, j, k;
                    Package.Load(stream);
                    ExcelWorksheet  worksheet   = package.get_Workbook().get_Worksheets().get_Item(1);
                    OfficeOpenXml.ExcelRange    range       = worksheet.Cells;
                    rowCount                    = worksheet.Dimension.End.Row - worksheet.Dimension.Start.Row + 1;

                    for (i = 2; i<= rowCount; i++)
                    { 
                        ledgerJournalTrans      = ledgerJOurnalTrans_DS.cursor();
                        postingDate             = range.get_Item(i, 1).value;
                        ledgerAccType           = range.get_Item(i, 2).value;
                        ledgerMainAccount       = range.get_Item(i, 3).value;
                        transTxt                = range.get_Item(i, 4).value;
                        amountDebit             = range.get_Item(i, 5).value;
                        amountCredit            = range.get_Item(i, 6).value;
                        currencyCode            = range.get_Item(i, 7).value;
                        ExchRate                = range.get_Item(i, 8).value;
                        offsetAccType           = range.get_Item(i, 9).value;
                        offsetMainAccount       = range.get_Item(i, 10).value;
                        invoiceID               = range.get_Item(i, 11).value;
                        documentNum             = range.get_Item(i, 12).value;
                        documentDate            = range.get_Item(i, 13).value;
                        dueDate                 = range.get_Item(i, 14).value;
                        assetTransType          = range.get_Item(i, 15).value;
                        taxGroup                = range.get_Item(i, 16).value;
                        taxItemGroup            = range.get_Item(i, 17).value;
                        tmpLegal_Entity         = range.get_Item(i, 18).value;
                        tmpOffice_Location      = range.get_Item(i, 19).value;
                        tmpProject_Location     = range.get_Item(i, 20).value;
                        tmpDepartment           = range.get_Item(i, 21).value;
                        tmpService_Line         = range.get_Item(i, 22).value;
                        tmpSub_Service_Line     = range.get_Item(i, 23).value;
                        tmpIndustry             = range.get_Item(i, 24).value;
                        tmpSub_Industry         = range.get_Item(i, 25).value;
                        tmpCoIndustry           = range.get_Item(i, 26).value;
                        tmpPartner              = range.get_Item(i, 27).value;
                        tmpPM_Employee          = range.get_Item(i, 28).value;
                        tmpProject              = range.get_Item(i, 29).value;
                        //journalNum              = ledgerJournalTrans.JournalNum;

                        conVal                  = [tmpLegal_Entity, tmpOffice_Location, tmpProject_Location, tmpDepartment, tmpService_Line, tmpSub_Service_Line, tmpIndustry,
                                                    tmpSub_Industry, tmpCoIndustry, tmpPartner, tmpPM_Employee, tmpProject];
                        //ttsbegin;
                        if(ledgerJournalTrans.JournalNum)
                        {
                            //ledgerJournalTrans.clear();
                            //ledgerJournalTrans.initValue();
                            //ledgerAccountContract           = new LedgerAccountContract();
                            //offsetledgerAccountContract     = new LedgerAccountContract();

                            LedgerJournalTable  = LedgerJournalTable::find(ledgerJournalTrans.JournalNum);
                            numSeqTable         = NumberSequenceTable::find(LedgerJournalName::find(ledgerJournalTable.journalName).NumberSequenceTable);
                            numberseq           = numberseq::newGetVoucherFromCode(numSeqTable.NumberSequence);
                            voucher             = numberseq.voucher();
                            ledgerJournalTrans.Voucher              = voucher;
                            //Ledger Dim Begin
                            if(ledgeraccType    ==  '5')
                            {
                           
                                ledgerJournalTrans.AccountType          =  LedgerJournalACType::Bank;
                                ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(ledgerMainAccount, LedgerJournalACType::Bank);
                            }
                            if(ledgeraccType    ==  '1')
                            {
                             
                                ledgerJournalTrans.AccountType          =  LedgerJournalACType::Cust;
                                ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(ledgerMainAccount, LedgerJournalACType::Cust);
                            }
                            if(ledgeraccType    ==  '2')
                            {
                             
                                ledgerJournalTrans.AccountType          =  LedgerJournalACType::Vend;
                                ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(ledgerMainAccount, LedgerJournalACType::Vend);
                            }
                            if(ledgeraccType    ==  '4')
                            {
                               
                                ledgerJournalTrans.AccountType          =  LedgerJournalACType::FixedAssets;
                                ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(ledgerMainAccount, LedgerJournalACType::FixedAssets);
                            }
                            if(ledgeraccType    ==  '3')
                            {
                               
                                ledgerJournalTrans.AccountType          =  LedgerJournalACType::Project;
                                ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(ledgerMainAccount, LedgerJournalACType::Project);
                            }
                            if(ledgerAccType    ==  '0')
                            {
                                DimensionServiceProvider        DimensionServiceProvider    = new DimensionServiceProvider();
                                LedgerAccountContract           LedgerAccountContract       = new LedgerAccountContract();
                                DimensionAttributeValueContract                             ValueContract;
                                List ListValueContract                                      = new List(Types::Class);
                                dimensionAttributeValueCombination                          dimensionAttributeValueCombination;
                                DimensionStorage                                            dimStorage;
                                DimensionSetSegmentName                                     dimensionSet;
                                DimensionAttribute                                          dimensionAttribute;
                                DimensionAttributeValue                                     dimensionAttributeValue;

                                int64       ledger  = ledger::current();
                                mainAccount         = MainAccount::findByMainAccountId(ledgerMainAccount);
                                select mainAccount where mainAccount.MainAccountId == ledgerMainAccount;
                                recordvalue         = DimensionHierarchy::getAccountStructure(mainAccount.RecId,Ledger::current());
                                hierarchyCount      = DimensionHierarchy::getLevelCount(recordvalue);
                                DimensionSet        = DimensionHierarchyLevel::getDimensionHierarchyLevelNames(recordvalue);
                                for(hierarchyidx    = 1; hierarchyidx<=hierarchycount; hierarchyidx++)
                                {
                                    if(hierarchyidx == 1)
                                    continue;
                                    dimensionattribute = dimensionattribute::findbylocalizedname(dimensionset[hierarchyidx],false,"en-us");
                                    if(dimensionattribute)
                                    {
                                        dimensionattributevalue = dimensionattributevalue::findbydimensionattributeandvalue(dimensionattribute,conpeek(conval,hierarchyidx-1));
                                        if(dimensionattributevalue)
                                        {
                                            valuecontract = new dimensionattributevaluecontract();
                                            valuecontract.parmname(dimensionattribute.name) ;
                                            valuecontract.parmvalue(dimensionattributevalue.cacheddisplayvalue);
                                            ListValueContract.addend(valuecontract);
                                        }
                                    }
                                }

                                LedgerAccountContract.parmMainAccount(ledgerMainAccount);
                                LedgerAccountContract.parmValues(ListValueContract);
                                dimStorage  = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
                                dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
                                ledgerRecId = dimensionAttributeValueCombination.RecId;
                                ledgerDim   = ledgerRecId;
                            }
                            //Ledger Dim endds

                            //Offset Begin
                            if(offsetAccType    ==  '5')
                            {
                           
                                ledgerJournalTrans.OffsetAccountType    =  LedgerJournalACType::Bank;
                                offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(offsetMainAccount, LedgerJournalACType::Bank);
                            }
                            if(offsetAccType    ==  '1')
                            {
                             
                                ledgerJournalTrans.OffsetAccountType    =  LedgerJournalACType::Cust;
                                offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(offsetMainAccount, LedgerJournalACType::Cust);
                            }
                            if(offsetAccType    == '2')
                            {
                             
                                ledgerJournalTrans.OffsetAccountType    =  LedgerJournalACType::Vend;
                                offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(offsetMainAccount, LedgerJournalACType::Vend);
                            }
                            if(offsetAccType    ==  '4')
                            {
                               
                                ledgerJournalTrans.OffsetAccountType    =  LedgerJournalACType::FixedAssets;
                                offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(offsetMainAccount, LedgerJournalACType::FixedAssets);
                            }
                            if(offsetAccType    ==  '3')
                            {
                               
                                ledgerJournalTrans.OffsetAccountType    =  LedgerJournalACType::Project;
                                offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(offsetMainAccount, LedgerJournalACType::Project);
                            }
                            if(offsetAccType    ==  '0')
                            {
                                DimensionServiceProvider        offsetDimensionServiceProvider    = new DimensionServiceProvider();
                                LedgerAccountContract           offsetLedgerAccountContract       = new LedgerAccountContract();
                                DimensionAttributeValueContract                                   offsetValueContract;
                                List offsetListValueContract                                      = new List(Types::Class);
                                dimensionAttributeValueCombination                                offsetdimensionAttributeValueCombination;
                                DimensionStorage                                                  offsetdimStorage;
                                container                                                         offsetdimensionName = INTC_Global::getDimensionNameTID();
                                DimensionSetSegmentName                                           offsetdimensionSet;
                                DimensionAttribute                                                offsetdimensionAttribute;
                                DimensionAttributeValue                                           offsetdimensionAttributeValue;
                               
                                int64       ledger  = ledger::current();
                                mainAccount         = MainAccount::findByMainAccountId(offsetMainAccount);
                                select mainAccount where mainAccount.MainAccountId == offsetMainAccount;
                                offsetrecordvalue         = DimensionHierarchy::getAccountStructure(mainAccount.RecId,Ledger::current());
                                offsethierarchyCount      = DimensionHierarchy::getLevelCount(offsetrecordvalue);
                                offsetdimensionSet        = DimensionHierarchyLevel::getDimensionHierarchyLevelNames(offsetrecordvalue);
                                for(offsethierarchyIdx    = 1; offsethierarchyIdx <= offsethierarchyCount; offsethierarchyIdx++)
                                {
                                    if(offsethierarchyIdx == 1)
                                    continue;
                                    offsetdimensionAttribute = DimensionAttribute::findByLocalizedName(offsetdimensionSet[offsethierarchyIdx],false,"en-us");
                                    if(offsetdimensionAttribute)
                                    {
                                        offsetdimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(offsetdimensionAttribute,conPeek(conVal,offsethierarchyIdx-1));
                                        if(offsetdimensionAttributeValue)
                                        {
                                            offsetValueContract = new DimensionAttributeValueContract();
                                            offsetValueContract.parmName(offsetdimensionAttribute.Name) ;
                                            offsetValueContract.parmValue(offsetdimensionAttributeValue.CachedDisplayValue);
                                            offsetListValueContract.addEnd(offsetValueContract);
                                        }
                                    }
                                }
                                offsetledgerAccountContract.parmMainAccount(offsetMainAccount);
                                offsetledgerAccountContract.parmValues(offsetListValueContract);
                                offsetdimStorage  = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(offsetledgerAccountContract);
                                offsetdimensionAttributeValueCombination = DimensionAttributeValueCombination::find(offsetdimStorage.save());
                                offsetLedgerRecId = offsetdimensionAttributeValueCombination.RecId;
                                offsetLedgerDim   = offsetLedgerRecId;
                            }
                            // Offset Dim End

                            LedgerjournalTrans.LedgerDimension          = ledgerDim;
                            LedgerjournalTrans.OffsetLedgerDimension    = offsetLedgerDim;
                            LedgerjournalTrans.JournalNum               = ledgerJournalTable.JournalNum;
                            LedgerjournalTrans.TransDate                = postingDate;                           
                            ledgerJournalTrans.Txt                      = transTxt;
                            ledgerJournalTrans.AmountCurDebit           = amountDebit;
                            ledgerJournalTrans.AmountCurCredit          = amountCredit;
                            ledgerJournalTrans.CurrencyCode             = currencyCode;
                            ledgerJournalTrans.ExchRate                 = ExchRate;
                            ledgerJournalTrans.Invoice                  = invoiceID;
                            ledgerJournalTrans.DocumentNum              = documentNum;
                            ledgerJournalTrans.DocumentDate             = documentDate;
                            ledgerJournalTrans.Due                      = dueDate;
                            LedgerJournalTrans_Asset.TransType          = assetTransType;
                            ledgerJournalTrans.TaxGroup                 = taxGroup;
                            ledgerJournalTrans.TaxItemGroup             = taxItemGroup;

                            LedgerJournalEngine ledgerJournalEngine = new LedgerJournalEngine();
                            ledgerJournalEngine.accountNumModified(ledgerJournalTrans);
                               
                            ledgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans, LedgerDimension));
                            ledgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans, OffsetLedgerDimension));
                            ledgerJournalTrans.insert();

                        }
                        //ttscommit;
                    }
                }
            }
            else
            {
                error("Error");
            }
        }
    }

}