Пример #1
0
        public void Post_SuccessfullyCreated()
        {
            // Arrange
            _issuedInvoicePostModel                   = _issuedInvoiceClient.Default().AssertResult();
            _issuedInvoicePostModel.PartnerId         = PartnerId;
            _issuedInvoicePostModel.DeliveryAddressId = DeliveryAddressId1;
            _issuedInvoicePostModel.Description       = "Invoice";
            _issuedInvoicePostModel.Items.Clear();
            _issuedInvoicePostModel.Items.Add(new IssuedInvoiceItemPostModel
            {
                Name      = "Test",
                UnitPrice = 100
            });

            // Act
            var data = _issuedInvoiceClient.Post(_issuedInvoicePostModel).AssertResult();

            _issuedInvoiceId = data.Id;

            // Assert
            Assert.Greater(data.Id, 0);
            Assert.AreEqual(_issuedInvoicePostModel.DateOfIssue, data.DateOfIssue);
            Assert.AreEqual(PartnerId, data.PartnerId);
            Assert.Greater(data.Items.Count, 0);
            AssertDeliveryAddress(data.DeliveryAddress, DeliveryAddressId1);
        }
Пример #2
0
        public void PostWithOssRegime_SuccessfullyCreated()
        {
            // Arrange
            _issuedInvoicePostModel                 = _issuedInvoiceClient.Default().AssertResult();
            _issuedInvoicePostModel.PartnerId       = GermanPartnerId;
            _issuedInvoicePostModel.Description     = "MossTest";
            _issuedInvoicePostModel.HasVatRegimeOss = true;
            _issuedInvoicePostModel.Items.Clear();
            _issuedInvoicePostModel.Items.Add(new IssuedInvoiceItemPostModel
            {
                Name        = "Test",
                UnitPrice   = 100,
                VatRateType = VatRateType.Basic
            });

            // Act
            var data = _issuedInvoiceClient.Post(_issuedInvoicePostModel).AssertResult();

            // Assert
            Assert.That(data.HasVatRegimeOss, Is.True);
            Assert.Greater(data.Id, 0);
            Assert.Greater(data.Items.Count, 0);
            Assert.AreEqual(data.Items.First().VatRate, 19);

            // Teardown
            _issuedInvoiceClient.Delete(data.Id);
        }
Пример #3
0
 private void AssertIssuedInvoice(IssuedInvoicePostModel issuedInvoice, SalesOrderGetModel salesOrder)
 {
     Assert.AreEqual(SalesOrderId, issuedInvoice.SalesOrderId);
     Assert.AreEqual(salesOrder.Description, issuedInvoice.Description);
     Assert.AreEqual(salesOrder.CurrencyId, issuedInvoice.CurrencyId);
     Assert.AreEqual(salesOrder.ExchangeRate, issuedInvoice.ExchangeRate);
     Assert.AreEqual(salesOrder.ExchangeRateAmount, issuedInvoice.ExchangeRateAmount);
     Assert.AreEqual(salesOrder.PartnerId, issuedInvoice.PartnerId);
     Assert.AreEqual(salesOrder.PaymentOptionId, issuedInvoice.PaymentOptionId);
     Assert.AreEqual(salesOrder.OrderNumber, issuedInvoice.OrderNumber);
     Assert.AreEqual(salesOrder.MyAddress.AccountNumber, issuedInvoice.AccountNumber);
     Assert.AreEqual(salesOrder.MyAddress.Iban, issuedInvoice.Iban);
     Assert.AreEqual(salesOrder.MyAddress.Swift, issuedInvoice.Swift);
 }
Пример #4
0
        /// <summary>
        /// Maps issued invoice to recount model.
        /// </summary>
        /// <param name="source">Issued invoice.</param>
        /// <returns>Recount model.</returns>
        public static IssuedInvoiceRecountPostModel ToRecountModel(this IssuedInvoicePostModel source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new IssuedInvoiceRecountPostModel
            {
                CurrencyId = source.CurrencyId,
                DiscountPercentage = source.DiscountPercentage,
                DateOfTaxing = source.DateOfTaxing,
                ExchangeRate = source.ExchangeRate ?? 1,
                ExchangeRateAmount = source.ExchangeRateAmount ?? 1,
                Items = source.Items.Select(ToRecountModel).ToList(),
                PaymentOptionId = source.PaymentOptionId
            });
        }
Пример #5
0
        private void ValidatePost(IssuedInvoicePostModel model)
        {
            _ = model ?? throw new ArgumentNullException(nameof(model));

            if (model.ProformaInvoices == null || !model.ProformaInvoices.Any())
            {
                if (model.Items.Any(i => i.ItemType != PostIssuedInvoiceItemType.ItemTypeNormal))
                {
                    throw new ValidationException("Issued invoice can contain only normal items.");
                }
            }
            else
            {
                if (model.Items.Any(i => i.ItemType != PostIssuedInvoiceItemType.ItemTypeNormal && i.ItemType != PostIssuedInvoiceItemType.ItemTypeReduce))
                {
                    throw new ValidationException("Issued invoice can contain only normal or deductive items.");
                }
            }
        }
        public async Task PostAsync_SuccessfullyCreated()
        {
            // Arrange
            _issuedInvoicePostModelAsync             = _issuedInvoiceClient.Default().AssertResult();
            _issuedInvoicePostModelAsync.PartnerId   = PartnerId;
            _issuedInvoicePostModelAsync.Description = "Invoice";
            _issuedInvoicePostModelAsync.Items.Clear();
            _issuedInvoicePostModelAsync.Items.Add(new IssuedInvoiceItemPostModel
            {
                Name      = "Test",
                UnitPrice = 100
            });

            // Act
            var data = (await _issuedInvoiceClient.PostAsync(_issuedInvoicePostModelAsync)).AssertResult();

            _issuedInvoiceIdAsync = data.Id;

            // Assert
            Assert.Greater(data.Id, 0);
            Assert.AreEqual(_issuedInvoicePostModelAsync.DateOfIssue, data.DateOfIssue);
            Assert.AreEqual(PartnerId, data.PartnerId);
            Assert.Greater(data.Items.Count, 0);
        }
Пример #7
0
 /// <inheritdoc />
 public ApiResult <IssuedInvoiceGetModel> Post(IssuedInvoicePostModel model)
 {
     ValidatePost(model);
     return(Post <IssuedInvoicePostModel, IssuedInvoiceGetModel>(model));
 }
Пример #8
0
 /// <inheritdoc />
 public Task <ApiResult <IssuedInvoiceGetModel> > PostAsync(IssuedInvoicePostModel model, CancellationToken cancellationToken = default)
 {
     ValidatePost(model);
     return(PostAsync <IssuedInvoicePostModel, IssuedInvoiceGetModel>(model, cancellationToken));
 }