From 2d60244dbaaee7936b0ee12214ecabbac760b133 Mon Sep 17 00:00:00 2001 From: Robert Ivanc Date: Mon, 2 Sep 2019 22:35:14 +0200 Subject: [PATCH] fiscalization --- CebelcaAPISharp.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CebelcaAPISharp.cs b/CebelcaAPISharp.cs index f49b487..44c8c5f 100644 --- a/CebelcaAPISharp.cs +++ b/CebelcaAPISharp.cs @@ -119,5 +119,30 @@ namespace CebelcaAPI } + public async Task IssueInvoiceFiscalization(string invoiceId, string idLocation, string opTaxId, string opName, bool test_mode = false ) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo("sl-SI"); + var values = new Dictionary + { + + { "id", invoiceId }, + { "id_location", idLocation }, + { "op-tax-id", opTaxId }, + { "op-name", opName }, + { "fiscalize", "1" }, + { "test_mode", test_mode ? "1" : "0" }, + + }; + var ret = await APICall("invoice-sent", "finalize-invoice", values); + var json = JArray.Parse(ret); + var retname = (json[0][0] as JObject).Properties().First().Name; + if (retname != "docnum") + throw new Exception("Error from api: " + ret); + var id = json[0][0]["docnum"].Value(); + var eor = json[0][0]["eor"].Value(); + return id; + + } + } }