public IncomingWaybillRow ConvertToIncomingWaybillRow(ReceiptWaybillRow row) { return(new IncomingWaybillRow() { Batch = row, BatchDate = row.ReceiptWaybill.Date, Recipient = row.ReceiptWaybill.AccountOrganization, RecipientStorage = row.ReceiptWaybill.ReceiptStorage, Id = row.Id, IsReceipted = (row.FinalizationDate != null), // если позиция подавлена при приемке, то у нее дата проводки = дате согласования AcceptanceDate = row.IsAddedOnReceipt ? row.ReceiptWaybill.ApprovementDate.Value : row.ReceiptWaybill.AcceptanceDate.Value, FinalizationDate = row.FinalizationDate, Count = row.CurrentCount, AcceptedCount = row.AcceptedCount, ShippedCount = row.ShippedCount, FinallyMovedCount = row.FinallyMovedCount, Type = WaybillType.ReceiptWaybill, WaybillDate = row.ReceiptWaybill.Date, WaybillId = row.ReceiptWaybill.Id, WaybillNumber = row.ReceiptWaybill.Number, WaybillName = row.ReceiptWaybill.Name, AvailableInStorageCount = (row.ReceiptWaybill.IsReceipted && (!row.AreDivergencesAfterReceipt || row.AreDivergencesAfterReceipt && row.ReceiptWaybill.IsApproved) ? row.CurrentCount : 0) - row.FinallyMovedCount, PendingCount = (row.ReceiptWaybill.IsReceipted && (!row.AreDivergencesAfterReceipt || row.AreDivergencesAfterReceipt && row.ReceiptWaybill.IsApproved) ? 0 : row.PendingCount), DivergenceCount = (row.ReceiptWaybill.IsAccepted && row.AreDivergencesAfterReceipt && !row.ReceiptWaybill.IsApproved ? row.CurrentCount : 0), AvailableToReserveCount = row.AvailableToReserveCount, UsageAsManualSourceCount = row.UsageAsManualSourceCount }); }
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) }; }
public void Init() { numberA = "98"; var legalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson); juridicalPersonA = new JuridicalPerson(legalForm); juridicalPersonB = new JuridicalPerson(legalForm); juridicalPersonC = new JuridicalPerson(legalForm); juridicalPersonD = new JuridicalPerson(legalForm); senderOrganizationA = new AccountOrganization("Тестовое юридическое лицо A", "Тестовое юридическое лицо A", juridicalPersonA); senderOrganizationB = new AccountOrganization("Тестовое юридическое лицо B", "Тестовое юридическое лицо B", juridicalPersonB); receiverOrganizationC = new AccountOrganization("Тестовое юридическое лицо C", "Тестовое юридическое лицо C", juridicalPersonC); receiverOrganizationD = new AccountOrganization("Тестовое юридическое лицо D", "Тестовое юридическое лицо D", juridicalPersonD); storageA = new Storage("Тестовое хранилище A", StorageType.DistributionCenter) { Id = 1 }; storageB = new Storage("Тестовое хранилище B", StorageType.TradePoint) { Id = 2 }; articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа"); measureUnit = new MeasureUnit("шт.", "Штука", "123", 0) { Id = 1 }; articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true); articleB = new Article("Тестовый товар B", articleGroup, measureUnit, true); articleC = new Article("Тестовый товар C", articleGroup, measureUnit, true); valueAddedTax = new ValueAddedTax("18%", 18); receiptWaybillRowA1 = new ReceiptWaybillRow(articleA, 300, 3000, new ValueAddedTax("18%", 18)); receiptWaybillRowA2 = new ReceiptWaybillRow(articleA, 400, 4000, new ValueAddedTax("18%", 18)); receiptWaybillRowB = new ReceiptWaybillRow(articleB, 20, 250, new ValueAddedTax("18%", 18)); receiptWaybillRowC = new ReceiptWaybillRow(articleC, 20, 250, new ValueAddedTax("18%", 18)); rowA1_1 = new MovementWaybillRow(receiptWaybillRowA1, 60, valueAddedTax); rowA1_2 = new MovementWaybillRow(receiptWaybillRowA1, 22, valueAddedTax); rowA2_1 = new MovementWaybillRow(receiptWaybillRowA2, 40, valueAddedTax); rowA2_2 = new MovementWaybillRow(receiptWaybillRowA2, 55, valueAddedTax); rowB = new MovementWaybillRow(receiptWaybillRowB, 15, valueAddedTax); rowC = new MovementWaybillRow(receiptWaybillRowC, 18, valueAddedTax); priceLists = new List <ArticleAccountingPrice>() { new ArticleAccountingPrice(articleA, 100), new ArticleAccountingPrice(articleB, 200), new ArticleAccountingPrice(articleC, 300) }; user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null); }
//[TestMethod] //public void MovementWaybill_If_OutcomingWaybill_Exist_Row_Cannot_Be_Deleted() //{ // var accPriceA_sender = new ArticleAccountingPrice(articleA, 50); // var accPriceB_sender = new ArticleAccountingPrice(articleB, 60); // var accPriceB_recipient = new ArticleAccountingPrice(articleB, 70); // var accPriceC_recipient = new ArticleAccountingPrice(articleC, 80); // var senderPriceLists = new List<ArticleAccountingPrice> { accPriceA_sender, accPriceB_sender }; // var recipientPriceLists = new List<ArticleAccountingPrice> { accPriceB_recipient, accPriceC_recipient }; // var movementWaybill = new MovementWaybill("123", DateTime.Now, storageA, senderOrganizationA, storageB, senderOrganizationB); // movementWaybill.AddRow(rowA1_1); // Provider provider; // provider = new Provider("Тестовый поставщик", new ProviderType("Тестовый тип поставщика"), ProviderReliability.Medium); // provider.AddOrganization(senderOrganizationA.Organization); // var receiptWaybill = new ReceiptWaybill("321", DateTime.Now, storageA, senderOrganizationA, provider, 5000, new ValueAddedTax("10%", 10)); // receiptWaybill.AddRow(rowA1_1.ReceiptWaybillRow); // rowA1_1.ReceiptWaybillRow.PendingSum = 5000; // receiptWaybill.Receipt(5000, 500, new List<ArticleAccountingPrice>()); // movementWaybill.DeleteRow(rowA1_1); // movementWaybill.AddRow(rowB); // movementWaybill.AddRow(rowC); // movementWaybill.SetAsReadyToShip(); // movementWaybill.Ship(100M, 100M, 100M, senderPriceLists, recipientPriceLists); // movementWaybill.CancelShipping(); // Assert.IsNull(rowA1_1.SenderArticleAccountingPrice); // Assert.IsNull(rowB.SenderArticleAccountingPrice); // Assert.IsNull(rowC.SenderArticleAccountingPrice); // Assert.IsNull(rowA1_1.RecipientArticleAccountingPrice); // Assert.IsNull(rowB.RecipientArticleAccountingPrice); // Assert.IsNull(rowC.RecipientArticleAccountingPrice); //} private MovementWaybill InitMovementWaybill() { MovementWaybill waybill = new MovementWaybill(numberA, DateTime.Now, storageA, senderOrganizationA, storageB, receiverOrganizationC, valueAddedTax, user, user, DateTime.Now); var receiptWaybillRow = new ReceiptWaybillRow(articleA, 300, 3000, valueAddedTax); var row = new MovementWaybillRow(receiptWaybillRow, 10, valueAddedTax); waybill.AddRow(row); return(waybill); }
public void MovementWaybillRow_InitialParameters_MustBeSet() { var receiptWaybillRow = new ReceiptWaybillRow(articleA, 300, 3000, valueAddedTax); var row = new MovementWaybillRow(receiptWaybillRow, 10, valueAddedTax); Assert.AreEqual(articleA.FullName, row.Article.FullName); Assert.AreEqual(10, row.MovingCount); Assert.AreEqual(0, row.FinallyMovedCount); Assert.AreEqual(0, row.AcceptedCount); Assert.IsNotNull(row.ReceiptWaybillRow); Assert.IsNull(row.DeletionDate); Assert.IsNotNull(row.CreationDate); Assert.AreEqual(OutgoingWaybillRowState.Undefined, row.OutgoingWaybillRowState); }
public ArticleBatchAvailabilityExtendedInfo(ReceiptWaybillRow articleBatch, short storageId, int accountOrganizationId, decimal availableInStorageCount, decimal pendingCount, decimal reservedFromExactAvailabilityCount, decimal reservedFromIncomingAcceptedAvailabilityCount) { ArticleBatchId = articleBatch.Id; ArticleId = articleBatch.Article.Id; BatchName = articleBatch.BatchName; PurchaseCost = articleBatch.PurchaseCost; BatchDate = articleBatch.ReceiptWaybill.Date; ArticleMeasureUnitScale = articleBatch.ArticleMeasureUnitScale; StorageId = storageId; AccountOrganizationId = accountOrganizationId; AvailableInStorageCount = availableInStorageCount; PendingCount = pendingCount; ReservedFromExactAvailabilityCount = reservedFromExactAvailabilityCount; ReservedFromIncomingAcceptedAvailabilityCount = reservedFromIncomingAcceptedAvailabilityCount; }
public void MovementWaybillRow_ReDeletion_Must_Not_Work() { var receiptWaybillRow = new ReceiptWaybillRow(articleA, 300, 3000, valueAddedTax); var row = new MovementWaybillRow(receiptWaybillRow, 10, valueAddedTax); var curDate = DateTime.Now; var nextDate = curDate + new TimeSpan(1, 0, 0, 0); Assert.IsNull(row.DeletionDate); row.DeletionDate = curDate; Assert.AreEqual(curDate, row.DeletionDate); row.DeletionDate = nextDate; Assert.AreEqual(curDate, row.DeletionDate); Assert.AreNotEqual(nextDate, row.DeletionDate); }
public void Init() { creationDate = DateTime.Now; currentDate = DateTime.Now; storage = new Storage("qwe", StorageType.ExtraStorage); deal = new Mock <Deal>(); quota = new DealQuota("asd", 10, 45, 15000); user = new Mock <User>(); createdBy = new Mock <User>(); team = new Mock <Team>(); contract = new Mock <ClientContract>(); accountOrganization = new Mock <AccountOrganization>(); valueAddedTax = new ValueAddedTax("18%", 18); ag = new ArticleGroup("Группа товаров", "Группа товаров"); art1 = new Article("Товар 1", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); art2 = new Article("Товар 2", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); art3 = new Article("Товар 3", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); prices = new List <ArticleAccountingPrice>(); prices.Add(new ArticleAccountingPrice(art1, 10M)); prices.Add(new ArticleAccountingPrice(art2, 13M)); prices.Add(new ArticleAccountingPrice(art3, 15M)); receiptWaybillRow = new ReceiptWaybillRow(art1, 150, valueAddedTax, 75); user.Setup(x => x.Id).Returns(43); createdBy.Setup(x => x.Id).Returns(1); team.Setup(x => x.Id).Returns(1); 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); deal.Setup(x => x.Id).Returns(2); accountOrganization.Setup(x => x.Storages).Returns(new List <Storage> { storage }); contract.Setup(x => x.AccountOrganization).Returns(accountOrganization.Object); waybill = new ExpenditureWaybill("123", currentDate, storage, deal.Object, team.Object, quota, false, user.Object, DeliveryAddressType.CustomAddress, "qwerty", creationDate, createdBy.Object); waybillRow = new ExpenditureWaybillRow(receiptWaybillRow, 10, valueAddedTax); waybill.AddRow(waybillRow); }
/// <summary> /// Создание показателя проведенных накладных реализации по параметрам. /// </summary> /// <param name="startDate">Дата начала действия показателя.</param> /// <param name="row">Позиция, по которой создавать индикатор.</param> /// <param name="sign">Коэффициент, определяющий направление изменения индикатора. Принимает значение 1, или -1. При значении 1 индикатор будет увеличен, -1 — уменьшен.</param> private AcceptedPurchaseIndicator CreateAcceptedPurchaseIndicator(DateTime startDate, ReceiptWaybillRow row, short sign) { var waybill = row.ReceiptWaybill; return(new AcceptedPurchaseIndicator(startDate, row.Article.Id, waybill.Curator.Id, waybill.Contractor.Id, waybill.ReceiptStorage.Id, waybill.AccountOrganization.Id, waybill.ContractorOrganization.Id, waybill.Contract.Id, sign * Math.Round(row.PurchaseCost * row.CurrentCount, 6), sign * row.CurrentCount)); }
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 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; }
/// <summary> /// Получение списка входящих позиций по товару, МХ и организации, из которых доступно резервирование товаров /// </summary> /// <param name="article">Товар</param> /// <param name="storage">Место хранения</param> /// <param name="organization">Собственная организация</param> /// <param name="batch">Опциональный параметр для фильтра по партии</param> /// <param name="waybillType">Опциональный параметр для фильтра по типу накладной</param> /// <param name="startDate">Опциональный параметр для фильтра по дате (начало интервала)</param> /// <param name="endDate">Опциональный параметр для фильтра по дате (конец интервала)</param> /// <param name="number">Опциональный параметр для фильтра по номеру накладной</param> /// <returns>Отфильтрованный список позиций накладных с товаром article на складе storage от собственной организации organization</returns> public IEnumerable <IncomingWaybillRow> GetAvailableToReserveList(Article article, Storage storage, AccountOrganization organization, ReceiptWaybillRow batch = null, Guid?waybillRowId = null, WaybillType?waybillType = null, DateTime?startDate = null, DateTime?endDate = null, string number = null) { var result = new List <IncomingWaybillRow>(); var waybillRowArticleMovementSubquery = receiptWaybillRepository.SubQuery <WaybillRowArticleMovement>() .Where(x => x.DestinationWaybillRowId == waybillRowId).Select(x => x.SourceWaybillRowId); #region Приходы if (waybillType == null || waybillType == WaybillType.ReceiptWaybill) { var receiptWaybillSubQuery = receiptWaybillRepository.SubQuery <ReceiptWaybill>() .Where(x => x.ReceiptStorage.Id == storage.Id && x.AccountOrganization.Id == organization.Id && x.AcceptanceDate != null).Select(x => x.Id); var receiptWaybillRowsQuery = receiptWaybillRepository.Query <ReceiptWaybillRow>() .Where(x => x.Article.Id == article.Id) .PropertyIn(x => x.ReceiptWaybill, receiptWaybillSubQuery); if (waybillRowId != null) { var availableToReserveSubquery = receiptWaybillRepository.SubQuery <ReceiptWaybillRow>().Where(x => x.AvailableToReserveCount > 0).Select(x => x.Id); receiptWaybillRowsQuery.Or(x => x.PropertyIn(y => y.Id, waybillRowArticleMovementSubquery), x => x.PropertyIn(y => y.Id, availableToReserveSubquery)); } else { receiptWaybillRowsQuery.Where(x => x.AvailableToReserveCount > 0); } if (batch != null) { receiptWaybillRowsQuery.Where(x => x.Id == batch.Id); } if (startDate != null) { receiptWaybillSubQuery.Where(x => x.Date >= startDate); } if (endDate != null) { receiptWaybillSubQuery.Where(x => x.Date <= endDate); } if (number != null) { receiptWaybillSubQuery.Like(x => x.Number, number); } var receiptWaybillRows = receiptWaybillRowsQuery.ToList <ReceiptWaybillRow>(); foreach (var row in receiptWaybillRows) { result.Add(ConvertToIncomingWaybillRow(row)); } } #endregion #region Перемещения if (waybillType == null || waybillType == WaybillType.MovementWaybill) { var movementWaybillSubQuery = movementWaybillRepository.SubQuery <MovementWaybill>() .Where(x => x.RecipientStorage.Id == storage.Id && x.Recipient.Id == organization.Id && x.AcceptanceDate != null).Select(x => x.Id); var movementWaybillRowsQuery = movementWaybillRepository.Query <MovementWaybillRow>() .PropertyIn(x => x.MovementWaybill, movementWaybillSubQuery); if (waybillRowId != null) { var availableToReserveSubquery = receiptWaybillRepository.SubQuery <MovementWaybillRow>().Where(x => x.AvailableToReserveCount > 0).Select(x => x.Id); movementWaybillRowsQuery.Or(x => x.PropertyIn(y => y.Id, waybillRowArticleMovementSubquery), x => x.PropertyIn(y => y.Id, availableToReserveSubquery)); } else { movementWaybillRowsQuery.Where(x => x.AvailableToReserveCount > 0); } var batchSubQuery = movementWaybillRepository.SubQuery <ReceiptWaybillRow>().Where(x => x.Article.Id == article.Id).Select(x => x.Id); if (batch != null) { batchSubQuery.Where(x => x.Id == batch.Id); } if (number != null || startDate != null || endDate != null) { if (number != null) { movementWaybillSubQuery.Like(x => x.Number, number); } if (startDate != null) { movementWaybillSubQuery.Where(x => x.Date >= startDate); } if (endDate != null) { movementWaybillSubQuery.Where(x => x.Date <= endDate); } } var movementWaybillRows = movementWaybillRowsQuery.PropertyIn(x => x.ReceiptWaybillRow, batchSubQuery).ToList <MovementWaybillRow>(); foreach (var row in movementWaybillRows) { result.Add(ConvertToIncomingWaybillRow(row)); } } #endregion #region Смены собственника if (waybillType == null || waybillType == WaybillType.ChangeOwnerWaybill) { var changeOwnerWaybillSubQuery = changeOwnerWaybillRepository.SubQuery <ChangeOwnerWaybill>() .Where(x => x.Storage.Id == storage.Id && x.Recipient.Id == organization.Id && x.AcceptanceDate != null).Select(x => x.Id); var changeOwnerWaybillRowsQuery = changeOwnerWaybillRepository.Query <ChangeOwnerWaybillRow>() .PropertyIn(x => x.ChangeOwnerWaybill, changeOwnerWaybillSubQuery); if (waybillRowId != null) { var availableToReserveSubquery = receiptWaybillRepository.SubQuery <ChangeOwnerWaybillRow>().Where(x => x.AvailableToReserveCount > 0).Select(x => x.Id); changeOwnerWaybillRowsQuery.Or(x => x.PropertyIn(y => y.Id, waybillRowArticleMovementSubquery), x => x.PropertyIn(y => y.Id, availableToReserveSubquery)); } else { changeOwnerWaybillRowsQuery.Where(x => x.AvailableToReserveCount > 0); } var batchSubQuery = changeOwnerWaybillRepository.SubQuery <ReceiptWaybillRow>() .Where(x => x.Article.Id == article.Id).Select(x => x.Id); if (batch != null) { batchSubQuery.Where(x => x.Id == batch.Id); } if (number != null) { changeOwnerWaybillSubQuery.Like(x => x.Number, number); } if (startDate != null) { changeOwnerWaybillSubQuery.Where(x => x.Date >= startDate); } if (endDate != null) { changeOwnerWaybillSubQuery.Where(x => x.Date <= endDate); } var changeOwnerWaybillRows = changeOwnerWaybillRowsQuery.PropertyIn(x => x.ReceiptWaybillRow, batchSubQuery).ToList <ChangeOwnerWaybillRow>(); foreach (var row in changeOwnerWaybillRows) { result.Add(ConvertToIncomingWaybillRow(row)); } } #endregion #region Возврат от клиента if (waybillType == null || waybillType == WaybillType.ReturnFromClientWaybill) { var returnFromClientWaybillSubQuery = returnFromClientWaybillRepository.SubQuery <ReturnFromClientWaybill>() .Where(x => x.RecipientStorage.Id == storage.Id && x.Recipient.Id == organization.Id && x.AcceptanceDate != null).Select(x => x.Id); var returnFromClientWaybillRowsQuery = returnFromClientWaybillRepository.Query <ReturnFromClientWaybillRow>() .PropertyIn(x => x.ReturnFromClientWaybill, returnFromClientWaybillSubQuery); if (waybillRowId != null) { var availableToReserveSubquery = receiptWaybillRepository.SubQuery <ReturnFromClientWaybillRow>().Where(x => x.AvailableToReserveCount > 0).Select(x => x.Id); returnFromClientWaybillRowsQuery.Or(x => x.PropertyIn(y => y.Id, waybillRowArticleMovementSubquery), x => x.PropertyIn(y => y.Id, availableToReserveSubquery)); } else { returnFromClientWaybillRowsQuery.Where(x => x.AvailableToReserveCount > 0); } var batchSubQuery = returnFromClientWaybillRepository.SubQuery <ReceiptWaybillRow>().Where(x => x.Article.Id == article.Id).Select(x => x.Id); if (batch != null) { batchSubQuery.Where(x => x.Id == batch.Id); } if (number != null) { returnFromClientWaybillSubQuery.Like(x => x.Number, number); } if (startDate != null) { returnFromClientWaybillSubQuery.Where(x => x.Date >= startDate); } if (endDate != null) { returnFromClientWaybillSubQuery.Where(x => x.Date <= endDate); } var returnFromClientWaybillRows = returnFromClientWaybillRowsQuery .PropertyIn(x => x.ReceiptWaybillRow, batchSubQuery).ToList <ReturnFromClientWaybillRow>(); foreach (var row in returnFromClientWaybillRows) { result.Add(ConvertToIncomingWaybillRow(row)); } } #endregion return(result); }
public void Init() { employee1 = new Employee("Работник 1 имя", "Работник 1 фамилия", "Работник 1 отчество", new EmployeePost("Работник 1 пост"), null); curator = new User(employee1, "Куратор", "log", "pas", new Team("Тестовая команда", null), null); team = new Team("123", curator); economicAgent = new PhysicalPerson(new LegalForm("Легал форм", EconomicAgentType.PhysicalPerson)); accountOrganization = new AccountOrganization("Орг1 кор имя", "орг1 длин имя", economicAgent) { Id = 1 }; accountOrganizationAnother = new AccountOrganization("Орг2 кор имя", "орг2 длин имя", economicAgent) { Id = 2 }; clientOrganization = new ClientOrganization("client org", "cllll", economicAgent) { Id = 3 }; client = new Client("клиент1", new ClientType("основной тип клиента"), ClientLoyalty.Follower, new ClientServiceProgram("программа 1"), new ClientRegion("Регион 1"), 10); deal = new Deal("Тестовая сделка", curator); client.AddDeal(deal); storage = new Storage("Склад 1", StorageType.ExtraStorage); storage.AddAccountOrganization(accountOrganization); storage.AddAccountOrganization(accountOrganizationAnother); storage2 = new Storage("Склад 2", StorageType.ExtraStorage); returnFromClientReason = new ReturnFromClientReason("Брак"); returnFromClientWaybill = new ReturnFromClientWaybill("142", DateTime.Today, accountOrganization, deal, team, storage, returnFromClientReason, curator, curator, DateTime.Now); valueAddedTax = new ValueAddedTax("18%", 18); ag = new ArticleGroup("Группа товаров", "Группа товаров"); art1 = new Article("Товар 1", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); art2 = new Article("Товар 2", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); art3 = new Article("Товар 3", ag, new MeasureUnit("шт.", "штуки", "123", 1), false); Prices = new List <ArticleAccountingPrice>(); Prices.Add(new ArticleAccountingPrice(art1, 10M)); Prices.Add(new ArticleAccountingPrice(art2, 13M)); Prices.Add(new ArticleAccountingPrice(art3, 15M)); deal1 = new Deal("Deal1", curator); deal2 = new Deal("Deal2", curator); quota1 = new DealQuota("qq", 1); quota2 = new DealQuota("qq", 2); deal1.AddQuota(quota1); deal2.AddQuota(quota2); deal1.Contract = new ClientContract(accountOrganization, clientOrganization, "Договор", "1", DateTime.Now, DateTime.Now); deal2.Contract = new ClientContract(accountOrganizationAnother, clientOrganization, "kk", "22", DateTime.Today, DateTime.Now); recRow1 = new ReceiptWaybillRow(art1, 5, 50, new ValueAddedTax("18%", 18)) { Id = Guid.NewGuid() }; recRow1_1 = new ReceiptWaybillRow(art1, 2, 30, new ValueAddedTax("18%", 18)) { Id = Guid.NewGuid() }; recRow2 = new ReceiptWaybillRow(art2, 7, 35, new ValueAddedTax("18%", 18)) { Id = Guid.NewGuid() }; recRow3 = new ReceiptWaybillRow(art3, 9, 90, new ValueAddedTax("18%", 18)) { Id = Guid.NewGuid() }; recRow1.PurchaseCost = 50 / 5; recRow1.PurchaseCost = 35 / 7; recRow1.PurchaseCost = 90 / 9; saleRow1 = new ExpenditureWaybillRow(recRow1, 3, valueAddedTax) { Id = Guid.NewGuid() }; saleRow1_1 = new ExpenditureWaybillRow(recRow1_1, 1, valueAddedTax) { Id = Guid.NewGuid() }; saleRow2 = new ExpenditureWaybillRow(recRow2, 4, valueAddedTax) { Id = Guid.NewGuid() }; saleRow3 = new ExpenditureWaybillRow(recRow3, 5, valueAddedTax) { Id = Guid.NewGuid() }; saleRowAnother1 = new ExpenditureWaybillRow(recRow1, 3, valueAddedTax) { Id = Guid.NewGuid() }; saleRowAnother2 = new ExpenditureWaybillRow(recRow2, 4, valueAddedTax) { Id = Guid.NewGuid() }; saleRowAnother3 = new ExpenditureWaybillRow(recRow3, 5, valueAddedTax) { Id = Guid.NewGuid() }; sale = new ExpenditureWaybill("1", DateTime.Today, storage, deal1, team, quota1, true, curator, DeliveryAddressType.ClientAddress, "", DateTime.Now, curator) { Id = Guid.NewGuid() }; saleAnother = new ExpenditureWaybill("1", DateTime.Today, storage, deal2, team, quota2, true, curator, DeliveryAddressType.ClientAddress, "", DateTime.Now, curator) { Id = Guid.NewGuid() }; sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow1); sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow2); sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow3); saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother1); saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother2); saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother3); sale.As <ExpenditureWaybill>().Accept(Prices, false, curator, DateTime.Now); saleAnother.As <ExpenditureWaybill>().Accept(Prices, false, curator, DateTime.Now); }