private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { return; } try { Region = RepositoriesFactory.Get <Region>().Get(region => region.Id == Config.CurrentRegionId); if (Region != null) { lblRegionName.Content = Region.Name ?? string.Empty; UpdateDepartments(); GlobalEvents.OnDepartmentsChanged += UpdateDepartments; } else { lblRegionName.Content = "Район не задан"; lblRegionName.Foreground = Brushes.Red; cbDepartmentSelector.IsEnabled = false; } } catch (Exception ex) { var message = "Ошибка загрузки департаметов."; Log.Error(message, ex); Message.Error(message); } }
public void FindAndApplyCustomer(uint number, Department department) { if (department == null) { throw new Exception("Отделение для поиска не задано"); } var operationName = $"Поиск плательщика за электроэнергию {number}, отделение \"{department.Code} {department.Name}\""; Log.Info($"Запуск -> {operationName}"); var potencialCustomers = RepositoriesFactory.Get <EnergyCustomer>().Filter(customer => customer.Number == number && customer.IsActive); Customer.Value = potencialCustomers.FirstOrDefault(customer => customer.Department.Id == department.Id) ?? potencialCustomers.FirstOrDefault(customer => customer.Department.Code == department.Code); if (Customer.Value == null) { Log.Info($"Не найдено -> {operationName}"); } else { Log.Info($"Найдено -> {operationName}"); } }
protected override bool TryUpdateExistingItem(DbfArticle dbfArticle) { var existingArticle = RepositoriesFactory.Get <Article>().Get(article => article.Code == dbfArticle.Code); if (existingArticle == null) { return(false); } existingArticle.Name = dbfArticle.Name ?? string.Empty; existingArticle.Barcode = dbfArticle.Barcode ?? string.Empty; existingArticle.IsActive = true; var articlePrice = existingArticle.ArticlePrices.FirstOrDefault(price => price.ArticlePriceType == PriceType && price.EntryDate == dbfArticle.EntryDate); if (articlePrice != null) { articlePrice.Value = dbfArticle.Price; return(true); } var newArticlePrice = new ArticlePrice { Article = existingArticle, ArticlePriceType = PriceType, EntryDate = dbfArticle.EntryDate, Value = dbfArticle.Price }; existingArticle.ArticlePrices.Add(newArticlePrice); return(true); }
protected override int DeleteAllTargetItems() { var articlesForDelete = RepositoriesFactory.Get <Article>().Filter(article => article.IsActive).ToList(); foreach (var article in articlesForDelete) { article.IsActive = false; } return(articlesForDelete.Count); }
protected override int DeleteAllTargetItems() { int count = 0; foreach (var waterCustomer in RepositoriesFactory.Get <WaterCustomer>().GetAll()) { waterCustomer.IsActive = false; count++; } return(count); }
private void CloseHandler(object data) { RepositoriesFactory.Get <Department>().RollbackItemsChanges(); var window = data as Window; if (window != null) { window.DialogResult = false; window.Close(); } }
public SettingsDialogViewModel() { CashierName.OnChange += (newValue) => DispatchPropertyChanged("CashierName"); ArticlesDocumentNumberCurrentValue.OnChange += (newValue) => DispatchPropertyChanged("ArticlesDocumentNumberCurrentValue"); ArticlesWarehouseCode.OnChange += (newValue) => DispatchPropertyChanged("ArticlesWarehouseCode"); ArticlesWarehouseName.OnChange += (newValue) => DispatchPropertyChanged("ArticlesWarehouseName"); ArticlesManipulatorType.OnChange += (newValue) => DispatchPropertyChanged("ArticlesManipulatorType"); ArticlesZeusDbUrl.OnChange += (newValue) => DispatchPropertyChanged("ArticlesZeusDbUrl"); ArticlesZeusDbPath.OnChange += (newValue) => DispatchPropertyChanged("ArticlesZeusDbPath"); WaterСommissionPercent.OnChange += (newValue) => DispatchPropertyChanged("WaterСommissionPercent"); GarbageCollectionFilialCode.OnChange += (newValue) => DispatchPropertyChanged("GarbageCollectionFilialCode"); GarbageCollectionComissionPercent.OnChange += (newValue) => DispatchPropertyChanged("GarbageCollectionComissionPercent"); HotWaterСommissionPercent.OnChange += (newValue) => DispatchPropertyChanged("HotWaterСommissionPercent"); RepairFilialCode.OnChange += (newValue) => DispatchPropertyChanged("RepairFilialCode"); RepairComissionPercent.OnChange += (newValue) => DispatchPropertyChanged("RepairComissionPercent"); EnergyPerformerInn.OnChange += (newValue) => DispatchPropertyChanged("EnergyPerformerInn"); EnergyPerformerName.OnChange += (newValue) => DispatchPropertyChanged("EnergyPerformerName"); EnergyPerformerKpp.OnChange += (newValue) => DispatchPropertyChanged("EnergyPerformerKpp"); EnergyReceiverInn.OnChange += (newValue) => DispatchPropertyChanged("EnergyReceiverInn"); EnergyReceiverName.OnChange += (newValue) => DispatchPropertyChanged("EnergyReceiverName"); EnergyReceiverBankName.OnChange += (newValue) => DispatchPropertyChanged("EnergyReceiverBankName"); EnergyReceiverBankBik.OnChange += (newValue) => DispatchPropertyChanged("EnergyReceiverBankBik"); EnergyReceiverAccount.OnChange += (newValue) => DispatchPropertyChanged("EnergyReceiverAccount"); CashierName.Value = Settings.CasherName; ArticlesDocumentNumberCurrentValue.Value = Settings.ArticlesDocumentNumberCurrentValue; ArticlesWarehouseCode.Value = Settings.ArticlesWarehouseCode; ArticlesWarehouseName.Value = Settings.ArticlesWarehouseName; ArticlesManipulatorType.Value = Settings.ArticlesManipulatorType; ArticlesZeusDbUrl.Value = Settings.ArticlesZeusDbUrl; ArticlesZeusDbPath.Value = Settings.ArticlesZeusDbPath; WaterСommissionPercent.Value = Settings.WaterСommissionPercent; GarbageCollectionFilialCode.Value = Settings.GarbageCollectionFilialCode; GarbageCollectionComissionPercent.Value = Settings.GarbageCollectionCommissionPercent; HotWaterСommissionPercent.Value = Settings.HotWaterСommissionPercent; RepairFilialCode.Value = Settings.RepairFilialCode; RepairComissionPercent.Value = Settings.RepairCommissionPercent; EnergyPerformerInn.Value = Settings.EnergyPerformerInn; EnergyPerformerName.Value = Settings.EnergyPerformerName; EnergyPerformerKpp.Value = Settings.EnergyPerformerKpp; EnergyReceiverInn.Value = Settings.EnergyReceiverInn; EnergyReceiverName.Value = Settings.EnergyReceiverName; EnergyReceiverBankName.Value = Settings.EnergyReceiverBankName; EnergyReceiverBankBik.Value = Settings.EnergyReceiverBankBik; EnergyReceiverAccount.Value = Settings.EnergyReceiverAccount; Deparments = RepositoriesFactory.Get <Department>().Filter( department => department.RegionId == Config.CurrentRegionId).ToList(); SaveCommand = new Command(SaveHandler); CloseCommand = new Command(CloseHandler); }
public CustomerDbfImportViewModel() { SelectedImportTarget.OnChange += (newValue) => DispatchPropertyChanged("SelectedImportTarget"); DbfFilename.OnChange += (newValue) => DispatchPropertyChanged("DbfFilename"); SelectedDepartment.OnChange += (newValue) => DispatchPropertyChanged("SelectedDepartment"); SelectedArticlePriceType.OnChange += (newValue) => DispatchPropertyChanged("SelectedArticlePriceType"); IsAddArticleQuantities.OnChange += (newValue) => DispatchPropertyChanged("IsAddArticleQuantities"); ImportCommand = new Command(DoImport); SelectedImportTarget.Value = ImportTargets.FirstOrDefault(); SelectedArticlePriceType.Value = RepositoriesFactory.Get <ArticlePriceType>().Get(item => true); }
public override void StorePaymentToDb(int financialPeriodCode, DateTime createDate, int organizationCode, int filialCode, int customerNumber, decimal cost) { var payment = new RepairPayment { FinancialPeriodCode = financialPeriodCode, CreateDate = createDate, OrganizationCode = organizationCode, FilialCode = filialCode, CustomerNumber = customerNumber, Cost = cost, CommissionValue = Utils.GetCommission(cost, Settings.RepairCommissionPercent) }; RepositoriesFactory.Get <RepairPayment>().Add(payment); }
public void FindAndApplyCustomer(uint number) { var operationName = $"Поиск плательщика за воду {number}"; Log.Info($"Запуск -> {operationName}"); Customer.Value = RepositoriesFactory.Get <WaterCustomer>().Get(waterCustomer => waterCustomer.Number == number); if (Customer.Value == null) { Log.Info($"Не найдено -> {operationName}"); } else { Log.Info($"Найдено -> {operationName}"); } }
protected override bool TryUpdateExistingItem(DbfWaterCustomer dbfWaterCustomer) { var existingWaterCustomer = RepositoriesFactory.Get <WaterCustomer>().Get(waterCustomer => waterCustomer.Number == dbfWaterCustomer.Number); if (existingWaterCustomer == null) { return(false); } existingWaterCustomer.Name = dbfWaterCustomer.Name; existingWaterCustomer.Address = dbfWaterCustomer.Address; existingWaterCustomer.CounterNumber1 = dbfWaterCustomer.CounterNumber1; existingWaterCustomer.CounterNumber2 = dbfWaterCustomer.CounterNumber2; existingWaterCustomer.CounterNumber3 = dbfWaterCustomer.CounterNumber3; existingWaterCustomer.CounterNumber4 = string.Empty; existingWaterCustomer.IsActive = true; return(true); }
protected override List<AllPaymentsContainer> GetSourceItems(DateTime beginDatetime, DateTime endDatetime) { var db = new CashCenterContext(); return new List<AllPaymentsContainer> { new AllPaymentsContainer( RepositoriesFactory.Get<EnergyCustomerPayment>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList(), RepositoriesFactory.Get<WaterCustomerPayment>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList(), RepositoriesFactory.Get<ArticleSale>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList(), RepositoriesFactory.Get<GarbageCollectionPayment>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList(), RepositoriesFactory.Get<RepairPayment>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList(), RepositoriesFactory.Get<HotWaterPayment>().Filter(customerPayment => beginDatetime <= customerPayment.CreateDate && customerPayment.CreateDate <= endDatetime).ToList()) }; }
protected override bool TryUpdateExistingItem(DbfEnergyCustomer dbfCustomer) { var existingCustomer = RepositoriesFactory.Get <EnergyCustomer>().Get(customer => customer.Department.Id == TargetDepartment.Id && customer.Number == dbfCustomer.Number); if (existingCustomer == null) { return(false); } existingCustomer.Name = dbfCustomer.Name; existingCustomer.Address = dbfCustomer.Address; existingCustomer.DayValue = dbfCustomer.DayValue; existingCustomer.NightValue = dbfCustomer.NightValue; existingCustomer.Balance = dbfCustomer.Balance; existingCustomer.IsActive = true; existingCustomer.IsClosed = dbfCustomer.IsClosed; existingCustomer.PaymentDocumentIdentifier = dbfCustomer.PaymentDocumentIdentifier ?? string.Empty; existingCustomer.HusIdentifier = dbfCustomer.HusIdentifier ?? string.Empty; return(true); }
protected override bool TryUpdateExistingItem(DbfArticleQuantity dbfArticleQuantity) { var existingArticle = RepositoriesFactory.Get <Article>().Get(article => article.Code == dbfArticleQuantity.ArticleCode); if (existingArticle == null) { return(false); } if (IsAddQuantities) { existingArticle.Quantity += dbfArticleQuantity.Quantity; } else { existingArticle.Quantity = dbfArticleQuantity.Quantity; } existingArticle.Measure = dbfArticleQuantity.Measure; return(true); }
protected override List <CommonPaymentsDataSource> GetSourceItems(DateTime beginDatetime, DateTime endDatetime) { var waterCustomersPayments = RepositoriesFactory.Get <WaterCustomerPayment>().Filter(waterCustomerPayment => beginDatetime <= waterCustomerPayment.CreateDate && waterCustomerPayment.CreateDate <= endDatetime).ToList(); var energyCustomersPayments = RepositoriesFactory.Get <EnergyCustomerPayment>().Filter(energyCustomerPayment => beginDatetime <= energyCustomerPayment.CreateDate && energyCustomerPayment.CreateDate <= endDatetime).ToList(); var garbagePayments = RepositoriesFactory.Get <GarbageCollectionPayment>().Filter(garbagePayment => beginDatetime <= garbagePayment.CreateDate && garbagePayment.CreateDate <= endDatetime).ToList(); var repairPayments = RepositoriesFactory.Get <RepairPayment>().Filter(repairPayment => beginDatetime <= repairPayment.CreateDate && repairPayment.CreateDate <= endDatetime).ToList(); var db = new CashCenterContext(); var hotWaterPayments = db.HotWaterPayments.Where(hotWaterPayment => beginDatetime <= hotWaterPayment.CreateDate && hotWaterPayment.CreateDate <= endDatetime).ToList(); return(new List <CommonPaymentsDataSource> { new CommonPaymentsDataSource(waterCustomersPayments, energyCustomersPayments, garbagePayments, repairPayments, hotWaterPayments) }); }
protected override List <WaterCustomerPayment> GetSourceItems(DateTime beginDatetime, DateTime endDatetime) { return(RepositoriesFactory.Get <WaterCustomerPayment>().Filter(waterCustomerPayment => beginDatetime <= waterCustomerPayment.CreateDate && waterCustomerPayment.CreateDate <= endDatetime).ToList()); }
public void Pay(string email, int dayValue, int nightValue, decimal cost, PaymentReason paymentReason, string description, bool isWithoutCheck) { if (Customer.Value == null) { throw new Exception("Отсутствует плательщик"); } var errors = new List <string>(); if (cost <= 0) { errors.Add($"Сумма платежа должна быть положительна ({cost})"); } if (!Customer.Value.IsNormative() && dayValue < Customer.Value.DayValue) { errors.Add($"Новое показание дневного счетчика меньше предыдущего ({dayValue} < {Customer.Value.DayValue})"); } if (!Customer.Value.IsNormative() && Customer.Value.IsTwoTariff() && nightValue < Customer.Value.NightValue) { errors.Add($"Новое показание ночного счетчика меньше меньше предыдущего ({nightValue} < {Customer.Value.NightValue})"); } if (paymentReason == null) { errors.Add("Основание для оплаты не задано"); } var isEmailChange = !string.IsNullOrEmpty(email) && Customer.Value.Email != email; if (isEmailChange) { if (!StringUtils.IsValidEmail(email)) { errors.Add("Адрес электронной почты имеет не верный формат"); } } if (errors.Count > 0) { throw new IncorrectDataException(errors); } if (isEmailChange) { Log.Info($"Изменение email плательщика за электроэнергию с {Customer.Value.Email} на {email}"); Customer.Value.Email = email; RepositoriesFactory.Get <EnergyCustomer>().Update(Customer.Value); } var operationName = $"Платеж за электроэнергию: email={email}, dayValue={dayValue}; nightValue={nightValue}; cost={cost}; paymentReason={paymentReason.Name}; description={description}, isWithoutCheck={isWithoutCheck}"; Log.Info($"Старт -> {operationName}"); if (isWithoutCheck || TryPrintChecks(cost, Customer.Value.Department.Code, Customer.Value.Number, Customer.Value.Name, paymentReason.Name, Customer.Value.Email)) { var payment = new EnergyCustomerPayment { CustomerId = Customer.Value.Id, NewDayValue = dayValue, NewNightValue = nightValue, Cost = cost, ReasonId = paymentReason.Id, CreateDate = DateTime.Now, Description = description, FiscalNumber = 0 // TODO: Fill fiscal }; RepositoriesFactory.Get <EnergyCustomerPayment>().Add(payment); Log.Info($"Успешно завершено -> {operationName}"); } else { Log.Info($"Не произведено -> {operationName}"); throw new Exception("Платеж не произведен"); } }
protected override List <ArticleSale> GetSourceItems(DateTime beginDatetime, DateTime endDatetime) { return(RepositoriesFactory.Get <ArticleSale>().Filter(articleSale => beginDatetime <= articleSale.CreateDate && articleSale.CreateDate <= endDatetime).ToList()); }
protected override void CreateNewItems(IEnumerable <EnergyCustomer> customers) { RepositoriesFactory.Get <EnergyCustomer>().AddRange(customers); }
protected override void CreateNewItems(IEnumerable <WaterCustomer> waterCustomers) { RepositoriesFactory.Get <WaterCustomer>().AddRange(waterCustomers); }
protected override List <GarbageCollectionPayment> GetSourceItems(DateTime beginDatetime, DateTime endDatetime) { return(RepositoriesFactory.Get <GarbageCollectionPayment>().Filter(garbagePayment => beginDatetime <= garbagePayment.CreateDate && garbagePayment.CreateDate <= endDatetime).ToList()); }
public void Pay(string email, double counter1Value, double counter2Value, double counter3Value, double counter4Value, decimal penalty, decimal cost, string description, bool isWithoutCheck) { if (Customer.Value == null) { throw new Exception("Отсутствует плательщик"); } var errors = new List <string>(); if (counter1Value < 0) { errors.Add("Показание счетчика 1 не должно быть меньше 0"); } if (counter2Value < 0) { errors.Add("Показание счетчика 2 не должно быть меньше 0"); } if (counter3Value < 0) { errors.Add("Показание счетчика 3 не должно быть меньше 0"); } if (counter4Value < 0) { errors.Add("Показание счетчика 4 не должно быть меньше 0"); } if (cost <= 0) { errors.Add("Сумма должна быть больше нуля"); } if (penalty < 0) { errors.Add("Пени не может быть меньше нуля"); } var isEmailChange = !string.IsNullOrEmpty(email) && Customer.Value.Email != email; if (isEmailChange) { if (!StringUtils.IsValidEmail(email)) { errors.Add("Адрес электронной почты имеет не верный формат"); } } if (errors.Count > 0) { throw new IncorrectDataException(errors); } if (isEmailChange) { Log.Info($"Изменение email плательщика за воду с {Customer.Value.Email} на {email}"); Customer.Value.Email = email; RepositoriesFactory.Get <WaterCustomer>().Update(Customer.Value); } var operationName = $"Платеж за воду: email={email}, counter1Value={counter1Value}, counter2Value={counter2Value}, counter3Value={counter3Value}, counter4Value={counter4Value}, penalty={penalty}, cost={cost}, description={description}, isWithoutCheck={isWithoutCheck}"; Log.Info($"Старт -> {operationName}"); decimal costWithoutCommission = cost + penalty; decimal commissionValue = Utils.GetCommission(costWithoutCommission, Settings.WaterСommissionPercent); decimal costWithComission = costWithoutCommission + commissionValue; if (isWithoutCheck || TryPrintChecks(costWithoutCommission, commissionValue, costWithComission, Customer.Value.Number, Customer.Value.Name, Customer.Value.Email)) { var payment = new WaterCustomerPayment { CreateDate = DateTime.Now, CustomerId = Customer.Value.Id, CounterValue1 = counter1Value, CounterValue2 = counter2Value, CounterValue3 = counter3Value, CounterValue4 = counter4Value, Description = description ?? string.Empty, Penalty = penalty, Cost = cost, FiscalNumber = 0, // TODO: Fill fiscal CommissionValue = commissionValue }; RepositoriesFactory.Get <WaterCustomerPayment>().Add(payment); Log.Info($"Успешно завершено -> {operationName}"); } else { Log.Info($"Не произведено -> {operationName}"); throw new Exception("Платеж не произведен"); } }
public ArticleSale AddArticleSale(ArticleSale articleSale) { RepositoriesFactory.Get <ArticleSale>().Add(articleSale); return(articleSale); }
protected override void CreateNewItems(IEnumerable <Article> articles) { RepositoriesFactory.Get <Article>().AddRange(articles); }