コード例 #1
0
        private void DistributeIncomeCashRemainingAmount(IUnitOfWork uow, RouteList routeList, Income income, decimal amount)
        {
            var operation = new OrganisationCashMovementOperation
            {
                OperationTime = DateTime.Now,
                Organisation  = cashDistributionCommonOrganisationProvider.GetCommonOrganisation(uow),
                Amount        = amount
            };

            var address  = routeList.Addresses.First(x => x.TotalCash > 0);
            var document = CreateRouteListItemCashDistributionDocument(operation, address, income);

            Save(uow, operation, document);
        }
コード例 #2
0
        public void DistributeCash(IUnitOfWork uow, FuelDocument fuelDoc)
        {
            var org = cashDistributionCommonOrganisationProvider.GetCommonOrganisation(uow);

            var operation = new OrganisationCashMovementOperation
            {
                Organisation  = org,
                OperationTime = DateTime.Now,
                Amount        = -fuelDoc.PayedForFuel.Value
            };

            var fuelCashDistributionDoc = new FuelExpenseCashDistributionDocument
            {
                Author         = fuelDoc.Author,
                CreationDate   = DateTime.Now,
                Organisation   = org,
                FuelDocument   = fuelDoc,
                Employee       = fuelDoc.Driver,
                LastEditor     = fuelDoc.LastEditor,
                LastEditedTime = DateTime.Now,
                Expense        = fuelDoc.FuelCashExpense,
                OrganisationCashMovementOperation = operation,
                Amount = operation.Amount
            };

            Save(operation, fuelCashDistributionDoc, uow);
        }
コード例 #3
0
        public void DistributeCashForIncome(IUnitOfWork uow, Income income, Organization organisation = null)
        {
            var org       = organisation ?? cashDistributionCommonOrganisationProvider.GetCommonOrganisation(uow);
            var operation = CreateOrganisationCashMovementOperation(income, org);
            var incomeCashDistributionDoc = CreateIncomeCashDistributionDocument(income, operation);

            Save(operation, incomeCashDistributionDoc, uow);
        }
コード例 #4
0
        private void ConfigureDlg()
        {
            if (Entity.Id == 0)
            {
                Entity.OrganisationForSalary = commonOrganisationProvider.GetCommonOrganisation(UoW);
            }

            canManageDriversAndForwarders = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_drivers_and_forwarders");
            canManageOfficeWorkers        = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_office_workers");
            canEditOrganisationForSalary  = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_edit_organisation_for_salary");

            ConfigureCategory();
            ConfigureSubdivision();
            OnRussianCitizenToggled(null, EventArgs.Empty);
            dataentryDrivingNumber.MaxLength = 20;
            dataentryDrivingNumber.Binding.AddBinding(Entity, e => e.DrivingLicense, w => w.Text).InitializeFromSource();
            UoWGeneric.Root.PropertyChanged += OnPropertyChanged;
            notebookMain.Page        = 0;
            notebookMain.ShowTabs    = false;
            GenderComboBox.ItemsEnum = typeof(Gender);
            GenderComboBox.Binding.AddBinding(Entity, e => e.Gender, w => w.SelectedItemOrNull).InitializeFromSource();

            subdivisionService = SubdivisionParametersProvider.Instance;

            yenumcomboStatus.ItemsEnum = typeof(EmployeeStatus);
            yenumcomboStatus.Binding.AddBinding(Entity, e => e.Status, w => w.SelectedItem).InitializeFromSource();

            chkDriverForOneDay.Binding.AddBinding(Entity, e => e.IsDriverForOneDay, w => w.Active).InitializeFromSource();
            cmbDriverOf.ItemsEnum = typeof(CarTypeOfUse);
            cmbDriverOf.Binding.AddBinding(Entity, e => e.DriverOf, w => w.SelectedItemOrNull).InitializeFromSource();

            dataentryLastName.Binding.AddBinding(Entity, e => e.LastName, w => w.Text).InitializeFromSource();
            dataentryName.Binding.AddBinding(Entity, e => e.Name, w => w.Text).InitializeFromSource();
            dataentryPatronymic.Binding.AddBinding(Entity, e => e.Patronymic, w => w.Text).InitializeFromSource();
            dataentryInnerPhone.Binding.AddBinding(Entity, e => e.InnerPhone, w => w.Text, new Gamma.Binding.Converters.NumbersToStringConverter()).InitializeFromSource();

            entryAddressCurrent.Binding.AddBinding(Entity, e => e.AddressCurrent, w => w.Text).InitializeFromSource();
            entryAddressRegistration.Binding.AddBinding(Entity, e => e.AddressRegistration, w => w.Text).InitializeFromSource();
            entryInn.Binding.AddBinding(Entity, e => e.INN, w => w.Text).InitializeFromSource();

            dataentryAndroidLogin.Binding.AddBinding(Entity, e => e.AndroidLogin, w => w.Text).InitializeFromSource();
            dataentryAndroidPassword.Binding.AddBinding(Entity, e => e.AndroidPassword, w => w.Text).InitializeFromSource();

            var filterDefaultForwarder = new EmployeeFilterViewModel();

            filterDefaultForwarder.SetAndRefilterAtOnce(
                x => x.Category = EmployeeCategory.forwarder,
                x => x.Status   = EmployeeStatus.IsWorking
                );
            repEntDefaultForwarder.RepresentationModel = new EmployeesVM(filterDefaultForwarder);
            repEntDefaultForwarder.Binding.AddBinding(Entity, e => e.DefaultForwarder, w => w.Subject).InitializeFromSource();

            referenceNationality.SubjectType = typeof(Nationality);
            referenceNationality.Binding.AddBinding(Entity, e => e.Nationality, w => w.Subject).InitializeFromSource();
            referenceCitizenship.SubjectType = typeof(Citizenship);
            referenceCitizenship.Binding.AddBinding(Entity, e => e.Citizenship, w => w.Subject).InitializeFromSource();

            referenceUser.SubjectType      = typeof(User);
            referenceUser.CanEditReference = false;
            referenceUser.Binding.AddBinding(Entity, e => e.User, w => w.Subject).InitializeFromSource();
            referenceUser.Sensitive = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_manage_users");

            yenumcombobox13.ItemsEnum = typeof(RegistrationType);
            yenumcombobox13.Binding.AddBinding(Entity, e => e.Registration, w => w.SelectedItemOrNull).InitializeFromSource();

            comboDriverType.ItemsEnum = typeof(DriverType);
            comboDriverType.Binding.AddBinding(Entity, e => e.DriverType, w => w.SelectedItemOrNull).InitializeFromSource();

            ydatepicker1.Binding.AddBinding(Entity, e => e.BirthdayDate, w => w.DateOrNull).InitializeFromSource();
            dateFired.Binding.AddBinding(Entity, e => e.DateFired, w => w.DateOrNull).InitializeFromSource();
            dateHired.Binding.AddBinding(Entity, e => e.DateHired, w => w.DateOrNull).InitializeFromSource();
            dateCalculated.Binding.AddBinding(Entity, e => e.DateCalculated, w => w.DateOrNull).InitializeFromSource();

            photoviewEmployee.Binding.AddBinding(Entity, e => e.Photo, w => w.ImageFile).InitializeFromSource();
            photoviewEmployee.GetSaveFileName = () => Entity.FullName;

            attachmentFiles.AttachToTable = OrmConfig.GetDBTableName(typeof(Employee));
            if (Entity.Id != 0)
            {
                attachmentFiles.ItemId = UoWGeneric.Root.Id;
                attachmentFiles.UpdateFileList();
            }
            phonesView.UoW = UoWGeneric;
            if (UoWGeneric.Root.Phones == null)
            {
                UoWGeneric.Root.Phones = new List <Phone>();
            }
            phonesView.Phones            = UoWGeneric.Root.Phones;
            accountsView.ParentReference = new ParentReferenceGeneric <Employee, Account>(UoWGeneric, o => o.Accounts);
            accountsView.SetTitle("Банковские счета сотрудника");
            ydateFirstWorkDay.Binding.AddBinding(Entity, e => e.FirstWorkDay, w => w.DateOrNull).InitializeFromSource();
            yspinTripsPriority.Binding.AddBinding(Entity, e => e.TripPriority, w => w.ValueAsShort).InitializeFromSource();
            yspinDriverSpeed.Binding.AddBinding(Entity, e => e.DriverSpeed, w => w.Value, new MultiplierToPercentConverter()).InitializeFromSource();
            minAddressesSpin.Binding.AddBinding(Entity, e => e.MinRouteAddresses, w => w.ValueAsInt).InitializeFromSource();
            maxAddressesSpin.Binding.AddBinding(Entity, e => e.MaxRouteAddresses, w => w.ValueAsInt).InitializeFromSource();
            checkbuttonRussianCitizen.Binding.AddBinding(Entity, e => e.IsRussianCitizen, w => w.Active).InitializeFromSource();
            checkVisitingMaster.Binding.AddBinding(Entity, e => e.VisitingMaster, w => w.Active).InitializeFromSource();
            checkChainStoreDriver.Binding.AddBinding(Entity, e => e.IsChainStoreDriver, w => w.Active).InitializeFromSource();

            ylblUserLogin.TooltipText = "При сохранении сотрудника создаёт нового пользователя с введённым логином и отправляет сотруднику SMS с сгенерированным паролем";
            yentryUserLogin.Binding.AddBinding(Entity, e => e.LoginForNewUser, w => w.Text);
            yentryUserLogin.Sensitive = CanCreateNewUser;

            specialListCmbOrganisation.ItemsList = UoW.GetAll <Organization>();
            specialListCmbOrganisation.Binding.AddBinding(Entity, e => e.OrganisationForSalary, w => w.SelectedItem).InitializeFromSource();
            specialListCmbOrganisation.Sensitive = canEditOrganisationForSalary;

            ConfigureWorkSchedules();
            ConfigureDistrictPriorities();

            ytreeviewEmployeeDocument.ColumnsConfig = FluentColumnsConfig <EmployeeDocument> .Create()
                                                      .AddColumn("Документ").AddTextRenderer(x => x.Document.GetEnumTitle())
                                                      .AddColumn("Доп. название").AddTextRenderer(x => x.Name)
                                                      .Finish();

            ytreeviewEmployeeDocument.SetItemsSource(Entity.ObservableDocuments);

            ytreeviewEmployeeContract.ColumnsConfig = FluentColumnsConfig <EmployeeContract> .Create()
                                                      .AddColumn("Договор").AddTextRenderer(x => x.EmployeeContractTemplate.TemplateType.GetEnumTitle())
                                                      .AddColumn("Название").AddTextRenderer(x => x.Name)
                                                      .AddColumn("Дата начала").AddTextRenderer(x => x.FirstDay.ToString("dd/MM/yyyy"))
                                                      .AddColumn("Дата конца").AddTextRenderer(x => x.LastDay.ToString("dd/MM/yyyy"))
                                                      .Finish();

            ytreeviewEmployeeContract.SetItemsSource(Entity.ObservableContracts);

            wageParametersView.ViewModel = new EmployeeWageParametersViewModel
                                           (
                Entity,
                this,
                UoW,
                new HierarchicalPresetPermissionValidator(EmployeeSingletonRepository.GetInstance(), new PermissionRepository()),
                UserSingletonRepository.GetInstance(),
                ServicesConfig.CommonServices,
                NavigationManagerProvider.NavigationManager
                                           );

            logger.Info("Ok");
        }
コード例 #5
0
        public EmployeeViewModel(
            IAuthorizationService authorizationService,
            IEmployeeWageParametersFactory employeeWageParametersFactory,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IEmployeePostsJournalFactory employeePostsJournalFactory,
            ICashDistributionCommonOrganisationProvider commonOrganisationProvider,
            ISubdivisionService subdivisionService,
            IEmailServiceSettingAdapter emailServiceSettingAdapter,
            IWageCalculationRepository wageCalculationRepository,
            IEmployeeRepository employeeRepository,
            IUnitOfWorkGeneric <Employee> uowGeneric,
            ICommonServices commonServices,
            IValidationContextFactory validationContextFactory,
            IPhonesViewModelFactory phonesViewModelFactory,
            IWarehouseRepository warehouseRepository,
            IRouteListRepository routeListRepository,
            DriverApiUserRegisterEndpoint driverApiUserRegisterEndpoint,
            UserSettings userSettings,
            IUserRepository userRepository,
            BaseParametersProvider baseParametersProvider,
            bool traineeToEmployee = false,
            INavigationManager navigationManager = null
            ) : base(commonServices?.InteractiveService, navigationManager)
        {
            _authorizationService         = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
            EmployeeWageParametersFactory =
                employeeWageParametersFactory ?? throw new ArgumentNullException(nameof(employeeWageParametersFactory));
            EmployeeJournalFactory      = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            EmployeePostsJournalFactory = employeePostsJournalFactory ?? throw new ArgumentNullException(nameof(employeePostsJournalFactory));
            SubdivisionJournalFactory   = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));

            if (commonOrganisationProvider == null)
            {
                throw new ArgumentNullException(nameof(commonOrganisationProvider));
            }

            _subdivisionService            = subdivisionService ?? throw new ArgumentNullException(nameof(subdivisionService));
            _emailServiceSettingAdapter    = emailServiceSettingAdapter ?? throw new ArgumentNullException(nameof(emailServiceSettingAdapter));
            _wageCalculationRepository     = wageCalculationRepository ?? throw new ArgumentNullException(nameof(wageCalculationRepository));
            _employeeRepository            = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            _warehouseRepository           = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository));
            _routeListRepository           = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository));
            _driverApiUserRegisterEndpoint = driverApiUserRegisterEndpoint ?? throw new ArgumentNullException(nameof(driverApiUserRegisterEndpoint));
            _userSettings           = userSettings ?? throw new ArgumentNullException(nameof(userSettings));
            UoWGeneric              = uowGeneric ?? throw new ArgumentNullException(nameof(uowGeneric));
            _commonServices         = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            _userRepository         = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            _baseParametersProvider = baseParametersProvider ?? throw new ArgumentNullException(nameof(baseParametersProvider));

            if (validationContextFactory == null)
            {
                throw new ArgumentNullException(nameof(validationContextFactory));
            }

            ConfigureValidationContext(validationContextFactory);

            if (phonesViewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(phonesViewModelFactory));
            }

            PhonesViewModel = phonesViewModelFactory.CreateNewPhonesViewModel(UoW);

            if (Entity.Id == 0)
            {
                Entity.OrganisationForSalary = commonOrganisationProvider.GetCommonOrganisation(UoW);
                TabName = "Новый сотрудник";
            }
            else
            {
                TabName = Entity.GetPersonNameWithInitials();
            }

            if (Entity.Phones == null)
            {
                Entity.Phones = new List <Phone>();
            }

            SetPermissions();

            Entity.PropertyChanged += OnEntityPropertyChanged;

            organizations = UoW.GetAll <Organization>().ToList();
            FillHiddenCategories(traineeToEmployee);

            CanRegisterMobileUser = string.IsNullOrWhiteSpace(Entity.AndroidLogin) && string.IsNullOrWhiteSpace(Entity.AndroidPassword);

            var permissionResult =
                _commonServices.PermissionService.ValidateUserPermission(typeof(Employee), _commonServices.UserService.CurrentUserId);

            if (!permissionResult.CanRead)
            {
                AbortOpening(PermissionsSettings.GetEntityReadValidateResult(typeof(Employee)));
            }
        }