Exemplo n.º 1
0
        void OnUpdate(bool hide = false)
        {
            if (!UserSubdivisions.Any())
            {
                ServicesConfig.InteractiveService.ShowMessage(ImportanceLevel.Error, "Пользователь не имеет доступа к кассам. Отчет сформировать невозможно.");
                return;
            }

            LoadReport?.Invoke(this, new LoadReportEventArgs(GetReportInfo(), hide));
        }
Exemplo n.º 2
0
        public CashBookReport(ISubdivisionRepository subdivisionRepository, ICommonServices commonServices)
        {
            this.Build();
            this.subdivisionRepository = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.commonServices        = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            UoW = UnitOfWorkFactory.CreateWithoutRoot();
            UserSubdivisions = GetSubdivisionsForUser();

            dateperiodpicker.StartDate = DateTime.Now.Date;
            dateperiodpicker.EndDate   = DateTime.Now.Date;

            #region Выбор кассы
            var subdivisions = subdivisionRepository.GetSubdivisionsForDocumentTypes(UoW, new Type[] { typeof(Income), typeof(Income) });
            var itemsList    = subdivisions.ToList();
            {
                IEnumerable <int> fromTypes = itemsList.Select(x => x.Id);
                IEnumerable <int> fromUser  = UserSubdivisions.Select(x => x.Id);
                if (!new HashSet <int>(fromTypes).IsSupersetOf(fromUser))
                {
                    subdivisions = itemsList.Concat(UserSubdivisions);
                }
            }
            itemsList.Add(new Subdivision {
                Name = "Все"
            });

            yspeccomboboxCashSubdivision.SetRenderTextFunc <Subdivision>(s => s.Name);
            yspeccomboboxCashSubdivision.ItemsList    = itemsList;
            yspeccomboboxCashSubdivision.SelectedItem = UserSubdivisions.Count != 0 ? UserSubdivisions?.First() : itemsList.First();
            #endregion

            hboxOrganisations.Visible = false;
            Organizations             = UoW.GetAll <Organization>();
            specialListCmbOrganisations.SetRenderTextFunc <Organization>(s => s.Name);
            specialListCmbOrganisations.ItemsList = Organizations;

            int  currentUserId = commonServices.UserService.CurrentUserId;
            bool canCreateCashReportsForOrganisations =
                commonServices.PermissionService.ValidateUserPresetPermission("can_create_cash_reports_for_organisations", currentUserId);
            ycheckOrganisations.Visible  = canCreateCashReportsForOrganisations;
            ycheckOrganisations.Toggled += CheckOrganisationsToggled;

            buttonCreateRepot.Clicked += OnButtonCreateRepotClicked;
        }
Exemplo n.º 3
0
        private ReportInfo GetReportInfo()
        {
            string ReportName;

            switch (checkOrganisations.Active)
            {
            case true:
                if (checkDetail.Active)
                {
                    if (comboPart.SelectedItem.Equals(Gamma.Widgets.SpecialComboState.All))
                    {
                        ReportName = "Cash.CashFlowDetailOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.IncomeAll))
                    {
                        ReportName = "Cash.CashFlowDetailIncomeAllOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Income))
                    {
                        ReportName = "Cash.CashFlowDetailIncomeOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.IncomeReturn))
                    {
                        ReportName = "Cash.CashFlowDetailIncomeReturnOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.ExpenseAll))
                    {
                        ReportName = "Cash.CashFlowDetailExpenseAllOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Expense))
                    {
                        ReportName = "Cash.CashFlowDetailExpenseOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Advance))
                    {
                        ReportName = "Cash.CashFlowDetailAdvanceOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.AdvanceReport))
                    {
                        ReportName = "Cash.CashFlowDetailAdvanceReportOrganisations";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.UnclosedAdvance))
                    {
                        ReportName = "Cash.CashFlowDetailUnclosedAdvanceOrganisations";
                    }
                    else
                    {
                        throw new InvalidOperationException("Неизвестный раздел.");
                    }
                }
                else
                {
                    ReportName = "Cash.CashFlowOrganisations";
                }

                break;

            default:
                if (checkDetail.Active)
                {
                    if (comboPart.SelectedItem.Equals(Gamma.Widgets.SpecialComboState.All))
                    {
                        ReportName = "Cash.CashFlowDetail";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.IncomeAll))
                    {
                        ReportName = "Cash.CashFlowDetailIncomeAll";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Income))
                    {
                        ReportName = "Cash.CashFlowDetailIncome";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.IncomeReturn))
                    {
                        ReportName = "Cash.CashFlowDetailIncomeReturn";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.ExpenseAll))
                    {
                        ReportName = "Cash.CashFlowDetailExpenseAll";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Expense))
                    {
                        ReportName = "Cash.CashFlowDetailExpense";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.Advance))
                    {
                        ReportName = "Cash.CashFlowDetailAdvance";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.AdvanceReport))
                    {
                        ReportName = "Cash.CashFlowDetailAdvanceReport";
                    }
                    else if (comboPart.SelectedItem.Equals(ReportParts.UnclosedAdvance))
                    {
                        ReportName = "Cash.CashFlowDetailUnclosedAdvance";
                    }
                    else
                    {
                        throw new InvalidOperationException("Неизвестный раздел.");
                    }
                }
                else
                {
                    ReportName = "Cash.CashFlow";
                }

                break;
            }

            var inCat =
                comboIncomeCategory.SelectedItem == null ||
                comboIncomeCategory.SelectedItem.Equals(Gamma.Widgets.SpecialComboState.All)
                                ? -1
                                : (comboIncomeCategory.SelectedItem as IncomeCategory).Id;

            TreeIter iter;

            comboExpenseCategory.GetActiveIter(out iter);
            var  exCategory         = (ExpenseCategory)comboExpenseCategory.Model.GetValue(iter, 0);
            bool exCategorySelected = exCategory != allItem;
            var  ids = new List <int>();

            if (exCategorySelected)
            {
                FineIds(ids, exCategory);
            }
            else
            {
                ids.Add(0);                 //Add fake value
            }
            var casherId     = evmeCashier.Subject == null ? -1 : evmeCashier.SubjectId;
            var casherName   = evmeCashier.Subject == null ? "" : ((Employee)evmeCashier.Subject).ShortName;
            var employeeId   = evmeEmployee.Subject == null ? -1 : evmeEmployee.SubjectId;
            var employeeName = evmeEmployee.Subject == null ? "" : ((Employee)evmeEmployee.Subject).ShortName;

            IEnumerable <int> cashSubdivisions;
            IEnumerable <int> organisations;

            if (specialListCmbCashSubdivisions.SelectedItem == null)
            {
                cashSubdivisions = UserSubdivisions.Any() ? UserSubdivisions.Select(x => x.Id) : new[] { -1 };
            }
            else
            {
                cashSubdivisions = new[] { (specialListCmbCashSubdivisions.SelectedItem as Subdivision).Id };
            }

            if (specialListCmbOrganisations.SelectedItem == null)
            {
                organisations = Organisations.Any() ? Organisations.Select(x => x.Id) : new[] { -1 };
            }
            else
            {
                organisations = new[] { (specialListCmbOrganisations.SelectedItem as Organization).Id };
            }

            var cashSubdivisionsName = specialListCmbCashSubdivisions.SelectedItem == null?
                                       string.Join(", ", UserSubdivisions.Select(x => x.Name))
                                           : UserSubdivisions.Where(x => x.Id == (specialListCmbCashSubdivisions.SelectedItem as Subdivision).Id)
                                           .Select(x => x.Name)
                                           .SingleOrDefault();

            var reportInfo = new ReportInfo {
                Identifier = ReportName,
                Parameters = new Dictionary <string, object> {
                    { "StartDate", dateStart.DateOrNull.Value },
                    { "EndDate", dateEnd.DateOrNull.Value },
                    { "IncomeCategory", inCat },
                    { "ExpenseCategory", ids },
                    { "ExpenseCategoryUsed", exCategorySelected ? 1 : 0 },
                    { "Casher", casherId },
                    { "Employee", employeeId },
                    { "CasherName", casherName },
                    { "EmployeeName", employeeName }
                }
            };

            if (checkOrganisations.Active)
            {
                reportInfo.Parameters.Add("organisations", organisations);
                reportInfo.Parameters.Add("organisation_name",
                                          (specialListCmbOrganisations.SelectedItem as Organization) != null
                                                ? (specialListCmbOrganisations.SelectedItem as Organization).Name
                                                : "Все организации");
            }
            else
            {
                reportInfo.Parameters.Add("cash_subdivisions", cashSubdivisions);
                reportInfo.Parameters.Add("cash_subdivisions_name", cashSubdivisionsName);
            }

            var cashCategoryParametersProvider = new OrganizationCashTransferDocumentParametersProvider(new ParametersProvider());

            reportInfo.Parameters.Add("cash_income_category_transfer_id", cashCategoryParametersProvider.CashIncomeCategoryTransferId);
            reportInfo.Parameters.Add("cash_expense_category_transfer_id", cashCategoryParametersProvider.CashExpenseCategoryTransferId);

            return(reportInfo);
        }