Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

E-fakture download izlaznih faktura u PDF-u sa SEF-a

[es] :: Access :: E-fakture download izlaznih faktura u PDF-u sa SEF-a

[ Pregleda: 2563 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

mustur
Mustur Gojko
Beograd

Član broj: 32122
Poruke: 48
*.dynamic.sbb.rs.



+1 Profil

icon E-fakture download izlaznih faktura u PDF-u sa SEF-a09.03.2023. u 09:34 - pre 13 meseci
Da li je neko imao iskustvo sa automatizacijom download-a izlaznih faktura u PDF-u sa SEF-a.
 
Odgovor na temu

bokinet

Član broj: 29844
Poruke: 574



+50 Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a12.03.2023. u 21:17 - pre 13 meseci
svih.
 
Odgovor na temu

mustur
Mustur Gojko
Beograd

Član broj: 32122
Poruke: 48
*.dynamic.sbb.rs.



+1 Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a14.03.2023. u 11:58 - pre 13 meseci
Moze svih, moze pojedinacno.
 
Odgovor na temu

mmarkoni
Milan Marković

Član broj: 95013
Poruke: 44
*.dynamic.isp.telekom.rs.



Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a15.03.2023. u 09:25 - pre 13 meseci
Onako na brzinu

Potrebne reference
WinHttpRequest.5.1,
Microsoft Scripting Runtime

Potrebno je preuzeti vba modul JsonConverter.bas sa sajta: [url=]https://github.com/VBA-tools/VBA-JSON[/url]


Code:

Public Function PurchaseInvoiceIds()
    Dim http As Object
    Dim strUrl As String
    strUrl = "https://efaktura.mfin.gov.rs/api/publicApi/purchase-invoice/ids"
    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
    With http
        .Open "Post", strUrl, False
        .setRequestHeader "ApiKey", "tvoj api key"
        .setRequestHeader "Content-Type", "*/*"
        .Send
        If .Status = 200 Then
            Dim strOdgovor As String
            strOdgovor = http.ResponseText
            Debug.Print strOdgovor
            Debug.Print JsonConverter.ConvertToJson(strOdgovor, Whitespace:=2)
            PurchaseInvoiceIds = JsonConverter.ConvertToJson(strOdgovor, Whitespace:=2)
        Else
            Debug.Print .Status
            PurchaseInvoiceIds = ""
        End If
    End With
    Set http = Nothing
    On Error GoTo 0
    Exit Function
End Function

Code:

Public Function PurchaseInvoiceById(ByVal IdEfak As LongPtr)
    Dim http As Object
    Dim strUrl As String
    strUrl = "https://efaktura.mfin.gov.rs/a...pi/purchase-invoice?invoiceid=" & IdEfak
    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
    With http
        .Open "Get", strUrl, False
        .setRequestHeader "ApiKey", "tvoj api key"
        .setRequestHeader "Content-Type", "*/*"
        .Send
        If .Status = 200 Then
            Dim strOdgovor As String
            strOdgovor = http.ResponseText
            Debug.Print strOdgovor
            Debug.Print JsonConverter.ConvertToJson(strOdgovor, Whitespace:=2)
            PurchaseInvoiceById = JsonConverter.ConvertToJson(strOdgovor, Whitespace:=2)
        Else
            Debug.Print .Status
            PurchaseInvoiceById = ""
        End If
    End With
    Set http = Nothing
    On Error GoTo 0
    Exit Function
End Function

Pozdrav

 
Odgovor na temu

mmarkoni
Milan Marković

Član broj: 95013
Poruke: 44
*.dynamic.isp.telekom.rs.



Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a15.03.2023. u 21:19 - pre 13 meseci
Malo smernice u radu sa json odgovorima Sef api-ja na prethoodom primeru

PurchaseInvoiceIds drugi pristup što bi rekli "u sitna crevca"
Code:

Public Function PurchaseInvoiceIds(strApiKey As String) ' Ovde smo stavili Api key kao parametar funkcije
    Dim http As Object
    Dim strUrl As String
    Dim aNiz() As Long
    strUrl = "https://efaktura.mfin.gov.rs/api/publicApi/purchase-invoice/ids"
    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
    With http
        .Open "Post", strUrl, False
        .setRequestHeader "ApiKey", strApiKey
        .setRequestHeader "Content-Type", "*/*"
        .Send
        If .Status = 200 Then
            Dim strOdgovor As String
            strOdgovor = http.responseText
            Dim jsonObject As Object
            Dim strString As Variant
            
            Dim output As String
            Dim i As LongPtr
            Dim Parsed As Scripting.Dictionary
            Dim Parsed2 As VBA.Collection
            Dim InvoiceIds As Scripting.Dictionary
            Dim lngBroj As LongPtr
            Dim Item As Object

            Set jsonObject = JsonConverter.ParseJson(.responseText)
            If TypeOf jsonObject Is Scripting.Dictionary Then                     ' Proveravamo dalije jsonObjrkt json
                Debug.Print "Korak 1"                                                      ' Ovaj korak se dešava ako postoji .responseText
                Set Parsed = jsonObject
                If jsonObject.Exists("PurchaseInvoiceIds") Then
                    Debug.Print "Korak 2"                                                    ' Ovaj korak se dešava ako ima ID ulaznih računa
                Set Parsed = jsonObject
                    If TypeOf jsonObject.Item("PurchaseInvoiceIds") Is Scripting.Dictionary Then
                            Debug.Print "Korak 3"      ' Ovaj korak se neće dogoditi u našeoj funkciji jer vrednost ključa PurchaseInvoiceIds nije json, ali sam ipak naveo kako se radi ako jeste
                            Set Parsed = jsonObject.Item("PurchaseInvoiceIds")
                            lngBroj = Parsed.Count
                            ReDim aNiz(lngBroj)
                            i = 0
                            
                            For Each Item In Parsed
                                Debug.Print Item
                                aNiz(i) = Item
                                i = i + 1
                            Next Item
                            '  
                        Else
                            Debug.Print "jsonObject vraca JSON Objekat sa PurchaseInvoiceIds key čija vrednost nije JSON Objekat, već je VBA kolekcija"
                            Set Parsed2 = jsonObject.Item("PurchaseInvoiceIds")
                            lngBroj = Parsed2.Count
                            Debug.Print lngBroj
                            ReDim aNiz(lngBroj)
                            For i = 1 To Parsed2.Count
                                aNiz(i) = Parsed2(i)
                                Debug.Print aNiz(i)
                            Next i
                    End If
 
                Else
                        Debug.Print "jsonObject je vratio JSON Object bez PurchaseInvoiceIds ključa, znači nema ulaznih faktura"
                        PurchaseInvoiceIds = .""
                        Exit Function
                End If

            Else
                    Debug.Print "jsonObject nije vratio JSON Objekat"
                    PurchaseInvoiceIds = .""
                    Exit Function
            End If
            PurchaseInvoiceIds = .responseText

        Else
            Debug.Print .Status

        End If
    End With
    Set http = Nothing
    On Error GoTo 0
    Exit Function
End Function



Nadam se da če primer malo pojasniti kako se radi sa json objektima.
 
Odgovor na temu

konajed
Belgrade

Član broj: 347883
Poruke: 1



Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a26.03.2023. u 10:17 - pre 12 meseci
ovo su sve primeri kako da skinemo fakturu u json formatu. postoje primeri kako to i da se uradi u XML formatu. Da li postoji mogućnost da se skine PDF koji se generiše na SEFu? Pretpostavljam da oni direktno na serveru konvertuju XML u PDF tj imaju predefinisanu formu u koju vrv iz baze upisuju podatke i generišu PDF. Ali da li neko zna da li je moguće to skinuti jer i oni daju download?
 
Odgovor na temu

mmarkoni
Milan Marković

Član broj: 95013
Poruke: 44
*.dynamic.isp.telekom.rs.



Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a27.03.2023. u 10:36 - pre 12 meseci
Kada skineš XML primljene fakture u njemu imaš red:

Code:

<env:DocumentPdf mimeCode="application/pdf">JVBERi0xLjQKJ ... ==</env:DocumentPdf>


pri čemu je string base64encoded, Stavio sam tri tačke jer je string prilično veliki.

Taj string treba da encoduješ i sačuvaš kao pdf.
U primeru je kod modula basBase64 koji ja koristim za Besr64 enkodovanje i dekodovanje:

Treba uključiti biblioteke Microsoft XML, V6 i Microsoft ActiveX Data Objects x.x Library

Code:

Option Compare Database
Option Explicit
' https://social.msdn.microsoft....31b16/pdf-to-base64?forum=vsto
' https://social.msdn.microsoft....eld-conversion?forum=accessdev
' http://web.archive.org/web/200...o-encode-decode-base64-vb6.asp
' http://cwestblog.com/2013/09/2...ript-convert-image-to-base-64/
' https://medium.com/cainhill/ho...a-file-to-base-64-d124c9b2958a

Sub TestConvert()
    Dim bytes
    Dim B64String
    With CreateObject("ADODB.Stream")
        .Open
        .Type = ADODB.adTypeBinary
        .LoadFromFile "C:\Users\v-guaxu\Desktop\Test.pdf"
        bytes = .Read
        .Close
    End With
    B64String = EncodeBase64(bytes)
    
    
    Dim str As String
    str = B64String
    Dim Base64Byte() As Byte
    Base64Byte = decodeBase64(str)

    With CreateObject("ADODB.Stream")
        .Open
        .Type = adTypeBinary
        .Write Base64Byte
        .SaveToFile "C:\Users\v-guaxu\Desktop\Converted.pdf"
        .Close
    End With
    
End Sub

Private Function EncodeBase64(bytes) As String
    Dim objXML As MSXML2.DOMDocument60
    Dim objNode As MSXML2.IXMLDOMElement

    Set objXML = New MSXML2.DOMDocument60
    Set objNode = objXML.createElement("b64")

    objNode.DataType = "bin.base64"
    objNode.nodeTypedValue = bytes
    EncodeBase64 = objNode.Text

    Set objNode = Nothing
    Set objXML = Nothing
End Function

Private Function decodeBase64(ByVal strData As String) As Byte()
    Dim objXML As MSXML2.DOMDocument60
    Dim objNode As MSXML2.IXMLDOMElement
    
    Set objXML = New MSXML2.DOMDocument60
    Set objNode = objXML.createElement("b64")
    objNode.DataType = "bin.base64"
    objNode.Text = strData
    decodeBase64 = objNode.nodeTypedValue
    
    Set objNode = Nothing
    Set objXML = Nothing
End Function


Pozdrav i sretno kodiranje
 
Odgovor na temu

mustur
Mustur Gojko
Beograd

Član broj: 32122
Poruke: 48
*.dynamic.sbb.rs.



+1 Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a29.03.2023. u 10:27 - pre 12 meseci
Nisam uspeo da uradim nista sa ovim Codovima. Prekopiram ih u VB ms Acceasa, aktiviram sve potrebne reference. Podesim da se funkcije aktiviraju na event Onclick dugme forme. Nista se ne desava.
Meni je potrebna pomoc da kada uspesno posaljem fakturu u SEF automatski stampam pdf fakturu koji SEF napravi tj preuzmem pdf fakturu iz SEF-a i stampam je.
Ako neko moze da mi pomogne, Hvala.
 
Odgovor na temu

bokinet

Član broj: 29844
Poruke: 574



+50 Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a31.03.2023. u 10:42 - pre 12 meseci
Ako je dokument uspesno poslat (zaprimljen) na SEF-u isti vraca invoiceid, purchaseinvoiceid i salesinvoiceid.
U zavisnosti sta se hoce, ako recimo u pitanju izlazni dokument onda se koristi salesinvoiceid tj. invoiceid koji se dobio nakon uspesnog slanja na SEF.
Pozivanje odgovarajuce API f-je za preuzimanje dokumenta uz odgovarajuci invoiceid i ostale stvari koje su potrebe po tehnickom uputstvu dobija se ubl (xml) dokument.
Po dobijanju ubl dokumenta potrebno je isti ucitati i izdvojiti pdf file koji se nalazi u headeru. U istom file ako je bilo priloga takodje isto je moguce izdvojiti i koirstiti priloge.
Nakon sto se izdvoji zeljeni file (u ovom slucaju generisani dokument iz zaglavlja) isti se moze snimiti, stampati i sta se vec hoce...
 
Odgovor na temu

savkov
Igor Savkov
Vrsac

Član broj: 21550
Poruke: 94
*.dynamic.mbb.telenor.rs.



+2 Profil

icon Re: E-fakture download izlaznih faktura u PDF-u sa SEF-a04.04.2023. u 10:37 - pre 12 meseci
ja sam za moje potrebe uradio program za preuzimanje poslatih faktura kopirati direktorijum C:\efiskal

[Ovu poruku je menjao savkov dana 04.04.2023. u 11:48 GMT+1]

[Ovu poruku je menjao savkov dana 04.04.2023. u 11:49 GMT+1]
Igor
Prikačeni fajlovi
 
Odgovor na temu

[es] :: Access :: E-fakture download izlaznih faktura u PDF-u sa SEF-a

[ Pregleda: 2563 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.