示例#1
0
        public async Task ItCanSellAnAsset()
        {
            var currentDate = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1);
            var rand        = new Random();
            var asset       = new Asset()
            {
                Number                    = "TestProd" + rand.Next(9999999),
                Description               = "TEST PRODUCT",
                TypeId                    = "8",
                DepreciationMethod        = "0",
                AcquisitionValue          = 13000,
                DepreciateToResidualValue = 1300,
                AcquisitionDate           = currentDate,
                AcquisitionStart          = currentDate.AddMonths(1),
                DepreciationFinal         = currentDate.AddYears(1),
            };

            var request = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var result  = await AssetsService.CreateAssetAsync(request, asset);

            Assert.AreEqual(asset.Number, result.Number);

            var sellAsset = new SellAsset {
                Percentage = 0, Price = 10000, Comment = "Sell comment", Date = currentDate.AddMonths(1).ToString("yyyy-MM-dd")
            };
            var soldAsset = await AssetsService.SellAssetAsync(request, $"{result.Id}", sellAsset);
        }