コード例 #1
0
        public IncomingWaybillRow ConvertToIncomingWaybillRow(MovementWaybillRow row)
        {
            return(new IncomingWaybillRow()
            {
                Batch = row.ReceiptWaybillRow,
                BatchDate = row.ReceiptWaybillRow.ReceiptWaybill.Date,
                Recipient = row.MovementWaybill.Recipient,
                RecipientStorage = row.MovementWaybill.RecipientStorage,
                Count = row.MovingCount,
                FinallyMovedCount = row.FinallyMovedCount,
                Id = row.Id,
                IsReceipted = row.MovementWaybill.IsReceipted,
                AcceptanceDate = row.MovementWaybill.AcceptanceDate.Value,
                FinalizationDate = row.MovementWaybill.ReceiptDate,
                AcceptedCount = row.AcceptedCount,
                ShippedCount = row.ShippedCount,
                Type = WaybillType.MovementWaybill,
                WaybillDate = row.MovementWaybill.Date,
                WaybillId = row.MovementWaybill.Id,
                WaybillNumber = row.MovementWaybill.Number,
                WaybillName = row.MovementWaybill.Name,

                AvailableInStorageCount = (row.MovementWaybill.IsReceipted ? row.MovingCount - row.FinallyMovedCount : 0),
                PendingCount = (!row.MovementWaybill.IsReceipted ? row.MovingCount - row.FinallyMovedCount : 0),
                DivergenceCount = 0,

                AvailableToReserveCount = row.AvailableToReserveCount,
                UsageAsManualSourceCount = row.UsageAsManualSourceCount
            });
        }
コード例 #2
0
 /// <summary>
 /// Расчет основных показателей для одной позиции накладной перемещения
 /// </summary>
 public MovementWaybillRowMainIndicators GetMainRowIndicators(MovementWaybillRow row, User user, bool calculateValueAddedTaxSums = false, bool calculateMarkups = false)
 {
     return(GetMainIndicatorsForRowList(row.MovementWaybill, new List <MovementWaybillRow>()
     {
         row
     },
                                        articleRepository.GetArticleSubQuery(row.Article.Id),
                                        user, calculateValueAddedTaxSums, calculateMarkups)[row.Id]);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        /// <summary>
        /// Удаление позиции из накладной
        /// </summary>
        public virtual void DeleteRow(MovementWaybill waybill, MovementWaybillRow row, User user)
        {
            CheckPossibilityToDeleteRow(row, user);

            if (row.IsUsingManualSource)
            {
                articleMovementService.ResetManualSources(row);
            }

            waybill.DeleteRow(row);
        }
コード例 #5
0
        //[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);
        }
コード例 #6
0
        public void CheckPossibilityToDeleteRow(MovementWaybillRow row, User user)
        {
            // права
            CheckPermissionToPerformOperation(row.MovementWaybill, user, Permission.MovementWaybill_Delete_Row_Delete);

            // удалить можно только позицию накладной, исходящей из места хранения пользователя
            user.CheckStorageAvailability(row.MovementWaybill.SenderStorage, Permission.MovementWaybill_Delete_Row_Delete);

            // сущность
            row.CheckPossibilityToDelete();
        }
コード例 #7
0
        public bool IsPossibilityToDeleteRow(MovementWaybillRow row, User user)
        {
            try
            {
                CheckPossibilityToDeleteRow(row, user);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #8
0
        private void AddRowLocal(MovementWaybill waybill, MovementWaybillRow row, IEnumerable <WaybillRowManualSource> sourceDistributionInfo, User user)
        {
            CheckPossibilityToEdit(waybill, user);

            waybill.AddRow(row);

            movementWaybillRepository.Save(waybill);

            if (sourceDistributionInfo != null)
            {
                articleMovementService.SetManualSources(row, sourceDistributionInfo);
            }
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        /// <summary>
        /// Упрощенное добавление позиции в накладную
        /// </summary>
        /// <param name="waybill">Накладная</param>
        /// <param name="article">Товар</param>
        /// <param name="count">Кол-во резервируемого товара</param>
        /// <param name="user">Пользователь</param>
        public void AddRowSimply(MovementWaybill waybill, Article article, decimal count, User user)
        {
            CheckPossibilityToEdit(waybill, user);

            // распределяем кол-во товара по партиям
            var countDistributionInfo = DistributeCountByBatches(article, waybill.SenderStorage, waybill.Sender, count);

            var batchList = receiptWaybillService.GetRows(countDistributionInfo.Keys);

            foreach (var item in countDistributionInfo)
            {
                var batch = batchList[item.Key];
                var row   = new MovementWaybillRow(batch, item.Value, waybill.ValueAddedTax);

                AddRow(waybill, row, user);
            }
        }
コード例 #11
0
        private void SaveRowLocal(MovementWaybill waybill, MovementWaybillRow row, IEnumerable <WaybillRowManualSource> sourceDistributionInfo, User user)
        {
            CheckPossibilityToEdit(waybill, user);

            // если у позиции источники уже установлены вручную, то сначала сбрасываем источники
            // TODO: в будущем добавить параметр о необходимости сброса источников в метод SetManualSources
            if (row.IsUsingManualSource)
            {
                articleMovementService.ResetManualSources(row);
            }

            if (sourceDistributionInfo != null)
            {
                articleMovementService.SetManualSources(row, sourceDistributionInfo);
            }

            movementWaybillRepository.Save(waybill);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 public OutgoingWaybillRow ConvertToOutgoingWaybillRow(MovementWaybillRow row)
 {
     return(new OutgoingWaybillRow()
     {
         Batch = row.ReceiptWaybillRow,
         Count = row.MovingCount,
         Id = row.Id,
         Sender = row.MovementWaybill.Sender,
         SenderStorage = row.MovementWaybill.SenderStorage,
         State = row.OutgoingWaybillRowState,
         Type = WaybillType.MovementWaybill,
         WaybillDate = row.MovementWaybill.Date,
         WaybillId = row.MovementWaybill.Id,
         WaybillNumber = row.MovementWaybill.Number,
         SenderAccountingPrice = row.SenderArticleAccountingPrice != null ? row.SenderArticleAccountingPrice.AccountingPrice : 0,
         AreSourcesDetermined = row.AreSourcesDetermined,
         AcceptanceDate = row.MovementWaybill.AcceptanceDate,
         FinalizationDate = row.MovementWaybill.ReceiptDate
     });
 }
コード例 #14
0
 /// <summary>
 /// Добавление позиции в накладную
 /// </summary>
 public virtual void AddRow(MovementWaybill waybill, MovementWaybillRow row, User user)
 {
     AddRowLocal(waybill, row, null, user);
 }
コード例 #15
0
 public void SaveRow(MovementWaybillRow entity)
 {
     CurrentSession.SaveOrUpdate(entity);
 }
コード例 #16
0
 /// <summary>
 /// Сохранение позиции с указанием источников вручную (при редактировании)
 /// </summary>
 public void SaveRow(MovementWaybill waybill, MovementWaybillRow row, IEnumerable <WaybillRowManualSource> sourceDistributionInfo, User user)
 {
     SaveRowLocal(waybill, row, sourceDistributionInfo, user);
 }
コード例 #17
0
 public void SaveRow(MovementWaybill waybill, MovementWaybillRow row, User user)
 {
     SaveRowLocal(waybill, row, null, user);
 }