public async Task <SendRevenueResult> SendRevenueAsync(RevenueRecord record, EetMode mode = EetMode.Operational) { Logger?.Info($"Sending revenue record for bill '{record.BillNumber}' to EET servers in {mode} mode.", new { RecordIdentifier = record.Identifier }); var xmlMessage = new SendRevenueMessage(record, mode).GetXmlMessage(); Logger?.Debug("DTOs for XML mapping were created.", xmlMessage); var sendRevenueResult = await EetSoapClient.SendRevenueAsync(xmlMessage); Logger?.Debug("Result received and successfully deserialized from XML DTOs.", sendRevenueResult); var result = new SendRevenueResult(sendRevenueResult); if (result.IsError) { Logger?.Info($"Got error response from EET servers for bill '{record.BillNumber}'.", result); } else { Logger?.Info($"Got success response from EET servers for bill '{record.BillNumber}'. FIK: '{result.Success.FiscalCode}'.", result); } return(result); }
public async Task SendRevenue() { var fixture = Fixtures.Third; var certificate = new Certificate( password: fixture.CertificatePassword, data: fixture.CertificateData ); var record = new RevenueRecord( identification: new Identification( taxPayerIdentifier: new TaxIdentifier(fixture.TaxId), registryIdentifier: new RegistryIdentifier("01"), premisesIdentifier: new PremisesIdentifier(fixture.PremisesId), certificate: certificate ), revenue: new Revenue( gross: new CurrencyValue(1234.00m), notTaxable: new CurrencyValue(0.00m), standardTaxRate: new TaxRateItem( net: new CurrencyValue(100.00m), tax: new CurrencyValue(21.00m), goods: null ) ), billNumber: new BillNumber("2016-123") ); var client = new EetClient(certificate, EetEnvironment.Playground); var response = await client.SendRevenueAsync(record); Assert.Null(response.Error); Assert.NotNull(response.Success); Assert.NotNull(response.Success.FiscalCode); Assert.False(response.Warnings.Any()); }
public void SendRevenueSimple() { var fixture = Fixtures.Second; var certificate = new Certificate( password: fixture.CertificatePassword, data: fixture.CertificateData ); var record = new RevenueRecord( identification: new Identification( taxPayerIdentifier: new TaxIdentifier(fixture.TaxId), registryIdentifier: new RegistryIdentifier("01"), premisesIdentifier: new PremisesIdentifier(fixture.PremisesId), certificate: certificate ), revenue: new Revenue( gross: new CurrencyValue(1234.00m) ), billNumber: new BillNumber("2016-123") ); var client = new EetClient(certificate, EetEnvironment.Playground); var response = client.SendRevenue(record); Assert.Null(response.Error); Assert.NotNull(response.Success); Assert.NotNull(response.Success.FiscalCode); Assert.False(response.Warnings.Any()); }
public async Task TaxIsSerializedCorrectly() { var fixture = Fixtures.First; var certificate = CreateCertificate(fixture); var record = new RevenueRecord( identification: new Identification( taxPayerIdentifier: new TaxIdentifier(fixture.TaxId), registryIdentifier: new RegistryIdentifier("01"), premisesIdentifier: new PremisesIdentifier(fixture.PremisesId), certificate: certificate ), revenue: new Revenue( gross: new CurrencyValue(1234.00m), lowerReducedTaxRate: new TaxRateItem( new CurrencyValue(100m), new CurrencyValue(10m), new CurrencyValue(11m) ), reducedTaxRate: new TaxRateItem( new CurrencyValue(200m), new CurrencyValue(30m), new CurrencyValue(12m) ), standardTaxRate: new TaxRateItem( new CurrencyValue(300m), new CurrencyValue(63m), new CurrencyValue(13m) ), deposit: new CurrencyValue(432m), usedDeposit: new CurrencyValue(543m) ), billNumber: new BillNumber("2016-123") ); var client = new EetClient(certificate, EetEnvironment.Playground); client.XmlMessageSerialized += (sender, args) => { var xmlElement = args.XmlElement; Assert.NotNull(xmlElement); var namespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); namespaceManager.AddNamespace("eet", "http://fs.mfcr.cz/eet/schema/v3"); var dataNode = xmlElement.SelectSingleNode("//eet:Data", namespaceManager); var attributes = dataNode.Attributes; Assert.AreEqual("300.00", attributes["zakl_dan1"].Value); Assert.AreEqual("200.00", attributes["zakl_dan2"].Value); Assert.AreEqual("100.00", attributes["zakl_dan3"].Value); Assert.AreEqual("63.00", attributes["dan1"].Value); Assert.AreEqual("30.00", attributes["dan2"].Value); Assert.AreEqual("10.00", attributes["dan3"].Value); Assert.AreEqual("11.00", attributes["pouzit_zboz3"].Value); Assert.AreEqual("12.00", attributes["pouzit_zboz2"].Value); Assert.AreEqual("13.00", attributes["pouzit_zboz1"].Value); Assert.AreEqual("543.00", attributes["cerp_zuct"].Value); Assert.AreEqual("432.00", attributes["urceno_cerp_zuct"].Value); }; await client.SendRevenueAsync(record); }
public void Test8() { var sut = new RevenueRecord(); sut.Week = 300; var actual = sut.Week; Assert.True(actual == 300); }
public void Test7() { var sut = new RevenueRecord(); sut.Revenue = 275; var actual = sut.Revenue; Assert.True(actual == 275); }
public void Test5() { var sut = new RevenueRecord(); sut.Month = 42; var actual = sut.Month; Assert.True(actual == 42); }
public void Test4() { var sut = new RevenueRecord(); sut.Week = 42; var actual = sut.Week; Assert.True(actual == 42); }
public void Test3() { var sut = new RevenueRecord(); sut.Year = 42; var actual = sut.Year; Assert.True(actual == 42); }
public void Test2() { var sut = new RevenueRecord(); sut.Year = 1000; var actual = sut.Year; Assert.True(actual == 1000); }
public void Test10() { var sut = new RevenueRecord(); sut.Revenue = (decimal)42.765; var actual = sut.Revenue; Assert.True(actual == (decimal)42.765); }
public void Test9() { var sut = new RevenueRecord(); sut.Revenue = (decimal)4000.1; var actual = sut.Revenue; Assert.True(actual == (decimal)4000.1); }
public void Test6() { var sut = new RevenueRecord(); sut.Revenue = 42; var actual = sut.Revenue; Assert.True(actual == 42); }
public async Task <SendRevenueResult> SendRevenueAsync(RevenueRecord record, EetMode mode = EetMode.Operational) { Logger?.Info($"Sending bill {record.BillNumber} to EET servers in {mode} mode."); var xmlMessage = new SendRevenueMessage(record, mode).GetXmlMessage(); var sendRevenueResult = await EetSoapClient.SendRevenueAsync(xmlMessage).ConfigureAwait(continueOnCapturedContext: false); var result = new SendRevenueResult(sendRevenueResult); if (result.IsError) { Logger?.Info($"Got error response from EET servers for bill {record.BillNumber}."); } else { Logger?.Info($"Got success response from EET servers for bill {record.BillNumber}."); } return(result); }
public async Task HandlesError() { var certificate = CreateCertificate(Fixtures.First); var record = new RevenueRecord( identification: new Identification( taxPayerIdentifier: new TaxIdentifier("CZ111444789"), registryIdentifier: new RegistryIdentifier("01"), premisesIdentifier: new PremisesIdentifier(Fixtures.First.PremisesId), certificate: certificate ), revenue: new Revenue( gross: new CurrencyValue(1234.00m) ), billNumber: new BillNumber("2016-123") ); var client = new EetClient(certificate, EetEnvironment.Playground); var response = await client.SendRevenueAsync(record); Assert.NotNull(response.Error); Assert.AreEqual(6, response.Error.Reason.Code); }
public Task <SendRevenueResult> SendRevenueAsync(RevenueRecord record, EetMode mode = EetMode.Operational) { var task = EetSoapClient.SendRevenue(new SendRevenueMessage(record, mode).GetXmlMessage()); return(task.ContinueWith(t => Task.FromResult(new SendRevenueResult(t.Result))).Unwrap()); }
public SendRevenueMessage(RevenueRecord record, EetMode mode) { RevenueRecord = record; EetMode = mode; }
static void StoreRun() { Console.WriteLine("Enter 1 for Domino's, 2 for Pizza Hut"); int StoreChoice = int.Parse(Console.ReadLine()); var context = new myDBContext(); var Store = context.Stores.Single(a => a.Id == StoreChoice); Console.WriteLine("Enter 1 for complete order history, 2 for weekly revenue, 3 for monthly"); int InformationChoice = int.Parse(Console.ReadLine()); if (InformationChoice == 1) { var OrderList = context.Orders.Where(a => a.StoreId == Store.Id); foreach (var Order in OrderList) { Console.WriteLine($"Customer {Order.CustomerId} spent {Order.Price} dollars on {Order.DateAndTime}"); } } var revenueRecords = new List <RevenueRecord>(); SqlConnection connection = new SqlConnection("Server=tcp:p1.database.windows.net,1433;Initial Catalog=myDB;User ID=p1;Password=Pword000"); if (InformationChoice == 2) { SqlCommand cmd = new SqlCommand($"SELECT SUM(Price) AS REVENUE, DATEPART(YEAR, DateAndTime) AS YEAR, DATEPART(WEEK, DateAndTime) AS WEEK FROM Orders WHERE StoreID = {StoreChoice} GROUP BY DATEPART(YEAR, DateAndTime), DATEPART(WEEK, DateAndTime);", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { RevenueRecord revenueRecord = new RevenueRecord(); revenueRecord.Revenue = reader.GetDecimal(reader.GetOrdinal("REVENUE")); revenueRecord.Year = reader.GetInt32(reader.GetOrdinal("YEAR")); revenueRecord.Week = reader.GetInt32(reader.GetOrdinal("WEEK")); revenueRecords.Add(revenueRecord); } foreach (RevenueRecord revenueRecord1 in revenueRecords) { Console.WriteLine(revenueRecord1.WeekPrint()); } } } else { //monthly rev SqlCommand cmd = new SqlCommand($"SELECT SUM(Price) AS REVENUE, DATEPART(YEAR, DateAndTime) AS YEAR, DATEPART(MONTH, DateAndTime) AS MONTH FROM Orders WHERE StoreID = {StoreChoice} GROUP BY DATEPART(YEAR, DateAndTime), DATEPART(MONTH, DateAndTime);", connection); connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { RevenueRecord revenueRecord = new RevenueRecord(); revenueRecord.Revenue = reader.GetDecimal(reader.GetOrdinal("REVENUE")); revenueRecord.Year = reader.GetInt32(reader.GetOrdinal("YEAR")); revenueRecord.Month = reader.GetInt32(reader.GetOrdinal("MONTH")); revenueRecords.Add(revenueRecord); } foreach (RevenueRecord revenueRecord1 in revenueRecords) { Console.WriteLine(revenueRecord1.MonthPrint()); } } } }
public SendRevenueResult SendRevenue(RevenueRecord record, EetMode mode = EetMode.Operational) { return(SendRevenueAsync(record, mode).Result); }