public void Delete(ProviderOrganization providerOrganization, User user) { user.CheckPermission(Permission.ProviderOrganization_Delete); CheckPossibilityToDeleteProviderOrganization(providerOrganization, user); // Удаляем все расчетные счета из организации var bankAccountList = new List <RussianBankAccount>(providerOrganization.RussianBankAccounts); foreach (var bankAccount in bankAccountList) { providerOrganization.DeleteRussianBankAccount(bankAccount); } // Удаляем организацию из всех поставщиков, где она фигурировала var providerOrganizationContractorList = new List <Contractor>(providerOrganization.Contractors); foreach (var contractor in providerOrganizationContractorList) { Provider provider = contractor.As <Provider>(); provider.RemoveContractorOrganization(providerOrganization); } // Удаляем саму организацию providerOrganizationRepository.Delete(providerOrganization); }
public void Init() { providerType = new ProviderType("Тестовый тип поставщика") { Id = 1 }; provider = new Provider("Поставщик", providerType, ProviderReliability.Medium, 5) { Id = 2 }; juridicalPerson = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 3 }; providerOrganization = new ProviderOrganization("Юрик", "Юрик", juridicalPerson) { Id = 4 }; physicalPerson = new PhysicalPerson(new LegalForm("ИП", EconomicAgentType.PhysicalPerson)) { Id = 5 }; accountOrganization = new AccountOrganization("Физик", "Физик", physicalPerson) { Id = 6 }; contract = new ProviderContract(accountOrganization, providerOrganization, "Договор", "111", DateTime.Today, DateTime.Today) { Id = 7 }; }
public void Delete(Provider provider, User user) { user.CheckPermission(Permission.Provider_Delete); CheckPossibilityToDelete(provider); var contractList = new List <Contract>(provider.Contracts); foreach (Contract contract in contractList) { ProviderContract providerContract = contract.As <ProviderContract>(); provider.RemoveProviderContract(providerContract); providerContractRepository.Delete(providerContract); } var contractorOrganizationList = new List <ContractorOrganization>(provider.Organizations); foreach (ContractorOrganization contractorOrganization in contractorOrganizationList) { ProviderOrganization providerOrganization = contractorOrganization.As <ProviderOrganization>(); provider.RemoveContractorOrganization(providerOrganization); } providerRepository.Delete(provider); }
public void RemoveProviderOrganization(Provider provider, ProviderOrganization providerOrganization) { CheckPossibilityToRemoveProviderOrganization(providerOrganization, provider); provider.RemoveContractorOrganization(providerOrganization); providerRepository.Save(provider); }
public void DeleteForeignBankAccount(ProviderOrganization providerOrganization, ForeignBankAccount bankAccount) { CheckForeignBankAccountDeletionPossibility(providerOrganization, bankAccount); providerOrganization.DeleteForeignBankAccount(bankAccount); providerOrganizationRepository.Save(providerOrganization); }
public void AddContractorOrganization(Provider provider, ProviderOrganization providerOrganization) { if (providerRepository.Query <AccountOrganization>().Where(x => x.Id == providerOrganization.Id).Count() > 0) { throw new Exception("Организация не является организацией, доступной для поставщиков. Она включена в список собственных организаций."); } provider.AddContractorOrganization(providerOrganization); }
public void Init() { storage = new Storage("Тестовое место хранения", StorageType.DistributionCenter) { Id = 1 }; writeoffReason = new WriteoffReason("Тестовая причина списания") { Id = 2 }; var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson) { Id = 3 }; var juridicalPerson = new JuridicalPerson(juridicalLegalForm) { Id = 4 }; var juridicalPerson2 = new JuridicalPerson(juridicalLegalForm) { Id = 15 }; accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson) { Id = 5 }; var provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5) { Id = 6 }; var providerOrganization = new ProviderOrganization("Организация поставщика", "Организация поставщика", juridicalPerson2); var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа"); var measureUnit = new MeasureUnit("шт.", "Штука", "123", 0) { Id = 1 }; var customDeclarationNumber = new String('0', 25); article = new Article("Тестовый товар А", articleGroup, measureUnit, true); providerContract = new ProviderContract(accountOrganization, providerOrganization, "Договор", "4645", DateTime.Now, DateTime.Now); provider.AddProviderContract(providerContract); user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); receiptWaybill = new ReceiptWaybill("123АБВ", DateTime.Today.AddDays(1), storage, accountOrganization, provider, 1234.5M, 0M, new ValueAddedTax("18%", 18), providerContract, customDeclarationNumber, user, user, DateTime.Now); receiptWaybillRow = new ReceiptWaybillRow(article, 100, 1234.5M, receiptWaybill.PendingValueAddedTax); receiptWaybill.AddRow(receiptWaybillRow); writeoffWaybill = new WriteoffWaybill("123", DateTime.Today, storage, accountOrganization, writeoffReason, user, user, DateTime.Now); priceLists = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(article, 10M) }; }
private void CheckPossibilityToRemoveProviderOrganization(ProviderOrganization providerOrganization, Provider provider) { int contractCount = providerOrganization.Contracts.Count(x => x.Contractors.Any(z => z.Id == provider.Id)); if (contractCount > 0) { throw new Exception(String.Format("Невозможно удалить организацию поставщика. Для данного поставщика существуют договоры с ее участием в количестве {0}.", contractCount)); } }
public void Init() { var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var physicalLegalForm = new LegalForm("ООО", EconomicAgentType.PhysicalPerson); juridicalPerson = new JuridicalPerson(juridicalLegalForm) { Id = 1, CashierName = "Кассиров В.В.", DirectorName = "Директоров В.В.", DirectorPost = "Главный директор", INN = "123456789", KPP = "2020202020", MainBookkeeperName = "Главбухова А.А.", OGRN = "12345", OKPO = "5431" }; physicalPerson = new PhysicalPerson(physicalLegalForm) { Id = 2, INN = "234567890", OGRNIP = "23456", OwnerName = "Физиков Ф.Ф.", Passport = new ValueObjects.PassportInfo { Series = "18 00", Number = "689689", IssuedBy = "Центральным РОВД г. Волгограда", IssueDate = DateTime.Parse("04.04.2001"), DepartmentCode = "342-001" } }; accountOrganization = new AccountOrganization("short_Name", "full_Name", juridicalPerson) { Id = 21 }; clientOrganization = new ClientOrganization("Короткое имя", "Длинное имя", physicalPerson) { Id = 22 }; providerOrganization = new ProviderOrganization("Краткое имя", "Полное имя", juridicalPerson) { Id = 23 }; provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5); provider.AddContractorOrganization(providerOrganization); client = new Client("Тестовый клиент", new ClientType("Тестовый тип клиента"), ClientLoyalty.Follower, new ClientServiceProgram("Программа"), new ClientRegion("Волгоград"), (byte)3); }
public ProviderOrganizationResponseModel(ProviderOrganization providerOrganization, string obj = "providerOrganization") : base(obj) { if (providerOrganization == null) { throw new ArgumentNullException(nameof(providerOrganization)); } Id = providerOrganization.Id; ProviderId = providerOrganization.ProviderId; OrganizationId = providerOrganization.OrganizationId; Key = providerOrganization.Key; Settings = providerOrganization.Settings; CreationDate = providerOrganization.CreationDate; RevisionDate = providerOrganization.RevisionDate; }
/// <summary> /// Проверка возможности удаления организации поставщика /// </summary> /// <param name="providerOrganization">Организация поставщика</param> private void CheckPossibilityToDeleteProviderOrganization(ProviderOrganization providerOrganization, User user) { // TODO: сделать проверки на возможность удаления расчетного счета, принадлежащего организации поставщика // TODO: когда можно будет связывать один договор с несколькими поставщиками, сделать доп. проверки на возможность их удаления var contractCount = providerOrganization.ContractCount; if (contractCount > 0) { string message = String.Format("Невозможно удалить организацию поставщика, так как с ней заключены договоры в количестве {0} шт.", contractCount); decimal purchaseCostSum = articlePurchaseService.GetTotalPurchaseCostSum(providerOrganization, user); if (purchaseCostSum > 0 && user.HasPermission(Permission.PurchaseCost_View_ForEverywhere)) { message += String.Format(", для которых существуют приходные накладные на сумму {0} р.", purchaseCostSum.ForDisplay(ValueDisplayType.Money)); } throw new Exception(message); } }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 31, Configuration.FieldSeparator), Id, ProviderInvoiceNumber?.ToDelimitedString(), PayerInvoiceNumber?.ToDelimitedString(), ContractAgreementNumber?.ToDelimitedString(), InvoiceControl?.ToDelimitedString(), InvoiceReason?.ToDelimitedString(), InvoiceType?.ToDelimitedString(), InvoiceDateTime.HasValue ? InvoiceDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, InvoiceAmount?.ToDelimitedString(), PaymentTerms, ProviderOrganization?.ToDelimitedString(), PayerOrganization?.ToDelimitedString(), Attention?.ToDelimitedString(), LastInvoiceIndicator, InvoiceBookingPeriod.HasValue ? InvoiceBookingPeriod.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, Origin, InvoiceFixedAmount?.ToDelimitedString(), SpecialCosts?.ToDelimitedString(), AmountForDoctorsTreatment?.ToDelimitedString(), ResponsiblePhysician?.ToDelimitedString(), CostCenter?.ToDelimitedString(), InvoicePrepaidAmount?.ToDelimitedString(), TotalInvoiceAmountWithoutPrepaidAmount?.ToDelimitedString(), TotalAmountOfVat?.ToDelimitedString(), VatRatesApplied != null ? string.Join(Configuration.FieldRepeatSeparator, VatRatesApplied.Select(x => x.ToString(Consts.NumericFormat, culture))) : null, BenefitGroup?.ToDelimitedString(), ProviderTaxId, PayerTaxId, ProviderTaxStatus?.ToDelimitedString(), PayerTaxStatus?.ToDelimitedString(), SalesTaxId ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
private Task <OrganizationResult> UpdateProviderOrganization(ProviderOrganization providerOrganization, ProviderOrganizationInput input, Organization organization) { _logger.LogInformation(GetLogMessage("Organization:{0}; input:{@input}"), providerOrganization.Id, input); providerOrganization.DefaultAccountManagerId = input.DefaultAccountManagerId; providerOrganization.DefaultProjectManagerId = input.DefaultProjectManagerId; providerOrganization.DefaultContractorId = input.DefaultContractorId; providerOrganization.Discoverable = input.Discoverable; providerOrganization.InjectFrom(input); providerOrganization.Updated = DateTimeOffset.UtcNow; providerOrganization.ObjectState = ObjectState.Modified; organization.ProviderOrganization = providerOrganization; var result = Repository.InsertOrUpdateGraph(organization, true); _logger.LogDebug(GetLogMessage("{0} Records updated"), result); return(Task.FromResult(new OrganizationResult() { OrganizationId = organization?.Id, Succeeded = result > 0 })); }
public void Init() { receiptWaybillRepository = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>()); productionOrderRepository = Mock.Get(IoCContainer.Resolve <IProductionOrderRepository>()); productionOrderBatchRepository = Mock.Get(IoCContainer.Resolve <IProductionOrderBatchRepository>()); defaultProductionOrderStageRepository = Mock.Get(IoCContainer.Resolve <IDefaultProductionOrderStageRepository>()); taskRepository = Mock.Get(IoCContainer.Resolve <ITaskRepository>()); articleAccountingPriceIndicatorService = Mock.Get(IoCContainer.Resolve <IArticleAccountingPriceIndicatorService>()); productionOrderService_accessor = new Mock <ProductionOrderService_Accessor>(productionOrderRepository.Object, productionOrderBatchRepository.Object, receiptWaybillRepository.Object, taskRepository.Object, defaultProductionOrderStageRepository.Object); productionOrderService = new Mock <ProductionOrderService>(productionOrderRepository.Object, productionOrderBatchRepository.Object, receiptWaybillRepository.Object, taskRepository.Object, defaultProductionOrderStageRepository.Object); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var providerType = new ProviderType("Тестовый тип поставщика"); var articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника"); var measureUnit = new MeasureUnit("шт", "штука", "123", 0); article1 = new Article("Пылесос", articleGroup, measureUnit, true) { Id = 1 }; article2 = new Article("Пылесос2", articleGroup, measureUnit, true) { Id = 2 }; article3 = new Article("Пылесос3", articleGroup, measureUnit, true) { Id = 3 }; priceLists = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(article1, 100M), new ArticleAccountingPrice(article2, 150M), new ArticleAccountingPrice(article3, 200M) }; var provider = new Provider("Нейтральная организация", providerType, ProviderReliability.Medium, 5); var providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", new JuridicalPerson(juridicalLegalForm)) { Id = 1 }; var accountOrganization = new AccountOrganization(@"ООО ""Юридическое лицо""", @"ООО ""Юридическое лицо""", new JuridicalPerson(juridicalLegalForm)) { Id = 2 }; provider.AddContractorOrganization(providerOrganization); var providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today); provider.AddProviderContract(providerContract); role = new Role("Администратор"); role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Delete_Row_Delete, PermissionDistributionType.All)); user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); user.AddRole(role); storage = new Storage("МХ", StorageType.TradePoint); storage.AddAccountOrganization(accountOrganization); producer = new Producer("producer", "organization", 5, user, false); var producerContract = new ProducerContract(accountOrganization, producer.Organization, "ABC", "123", DateTime.Now, DateTime.Today); currency = new Currency("755", "EUR", "Евро"); var stage1 = new ProductionOrderBatchStage_Accessor("1", ProductionOrderBatchStageType.Calculation, 1, false) { IsDefault = true }; var stage2 = new ProductionOrderBatchStage_Accessor("2", ProductionOrderBatchStageType.Closed, 0, false) { IsDefault = true }; var stage3 = new ProductionOrderBatchStage_Accessor("3", ProductionOrderBatchStageType.Closed, 0, false) { IsDefault = true }; var currentDateTime = DateTimeUtils.GetCurrentDateTime(); productionOrder = new ProductionOrder("ЗАКАЗ", producer, currency, (ProductionOrderBatchStage)stage1.Target, (ProductionOrderBatchStage)stage2.Target, (ProductionOrderBatchStage)stage3.Target, ProductionOrderArticleTransportingPrimeCostCalculationType.Weight, true, true, true, true, true, false, false, user, currentDateTime) { Storage = storage }; productionOrder.AddContract(producerContract); productionOrderBatch = productionOrder.Batches.FirstOrDefault(); manufacturer = new Manufacturer("Изготовитель"); producer.AddManufacturer(manufacturer); productionOrderBatchRow1 = new ProductionOrderBatchRow(article1, currency, 5M, 10M, 1.0M, new Country("Страна1", "686"), manufacturer) { Id = Guid.NewGuid() }; productionOrderBatchRow2 = new ProductionOrderBatchRow(article2, currency, 25M, 5M, 2.0M, new Country("Страна2", "686"), manufacturer) { Id = Guid.NewGuid() }; productionOrderBatchRow3 = new ProductionOrderBatchRow(article3, currency, 100M, 2M, 1.5M, new Country("Страна3", "686"), manufacturer) { Id = Guid.NewGuid() }; productionOrderBatch.AddRow(productionOrderBatchRow1); productionOrderBatch.AddRow(productionOrderBatchRow2); productionOrderBatch.AddRow(productionOrderBatchRow3); var customDeclarationNumber = new String('0', 25); receiptWaybill_accessor = new ReceiptWaybill_Accessor(productionOrderBatch, "999999", DateTime.Today, new ValueAddedTax("10%", 10), customDeclarationNumber, user, user, DateTime.Now); receiptWaybill = (ReceiptWaybill)receiptWaybill_accessor.Target; receiptWaybillRow1 = new ReceiptWaybillRow(article1, 10M, 0M, receiptWaybill.PendingValueAddedTax) { Id = Guid.NewGuid() }; receiptWaybill.AddRow(receiptWaybillRow1); productionOrderBatch.Rows.Where(x => x.Article == article1).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow1; receiptWaybillRow2 = new ReceiptWaybillRow(article2, 5M, 0M, receiptWaybill.PendingValueAddedTax) { Id = Guid.NewGuid() }; receiptWaybill.AddRow(receiptWaybillRow2); productionOrderBatch.Rows.Where(x => x.Article == article2).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow2; receiptWaybillRow3 = new ReceiptWaybillRow(article3, 2M, 0M, receiptWaybill.PendingValueAddedTax) { Id = Guid.NewGuid() }; receiptWaybill.AddRow(receiptWaybillRow3); productionOrderBatch.Rows.Where(x => x.Article == article3).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow3; receiptWaybillList = new List <ReceiptWaybill> { receiptWaybill }; receiptWaybillRepository.Setup(x => x.Delete(It.IsAny <ReceiptWaybill>())).Callback <ReceiptWaybill>(waybill => receiptWaybillList.Remove(waybill)); receiptWaybill.Accept(priceLists, user, DateTime.Now); receiptWaybillRow1.ReceiptedCount = receiptWaybillRow1.PendingCount; receiptWaybillRow1.ProviderCount = receiptWaybillRow1.PendingCount; receiptWaybillRow1.ProviderSum = 0M; receiptWaybillRow2.ReceiptedCount = receiptWaybillRow2.PendingCount; receiptWaybillRow2.ProviderCount = receiptWaybillRow2.PendingCount; receiptWaybillRow2.ProviderSum = 0M; receiptWaybillRow3.ReceiptedCount = receiptWaybillRow3.PendingCount; receiptWaybillRow3.ProviderCount = receiptWaybillRow3.PendingCount; receiptWaybillRow3.ProviderSum = 0M; }
public void Save(ProviderOrganization Value) { CurrentSession.SaveOrUpdate(Value); }
public void Init() { // инициализация IoC IoCInitializer.Init(); receiptWaybillRepository = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>()); receiptWaybillService = new ReceiptWaybillService(IoCContainer.Resolve <IArticleRepository>(), receiptWaybillRepository.Object, IoCContainer.Resolve <IMovementWaybillRepository>(), IoCContainer.Resolve <IExpenditureWaybillRepository>(), IoCContainer.Resolve <IStorageRepository>(), IoCContainer.Resolve <IUserRepository>(), IoCContainer.Resolve <IChangeOwnerWaybillRepository>(), IoCContainer.Resolve <IWriteoffWaybillRepository>(), IoCContainer.Resolve <IStorageService>(), IoCContainer.Resolve <IAccountOrganizationService>(), IoCContainer.Resolve <IProviderService>(), IoCContainer.Resolve <IProviderContractService>(), IoCContainer.Resolve <IValueAddedTaxService>(), IoCContainer.Resolve <IArticleMovementService>(), IoCContainer.Resolve <IArticlePriceService>(), IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IArticleAccountingPriceIndicatorService>(), IoCContainer.Resolve <IArticleMovementOperationCountService>(), IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IArticleMovementFactualFinancialIndicatorService>(), IoCContainer.Resolve <IFactualFinancialArticleMovementService>(), IoCContainer.Resolve <IAcceptedSaleIndicatorService>(), IoCContainer.Resolve <IShippedSaleIndicatorService>(), IoCContainer.Resolve <IReceiptedReturnFromClientIndicatorService>(), IoCContainer.Resolve <IAcceptedReturnFromClientIndicatorService>(), IoCContainer.Resolve <IReturnFromClientBySaleAcceptanceDateIndicatorService>(), IoCContainer.Resolve <IReturnFromClientBySaleShippingDateIndicatorService>(), IoCContainer.Resolve <IArticleRevaluationService>(), IoCContainer.Resolve <IArticlePurchaseService>(), IoCContainer.Resolve <IAcceptedPurchaseIndicatorService>(), IoCContainer.Resolve <IApprovedPurchaseIndicatorService>(), IoCContainer.Resolve <IArticleAvailabilityService>() ); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var providerType = new ProviderType("Тестовый тип поставщика"); var articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника"); var measureUnit = new MeasureUnit("шт", "штука", "123", 0); var article = new Article("Пылесос", articleGroup, measureUnit, true) { Id = 1 }; priceLists = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(article, 100M) }; var provider = new Provider("Нейтральная организация", providerType, ProviderReliability.Medium, 5); var providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", new JuridicalPerson(juridicalLegalForm)) { Id = 1 }; var accountOrganization = new AccountOrganization(@"ООО ""Юридическое лицо""", @"ООО ""Юридическое лицо""", new JuridicalPerson(juridicalLegalForm)) { Id = 2 }; provider.AddContractorOrganization(providerOrganization); var providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today); provider.AddProviderContract(providerContract); role = new Role("Администратор"); role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Delete_Row_Delete, PermissionDistributionType.All)); user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); user.AddRole(role); createdBy = new User(new Employee("Олег", "Олегов", "Олегович", new EmployeePost("Менеджер"), null), "Олегов Олег", "olegov", "pa$$w0rd", new Team("Тестовая команда", null), null); createdBy.AddRole(role); acceptedBy = new User(new Employee("Петр", "Петров", "Петрович", new EmployeePost("Менеджер"), null), "Петров Петр", "petrov", "pa$$w0rd", new Team("Тестовая команда", null), null); acceptedBy.AddRole(role); receiptedBy = new User(new Employee("Николай", "Николаев", "Николаевия", new EmployeePost("Менеджер"), null), "Николаев Николай", "nikolaev", "pa$$w0rd", new Team("Тестовая команда", null), null); receiptedBy.AddRole(role); var customDeclarationNumber = new String('0', 25); receiptWaybill = new ReceiptWaybill("999999", DateTime.Today, new Storage("Третий склад", StorageType.DistributionCenter), accountOrganization, provider, 50, 0M, new ValueAddedTax("10%", 10), providerContract, customDeclarationNumber, user, createdBy, DateTime.Now); receiptWaybillRow = new ReceiptWaybillRow(article, 5, 50M, receiptWaybill.PendingValueAddedTax); receiptWaybill.AddRow(receiptWaybillRow); receiptWaybillList = new List <ReceiptWaybill> { receiptWaybill }; receiptWaybillRepository.Setup(x => x.Delete(It.IsAny <ReceiptWaybill>())).Callback <ReceiptWaybill>(waybill => receiptWaybillList.Remove(waybill)); }
public void Save(ProviderOrganization providerOrganization) { organizationService.CheckOrganizationUniqueness(providerOrganization); providerOrganizationRepository.Save(providerOrganization); }
/// <summary> /// Проверка возможности удаления расчетного счета, принадлежащего организации поставщика /// </summary> /// <param name="providerOrganization">Организация поставщика, которой принадлежит расчетный счет</param> /// <param name="bankAccount">Расчетный счет</param> private void CheckForeignBankAccountDeletionPossibility(ProviderOrganization providerOrganization, ForeignBankAccount bankAccount) { // TODO: сделать проверки на возможность удаления расчетного счета, принадлежащего организации поставщика //organizationService.CheckBankAccountDeletionPossibility(bankAccount); }
public void Init() { articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника"); articleGroup.SalaryPercent = 15; articleGroup.Id = 8; measureUnit = new MeasureUnit("шт.", "Штука", "123", 0); measureUnit.Id = 17; articleA = new Article("Пылесос", articleGroup, measureUnit, true) { Id = 29, Number = "ПЫЛ" }; articleB = new Article("Холодильник", articleGroup, measureUnit, true) { Id = 38, Number = "ХО-1" }; articleC = new Article("Плита газовая", articleGroup, measureUnit, true) { Id = 48, Number = "ПГ1" }; articleAccountingPriceA1 = new ArticleAccountingPrice(articleA, 1M); articleAccountingPriceA2 = new ArticleAccountingPrice(articleA, 1001M); articleAccountingPriceA3 = new ArticleAccountingPrice(articleA, 1192.45M); articleAccountingPriceB = new ArticleAccountingPrice(articleB, 150M); articleAccountingPriceC = new ArticleAccountingPrice(articleC, 180M); articleAccountingPriceWrongListOnlyA = new List <ArticleAccountingPrice>(); articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA1); articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA2); articleAccountingPriceWrongListOnlyA.Add(articleAccountingPriceA3); articleAccountingPriceCorrectList1 = new List <ArticleAccountingPrice>(); articleAccountingPriceCorrectList1.Add(articleAccountingPriceA2); articleAccountingPriceCorrectList1.Add(articleAccountingPriceB); articleAccountingPriceCorrectList1.Add(articleAccountingPriceC); storage1 = new Storage("Торговая точка номер 1", StorageType.TradePoint); storage2 = new Storage("Доп. склад северный", StorageType.ExtraStorage); storage3 = new Storage("Торговая точка номер 2", StorageType.TradePoint); storageList1 = new List <Storage>(); storageList1.Add(storage1); storageList1.Add(storage2); storageList1.Add(storage3); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var physicalLegalForm = new LegalForm("ИП", EconomicAgentType.PhysicalPerson); juridicalPerson = new JuridicalPerson(juridicalLegalForm) { Id = 1 }; physicalPerson = new PhysicalPerson(physicalLegalForm) { Id = 2 }; accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson) { Id = 1 }; providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", physicalPerson) { Id = 2 }; provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5); provider.AddContractorOrganization(providerOrganization); providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today); provider.AddProviderContract(providerContract); user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); var customDeclarationNumber = new String('0', 25); receiptWaybill = new ReceiptWaybill("123АБВ", DateTime.Today, storage1, accountOrganization, provider, 100.05M, 0M, new ValueAddedTax("18%", 18), providerContract, customDeclarationNumber, user, user, DateTime.Now); priceRule = new AccountingPriceCalcRule( new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByMinimalPurchaseCost, new MarkupPercentDeterminationRule(10))); digitRule = new LastDigitCalcRule(LastDigitCalcRuleType.SetCustom); user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); }
public void Delete(ProviderOrganization Value) { Value.DeletionDate = DateTime.Now; CurrentSession.SaveOrUpdate(Value); }
[EfPolicyApplicableToUserInlineAutoData(OrganizationUserType.User, false, OrganizationUserStatusType.Invited, false, true, true, false)] // User not minStatus public async void GetManyByTypeApplicableToUser_Works_DataMatches( // Inline data OrganizationUserType userType, bool canManagePolicies, OrganizationUserStatusType orgUserStatus, bool includeInvited, bool policyEnabled, bool policySameType, bool isProvider, // Auto data - models Policy policy, User user, Organization organization, OrganizationUser orgUser, Provider provider, ProviderOrganization providerOrganization, ProviderUser providerUser, PolicyCompareIncludingOrganization equalityComparer, // Auto data - EF repos List <EfRepo.PolicyRepository> suts, List <EfRepo.UserRepository> efUserRepository, List <EfRepo.OrganizationRepository> efOrganizationRepository, List <EfRepo.OrganizationUserRepository> efOrganizationUserRepository, List <EfRepo.ProviderRepository> efProviderRepository, List <EfRepo.ProviderOrganizationRepository> efProviderOrganizationRepository, List <EfRepo.ProviderUserRepository> efProviderUserRepository, // Auto data - SQL repos SqlRepo.PolicyRepository sqlPolicyRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrganizationRepo, SqlRepo.ProviderRepository sqlProviderRepo, SqlRepo.OrganizationUserRepository sqlOrganizationUserRepo, SqlRepo.ProviderOrganizationRepository sqlProviderOrganizationRepo, SqlRepo.ProviderUserRepository sqlProviderUserRepo ) { // Combine EF and SQL repos into one list per type var policyRepos = suts.ToList <IPolicyRepository>(); policyRepos.Add(sqlPolicyRepo); var userRepos = efUserRepository.ToList <IUserRepository>(); userRepos.Add(sqlUserRepo); var orgRepos = efOrganizationRepository.ToList <IOrganizationRepository>(); orgRepos.Add(sqlOrganizationRepo); var orgUserRepos = efOrganizationUserRepository.ToList <IOrganizationUserRepository>(); orgUserRepos.Add(sqlOrganizationUserRepo); var providerRepos = efProviderRepository.ToList <IProviderRepository>(); providerRepos.Add(sqlProviderRepo); var providerOrgRepos = efProviderOrganizationRepository.ToList <IProviderOrganizationRepository>(); providerOrgRepos.Add(sqlProviderOrganizationRepo); var providerUserRepos = efProviderUserRepository.ToList <IProviderUserRepository>(); providerUserRepos.Add(sqlProviderUserRepo); // Arrange data var savedPolicyType = PolicyType.SingleOrg; var queriedPolicyType = policySameType ? savedPolicyType : PolicyType.DisableSend; orgUser.Type = userType; orgUser.Status = orgUserStatus; var permissionsData = new Permissions { ManagePolicies = canManagePolicies }; orgUser.Permissions = JsonSerializer.Serialize(permissionsData, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }); policy.Enabled = policyEnabled; policy.Type = savedPolicyType; var results = new List <Policy>(); foreach (var policyRepo in policyRepos) { var i = policyRepos.IndexOf(policyRepo); // Seed database var savedUser = await userRepos[i].CreateAsync(user); var savedOrg = await orgRepos[i].CreateAsync(organization); // Invited orgUsers are not associated with an account yet, so they are identified by Email not UserId if (orgUserStatus == OrganizationUserStatusType.Invited) { orgUser.Email = savedUser.Email; orgUser.UserId = null; } else { orgUser.UserId = savedUser.Id; } orgUser.OrganizationId = savedOrg.Id; await orgUserRepos[i].CreateAsync(orgUser); if (isProvider) { var savedProvider = await providerRepos[i].CreateAsync(provider); providerOrganization.OrganizationId = savedOrg.Id; providerOrganization.ProviderId = savedProvider.Id; await providerOrgRepos[i].CreateAsync(providerOrganization); providerUser.UserId = savedUser.Id; providerUser.ProviderId = savedProvider.Id; await providerUserRepos[i].CreateAsync(providerUser); } policy.OrganizationId = savedOrg.Id; await policyRepo.CreateAsync(policy); if (suts.Contains(policyRepo)) { (policyRepo as EfRepo.BaseEntityFrameworkRepository).ClearChangeTracking(); } var minStatus = includeInvited ? OrganizationUserStatusType.Invited : OrganizationUserStatusType.Accepted; // Act var result = await policyRepo.GetManyByTypeApplicableToUserIdAsync(savedUser.Id, queriedPolicyType, minStatus); results.Add(result.FirstOrDefault()); } // Assert var distinctItems = results.Distinct(equalityComparer); Assert.True(results.All(r => r == null) || !distinctItems.Skip(1).Any()); }
public void Init() { // инициализация IoC IoCInitializer.Init(); receiptWaybillRepository = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>()); articleRepository = Mock.Get(IoCContainer.Resolve <IArticleRepository>()); storageRepository = Mock.Get(IoCContainer.Resolve <IStorageRepository>()); movementWaybillRepository = Mock.Get(IoCContainer.Resolve <IMovementWaybillRepository>()); changeOwnerWaybillRepository = Mock.Get(IoCContainer.Resolve <IChangeOwnerWaybillRepository>()); writeoffWaybillRepository = Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>()); expenditureWaybillRepository = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>()); returnFromClientWaybillRepository = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>()); waybillRowArticleMovementRepository = Mock.Get(IoCContainer.Resolve <IWaybillRowArticleMovementRepository>()); var incomingWaybillRowService = new IncomingWaybillRowService(receiptWaybillRepository.Object, movementWaybillRepository.Object, changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object); var outgoingWaybillRowService = new OutgoingWaybillRowService(movementWaybillRepository.Object, IoCContainer.Resolve <IWriteoffWaybillRepository>(), IoCContainer.Resolve <IExpenditureWaybillRepository>(), changeOwnerWaybillRepository.Object, waybillRowArticleMovementRepository.Object); var articleMovementService = new ArticleMovementService(waybillRowArticleMovementRepository.Object, receiptWaybillRepository.Object, movementWaybillRepository.Object, changeOwnerWaybillRepository.Object, returnFromClientWaybillRepository.Object, Mock.Get(IoCContainer.Resolve <IWriteoffWaybillRepository>()).Object, Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>()).Object, incomingWaybillRowService, outgoingWaybillRowService); articleAvailabilityService = new ArticleAvailabilityService(receiptWaybillRepository.Object, movementWaybillRepository.Object, changeOwnerWaybillRepository.Object, writeoffWaybillRepository.Object, expenditureWaybillRepository.Object, returnFromClientWaybillRepository.Object, articleRepository.Object, storageRepository.Object, IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(), IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(), incomingWaybillRowService); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var physicalLegalForm = new LegalForm("ИП", EconomicAgentType.PhysicalPerson); juridicalPerson = new JuridicalPerson(juridicalLegalForm) { Id = 1 }; physicalPerson = new PhysicalPerson(physicalLegalForm) { Id = 2 }; accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson) { Id = 1 }; providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", physicalPerson) { Id = 2 }; provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium, 5); provider.AddContractorOrganization(providerOrganization); providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today); provider.AddProviderContract(providerContract); articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа"); measureUnit = new MeasureUnit("шт.", "Штука", "123", 0) { Id = 1 }; storageG = new Storage("G", StorageType.DistributionCenter) { Id = 1 }; storageM = new Storage("M", StorageType.DistributionCenter) { Id = 2 }; storageN = new Storage("N", StorageType.DistributionCenter) { Id = 3 }; articleA = new Article("A", articleGroup, measureUnit, false) { Id = 101 }; articleB = new Article("B", articleGroup, measureUnit, false) { Id = 102 }; articleC = new Article("C", articleGroup, measureUnit, false) { Id = 103 }; valueAddedTax = new ValueAddedTax("18%", 18); priceLists = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(articleA, 100), new ArticleAccountingPrice(articleB, 200), new ArticleAccountingPrice(articleC, 300) }; }