Giter VIP home page Giter VIP logo

szamlazz-hu-sdk's Introduction

.Net Core SDK for Számlázz.hu Build Status Coverage Status NuGet

Minimal working example

var request = new CreateInvoiceRequest();
request.AuthenticationData.ApiKey = "<YOUR AGENT KEY>";

request.Seller.BankName = "Our Bank";
request.Seller.BankAccount = "11111111-22222222-33333333";

request.Customer.Name = "Good Friend Inc.";
request.Customer.CustomerAddress.PostalCode = "1132";
request.Customer.CustomerAddress.City = "Budapest";
request.Customer.CustomerAddress.StreetAddress = "Tárnoki út 23.";
request.Customer.TaxNumber = "12345678-1-42";

request.Items = new List<InvoiceItem> {
    new InvoiceItem {
        Name = "Something we sell",
        Quantity = 1,
        UnitOfQuantity = "piece",
        UnitPrice = 1000,
        VatRate = "EU",
        NetPrice = 1000,
        VatAmount = 0,
        GrossAmount = 1000
    }
};

var api = new SzamlazzHuApi();
var response = await api.CreateInvoice(request);

//Optionally write invoice PDF to the disk
File.WriteAllBytes("invoice.pdf", response.InvoicePdf);

Query taxpayers

This is used to query the validity of a VAT number and to get additional information about the taxpayer. The data is from the Online Invoice Platform of NAV, the Hungarian National Tax and Customs Administration.

Request building

The API endpoint can be used through the SzamlazzHuApi.QueryTaxpayer method, which requires a QueryTaxpayerRequest object as parameter. The request object contains authentication data, and a core tax nuber.

var request = new QueryTaxpayerRequest();
request.AuthenticationData.ApiKey = "<YOUR AGENT KEY>";
request.TaxpayerId = "<CORE TAX NUMBER (FIRST 8 DIGIT OF THE VAT NUMBER)>"

var api = new SzamlazzHuApi();
var response = await api.QueryTaxpayer(request);

Response

The response object contains information about the technical result of the query and optionally details about the taxpayer. Additional data about the holder of the VAT number is only presented if:

  1. The request was successful (response.Success == true)
  2. There is a valid taxpayer on the given core tax number. (response.TaxpayerValid == true)

In other cases response.Taxpayer can be null

public class QueryTaxpayerResponse
{
    // True, if the query was successful and there were no technical error in communication
    public bool Success { get; set; }
    // Contains error code about request. It is -1, if the query was successful
    public int ErrorCode { get; set; }
    // Contains error message. It is null if query was successful
    public string ErrorMessage { get; set; }
    // Holds information about the validity of the VAT number
    public bool TaxpayerValid { get; set; }
    // Contains everything about the holder of the queried VAT number. It can be null in case the TaxpayerValid is false
    public Taxpayer Taxpayer { get; set; }       
}

Taxpayer entity

This entity holds all of the data, which can be found in the NAV database. It has required and optional properties, which is based on the NAV API definition. For further information please check the API definition of NAV Online Invoicing.

public class Taxpayer
{
    // Contains the legal name of the taxpayer
    public string TaxpayerName { get; set; }
    // Contains the short name of the taxpayer, which can be null               
    public string TaxpayerShortName { get; set; }
    // Contains tax number of the taxpayer
    public TaxNumber TaxNumberDetail { get; set; }
    // Contains tax number of the VAT group, if taxpayer has group membership
    public TaxNumber VatGroupMembership { get; set; }
    // Contains the incorporation type of the taxpayer
    public string Incorporation { get; set; }
    // Contains a list of the taxpayer addresses. This can be empty list   
    public List<TaxpayerAddressItem> AddressList { get; set; }
}

TaxNumber entity

This entity contains a tax number. Based on the NAV API definition, the TaxpayerId is the only mandatory part of this entity. The other properties are just optional, don't take part of the identification.

public class TaxNumber
{
    // This contains the core tax number (XXXXXXXX)-X-XX
    public string TaxpayerId { get; set; }
    // This contains the VAT code, it can be null if it is not presented (eg. group VAT number) XXXXXXXX-(X)-XX
    public string VatCode { get; set; }
    // This contains the country code, it can be null if it is not presented (eg. group VAT number) XXXXXXXX-X-(XX)
    public string CountryCode { get; set; }
}

TaxpayerAddressItem entity

This entity contains an address and also holds information about the type of the address. Address types can be found in NAV documentation.

public class TaxpayerAddressItem
{
    // This holds information about the type of the address (eg. HQ, SITE, etc.). See NAV documentation about the possible codes.
    public string AddressType { get; set; }
    // This contains the address    
    public Address Address { get; set; }
}

Pull Requests are Welcome!

If you are missing something please open an issue, or send a pull request! Every contribution is welcome :)

szamlazz-hu-sdk's People

Contributors

agabor avatar bmiki avatar felegy avatar forbidwolf avatar hnorbert90 avatar hodasza avatar safigi avatar tthgbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

szamlazz-hu-sdk's Issues

XLM válaszban spec karakterek

A HttpUploadXmlFile hívásban nincs kezelve, ha az API válaszban ékezetes karakterek vannak pl hibaüzenet miatt, emiatt valahol az xml parse benyeli a hiba nagy részét és csak ennyi jön vissza:
"[ERR] Sz&aacute"

A választ dekódolva már jó lesz (string xml = System.Web.HttpUtility.HtmlDecode(reader.ReadToEnd()); a 102. sorban)
"[ERR] Számla mentés sikertelen.\nA számla kelte csak a mai nap lehet: 2023.08.23..\r\n.........

Example hibás

Apróság, de a minta hibás.
StreetAddress van már nem Address ahogy nézem.
Illetve nem pdf hanem InvoicePdf

Szia Gábor!

Van egy problémám, hogy az alábbi kódrészlettel állítom be a számla tételeit:


var request = new CreateInvoiceRequest();
request.AuthenticationData.ApiKey = "*****";

        request.Header.IssueDate = DateTime.Now;
        request.Header.CompletionDate = DateTime.Now;
        request.Header.DueDate = DateTime.Now;
        request.Header.PaymentType = "Készpénz";
        request.Header.InvoiceNumberPrefix = "FRST1";

        request.Seller.BankName = "Our Bank";
        request.Seller.BankAccount = "11111111-22222222-33333333";

        request.Customer.Name = "Good Friend Inc.";
        request.Customer.CustomerAddress.PostalCode = "1132";
        request.Customer.CustomerAddress.City = "Budapest";
        request.Customer.CustomerAddress.StreetAddress = "Tárnoki út 23.";
        request.Customer.TaxNumber = "12345678-1-42";

        request.Settings.Electric = false;


        request.Items = new List<InvoiceItem> {
         new InvoiceItem
         {
            Name = "Citrom",
            Quantity = 11046M,
            UnitOfQuantity = "Dkg",
            UnitPrice = 20.96505522M, 
            VatRate = "27",
            NetPrice = 231580M, 
            VatAmount = 62526M, 
            GrossAmount = 294106M
         }
          };

        var api = new SzamlazzHuApi();
        var response = await api.CreateInvoice(request);

A számláz.hu -ról azzal a hibával jön vissza, hogy a nettó érték nem egyenlő a nettó egységár és a mennyiség szorzatával.
Van ötleted?

Köszi.
Zoli

EU adószám

Szia Gábor!

A levelezés alapján ez egy reminder, hogy ha időd engedi eu adószám hasznos lenne az sdk-ba.
A visual studio szerint 1.3.3 a legrégebbi nuget, de nuget.org-on van 1.3.3 is. Ez nem teljesen tiszta nekem h miért van, de mindegy is :)

Köszi

Could not find file

Szia Gábor!

Nagyon köszönöm, hogy feltetted ezt a plugint. Sokat segített nekem. Egy nopCommerce webshopban használom.

Eddig kipróbáltam a számla létrehozásához használt interfészt.

Az alábbi sorban kapok egy exceptiont:

response = await api.CreateInvoice(request);

Az exception message az alábbi:
{"Could not find file 'createInvoiceRequest.sbn"}

A callstack:
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at SzamlazzHu.XMLRenderer.RenderRequest(CreateInvoiceRequest request)
at SzamlazzHu.SzamlazzHuApi.d__0.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Nop.Plugin.Payments.SzamlazzHu.SzamlazzHuPaymentProcessor.d__11.MoveNext() in SzamlazzHuPaymentProcessor.cs:line 121

Üdv
Miki

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.