async void LoadGLTrans()
        {
            SetExpandAndCollapse(true);
            statementList.Clear();
            List <int> dim1 = null, dim2 = null, dim3 = null, dim4 = null, dim5 = null;

            var NumberOfDimensions = api.CompanyEntity.NumberOfDimensions;

            if (NumberOfDimensions >= 1)
            {
                dim1 = TransactionReport.GetRowIDs(cbdim1);
            }
            if (NumberOfDimensions >= 2)
            {
                dim2 = TransactionReport.GetRowIDs(cbdim2);
            }
            if (NumberOfDimensions >= 3)
            {
                dim3 = TransactionReport.GetRowIDs(cbdim3);
            }
            if (NumberOfDimensions >= 4)
            {
                dim4 = TransactionReport.GetRowIDs(cbdim4);
            }
            if (NumberOfDimensions >= 5)
            {
                dim5 = TransactionReport.GetRowIDs(cbdim5);
            }
            AccountStatement2.SetDateTime(txtDateFrm, txtDateTo);
            DateTime fromDate = AccountStatement2.DefaultFromDate, toDate = AccountStatement2.DefaultToDate;

            var isAscending = cbxAscending.IsChecked.Value;
            var skipBlank   = cbxSkipBlank.IsChecked.Value;

            var Pref = api.session.Preference;

            Pref.TransactionReport_isAscending = isAscending;
            Pref.TransactionReport_skipBlank   = skipBlank;

            string fromAccount = null, toAccount = null;
            var    accountObj = cmbFromAccount.EditValue;

            if (accountObj != null)
            {
                fromAccount = accountObj.ToString();
            }

            accountObj = cmbToAccount.EditValue;
            if (accountObj != null)
            {
                toAccount = accountObj.ToString();
            }

            string journal = cmbJournal.Text;

            busyIndicator.IsBusy = true;
            var transApi        = new Uniconta.API.GeneralLedger.ReportAPI(api);
            var dimensionParams = BalanceReport.SetDimensionParameters(dim1, dim2, dim3, dim4, dim5, true, true, true, true, true);
            var listTrans       = (GLTransClientTotal[])await transApi.GetTransactions(new GLTransClientTotal(), journal, fromAccount, toAccount, fromDate, toDate, dimensionParams, ReportAPI.SimplePrimo);

            if (listTrans != null)
            {
                string currentItem = null;
                AccountStatementList2     masterDbStatement = null;
                List <GLTransClientTotal> dbTransClientChildList = null;
                long SumAmount = 0, SumAmountCur = 0;
                byte currentCur = 0;

                foreach (var trans in listTrans)
                {
                    if (trans._Account != currentItem)
                    {
                        currentItem = trans._Account;

                        if (masterDbStatement != null)
                        {
                            if (!skipBlank || SumAmount != 0 || SumAmountCur != 0 || dbTransClientChildList.Count > 1)
                            {
                                masterDbStatement._SumAmount    = SumAmount / 100d;
                                masterDbStatement._SumAmountCur = SumAmountCur / 100d;
                                statementList.Add(masterDbStatement);
                            }
                        }

                        masterDbStatement              = new AccountStatementList2((GLAccount)accountCache.Get(currentItem));
                        dbTransClientChildList         = new List <GLTransClientTotal>();
                        masterDbStatement.ChildRecords = dbTransClientChildList;
                        SumAmount  = SumAmountCur = 0;
                        currentCur = (byte)masterDbStatement.Acc._Currency;
                    }

                    SumAmount   += trans._AmountCent;
                    trans._Total = SumAmount;
                    masterDbStatement._SumAmount = SumAmount;

                    if (trans._AmountCurCent != 0 && trans._Currency == currentCur)
                    {
                        SumAmountCur   += trans._AmountCurCent;
                        trans._TotalCur = SumAmountCur;
                    }

                    if (isAscending)
                    {
                        dbTransClientChildList.Add(trans);
                    }
                    else
                    {
                        dbTransClientChildList.Insert(0, trans);
                    }
                }

                if (masterDbStatement != null)
                {
                    if (!skipBlank || SumAmount != 0 || SumAmountCur != 0 || dbTransClientChildList.Count > 1)
                    {
                        masterDbStatement._SumAmount    = SumAmount / 100d;
                        masterDbStatement._SumAmountCur = SumAmountCur / 100d;
                        statementList.Add(masterDbStatement);
                    }
                }

                if (statementList.Count > 0)
                {
                    dgGLTrans.ItemsSource = null;
                    dgGLTrans.ItemsSource = statementList;
                }
                dgGLTrans.Visibility = Visibility.Visible;
            }
            else if (transApi.LastError != 0)
            {
                Uniconta.ClientTools.Util.UtilDisplay.ShowErrorCode(transApi.LastError);
            }
            busyIndicator.IsBusy = false;
            if (_master != null)
            {
                SetExpandAndCollapse(false);
            }
        }
示例#2
0
        async void LoadGLTrans()
        {
            childDgGLTrans.ClearSorting();
            SetExpandAndCollapse(true);
            List <int> dim1 = null, dim2 = null, dim3 = null, dim4 = null, dim5 = null;

            var NumberOfDimensions = api.CompanyEntity.NumberOfDimensions;

            if (NumberOfDimensions >= 1)
            {
                dim1 = TransactionReport.GetRowIDs(cbdim1);
            }
            if (NumberOfDimensions >= 2)
            {
                dim2 = TransactionReport.GetRowIDs(cbdim2);
            }
            if (NumberOfDimensions >= 3)
            {
                dim3 = TransactionReport.GetRowIDs(cbdim3);
            }
            if (NumberOfDimensions >= 4)
            {
                dim4 = TransactionReport.GetRowIDs(cbdim4);
            }
            if (NumberOfDimensions >= 5)
            {
                dim5 = TransactionReport.GetRowIDs(cbdim5);
            }
            AccountStatement.SetDateTime(txtDateFrm, txtDateTo);
            DateTime fromDate = AccountStatement.DefaultFromDate, toDate = AccountStatement.DefaultToDate;

            var showDimOnPrimo = cmbShowDimOnPrimo.SelectedIndex;

#if !SILVERLIGHT
            pageBreak = cbxPageBreak.IsChecked.Value;
#endif
            setShowDimOnPrimoIndex = showDimOnPrimo;

            string fromAccount = null, toAccount = null;
            var    accountObj = cmbFromAccount.EditValue;
            if (accountObj != null)
            {
                fromAccount = accountObj.ToString();
            }

            accountObj = cmbToAccount.EditValue;
            if (accountObj != null)
            {
                toAccount = accountObj.ToString();
            }

            busyIndicator.IsBusy = true;

            if (Simulated.Visible)
            {
                SimulatedVisible = true;
            }
            string journal = cmbJournal.Text;
            Simulated.Visible = SimulatedVisible && !string.IsNullOrWhiteSpace(journal);

            var dimensionParams = BalanceReport.SetDimensionParameters(dim1, dim2, dim3, dim4, dim5, true, true, true, true, true);
            var listTrans       = (GLTransClientTotal[])await transApi.GetTransactions(new GLTransClientTotal(), journal, fromAccount, toAccount, fromDate, toDate, dimensionParams, showDimOnPrimo);

            if (accountCache == null)
            {
                accountCache = await transApi.CompanyEntity.LoadCache(typeof(Uniconta.DataModel.GLAccount), api);
            }

            if (listTrans != null)
            {
                FillStatement(listTrans);
            }
            else if (transApi.LastError != 0)
            {
                Uniconta.ClientTools.Util.UtilDisplay.ShowErrorCode(transApi.LastError);
            }
            dgGLTrans.Visibility = Visibility.Visible;
            busyIndicator.IsBusy = false;
            SetExpandAndCollapse(IsCollapsed);
        }