private void DeleteJournal(InvJournalPostedClient selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }
            var deleteDialog = new DeletePostedJournal();

            deleteDialog.Closed += async delegate
            {
                if (deleteDialog.DialogResult == true)
                {
                    PostingAPI pApi = new PostingAPI(api);
                    ErrorCodes res  = await pApi.DeletePostedJournal(selectedItem, deleteDialog.Comment);

                    if (res == ErrorCodes.Succes)
                    {
                        UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("Journaldeleted"), selectedItem.RowId), Uniconta.ClientTools.Localization.lookup("Message"));
                        dgInvPostedJournal.UpdateItemSource(2, selectedItem);
                    }
                    else
                    {
                        UtilDisplay.ShowErrorCode(res);
                    }
                }
            };
            deleteDialog.Show();
        }
Exemplo n.º 2
0
        async void Import(BankImportFormatClient selectedbankFormat)
        {
            var journal = selectedbankFormat._Journal;

            if (journal == null)
            {
                SetMaster(selectedbankFormat);
            }

            var postingApi = new PostingAPI(api);

            var maxline = await postingApi.MaxLineNumber(journal);

            if (maxline == 0)
            {
                doImport(selectedbankFormat, postingApi, true, journal);
            }
            else
            {
                var text = string.Format(Uniconta.ClientTools.Localization.lookup("JournalContainsLines"), journal);
                CWConfirmationBox dialog = new CWConfirmationBox(text, Uniconta.ClientTools.Localization.lookup("Warning"), true);
                dialog.Closing += delegate
                {
                    var res = dialog.ConfirmationResult;
                    if (res != CWConfirmationBox.ConfirmationResultEnum.Cancel)
                    {
                        doImport(selectedbankFormat, postingApi, (res == CWConfirmationBox.ConfirmationResultEnum.No), journal);
                    }
                };
                dialog.Show();
            }
        }
Exemplo n.º 3
0
        public ErrorCodes Execute(UnicontaBaseEntity master, UnicontaBaseEntity currentRow, IEnumerable <UnicontaBaseEntity> source, string command, string args)
        {
            // Plugin must be installed on Control: GL_DailyJournal

            var journal = currentRow as GLDailyJournalClient;

            // TODO: Change Path
            using (TextFieldParser parser = new TextFieldParser(@"[FULL PATH TO DATA.CSV]"))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(";");
                // Read the first line to get rid of header
                parser.ReadFields();

                while (!parser.EndOfData)
                {
                    //Process row
                    string[] fields = parser.ReadFields();
                    // TODO: Process fields
                }

                // TODO insert new GLDailyJournalLines


                // Post Journals
                var postingAPI = new PostingAPI(Crud);

                // TODO Post (Bogfør) newly created GLDailyJournalLines
            }
            return(ErrorCodes.Succes);
        }
Exemplo n.º 4
0
        public ErrorCodes Execute(UnicontaBaseEntity master, UnicontaBaseEntity currentRow, IEnumerable <UnicontaBaseEntity> source, string command, string args)
        {
            // Plugin must be installed on Control: GL_DailyJournal
            var journal = currentRow as GLDailyJournalClient;

            Crud.LoadCache(typeof(DebtorClient)).Wait();

            // TODO: Change Path
            using (TextFieldParser parser = new TextFieldParser(@"C:\Users\Alexander Banks\api-training\JournalLoader\JournalLoader\Data.csv"))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(";");
                // Read the first line to get rid of header
                parser.ReadFields();

                var loc = Localization.GetLocalization(Language.da);

                var newJournalLines = new List <GLDailyJournalLineClient>();
                while (!parser.EndOfData)
                {
                    //Process row
                    string[] fields = parser.ReadFields();
                    // TODO: Process fields
                    var date        = DateTime.ParseExact(fields[0], "dd-MM-yyyy", CultureInfo.InvariantCulture);
                    var account     = fields[1];
                    var accountType = loc.Lookup(fields[2]);
                    var amount      = double.Parse(fields[3], CultureInfo.GetCultureInfo("da"));

                    var journalLine = new GLDailyJournalLineClient
                    {
                        // TODO: Insert properties from fields[]
                        Date        = date,
                        Account     = account,
                        _Account    = account,
                        AccountType = accountType,
                        Amount      = amount,
                    };
                    journal.Account = account;
                    journalLine.SetMaster(journal);
                    journal.Account = account;
                    newJournalLines.Add(journalLine);
                }

                // Done parsing file. Insert new journal lines.
                var result = Crud.Insert(newJournalLines).Result;
                if (result != ErrorCodes.Succes)
                {
                    // TODO: Do Error Handling.
                    return(result);
                }

                // Post Journals
                var postingAPI = new PostingAPI(Crud);
                var res        = postingAPI.PostDailyJournal(journal, DateTime.Now, "My Fine Comment", newJournalLines.Count, lines: newJournalLines).Result;
            }
            return(ErrorCodes.Succes);
        }
        private void InitializePage(List <UnicontaBaseEntity> masters = null)
        {
            this.DataContext = this;
            InitializeComponent();
            var Comp = this.api.CompanyEntity;

            filterDate         = BasePage.GetFilterDate(Comp, masters != null && masters.Count > 0);
            localMenu.dataGrid = dgAccountsTransGrid;
            SetRibbonControl(localMenu, dgAccountsTransGrid);
            if (IsmenuRemove)
            {
                RemoveMenuItem();
            }
            else
            {
                var CountryId = Comp._CountryId;
                if (CountryId == CountryCode.Iceland)
                {
                    if (api.session.User._Role < (byte)Uniconta.Common.User.UserRoles.Reseller)
                    {
                        RemoveDeleteVoucher();
                    }
                }
                else if ((CountryId == CountryCode.SouthAfrica || CountryId == CountryCode.UnitedKingdom || CountryId == CountryCode.Germany) &&
                         api.session.User._Role < (byte)Uniconta.Common.User.UserRoles.Distributor)
                {
                    RemoveDeleteVoucher();
                }
                if (Comp._UseQtyInLedger == false)
                {
                    RemoveChangeQuantity();
                }
            }
            masterlist = masters;
            gridControl.masterRecords = masters;
            dgAccountsTransGrid.api   = api;
            if (!Comp.HasDecimals)
            {
                Debit.HasDecimals = Credit.HasDecimals = Amount.HasDecimals = AmountBase.HasDecimals = AmountVat.HasDecimals = false;
            }
            dgAccountsTransGrid.BusyIndicator   = busyIndicator;
            localMenu.OnItemClicked            += localMenu_OnItemClicked;
            dgAccountsTransGrid.RowDoubleClick += DgAccountsTransGrid_RowDoubleClick;
            dgAccountsTransGrid.ShowTotalSummary();
            postingApiInv = new PostingAPI(api);

            if (Comp.GetCache(typeof(GLAccount)) == null)
            {
                api.LoadCache(typeof(GLAccount));
            }
        }
Exemplo n.º 6
0
 public GLAccountClosingSheetPage(UnicontaBaseEntity master)
     : base(master)
 {
     InitializeComponent();
     this.DataContext = this;
     masterRecord     = master as GLClosingSheet;
     postingApi       = new PostingAPI(api);
     rApi             = new Uniconta.API.GeneralLedger.ReportAPI(this.api);
     SetRibbonControl(localMenu, dgGLTable);
     dgGLTable.api      = api;
     localMenu.dataGrid = dgGLTable;
     dgGLTable.UpdateMaster(master);
     localMenu.OnItemClicked  += localMenu_OnItemClicked;
     dgGLTable.RowDoubleClick += dgGLTable_RowDoubleClick;
     dgGLTable.BusyIndicator   = busyIndicator;
     dgGLTable.View.DataControl.CurrentItemChanged += DataControl_CurrentItemChanged;
     ((TableView)dgGLTable.View).RowStyle           = Application.Current.Resources["RowStyle"] as Style;
 }
        private void InitializePage(UnicontaBaseEntity master = null)
        {
            InitializeComponent();
            var Comp = this.api.CompanyEntity;

            filterDate         = BasePage.GetFilterDate(Comp, master != null);
            localMenu.dataGrid = dgFamTransGrid;
            SetRibbonControl(localMenu, dgFamTransGrid);
            dgFamTransGrid.UpdateMaster(master);
            dgFamTransGrid.api = api;
            if (!Comp.HasDecimals)
            {
                Debit.HasDecimals = Credit.HasDecimals = Amount.HasDecimals = AmountBase.HasDecimals = AmountVat.HasDecimals = false;
            }
            dgFamTransGrid.BusyIndicator   = busyIndicator;
            localMenu.OnItemClicked       += localMenu_OnItemClicked;
            dgFamTransGrid.RowDoubleClick += DgFamTransGrid_RowDoubleClick;
            dgFamTransGrid.ShowTotalSummary();
            postingApiInv = new PostingAPI(api);
        }
        void TransferBankStatementToJournal()
        {
            CWTransferBankStatement winTransfer = new CWTransferBankStatement(fromDate, toDate, api, master, IsLedgerPosting: true);

            winTransfer.Closed += async delegate
            {
                if (winTransfer.DialogResult == true)
                {
                    master._Journal = winTransfer.Journal;
                    PostingAPI pApi = new PostingAPI(api);
                    var        res  = await pApi.TransferBankStatementToJournal(master, winTransfer.FromDate, winTransfer.ToDate, winTransfer.BankAsOffset, winTransfer.isMarkLine);

                    if (res == ErrorCodes.Succes)
                    {
                        string strmsg = string.Format("{0}; {1}! {2} ?", Uniconta.ClientTools.Localization.lookup("GenerateJournalLines"), Uniconta.ClientTools.Localization.lookup("Completed"),
                                                      string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"), Uniconta.ClientTools.Localization.lookup("JournalLines"))
                                                      );
                        var select = UnicontaMessageBox.Show(strmsg, Uniconta.ClientTools.Localization.lookup("Information"), MessageBoxButton.OKCancel);
                        if (select == MessageBoxResult.OK)
                        {
                            var jour = new GLDailyJournalClient();
                            jour._Journal = winTransfer.Journal;
                            var err = await api.Read(jour);

                            if (err == ErrorCodes.Succes)
                            {
                                AddDockItem(TabControls.GL_DailyJournalLine, jour, null, null, true);
                            }
                        }
                    }
                    else
                    {
                        UtilDisplay.ShowErrorCode(res);
                    }

                    InitQuery();
                }
            };
            winTransfer.Show();
        }
Exemplo n.º 9
0
 public void SetAPI(BaseAPI api)
 {
     _crudApi    = new CrudAPI(api);
     _postingAPI = new PostingAPI(api);
 }
Exemplo n.º 10
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgProjectJournal.SelectedItem as ProjectJournalClient;

            switch (ActionType)
            {
            case "AddRow":
                AddDockItem(TabControls.ProjectJournalPage2, api, string.Format("{0} {1}", Uniconta.ClientTools.Localization.lookup("Project"), Uniconta.ClientTools.Localization.lookup("Journal")), "Add_16x16.png");
                break;

            case "EditRow":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.ProjectJournalPage2, selectedItem, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Journal"), selectedItem.Journal));
                }
                break;

            case "ProjectJournalLine":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.ProjectJournalLinePage, selectedItem, string.Format("{0} {1} : {2}", Uniconta.ClientTools.Localization.lookup("Project"), Uniconta.ClientTools.Localization.lookup("Journal"), selectedItem.Journal));
                }
                break;

            case "JournalPosted":
                if (selectedItem != null)
                {
                    AddDockItem(TabControls.ProjectPostedJournalsPage, selectedItem, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("PostedJournals"), selectedItem.Journal));
                }
                break;

            case "DeleteAllJournalLines":
                if (selectedItem == null)
                {
                    return;
                }
                var             text = string.Format(Uniconta.ClientTools.Localization.lookup("JournalContainsLines"), selectedItem.Journal);
                EraseYearWindow EraseYearWindowDialog = new EraseYearWindow(text, false);
                EraseYearWindowDialog.Closed += async delegate
                {
                    if (EraseYearWindowDialog.DialogResult == true)
                    {
                        CloseDockItem(TabControls.ProjectJournalLinePage, selectedItem);
                        PostingAPI postApi = new PostingAPI(api);
                        var        res     = await postApi.DeleteJournalLines(selectedItem);

                        if (res != ErrorCodes.Succes)
                        {
                            UtilDisplay.ShowErrorCode(res);
                        }
                    }
                };
                EraseYearWindowDialog.Show();
                break;

            case "ImportData":
                if (selectedItem != null)
                {
                    OpenImportDataPage(selectedItem);
                }
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Exemplo n.º 11
0
        async private Task <ErrorCodes> ImportFromZipFile(BankImportFormatClient selectedbankFormat, SelectedFileInfo fileInfo, PostingAPI postingapi, bool append, DateTime fromDate, DateTime toDate)
        {
            var        zipContent      = new MemoryStream(fileInfo.FileBytes);
            var        zipFile         = new ZipFile(zipContent);
            ErrorCodes importZipResult = ErrorCodes.NoSucces;

            foreach (ZipEntry zipEntry in zipFile)
            {
                if (!zipEntry.IsFile)
                {
                    continue;
                }

                var bufferSize = (int)zipEntry.Size;
                var buffer     = UnistreamReuse.Create(bufferSize);
                var stream     = zipFile.GetInputStream(zipEntry);
                buffer.CopyFrom(stream);

                var zipFileInfo = new FileInfo(zipEntry.Name);
                importZipResult = await postingapi.ImportJournalLines(selectedbankFormat, buffer, append, fromDate, toDate);

                buffer.Release();

                if (importZipResult != ErrorCodes.Succes)
                {
                    break;
                }
            }

            return(importZipResult);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            int companyId      = 0;
            int IntervalOfDays = 0;

            if (!Int32.TryParse(ConfigurationManager.AppSettings["CompanyId"].ToString(), out companyId) || companyId == 0)
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }

            if (!Int32.TryParse(ConfigurationManager.AppSettings["IntervalOfDays"].ToString(), out IntervalOfDays) || IntervalOfDays == 0)
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }
            string tallyCompanyName = "";

            tallyCompanyName = ConfigurationManager.AppSettings["TallyCompanyName"].ToString();

            if (tallyCompanyName.Trim() == "")
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }

            Boolean isInsertPendingJobs = Convert.ToBoolean(ConfigurationManager.AppSettings["InsertPendingJobs"].ToString());

            if (isInsertPendingJobs)
            {
                List <PostingJob> postingJobList = PostingAPI.GetPendingPostingJobsForInputDate(companyId, IntervalOfDays);

                if (postingJobList != null && postingJobList.Count > 0)
                {
                    PostingAPI.InsertPostingStatus(companyId, postingJobList);
                }
            }



            //if (!BranchPosting.IsConnectingIPAddress())
            //{
            //    var Remarks = "Unable to connect to Server";
            //    Logger.WriteLog("Connection Failed :" + Remarks);
            //    //string msg = "Connection Failed :" + Remarks;
            //    //Email.SendMail(msg);
            //}

            try
            {
                Boolean isExportEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["ExportEnabled"].ToString());
                if (isExportEnabled)
                {
                    TallyExporter.ExportLedgersFromTally(companyId);
                }

                Boolean isExportCostCentreEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["ExportCostCentreEnabled"].ToString());
                if (isExportCostCentreEnabled)
                {
                    TallyExporter.ExportCostCentersFromTally(companyId);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog("Program", "Main", ex.Message);
            }

            Boolean isTestMode = Convert.ToBoolean(ConfigurationManager.AppSettings["TestMode"].ToString());

            if (isTestMode)
            {
                string   journeyDateStr = ConfigurationManager.AppSettings["JourneyDate"].ToString();
                DateTime journeyDate    = Convert.ToDateTime(journeyDateStr);

                Logger.WriteLog("Journey Date is :" + journeyDate.ToString("yyyy-MM-dd"));
                //Post Data to Tally
                BranchPosting.PostBranchData(companyId, journeyDate);
                // BranchPosting.PostBranchData(companyId, IntervalOfDays);
            }
            else
            {
                Logger.WriteLog("Started Job : First Checking Critical Log File Existence and then validation");
                string logpath = ConfigurationManager.AppSettings["LogPath"];
                if (File.Exists(@logpath + "Alertfile" + ".txt"))
                {
                    Logger.WriteLog("Validation Failed : Due to Existence of Critical File");
                    string msg = "Validation Failed :" + "Due to Existence of Critical File";
                    Email.SendMail(msg);
                }
                else
                {
                    List <PostingJob> pendingJobList = PostingAPI.GetPendingPostingJobsList(companyId);
                    Logger.WriteLog("No Of Pending Jobs: " + pendingJobList.Count);
                    if (pendingJobList != null && pendingJobList.Count > 0)
                    {
                        for (int i = 0; i < pendingJobList.Count; i++)
                        {
                            ValidationResult vr = BranchPosting.ValidateData(companyId, pendingJobList[i]);

                            if (vr.Status == 0)
                            {
                                // StatusId - 2 - Validation Failed
                                pendingJobList[i].StatusId = 2;
                                pendingJobList[i].Remarks  = vr.ErrorMessage;
                                Logger.WriteLogAlert("Running status to: " + "Validation Failed :" + pendingJobList[i].Remarks);
                                Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks);
                                PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                            }
                            else if (vr.Status == 1)
                            {
                                if (!TallyPostingAPI.IsTallyInstanceRunning())
                                {
                                    // Mark status as Cannot connect to Tally
                                    pendingJobList[i].StatusId = 3;
                                    pendingJobList[i].Remarks  = "Unable to connect to Tally";
                                    Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks);
                                    PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                }

                                else
                                {
                                    // Mark status as In-Progress
                                    pendingJobList[i].StatusId = 4;
                                    Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId);
                                    PostingAPI.UpdatePostingStatus(pendingJobList[i]);


                                    BranchPosting.PostBranchData(companyId, pendingJobList[i].JourneyDate);

                                    //Mark status as Completed
                                    pendingJobList[i].StatusId = 5;
                                    Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId);
                                    PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        async void doImport(BankImportFormatClient selectedbankFormat, PostingAPI postingApi, bool Append, string journal = null)
        {
            if (selectedbankFormat.Format != BankImportFormatType.LANDSBANKINN && selectedbankFormat.Format != BankImportFormatType.ISLANDSBANKI && selectedbankFormat.Format != BankImportFormatType.ARION)
            {
                if (ctrlBrowseFile.SelectedFileInfos == null && voucherClient == null)
                {
                    return;
                }
            }
            selectedbankFormat.BankAccountPos = cbBankAccountPos.Text;
            selectedbankFormat._Reverse       = chkReverse.IsChecked.Value;
            if (!selectedbankFormat._BankReconciliation)
            {
                if (selectedbankFormat.Format == BankImportFormatType.LANDSBANKINN || selectedbankFormat.Format == BankImportFormatType.ISLANDSBANKI || selectedbankFormat.Format == BankImportFormatType.ARION)
                {
                    selectedbankFormat._BankAccountNo = txtBankAccount.Text;
                }
                else
                {
                    selectedbankFormat._BankAccount = BankAccountLookupEditor.Text;
                }
                selectedbankFormat._PutLinesOnHold = chkPutLinesOnHold.IsChecked.Value;
            }
            else
            {
                if (selectedbankFormat.Format == BankImportFormatType.LANDSBANKINN || selectedbankFormat.Format == BankImportFormatType.ISLANDSBANKI || selectedbankFormat.Format == BankImportFormatType.ARION)
                {
                    selectedbankFormat._BankAccountNo = txtBankAccount.Text;
                }
            }

            Task <ErrorCodes> errt;
            ErrorCodes        err = ErrorCodes.NoSucces;
            var selectedFileInfo  = ctrlBrowseFile.SelectedFileInfos;

            if (selectedFileInfo != null && selectedFileInfo.Length > 0 && (selectedbankFormat.Format != BankImportFormatType.LANDSBANKINN || selectedbankFormat.Format != BankImportFormatType.ISLANDSBANKI || selectedbankFormat.Format != BankImportFormatType.ARION))
            {
                busyIndicator.IsBusy = true;
                foreach (var fileInfo in selectedFileInfo)
                {
                    if (fileInfo.FileExtension == ".zip")
                    {
                        err = await ImportFromZipFile(selectedbankFormat, fileInfo, postingApi, Append, txtFromDate.DateTime, txtToDate.DateTime);
                    }
                    else
                    {
                        errt = postingApi.ImportJournalLines(selectedbankFormat, new MemoryStream(fileInfo.FileBytes), Append, txtFromDate.DateTime, txtToDate.DateTime);
                        err  = await errt;
                    }

                    if (err != ErrorCodes.Succes)
                    {
                        break;
                    }
                }
            }
            else if (selectedbankFormat.Format == BankImportFormatType.LANDSBANKINN || selectedbankFormat.Format == BankImportFormatType.ISLANDSBANKI || selectedbankFormat.Format == BankImportFormatType.ARION)
            {
                busyIndicator.IsBusy = true;
                errt = postingApi.ImportJournalLines(selectedbankFormat, (Stream)null, Append, txtFromDate.DateTime, txtToDate.DateTime);
                err  = await errt;
            }
            else if (voucherClient != null)
            {
                busyIndicator.IsBusy = true;
                errt = postingApi.ImportJournalLines(selectedbankFormat, voucherClient, Append, txtFromDate.DateTime, txtToDate.DateTime);
                err  = await errt;
            }
            else
            {
                return;
            }

            busyIndicator.IsBusy = false;

            if (err != ErrorCodes.Succes)
            {
                UtilDisplay.ShowErrorCode(err);
            }
            else
            {
                var bsClient = importMaster as Uniconta.DataModel.BankStatement;
                if (bsClient != null)
                {
                    bsClient._BankImportId = selectedbankFormat.RowId;
                }

                ctrlBrowseFile.ResetControl();
                var text = string.Concat(Uniconta.ClientTools.Localization.lookup("ImportCompleted"), Environment.NewLine, string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"),
                                                                                                                                         !string.IsNullOrEmpty(journal) ? Uniconta.ClientTools.Localization.lookup("Journallines") : Uniconta.ClientTools.Localization.lookup("BankStatement")), " ?");

                var select = UnicontaMessageBox.Show(text, Uniconta.ClientTools.Localization.lookup("Information"), MessageBoxButton.OKCancel);
                if (select == MessageBoxResult.OK)
                {
                    if (selectedbankFormat._BankReconciliation)
                    {
                        ShowBankStatementLines(selectedbankFormat.BankAccount);
                    }
                    else
                    {
                        ShowGlDailyJournalLines(journal);
                    }
                }
            }
        }
Exemplo n.º 14
0
        public static void PostBranchData(int companyid, DateTime journeyDate)
        {
            // Initialize entry counter to Zero
            EntryCounter.GetInstance().ResetCount();

            Boolean toPostBranchBookings = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBranchBookings"].ToString());

            if (toPostBranchBookings)
            {
                #region Branch  Bookings


                try
                {
                    Logger.WriteLog("Started Branch Booking...");
                    List <Booking> bookingsList = BookingsAPI.GetBranchBookings(companyid, journeyDate);
                    Logger.WriteLog("Entry No 1 :  Branch Collection List : " + bookingsList.Count);

                    if (bookingsList != null && bookingsList.Count > 0)
                    {
                        BookingsAPI.CreateJournalForUserWiseCollection(companyid, bookingsList);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog("BranchPosting", "PostBranchBookings", "Exception in Posting Bookings: " + ex.Message);
                }


                #endregion
            }

            Boolean toPostOnlineAgentCollection = Convert.ToBoolean(ConfigurationManager.AppSettings["PostOnlineAgentCollection"].ToString());

            if (toPostOnlineAgentCollection)
            {
                #region Online Agent Collection


                try
                {
                    Logger.WriteLog("Started Online Agent Collection...");
                    List <OnlineAgentDetails> AgentList = OnlineAgentAPI.GetOnlineAgentCollection(companyid, journeyDate);
                    Logger.WriteLog("Entry No 2: Online Agent Collection List: " + AgentList.Count);

                    if (AgentList != null && AgentList.Count > 0)
                    {
                        OnlineAgentAPI.CreateJournalForOnlineAgentCollection(companyid, AgentList);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog("OnlineAgentPosting", "PostOnlineAgentCollection", "Exception in Posting AgentCollection: " + ex.Message);
                }


                #endregion
            }

            Boolean toPostOfflineAgentCollection = Convert.ToBoolean(ConfigurationManager.AppSettings["PostOfflineAgentCollection"].ToString());

            if (toPostOfflineAgentCollection)
            {
                #region Offline Agent Collection


                try
                {
                    Logger.WriteLog("Started Offline Agent Collection...");
                    List <OfflineAgentDetails> AgentList = OfflineAgentAPI.GetOfflineAgentCollection(companyid, journeyDate);
                    Logger.WriteLog("Entry No 3: Offline Agent Collection List: " + AgentList.Count);

                    if (AgentList != null && AgentList.Count > 0)
                    {
                        OfflineAgentAPI.CreateJournalForOfflineAgentCollection(companyid, AgentList);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog("OfflineAgentPosting", "PostOfflineAgentCollection", "Exception in Posting AgentCollection: " + ex.Message);
                }


                #endregion
            }

            Boolean toFranchiseBookings = Convert.ToBoolean(ConfigurationManager.AppSettings["PostFranchiseCollection"].ToString());

            if (toFranchiseBookings)
            {
                #region Franchise  Bookings


                try
                {
                    Logger.WriteLog("Started Franchise Booking...");
                    List <Franchise> franchiseList = FranchiseAPI.GetFranchiseCollection(companyid, journeyDate);
                    Logger.WriteLog("Entry No 4: Franchise Collection List: " + franchiseList.Count);

                    if (franchiseList != null && franchiseList.Count > 0)
                    {
                        FranchiseAPI.CreateSaleForFranchiseCollection(companyid, franchiseList);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLog("FranchisePosting", "PostFranchiseBookings", "Exception in Posting Franchise Bookings: " + ex.Message);
                }


                #endregion
            }

            Boolean toPostJournalEntry = Convert.ToBoolean(ConfigurationManager.AppSettings["PostJournalEntry"].ToString());
            if (toPostJournalEntry)
            {
                #region PostJournalEntry

                string logpath = ConfigurationManager.AppSettings["LogPath"];
                if (!File.Exists(@logpath + "Alertfile2" + ".txt"))
                {
                    Logger.WriteLog("Journal Entry Creation and Posting");
                    List <Journal> journalList = AccountingAPI.GetJournals(companyid);
                    Logger.WriteLog("Journal list Count: " + journalList.Count);
                    if (journalList != null && journalList.Count > 0)
                    {
                        for (int i = 0; i < journalList.Count; i++)
                        {
                            Logger.WriteLog("Entry Serial Journal : " + i + 1);
                            Journal jl = journalList[i];
                            List <JournalDetail> jdList = AccountingAPI.GetJournalDetail(jl.JournalId, jl.Type);
                            try
                            {
                                TallyResponse tr = TallyPostingAPI.PostJournal(jl, jdList);
                                if (tr != null && tr.Status == "1")
                                {
                                    AccountingAPI.UpdateTallyJournalIdInCRS(jl.JournalId, tr.EntityId);
                                }
                                //else
                                //{
                                //    Logger.WriteLogAlert("AccountingAPI " + "Error:PostingJournalIdInTally For JournalID: " + jl.JournalId);
                                //    //PostingAPI.UpdatePostingStatusForException(companyid, journalList[i].JournalDateTime, 10);
                                //    //throw new Exception();

                                //}
                            }
                            catch (Exception ex)
                            {
                                Logger.WriteLog("Posting Error", "Posting Error", " Posting Error: " + ex.Message);
                                //Logger.WriteLogAlert2("Posting Erro" + " Error for Posting : " + ex.Message);
                                PostingAPI.UpdatePostingStatusForException(companyid, journalList[i].JournalDateTime, 10);
                            }
                        }
                    }


                    //if (EntryCounter.GetInstance().GetCount() != journalList.Count)
                    //{
                    //    Email.SendMail("Mismatch in No Of Entry Generated Vs. Posted for Journey Date: " + journalList[0].JournalDateTime + " No Of Entry Generated: " + EntryCounter.GetInstance().GetCount() + " No Of Entry Posted: " + journalList.Count);
                    //}
                }
                else
                {
                    Logger.WriteLog("Posting not started, because there is generating error already exist. First remove it then continue..");
                }
                #endregion
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            int companyId      = 0;
            int IntervalOfDays = 0;

            if (!Int32.TryParse(ConfigurationManager.AppSettings["CompanyId"].ToString(), out companyId) || companyId == 0)
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }

            if (!Int32.TryParse(ConfigurationManager.AppSettings["IntervalOfDays"].ToString(), out IntervalOfDays) || IntervalOfDays == 0)
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }
            string tallyCompanyName = "";

            tallyCompanyName = ConfigurationManager.AppSettings["TallyCompanyName"].ToString();

            if (tallyCompanyName.Trim() == "")
            {
                Logger.WriteLog("Program", "Main", "Company Not Defined.");
                return;
            }

            //Boolean isInsertPendingJobs = Convert.ToBoolean(ConfigurationManager.AppSettings["InsertPendingJobs"].ToString());
            //if (isInsertPendingJobs)
            //{
            //    List<PostingJob> postingJobList = PostingAPI.GetPendingPostingJobsForInputDate(companyId, IntervalOfDays);

            //    if (postingJobList != null && postingJobList.Count > 0)
            //    {
            //        PostingAPI.InsertPostingStatus(companyId, postingJobList);
            //    }

            //}



            //if (!BranchPosting.IsConnectingIPAddress())
            //{
            //    var Remarks = "Unable to connect to Server";
            //    Logger.WriteLog("Connection Failed :" + Remarks);
            //    //string msg = "Connection Failed :" + Remarks;
            //    //Email.SendMail(msg);
            //}

            try
            {
                Boolean isExportEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["ExportEnabled"].ToString());
                if (isExportEnabled)
                {
                    TallyExporter.ExportLedgersFromTally(companyId);
                }

                Boolean isExportCostCentreEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["ExportCostCentreEnabled"].ToString());
                if (isExportCostCentreEnabled)
                {
                    TallyExporter.ExportCostCentersFromTally(companyId);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog("Program", "Main", ex.Message);
            }

            Boolean isTestMode = Convert.ToBoolean(ConfigurationManager.AppSettings["TestMode"].ToString());

            if (isTestMode)
            {
                string   journeyDateStr = ConfigurationManager.AppSettings["JourneyDate"].ToString();
                DateTime journeyDate    = Convert.ToDateTime(journeyDateStr);

                Boolean Del = Convert.ToBoolean(ConfigurationManager.AppSettings["DeletingScript"].ToString());

                if (Del)
                {
                    string strErr      = "";
                    CRSDAL dal         = new CRSDAL();
                    string JourneyDate = ConfigurationManager.AppSettings["DeletingDate"].ToString();
                    try
                    {
                        dal = new CRSDAL();
                        dal.AddParameter("p_CompanyID", companyId, ParameterDirection.Input);
                        dal.AddParameter("p_JourneyDate", journeyDate, ParameterDirection.Input);

                        int status = dal.ExecuteDML("spKabraTallySet_OnlineAgentCollection", CommandType.StoredProcedure, 0, ref strErr);

                        if (strErr != "")
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLog("Error in deletion for Date : " + JourneyDate + " " + ex.Message);
                    }
                }
                else
                {
                    Logger.WriteLog("Journey Date is :" + journeyDate.ToString("yyyy-MM-dd"));
                    //Post Data to Tally
                    BranchPosting.PostBranchData(companyId, journeyDate);
                    // BranchPosting.PostBranchData(companyId, IntervalOfDays);
                }
            }
            else
            {
                Logger.WriteLog("Started Job : First Checking Critical Log File Existence and then validation");
                string logpath = ConfigurationManager.AppSettings["LogPath"];
                if (File.Exists(@logpath + "Alertfile" + ".txt") || File.Exists(@logpath + "Alertfile2" + ".txt"))
                {
                    Logger.WriteLog("Validation Failed : Due to Existence of Critical File");
                    string msg = "Validation Failed :" + "Due to Existence of Critical File";
                    Email.SendMail(msg);
                }
                else
                {
                    List <PostingJob> pendingJobList = PostingAPI.GetPendingPostingJobsList(companyId);
                    Logger.WriteLog("No Of Pending Jobs: " + pendingJobList.Count);
                    if (pendingJobList != null && pendingJobList.Count > 0)
                    {
                        for (int i = 0; i < pendingJobList.Count; i++)
                        {
                            int     arrSlaveValue = 0;
                            int     intMinSecondsBehindMasterRequired = Convert.ToInt32(ConfigurationManager.AppSettings["MinSecondsBehindMasterRequired"]);
                            CRSDAL  dal     = new CRSDAL();
                            Boolean running = dal.SlaveStatus(ref arrSlaveValue);

                            // If Server Replicating is Delayed more than 300 sec
                            if (running && arrSlaveValue > intMinSecondsBehindMasterRequired)
                            {
                                pendingJobList[i].StatusId = 8;
                                pendingJobList[i].Remarks  = "Server Problem";
                                Logger.WriteLogAlert("Running status to: " + pendingJobList[i].StatusId + " Validation Failed :" + pendingJobList[i].Remarks + " Before Posting");
                                Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks + " Before Posting");
                                PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                            }
                            // If All is fine
                            else if (running && arrSlaveValue <= intMinSecondsBehindMasterRequired)
                            {
                                ValidationResult vr = BranchPosting.ValidateData(companyId, pendingJobList[i]);

                                if (vr.Status == 0)
                                {
                                    // StatusId - 2 - Validation Failed
                                    pendingJobList[i].StatusId = 2;
                                    pendingJobList[i].Remarks  = vr.ErrorMessage;
                                    Logger.WriteLogAlert("Running status to: " + pendingJobList[i].StatusId + " Validation Failed :" + pendingJobList[i].Remarks);
                                    Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks);
                                    PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                }
                                else if (vr.Status == 1)
                                {
                                    if (!TallyPostingAPI.IsTallyInstanceRunning())
                                    {
                                        // Mark status as Cannot connect to Tally
                                        pendingJobList[i].StatusId = 3;
                                        pendingJobList[i].Remarks  = "Unable to connect to Tally";
                                        Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks);
                                        PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                    }

                                    else
                                    {
                                        // Mark status as In-Progress
                                        pendingJobList[i].StatusId = 4;
                                        Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId);
                                        PostingAPI.UpdatePostingStatus(pendingJobList[i]);

                                        BranchPosting.PostBranchData(companyId, pendingJobList[i].JourneyDate);

                                        //if (File.Exists(@logpath + "Alertfile2" + ".txt"))
                                        //{
                                        //    //Nothing to do
                                        //}
                                        //else if (File.Exists(@logpath + "Alertfile" + ".txt"))
                                        //{
                                        //    Logger.WriteLog("Database error During Progress");
                                        //    string msg = "During Progress :" + " Due to Existence of Critical File";
                                        //    Email.SendMail(msg);
                                        //    pendingJobList[i].StatusId = 11;
                                        //    Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId);
                                        //    PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                        //}
                                        //else
                                        //{
                                        //Mark status as Completed
                                        pendingJobList[i].StatusId = 5;
                                        Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId);
                                        PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                                        //}
                                    }
                                }
                            }
                            // If Server is not Replicating
                            else
                            {
                                pendingJobList[i].StatusId = 8;
                                pendingJobList[i].Remarks  = "Server Porblem";
                                Logger.WriteLogAlert("Running status to: " + pendingJobList[i].StatusId + " Validation Failed :" + pendingJobList[i].Remarks + " Replication Stopped");
                                Logger.WriteLog("Updating status to: " + pendingJobList[i].StatusId + " Remarks: " + pendingJobList[i].Remarks + " Replication Stopped");
                                PostingAPI.UpdatePostingStatus(pendingJobList[i]);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            string header;
            var    selectedItem = dgAccountsTransGrid.SelectedItem as GLTransClient;

            switch (ActionType)
            {
            case "PostedTransaction":
                if (selectedItem == null)
                {
                    return;
                }
                header = string.Format("{0} / {1}", Uniconta.ClientTools.Localization.lookup("PostedTransactions"), selectedItem._JournalPostedId);
                AddDockItem(TabControls.PostedTransactions, selectedItem, header);
                break;

            case "ViewDownloadRow":
                if (selectedItem != null)
                {
                    DebtorTransactions.ShowVoucher(dgAccountsTransGrid.syncEntity, api, busyIndicator);
                }
                break;

            case "VoucherTransactions":
                if (selectedItem == null)
                {
                    return;
                }
                header = string.Format("{0} ({1})", Uniconta.ClientTools.Localization.lookup("VoucherTransactions"), selectedItem._Voucher);
                AddDockItem(TabControls.AccountsTransaction, dgAccountsTransGrid.syncEntity, header);
                break;

            case "AccountsTransaction":
                if (selectedItem != null)
                {
                    var glAccount = selectedItem.Master;
                    if (glAccount == null)
                    {
                        return;
                    }
                    string accHeader = string.Format("{0} ({1})", Uniconta.ClientTools.Localization.lookup("AccountsTransaction"), selectedItem._Account);
                    AddDockItem(TabControls.AccountsTransaction, glAccount, accHeader);
                }
                break;

            case "DragDrop":
            case "ImportVoucher":
                if (selectedItem != null)
                {
                    AddVoucher(selectedItem, ActionType);
                }
                break;

            case "CancelVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                CWCommentsDialogBox commentsDialog = new CWCommentsDialogBox(Uniconta.ClientTools.Localization.lookup("CancelVoucher"),
                                                                             true, selectedItem.Date);
#if !SILVERLIGHT
                commentsDialog.DialogTableId = 2000000035;
#endif
                commentsDialog.Closing += async delegate
                {
                    if (commentsDialog.DialogResult == true)
                    {
                        busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                        busyIndicator.IsBusy      = true;

                        var comments   = commentsDialog.Comments;
                        var date       = commentsDialog.Date;
                        var errorCodes = await postingApiInv.CancelVoucher(selectedItem, comments, date);

                        busyIndicator.IsBusy = false;

                        if (errorCodes != ErrorCodes.Succes)
                        {
                            UtilDisplay.ShowErrorCode(errorCodes);
                        }
                        else
                        {
                            UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("TransCanceled"), Uniconta.ClientTools.Localization.lookup("Error"));
                            BindGrid();
                        }
                    }
                };
                commentsDialog.Show();
                break;

            case "DeleteVoucher":
                if (selectedItem == null)
                {
                    return;
                }
                var deleteDialog = new DeletePostedJournal();
                deleteDialog.Closed += async delegate
                {
                    if (deleteDialog.DialogResult == true)
                    {
                        PostingAPI pApi = new PostingAPI(api);
                        ErrorCodes res  = await pApi.DeletePostedVoucher(selectedItem, deleteDialog.Comment);

                        UtilDisplay.ShowErrorCode(res);
                        if (res == ErrorCodes.Succes)
                        {
                            dgAccountsTransGrid.ItemsSource = new GLTransClient[0];
                        }
                    }
                };
                deleteDialog.Show();
                break;

            case "InvertSign":
                if (selectedItem != null)
                {
                    InvertSign(selectedItem);
                }
                break;

            case "RefVoucher":
                if (selectedItem == null)
                {
                    return;
                }

                var _refferedVouchers = new List <int>();
                var source            = (IList)dgAccountsTransGrid.ItemsSource;
                if (source != null)
                {
                    foreach (var statementLine in (IEnumerable <GLTrans>)source)
                    {
                        if (statementLine._DocumentRef != 0)
                        {
                            _refferedVouchers.Add(statementLine._DocumentRef);
                        }
                    }
                }
                CWAttachVouchers attachVouchersDialog = new CWAttachVouchers(api, _refferedVouchers);
                attachVouchersDialog.Closing += delegate
                {
                    if (attachVouchersDialog.DialogResult == true)
                    {
                        if (attachVouchersDialog.VoucherReference != 0 && selectedItem != null)
                        {
                            SaveAttachment(selectedItem, attachVouchersDialog.Voucher);
                        }
                    }
                };
                attachVouchersDialog.Show();
                break;

            case "RemoveVoucher":
                if (selectedItem == null || selectedItem._DocumentRef == 0)
                {
                    return;
                }
                if (UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("AskRemoveDocument"), Uniconta.ClientTools.Localization.lookup("Confirmation"), MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    postingApiInv.AddPhysicalVoucher(selectedItem, null, true);
                    selectedItem._DocumentRef = 0;
                }
                break;

            case "ChangeDimension":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeDimensionDialog = new CWChangeDimension(api, isChangeText: false);
                    ChangeDimensionDialog.Closing += delegate
                    {
                        if (ChangeDimensionDialog.DialogResult == true)
                        {
                            SetNewDim(selectedItem, ChangeDimensionDialog);
                        }
                    };
                    ChangeDimensionDialog.Show();
                }
                break;

            case "ChangeText":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeTextDialog = new CWChangeDimension(api, isChangeDimension: false);
                    ChangeTextDialog.Closing += delegate
                    {
                        if (ChangeTextDialog.DialogResult == true)
                        {
                            SetChangeText(selectedItem, ChangeTextDialog);
                        }
                    };
                    ChangeTextDialog.Show();
                }
                break;

            case "ChangeReference":
                if (selectedItem != null)
                {
                    CWChangeDimension updateReferenceDialog = new CWChangeDimension(api, isChangeDimension: false);
                    updateReferenceDialog.Closing += delegate
                    {
                        if (updateReferenceDialog.DialogResult == true)
                        {
                            SetChangeReference(selectedItem, updateReferenceDialog);
                        }
                    };
                    updateReferenceDialog.Show();
                }
                break;

            case "ChangeQuantity":
                if (selectedItem != null)
                {
                    CWChangeDimension ChangeQtyDialog = new CWChangeDimension(api, isChangeDimension: false, isChangeText: false);
                    ChangeQtyDialog.Closing += delegate
                    {
                        if (ChangeQtyDialog.DialogResult == true)
                        {
                            SetChangeQuantity(selectedItem, ChangeQtyDialog);
                        }
                    };
                    ChangeQtyDialog.Show();
                }
                break;

            case "AddEditNote":
                if (selectedItem != null)
                {
                    CWAddEditNote cwAddEditNote = new CWAddEditNote(api, null, selectedItem);
                    cwAddEditNote.Closed += delegate
                    {
                        if (cwAddEditNote.DialogResult == true)
                        {
                            if (cwAddEditNote.result == ErrorCodes.Succes)
                            {
                                BindGrid();
                            }
                        }
                    };
                    cwAddEditNote.Show();
                }
                break;

            case "PostedBy":
                if (selectedItem != null)
                {
                    JournalPosted(selectedItem);
                }
                break;

            case "ChangeDate":
                if (selectedItem == null)
                {
                    return;
                }
                var dateSelector = new CWDateSelector(selectedItem.Date, true);
#if !SILVERLIGHT
                dateSelector.DialogTableId = 2000000058;
#endif
                dateSelector.Closed += delegate
                {
                    if (dateSelector.DialogResult == true)
                    {
                        SetChangeDate(selectedItem, dateSelector.SelectedDate);
                    }
                };
                dateSelector.Show();
                break;

            case "RemoveVat":
                if (selectedItem != null)
                {
                    RemoveVat(selectedItem);
                }
                break;

            case "AddVat":
                if (selectedItem != null)
                {
                    AddVat(selectedItem);
                }
                break;

            case "SetNewDcAccount":
                if (selectedItem != null)
                {
                    SetNewAccount(selectedItem);
                }
                break;

            case "CopyVoucherToJournal":
                if (selectedItem != null)
                {
                    CopyToJOurnal();
                }
                break;

            case "ExportVouchers":
                var glTrans = ((IEnumerable <GLTransClient>)dgAccountsTransGrid.GetVisibleRows())?.Where(x => x._DocumentRef != 0);
                AddDockItem(TabControls.VoucherExportPage, new object[] { glTrans }, Uniconta.ClientTools.Localization.lookup("ExportVouchers"));
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }
Exemplo n.º 17
0
        private void localMenu_OnItemClicked(string ActionType)
        {
            var selectedItem = dgGldailyJournal.SelectedItem as GLDailyJournalClient;

            switch (ActionType)
            {
            case "AddRow":
                AddDockItem(TabControls.GLDailyJournalPage2, api, Uniconta.ClientTools.Localization.lookup("Posting"), "Add_16x16.png");
                break;

            case "EditRow":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.GLDailyJournalPage2, selectedItem);
                break;

            case "GLDailyJournalLine":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.GL_DailyJournalLine, selectedItem);
                break;

            case "GLDailyJournalPosted":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.PostedJournals, selectedItem);
                break;

            case "MatchVoucherToJournalLines":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.MatchPhysicalVoucherToGLDailyJournalLines, selectedItem);
                break;

            case "DeleteAllJournalLines":
                if (selectedItem == null)
                {
                    return;
                }
                var             text = string.Format(Uniconta.ClientTools.Localization.lookup("JournalContainsLines"), selectedItem._Name);
                EraseYearWindow EraseYearWindowDialog = new EraseYearWindow(text, false);
                EraseYearWindowDialog.Closed += async delegate
                {
                    if (EraseYearWindowDialog.DialogResult == true)
                    {
                        CloseDockItem(TabControls.GL_DailyJournalLine, selectedItem);
                        PostingAPI postApi = new PostingAPI(api);
                        var        res     = await postApi.DeleteJournalLines(selectedItem);

                        UtilDisplay.ShowErrorCode(res);
                        selectedItem.NumberOfLines = 0;
                    }
                };
                EraseYearWindowDialog.Show();
                break;

            case "ImportBankStatement":
                if (selectedItem == null)
                {
                    return;
                }
                AddDockItem(TabControls.ImportGLDailyJournal, selectedItem, string.Concat(string.Format(Uniconta.ClientTools.Localization.lookup("ImportOBJ"),
                                                                                                        Uniconta.ClientTools.Localization.lookup("BankStatement")), " : ", selectedItem._Journal), null, true);
                break;

            case "TransType":
                AddDockItem(TabControls.GLTransTypePage, null, Uniconta.ClientTools.Localization.lookup("TransTypes"));
                break;

            case "AppendTransType":
                CWAppendEnumeratedLabel dialog = new CWAppendEnumeratedLabel(api);
                dialog.Show();
                break;

            case "ImportData":
                if (selectedItem == null)
                {
                    return;
                }
                OpenImportDataPage(selectedItem);
                break;

            case "GLOffSetAccountTemplate":
                AddDockItem(TabControls.GLOffsetAccountTemplate, null, Uniconta.ClientTools.Localization.lookup("OffsetAccountTemplates"));
                break;

            case "AccountActivity":
                if (selectedItem == null)
                {
                    return;
                }

                AddDockItem(TabControls.GLTransLogPage, selectedItem, string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("GLTransLog"), selectedItem._Journal));
                break;

            case "BilagscanReadVouchers":
                ReadFromBilagscan(selectedItem);
                break;

            default:
                gridRibbon_BaseActions(ActionType);
                break;
            }
        }