Esempio n. 1
0
        /// <summary>
        /// Создание показателя отгруженных накладных реализации по параметрам
        /// </summary>
        private ShippedSaleIndicator CreateShippedSaleIndicator(DateTime startDate, ExpenditureWaybillRow row, short teamId, short sign)
        {
            ValidationUtils.Assert(sign == 1 || sign == -1, "Значение множителя может быть только 1 или -1.");

            var waybill = row.ExpenditureWaybill;

            return(new ShippedSaleIndicator(startDate, row.Article.Id, waybill.Curator.Id, row.ReceiptWaybillRow.ReceiptWaybill.Contractor.Id,
                                            waybill.SenderStorage.Id, waybill.Sender.Id, waybill.Deal.Client.Id, waybill.Deal.Id, waybill.Deal.Contract.ContractorOrganization.Id,
                                            teamId, row.ReceiptWaybillRow.Id,
                                            sign * Math.Round(row.PurchaseCost * row.SellingCount, 6),
                                            sign * Math.Round(row.SenderArticleAccountingPrice.AccountingPrice * row.SellingCount, 2),
                                            sign * Math.Round((row.SalePrice ?? 0) * row.SellingCount, 2),
                                            sign * row.SellingCount));
        }
Esempio n. 2
0
        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);
        }
 public OutgoingWaybillRow ConvertToOutgoingWaybillRow(ExpenditureWaybillRow row)
 {
     return(new OutgoingWaybillRow()
     {
         Batch = row.ReceiptWaybillRow,
         Count = row.SellingCount,
         Id = row.Id,
         Sender = row.ExpenditureWaybill.Sender,
         SenderStorage = row.ExpenditureWaybill.SenderStorage,
         State = row.OutgoingWaybillRowState,
         Type = WaybillType.ExpenditureWaybill,
         WaybillDate = row.ExpenditureWaybill.Date,
         WaybillId = row.ExpenditureWaybill.Id,
         WaybillNumber = row.ExpenditureWaybill.Number,
         SenderAccountingPrice = row.SenderArticleAccountingPrice != null ? row.SenderArticleAccountingPrice.AccountingPrice : 0,
         AreSourcesDetermined = row.AreSourcesDetermined,
         AcceptanceDate = row.ExpenditureWaybill.AcceptanceDate,
         FinalizationDate = row.ExpenditureWaybill.ShippingDate
     });
 }
 /// <summary>
 /// Получение отпускной цены для позиции накладной
 /// </summary>
 public decimal?CalculateRowSalePrice(ExpenditureWaybillRow waybillRow)
 {
     return(CalculateRowMainIndicators(waybillRow, calculateSalePrice: true)[waybillRow.Id].SalePrice);
 }
 public IDictionary <Guid, ExpenditureWaybillRowMainIndicators> CalculateRowMainIndicators(ExpenditureWaybillRow row, bool allowToViewAccPrices = true, bool calculateSalePrice = false, bool calculateValueAddedTaxSum = false)
 {
     return(GetMainIndicatorsForRowList(row.ExpenditureWaybill, new List <ExpenditureWaybillRow> {
         row
     }, articleRepository.GetArticleSubQuery(row.Article.Id),
                                        allowToViewAccPrices: allowToViewAccPrices, calculateSalePrice: calculateSalePrice, calculateValueAddedTaxSum: calculateValueAddedTaxSum));
 }
        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);
        }
 public void SaveRow(ExpenditureWaybillRow entity)
 {
     CurrentSession.SaveOrUpdate(entity);
 }
Esempio n. 8
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            setting = new Setting()
            {
                UseReadyToAcceptStateForExpenditureWaybill = 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);

            var articleGroup = new ArticleGroup("Тестовая группа", "Тестовая группа");
            var measureUnit  = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            articleA = new Article("Тестовый товар A", articleGroup, measureUnit, true)
            {
                Id = 1
            };

            receiptWaybillRow = new Mock <ReceiptWaybillRow>();
            receiptWaybillRow.Setup(x => x.Article).Returns(articleA);

            articleAccountingPrice = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(articleA, 100)
            };

            expenditureWaybillRepository = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillRepository>());
            articleRepository            = Mock.Get(IoCContainer.Resolve <IArticleRepository>());
            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);

            articleAvailabilityService = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());

            articleMovementService = Mock.Get(IoCContainer.Resolve <IArticleMovementService>());

            receiptWaybillService = Mock.Get(IoCContainer.Resolve <IReceiptWaybillService>());

            articleRevaluationService = Mock.Get(IoCContainer.Resolve <IArticleRevaluationService>());

            factualFinancialArticleMovementService = new Mock <IFactualFinancialArticleMovementService>();

            articleMovementOperationCountService = new Mock <IArticleMovementOperationCountService>();

            teamRepository = Mock.Get(IoCContainer.Resolve <ITeamRepository>());

            dealRepository = Mock.Get(IoCContainer.Resolve <IDealRepository>());

            expenditureWaybillIndicatorService = Mock.Get(IoCContainer.Resolve <IExpenditureWaybillIndicatorService>());

            dealPaymentDocumentDistributionService = Mock.Get(IoCContainer.Resolve <IDealPaymentDocumentDistributionService>());

            blockingService = Mock.Get(IoCContainer.Resolve <IBlockingService>());

            articleSaleService                = Mock.Get(IoCContainer.Resolve <IArticleSaleService>());
            teamService                       = Mock.Get(IoCContainer.Resolve <ITeamService>());
            dealService                       = Mock.Get(IoCContainer.Resolve <IDealService>());
            dealIndicatorService              = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());
            clientContractIndicatorService    = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            returnFromClientWaybillRepository = new Mock <IReturnFromClientWaybillRepository>();

            expenditureWaybillService = new ExpenditureWaybillService(settingRepository.Object, expenditureWaybillRepository.Object, teamRepository.Object,
                                                                      Mock.Get(IoCContainer.Resolve <IStorageRepository>()).Object, Mock.Get(IoCContainer.Resolve <IUserRepository>()).Object,
                                                                      dealRepository.Object, articlePriceService.Object, expenditureWaybillIndicatorService.Object, articleMovementService.Object,
                                                                      dealPaymentDocumentDistributionService.Object, blockingService.Object, articleSaleService.Object,
                                                                      factualFinancialArticleMovementService.Object, articleMovementOperationCountService.Object, teamService.Object, dealService.Object,
                                                                      dealIndicatorService.Object, clientContractIndicatorService.Object, articleAvailabilityService.Object,
                                                                      receiptWaybillService.Object, articleRevaluationService.Object, returnFromClientWaybillRepository.Object);

            deal                = new Mock <Deal>();
            quota               = new DealQuota("asd", 10, 45, 15000);
            team                = new Mock <Team>();
            contract            = new Mock <ClientContract>();
            accountOrganization = new Mock <AccountOrganization>();
            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.Setup(x => x.Storages).Returns(new List <Storage> {
                storage
            });
            contract.Setup(x => x.AccountOrganization).Returns(accountOrganization.Object);

            waybill = new ExpenditureWaybill("123", DateTime.Now, storage, deal.Object, team.Object, quota, false, user.Object, DeliveryAddressType.CustomAddress, "qwe", DateTime.Now, createdBy.Object);

            var row = new ExpenditureWaybillRow(receiptWaybillRow.Object, 10, valueAddedTax);

            waybill.AddRow(row);

            articleMovementService.Setup(x => x.CancelArticleAcceptance(It.IsAny <ExpenditureWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
            articleMovementService.Setup(x => x.AcceptArticles(It.IsAny <ExpenditureWaybill>()))
            .Returns(new List <OutgoingWaybillRowSourceReservationInfo>()
            {
                new OutgoingWaybillRowSourceReservationInfo(row.Id, 1, 1)
            });
        }