Giter VIP home page Giter VIP logo

e-fatura-node20's Introduction

🧾 e-Fatura

License MIT NPM JavaScript Style Guide npm downloads

Bu paket, Node.js aracılığıyla e-Arşiv üzerinden fatura oluşturma, düzenleme, imzalama gibi işlemleri yapabilmenize olanak sağlar.

🚨 Bu paket vergiye tabi olan belge oluşturur, hiç bir sorumluluk kabul edilmez ve ne yaptığınızdan emin olana kadar EInvoice.setTestMode(true) kullanarak test modu açık şekilde test verileriyle işlem yapmanız önerilir.

Kurulum

yarn add e-fatura

veya

npm i e-fatura

Paket Yapısı

import EInvoice, {
  getDateFormat, // Tarih formatını alma
  EInvoiceCountry, // Ülkeler
  EInvoiceApi, // e-Arşiv API servisi
  EInvoiceTypeError, // Tür hata sınıfı
  EInvoiceApiError, // API hata sınıfı
  InvoiceType, // Fatura türü
  EInvoiceApiErrorCode, // API hata kodları
  InvoiceApprovalStatus, // Fatura onay durumu
  EInvoiceCurrencyType, // Param birimi
  EInvoiceUnitType // Birim türü
  // ... Typescript türleri
} from 'e-fatura'

Özellikler

Kullanım

Kendi verileriniz ile test etmek için:

https://earsivportal.efatura.gov.tr/intragiris.html

Test hesaplarıyla test etmek için:

https://earsivportaltest.efatura.gov.tr/login.jsp

Test ortamı için kullanım örneği;

import EInvoice from 'e-fatura'

// Test modunu aktif/deaktif eder.
EInvoice.setTestMode(true) // varsayılan olarak false

// Anonim kullanıcı bilgileri atar.
await EInvoice.setAnonymousCredentials()

// e-Arşive bağlanır.
await EInvoice.connect() // veya EInvoice.getAccessToken()

// ... Diğer işlemler. Fatura oluşturma, listeleme, düzenleme vb.

// e-Arşiv oturumunu sonlandırır.
await EInvoice.logout()

Ürün ortamı için kullanım örneği;

import EInvoice from 'e-fatura'

// Test modunu aktif/deaktif eder.
EInvoice.setTestMode(false) // varsayılan olarak false

// Muhasebecinizden aldığınız giriş bilgileri.
EInvoice.setCredentials({
  username: 'kullanıcı kodu|adı',
  password: 'şifre'
})

// e-Arşive bağlanır.
await EInvoice.connect() // veya EInvoice.getAccessToken()

// ... Diğer işlemler. Fatura oluşturma, listeleme, düzenleme vb.

// e-Arşiv oturumunu sonlandırır.
await EInvoice.logout()

Hata Ayıklama

API ve tür hatalarının ayıklanması.

import EInvoice, {
  EInvoiceApiError,
  EInvoiceTypeError,
  EInvoiceApiErrorCode
} from 'e-fatura'

try {
  await EInvoice.createDraftInvoice({})
  // veya EInvoice.*()
} catch (e) {
  if (e instanceof EInvoiceTypeError) {
    console.error('Tür hatası meydana geldi:', e)
  } else if (e instanceof EInvoiceApiError) {
    const response = e.getResponse()

    switch (e.errorCode) {
      case EInvoiceApiErrorCode.SERVER_ERROR:
        console.error('Sunucu taraflı bir hata oluştu:', response)
        break
      case EInvoiceApiErrorCode.INVALID_RESPONSE:
        console.error('Geçersiz API cevabı:', response)
        break
      case EInvoiceApiErrorCode.INVALID_ACCESS_TOKEN:
        console.error('Geçersiz erişim jetonu:', response)
        break
      case EInvoiceApiErrorCode.BASIC_INVOICE_NOT_CREATED:
        console.error('Basit fatura oluşturulamadı:', response)
      // ...
    }
  } else {
    console.error('Bilinmeyen bir hata meydana geldi:', e)
  }
}

Not: Diğer API hata kodları için EInvoiceApiErrorCode.ts dosyasına bakabilirsiniz.

Ayrıca

Bu proje Furkan Kadıoğlu'nun efatura projesinden yola çıkılarak Node.js'e uyarlanmıştır.

e-fatura-node20's People

Contributors

bilaleren avatar h7ioo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.