Example #1
0
        public void Recount_WithRoundingItem_SuccessfullyRecounted()
        {
            // Arrange
            var item = new SalesReceiptItemRecountPostModel
            {
                UnitPrice   = 99.2M,
                Amount      = 2,
                Name        = "Test",
                PriceType   = PriceTypeWithoutOnlyBase.WithoutVat,
                VatRateType = VatRateType.Basic,
                ItemType    = SalesReceiptItemType.ItemTypeNormal
            };
            var rounding = new SalesReceiptItemRecountPostModel
            {
                UnitPrice   = 0.1M,
                Amount      = 1,
                Name        = "Rounding",
                PriceType   = PriceTypeWithoutOnlyBase.WithVat,
                VatRateType = VatRateType.Basic,
                ItemType    = SalesReceiptItemType.ItemTypeRound
            };
            var model = new SalesReceiptRecountPostModel
            {
                CurrencyId  = 1,
                DateOfIssue = DateTime.Today.SetKindUtc(),
                Items       = new List <SalesReceiptItemRecountPostModel> {
                    item, rounding
                },
                Payments = new List <SalesReceiptPaymentRecountPostModel> {
                    new SalesReceiptPaymentRecountPostModel {
                        PaymentOptionId = 1
                    }
                }
            };

            // Act
            var data = _client.Recount(model).AssertResult();

            // Assert
            var recountedItem = data.Items.First();
            var roundingItem  = data.Items.Single(i => i.ItemType == SalesReceiptItemType.ItemTypeRound);

            Assert.AreEqual(item.Id, recountedItem.Id);
            Assert.AreEqual(item.Name, recountedItem.Name);
            Assert.AreEqual(rounding.Name, roundingItem.Name);
            Assert.AreEqual(240.06M, recountedItem.Prices.TotalWithVat);
            Assert.AreEqual(240.06M, recountedItem.Prices.TotalWithVatHc);
            Assert.AreEqual(41.66M, recountedItem.Prices.TotalVat);
            Assert.AreEqual(41.66M, recountedItem.Prices.TotalVatHc);
            Assert.AreEqual(198.4M, recountedItem.Prices.TotalWithoutVat);
            Assert.AreEqual(198.4M, recountedItem.Prices.TotalWithoutVatHc);
            Assert.AreEqual(-0.06M, roundingItem.Prices.TotalWithVat);
            Assert.AreEqual(-0.06M, roundingItem.Prices.TotalWithVatHc);
            Assert.AreEqual(-0.00M, roundingItem.Prices.TotalVat);
            Assert.AreEqual(-0.00M, roundingItem.Prices.TotalVatHc);
            Assert.AreEqual(-0.06M, roundingItem.Prices.TotalWithoutVat);
            Assert.AreEqual(-0.06M, roundingItem.Prices.TotalWithoutVatHc);
        }
Example #2
0
        private void AssertRecountModel(SalesReceiptRecountGetModel recountGetModel, SalesReceiptRecountPostModel recountPostModel)
        {
            var itemToRecount = recountPostModel.Items.First();
            var recountedItem = recountGetModel.Items.First();

            Assert.AreEqual(itemToRecount.Id, recountedItem.Id);
            Assert.AreEqual(itemToRecount.Name, recountedItem.Name);
            Assert.AreEqual(242, recountedItem.Prices.TotalWithVat);
            Assert.AreEqual(242, recountedItem.Prices.TotalWithVatHc);
            Assert.AreEqual(42, recountedItem.Prices.TotalVat);
            Assert.AreEqual(42, recountedItem.Prices.TotalVatHc);
            Assert.AreEqual(200, recountedItem.Prices.TotalWithoutVat);
            Assert.AreEqual(200, recountedItem.Prices.TotalWithoutVatHc);
        }
Example #3
0
        public void Recount_ForeignCurrency_SuccessfullyRecounted()
        {
            // Arrange
            var item = new SalesReceiptItemRecountPostModel
            {
                UnitPrice   = 100,
                Amount      = 1,
                Name        = "Test",
                Id          = 1,
                PriceType   = PriceTypeWithoutOnlyBase.WithoutVat,
                VatRateType = VatRateType.Basic
            };
            var model = new SalesReceiptRecountPostModel
            {
                CurrencyId         = 2,
                ExchangeRate       = 20,
                ExchangeRateAmount = 1,
                DateOfIssue        = DateTime.Today.SetKindUtc(),
                Items = new List <SalesReceiptItemRecountPostModel> {
                    item
                },
                Payments = new List <SalesReceiptPaymentRecountPostModel> {
                    new SalesReceiptPaymentRecountPostModel {
                        PaymentOptionId = 1
                    }
                }
            };

            // Act
            var result = _client.Recount(model).AssertResult();

            // Assert
            var recountedItem = result.Items.First(x => x.ItemType == SalesReceiptItemType.ItemTypeNormal);

            Assert.AreEqual(1, result.ExchangeRateAmount);
            Assert.AreEqual(20, result.ExchangeRate);
            Assert.AreEqual(2, result.CurrencyId);
            Assert.AreEqual(121, recountedItem.Prices.TotalWithVat);
            Assert.AreEqual(2420, recountedItem.Prices.TotalWithVatHc);
        }
Example #4
0
        /// <inheritdoc />
        public ApiResult <SalesReceiptRecountGetModel> Recount(SalesReceiptRecountPostModel model)
        {
            var resource = $"{ResourceUrl}/Recount";

            return(Post <SalesReceiptRecountPostModel, SalesReceiptRecountGetModel>(resource, model));
        }
Example #5
0
        /// <inheritdoc />
        public Task <ApiResult <SalesReceiptRecountGetModel> > RecountAsync(SalesReceiptRecountPostModel model, CancellationToken cancellationToken = default)
        {
            var resource = $"{ResourceUrl}/Recount";

            return(PostAsync <SalesReceiptRecountPostModel, SalesReceiptRecountGetModel>(resource, model, cancellationToken));
        }