예제 #1
0
        public async Task <IActionResult> Create()
        {
            if (resToken != null)
            {
                var generalInfo = new GeneralInfoModel()
                {
                    Ettn               = null,
                    Prefix             = null,
                    InvoiceNumber      = "EPA2019131231477",//Manuel fatura İd tanımlamalarında yenilenmelidir
                    InvoiceProfileType = (int)InvoiceProfilType.EARSIVFATURA,
                    IssueDate          = DateTime.Now.ToString(),
                    Type               = 1,
                    CurrencyCode       = "TRY"
                };

                var addressBook = new AddressBookModel()
                {
                    IdentificationNumber  = "1111111111",
                    ReceiverPersonSurName = "Test",
                    Name              = "Test",
                    ReceiverCity      = "İstanbul",
                    ReceiverDistrict  = "Test",
                    ReceiverCountryId = 1
                };

                var invoiceLines = new List <InvoiceLineModel>();
                var invoiceLine  = new InvoiceLineModel()
                {
                    InventoryCard          = "Test",
                    Amount                 = 1,
                    DiscountAmount         = 0,
                    LineAmount             = 100,
                    UnitCode               = "C62",
                    UnitPrice              = 100,
                    VatRate                = 10,
                    VatExemptionReasonCode = "201"
                };
                invoiceLines.Add(invoiceLine);

                OutboxInvoiceCreateModel model = new OutboxInvoiceCreateModel()
                {
                    InvoiceId          = Guid.Empty.ToString(),
                    Status             = (int)InvoiceStatus.Draft,
                    XsltCode           = null,
                    UseManualInvoiceId = true,//Fatura oluşturulurke belirlenen fatura numarasını atar false durumunda otomatik bir fatura belirler
                    GeneralInfoModel   = generalInfo,
                    AddressBook        = addressBook,
                    InvoiceLines       = invoiceLines,
                    RecordType         = 0//e-fatura:1,e-arşiv:0 gönderilmelidir.
                };

                string token       = resToken.access_token;
                string parsedModel = JsonConvert.SerializeObject(model);
                using (var client = new HttpClient())
                    using (var request = new HttpRequestMessage(HttpMethod.Post, "https://efaturaservicetest.isim360.com/v1/outboxInvoice/create"))
                    {
                        if (!String.IsNullOrEmpty(parsedModel))
                        {
                            var content = new StringContent(parsedModel, Encoding.UTF8, "application/json");
                            request.Content = content;
                        }
                        request.Headers.Add("Authorization", $"Bearer {token}");
                        var response = await client.SendAsync(request);

                        var asString = await response.Content.ReadAsStringAsync();

                        var x = JsonConvert.DeserializeObject(asString);
                        return(Ok(x));
                    }
            }
            else
            {
                return(Ok("Token almak için /gettoken uç noktasını çağırın"));
            }
        }
예제 #2
0
 public GeneralInfoResponse()
 {
     generalInfo = new GeneralInfoModel();
 }