public void AccountOrganization_MustNotBeEqualToNonAccountOrganization() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест1", "Тест1", jp1) { Id = 5 }; DateTime nonAccountOrganization = new DateTime(2007, 12, 5); Assert.IsFalse(org1.Equals(nonAccountOrganization)); }
public void AccountOrganization_MustNotBeEqualToNull() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест1", "Тест1", jp1) { Id = 5 }; AccountOrganization accountOrganizationNull = null; Assert.IsFalse(org1.Equals(accountOrganizationNull)); Assert.IsFalse(org1.Equals(null)); }
public void AccountOrganization_Storage_Additon_And_Removing_Must_Be_Ok() { var storage = new Storage("Склад", StorageType.DistributionCenter); var jp = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)); var org = new AccountOrganization("Тест", "Тест", jp); org.AddStorage(storage); Assert.AreEqual(1, org.StorageCount); Assert.AreEqual(1, storage.AccountOrganizationCount); org.RemoveStorage(storage); Assert.AreEqual(0, org.StorageCount); Assert.AreEqual(0, storage.AccountOrganizationCount); }
public void AccountOrganization_2CallsOfGetHashCode_MustReturnSameValues() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест", "Тест", jp1) { Id = 5 }; var hashCode1 = org1.GetHashCode(); var hashCode2 = org1.GetHashCode(); Assert.IsTrue(hashCode1 == hashCode2); }
public void AccountOrganization_DifferentIds_MustHaveDifferent_HashCodes() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест", "Тест", jp1) { Id = 5 }; var org2 = new AccountOrganization("Тест", "Тест", jp1) { Id = 6 }; Assert.IsFalse(org1.GetHashCode() == org2.GetHashCode()); }
public void AccountOrganization_Deletion_Not_Added_Storage_Must_Throw_Exception() { try { var storage = new Storage("Склад", StorageType.DistributionCenter); var jp = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)); var org = new AccountOrganization("Тест", "Тест", jp); org.RemoveStorage(storage); Assert.Fail("Исключение не вызвано."); } catch (Exception ex) { Assert.AreEqual("Данное место хранения не связано с этой организацией. Возможно, оно было удалено.", ex.Message); } }
public void Init() { // инициализация IoC IoCInitializer.Init(); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); var juridicalPerson1 = new JuridicalPerson(juridicalLegalForm) { Id = 1 }; accountOrganization = new AccountOrganization("Тестовая собственная организация", "Тестовая собственная организация", juridicalPerson1) { Id = 1 }; var juridicalPerson2 = new JuridicalPerson(juridicalLegalForm) { Id = 2 }; clientOrganization = new ClientOrganization("Тестовая организация клиента", "Тестовая организация клиента", juridicalPerson2) { Id = 2 }; clientContractRepository = Mock.Get(IoCContainer.Resolve <IClientContractRepository>()); dealRepository = Mock.Get(IoCContainer.Resolve <IDealRepository>()); dealIndicatorService = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>()); expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>()); storageService = Mock.Get(IoCContainer.Resolve <IStorageService>()); clientContractIndicatorService = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>()); taskRepository = Mock.Get(IoCContainer.Resolve <ITaskRepository>()); dealServiceMock = new Mock <DealService>(dealRepository.Object, clientContractRepository.Object, taskRepository.Object, dealIndicatorService.Object, expenditureWaybillIndicatorService.Object, storageService.Object, clientContractIndicatorService.Object); dealService = dealServiceMock.Object; user = new Mock <User>(); user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All); clientContractIndicatorService.Setup(x => x.CalculateCashPaymentLimitExcessByPaymentsFromClient(It.IsAny <ClientContract>())).Returns(0); }
public void AccountOrganization_DifferentIdMustNotBeEqual() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест", "Тест", jp1) { Id = 5 }; var org2 = new AccountOrganization("Тест", "Тест", jp1) { Id = 6 }; bool areEqual = (org1 == org2); Assert.IsFalse(areEqual); }
public void AccountOrganization_DifferentIdMustHaveEqualsFalse() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест", "Тест", jp1) { Id = 5 }; var org2 = new AccountOrganization("Тест", "Тест", jp1) { Id = 6 }; Assert.IsFalse(org1.Equals(org2)); Assert.IsFalse(org2.Equals(org1)); }
/// <summary> /// Получение списка накладных по параметрам /// </summary> public IEnumerable <WriteoffWaybill> GetList(AccountOrganization accountOrganization = null, Storage storage = null) { ValidationUtils.Assert(accountOrganization != null || storage != null, "Все параметры не могут быть null."); var query = CurrentSession.Query <WriteoffWaybill>(); if (accountOrganization != null) { query = query.Where(x => x.Sender == accountOrganization); } if (storage != null) { query = query.Where(x => x.SenderStorage == storage); } return(query.Where(x => x.DeletionDate == null) .ToList()); }
/// <summary> /// Получение списка накладных по параметрам /// </summary> public IEnumerable <ReturnFromClientWaybill> GetList(AccountOrganization accountOrganization = null, Storage storage = null) { ValidationUtils.Assert(accountOrganization != null || storage != null, "Все параметры не могут быть null."); var query = CurrentSession.Query <ReturnFromClientWaybill>(); if (accountOrganization != null) { query = query.Where(x => x.Deal.Contract.AccountOrganization == accountOrganization); } if (storage != null) { query = query.Where(x => x.RecipientStorage == storage); } return(query.Where(x => x.DeletionDate == null) .ToList()); }
public void AccountOrganization_SameIds_MustHaveEqual_HashCodes() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест1", "Тест1", jp1) { Id = 5 }; var jp2 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 2 }; var org2 = new AccountOrganization("Тест", "Тест2", jp2) { Id = 5 }; Assert.IsTrue(org1.GetHashCode() == org2.GetHashCode()); }
public void AccountOrganization_ZeroIds_DifferentValues_ShouldHaveDifferent_HashCodes() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест1", "Тест1", jp1) { Id = 0 }; var jp2 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 2 }; var org2 = new AccountOrganization("Тест2", "Тест2", jp2) { Id = 0 }; Assert.IsFalse(org1.GetHashCode() == org2.GetHashCode()); }
public void AccountOrganization_SameIdMustBeEqual() { var jp1 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 1 }; var org1 = new AccountOrganization("Тест1", "Тест1", jp1) { Id = 5 }; var jp2 = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)) { Id = 2 }; var org2 = new AccountOrganization("Тест", "Тест2", jp2) { Id = 5 }; bool areEqual = (org1 == org2); Assert.IsTrue(areEqual); }
public void Init() { clientType = new ClientType("Тестовый тип клиента") { Id = 1 }; serviceProgram = new ClientServiceProgram("Тестовая программа") { Id = 2 }; region = new ClientRegion("Тестовый регион") { Id = 3 }; client = new Client("Тестовый клиент", clientType, ClientLoyalty.Customer, serviceProgram, region, 5) { Id = 4 }; user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); juridicalPerson = new JuridicalPerson(juridicalLegalForm) { Id = 1 }; accountOrganization = new AccountOrganization("Тестовое юридическое лицо", "Тестовое юридическое лицо", juridicalPerson) { Id = 1 }; clientOrganization = new ClientOrganization("Тестовая организация клиента", "Тестовая организация клиента", new JuridicalPerson(juridicalLegalForm) { Id = 2 }) { Id = 3 }; contract = new ClientContract(accountOrganization, clientOrganization, "12", "1", DateTime.Now, DateTime.Now); }
/// <summary> /// Проверка на возможность удаления связи "Собственная организация - МХ" /// </summary> /// <param name="organization"></param> /// <returns></returns> private void CheckPossibilityToDeleteAccountOrganizationToStorageLink(AccountOrganization organization, Storage storage) { // Проверяем наличие товаров данной организации на данном складе var isAvailability = articleAvailabilityService.IsExtendedArticleAvailability(storage.Id, organization.Id, DateTime.Now); ValidationUtils.Assert(isAvailability == false, string.Format("Невозможно удалить связь. На месте хранения «{0}» имеются товары, принадлежащие организации «{1}».", storage.Name, organization.ShortName)); var receiptWaybillList = receiptWaybillRepository.GetList(organization, storage); GetExceptionString(receiptWaybillList, 3, "приходной накладной", "и еще в {0} приходных накладных", "Невозможно удалить связанное место хранения, так как оно используется в"); var movementWaybillList = movementWaybillRepository.GetList(organization, storage); GetExceptionString(movementWaybillList, 3, "накладной перемещения", "и еще в {0} накладных перемещения", "Невозможно удалить связанное место хранения, так как оно используется в"); var changeOwnerWaybillList = changeOwnerWaybillRepository.GetList(organization, storage); GetExceptionString(changeOwnerWaybillList, 3, "накладной смены собственника", "и еще в {0} накладных смены собственника", "Невозможно удалить связанное место хранения, так как оно используется в"); var writeoffWaybillList = writeoffWaybillRepository.GetList(organization, storage); GetExceptionString(writeoffWaybillList, 3, "накладной списания", "и еще в {0} накладных списания", "Невозможно удалить связанное место хранения, так как оно используется в"); var expenditureWaybillList = expenditureWaybillRepository.GetList(organization, storage); GetExceptionString(expenditureWaybillList, 3, "накладной реализации", "и еще в {0} накладных реализации", "Невозможно удалить связанное место хранения, так как оно используется в"); var returnFromClientWaybillList = returnFromClientWaybillRepository.GetList(organization, storage); GetExceptionString(returnFromClientWaybillList, 3, "накладной возврата от клиента", "и еще в {0} накладных возврата от клиента", "Невозможно удалить связанное место хранения, так как оно используется в"); }
public void AddStorage(AccountOrganization organization, Storage storage, User user) { user.CheckStorageAvailability(storage, Permission.Storage_AccountOrganization_Add); organization.AddStorage(storage); }
/// <summary> /// Уникален ли номер накладной /// </summary> /// <param name="number">Номер для проверки</param> /// <param name="currentId">Id накладной</param> /// <param name="documentDate">Дата накладной</param> /// <param name="accountOrganization">Собственная организация накладной</param> public bool IsNumberUnique(string number, Guid currentId, DateTime documentDate, AccountOrganization accountOrganization) { var count = Query <ReturnFromClientWaybill>(false) .Where(x => x.Number == number && x.Id != currentId && documentDate.Year == x.Year && x.Recipient == accountOrganization).Count(); return(count == 0); }
/// <summary> /// Получение позиций накладных, проведенных до указанной даты и из которых на текущий момент возможно зарезервировать товар /// </summary> /// <param name="articleBatchSubquery">Подзапрос для партий товаров</param> /// <param name="storage">МХ</param> /// <param name="organization">Собственная организация</param> /// <param name="date">Дата, ограничивающая дату проводки выбираемых накладных</param> public IEnumerable <ReturnFromClientWaybillRow> GetAvailableToReserveRows(ISubQuery articleBatchSubquery, Storage storage, AccountOrganization organization, DateTime date) { var returnFromClientWaybills = SubQuery <ReturnFromClientWaybill>() .Where(x => x.RecipientStorage.Id == storage.Id && x.Recipient.Id == organization.Id && x.AcceptanceDate < date) .Select(x => x.Id); return(Query <ReturnFromClientWaybillRow>() .PropertyIn(x => x.ReturnFromClientWaybill, returnFromClientWaybills) .Where(x => x.AvailableToReserveCount > 0) .Restriction <ReceiptWaybillRow>(x => x.ReceiptWaybillRow) .PropertyIn(x => x.Id, articleBatchSubquery) .ToList <ReturnFromClientWaybillRow>()); }
public void AddForeignBankAccount(AccountOrganization organization, ForeignBankAccount bankAccount) { organization.AddForeignBankAccount(bankAccount); }
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) }; }
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 ChangeRecipientStorage(MovementWaybill movementWaybill, Storage newRecipientStorage, AccountOrganization newRecipient) { var articleList = movementWaybill.Rows.Select(x => x.Article); var accPriceList = articlePriceService.GetAccountingPrice(newRecipientStorage.Id, movementWaybillRepository.GetArticlesSubquery(movementWaybill.Id)); foreach (var article in articleList) { if (!accPriceList[article.Id].HasValue) { throw new Exception(String.Format("На месте хранения «{0}» не установлена учетная цена для одного или нескольких товаров.", newRecipientStorage.Name)); } } movementWaybill.RecipientStorage = newRecipientStorage; movementWaybill.Recipient = newRecipient; }
public void Delete(AccountOrganization Value) { CurrentSession.SaveOrUpdate(Value); }
public void Initialize() { var economicAgent = new JuridicalPerson(new LegalForm("ООО", EconomicAgentType.JuridicalPerson)); accountOrganization = new AccountOrganization("Тест", "ТестТест", economicAgent); }
public void AddRussianBankAccount(AccountOrganization organization, RussianBankAccount bankAccount) { organization.AddRussianBankAccount(bankAccount); }
public void DeleteRussianBankAccount(AccountOrganization organization, RussianBankAccount bankAccount) { organization.DeleteRussianBankAccount(bankAccount); }
public void Init() { // инициализация IoC IoCInitializer.Init(); setting = new Setting() { UseReadyToAcceptStateForReturnFromClientWaybill = false }; settingRepository = Mock.Get(IoCContainer.Resolve <ISettingRepository>()); settingRepository.Setup(x => x.Get()).Returns(setting); storage = new Storage("qwe", StorageType.ExtraStorage) { Id = 42 }; accOrgSender = new Mock <AccountOrganization>(); accOrgSender.Setup(x => x.Id).Returns(1); accOrgRecipient = new Mock <AccountOrganization>(); accOrgRecipient.Setup(x => x.Id).Returns(2); valueAddedTax = new ValueAddedTax(); user = new Mock <User>(); user.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All); createdBy = new Mock <User>(); createdBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All); acceptedBy = new Mock <User>(); acceptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All); receiptedBy = new Mock <User>(); receiptedBy.Setup(x => x.GetPermissionDistributionType(It.IsAny <Permission>())).Returns(PermissionDistributionType.All); var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа"); var measureUnit = new MeasureUnit("шт.", "Штука", "123", 0) { Id = 1 }; articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true) { Id = 1 }; articleB = new Article("Тестовый товар Б", articleGroup, measureUnit, true) { Id = 2 }; receiptWaybillRow1 = new Mock <ReceiptWaybillRow>(); receiptWaybillRow1.Setup(x => x.Article).Returns(articleA); receiptWaybillRow2 = new Mock <ReceiptWaybillRow>(); receiptWaybillRow2.Setup(x => x.Article).Returns(articleB); articleAccountingPrice = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(articleA, 100) }; returnFromClientWaybillRepository = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>()); articlePriceService = Mock.Get(IoCContainer.Resolve <IArticlePriceService>()); articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <IEnumerable <int> >())).Returns(articleAccountingPrice); articlePriceService.Setup(x => x.GetArticleAccountingPrices(It.Is <short>(y => y == storage.Id), It.IsAny <ISubQuery>(), It.IsAny <DateTime>())).Returns(articleAccountingPrice); returnFromClientWaybillRepository = Mock.Get(IoCContainer.Resolve <IReturnFromClientWaybillRepository>()); expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>()); articleAvailabilityService = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>()); returnFromClientWaybillService = new ReturnFromClientWaybillService( IoCContainer.Resolve <ISettingRepository>(), returnFromClientWaybillRepository.Object, IoCContainer.Resolve <ITeamRepository>(), IoCContainer.Resolve <IDealRepository>(), IoCContainer.Resolve <IStorageRepository>(), IoCContainer.Resolve <IUserRepository>(), IoCContainer.Resolve <IArticlePriceService>(), IoCContainer.Resolve <IAcceptedSaleIndicatorService>(), IoCContainer.Resolve <IReturnFromClientService>(), IoCContainer.Resolve <IFactualFinancialArticleMovementService>(), IoCContainer.Resolve <IArticleMovementOperationCountService>(), IoCContainer.Resolve <IArticleMovementService>(), IoCContainer.Resolve <IDealPaymentDocumentDistributionService>(), IoCContainer.Resolve <IDealIndicatorService>(), IoCContainer.Resolve <IArticleRevaluationService>(), expenditureWaybillIndicatorService.Object, articleAvailabilityService.Object ); deal = new Mock <Deal>(); quota = new DealQuota("asd", 10, 45, 15000); team = new Team("Тестовая команда", It.IsAny <User>()) { Id = 1 }; contract = new Mock <ClientContract>(); var economicAgent = new Mock <EconomicAgent>(); accountOrganization = new AccountOrganization("asd", "asd", economicAgent.Object); deal.Setup(x => x.IsActive).Returns(true); deal.Setup(x => x.IsClosed).Returns(false); deal.Setup(x => x.Quotas).Returns(new List <DealQuota> { quota }); deal.Setup(x => x.Contract).Returns(contract.Object); accountOrganization.AddStorage(storage); contract.Setup(x => x.AccountOrganization).Returns(accountOrganization); returnFromClientWaybill = new ReturnFromClientWaybill("123", DateTime.Now, accountOrganization, deal.Object, team, storage, new ReturnFromClientReason(), user.Object, createdBy.Object, DateTime.Now); sale = new Mock <ExpenditureWaybill>(); sale.Setup(x => x.Sender).Returns(accountOrganization); sale.Setup(x => x.Team).Returns(team); sale.Setup(x => x.Is <ExpenditureWaybill>()).Returns(true); sale.Setup(x => x.As <ExpenditureWaybill>()).Returns(sale.Object); #region Создание позиции 1 saleRow1 = new Mock <ExpenditureWaybillRow>(); saleRow1.Setup(x => x.ExpenditureWaybill).Returns(sale.Object); saleRow1.Setup(x => x.SaleWaybill).Returns(sale.Object); saleRow1.Setup(x => x.Id).Returns(Guid.NewGuid()); saleRow1.Setup(x => x.SellingCount).Returns(100); saleRow1.Setup(x => x.As <ExpenditureWaybillRow>()).Returns(saleRow1.Object); saleRow1.Setup(x => x.Is <ExpenditureWaybillRow>()).Returns(true); saleRow1.Setup(x => x.Article).Returns(articleA); saleRow1.Setup(x => x.SalePrice).Returns(128); saleRow1.Setup(x => x.ReceiptWaybillRow).Returns(receiptWaybillRow1.Object); #endregion #region Создание позиции 2 saleRow2 = new Mock <ExpenditureWaybillRow>(); saleRow2.Setup(x => x.ExpenditureWaybill).Returns(sale.Object); saleRow2.Setup(x => x.SaleWaybill).Returns(sale.Object); saleRow2.Setup(x => x.Id).Returns(Guid.NewGuid()); saleRow2.Setup(x => x.SellingCount).Returns(100); saleRow2.Setup(x => x.As <ExpenditureWaybillRow>()).Returns(saleRow2.Object); saleRow2.Setup(x => x.Is <ExpenditureWaybillRow>()).Returns(true); saleRow2.Setup(x => x.Article).Returns(articleA); saleRow2.Setup(x => x.SalePrice).Returns(128); saleRow2.Setup(x => x.ReceiptWaybillRow).Returns(receiptWaybillRow2.Object); #endregion ReturnFromClientWaybillRow row = new ReturnFromClientWaybillRow(saleRow1.Object, 1); returnFromClientWaybill.AddRow(row); articleMovementService = new Mock <IArticleMovementService>(); articleMovementService.Setup(x => x.CancelArticleAcceptance(It.IsAny <WriteoffWaybill>())) .Returns(new List <OutgoingWaybillRowSourceReservationInfo>() { new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1) }); articleMovementService.Setup(x => x.AcceptArticles(It.IsAny <WriteoffWaybill>())) .Returns(new List <OutgoingWaybillRowSourceReservationInfo>() { new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1) }); }
public void DeleteForeignBankAccount(AccountOrganization organization, ForeignBankAccount bankAccount) { organization.DeleteForeignBankAccount(bankAccount); }
/// <summary> /// Проверка номера накладной на уникальность /// </summary> /// <param name="number">Номер накладной</param> /// <param name="id">Код текущей накладной</param> /// <returns>Результат проверки</returns> private bool IsNumberUnique(string number, Guid id, DateTime documentDate, AccountOrganization accountOrganization) { return(returnFromClientWaybillRepository.IsNumberUnique(number, id, documentDate, accountOrganization)); }