Turn Supplier Order Note into Vendor Invoice

0

Good afternoon,

Once again I ask you to help. I would like to know how I can do the transformation of Documents, in the case of Transforming a Supplier Order Note into Invoice to Supplier using the PRIMAVERA APIs.

I have already referenced here how to copy, but I would like to make the Transformation of the Documents so that they remain with the identification of the Document that created its origin.

Dim objCopia As GcpBEDocumentoCompra
Dim objOrig As GcpBEDocumentoCompra

Set objOrig = Aplicacao.BSO.Comercial.Compras.Edita("000", "FPD", "2018", "8")

'Clona o objeto de origem
Set objCopia = PSO.FuncoesGlobais.ClonaObjecto(objOrig)

With objCopia
    .TipoDoc = "FD"
    .EmModoEdicao = False
    .Id = PSO.FuncoesGlobais.CriaGuid(True)
End With

For Each objLinha In objCopia.Linhas
    objLinha.IDLinha = PSO.FuncoesGlobais.CriaGuid(True)
Next

BSO.Comercial.Compras.Actualiza objCopia

Set objCopia = Nothing
Set objOrig = Nothing

João Diniz

    
asked by anonymous 28.11.2018 / 13:30

2 answers

0

Thanks to all who responded for the help.

Here's the solution if necessary:

        On Error GoTo Erro
        Dim objDocOrigem As GcpBEDocumentoCompra
        objDocOrigem = motor.Comercial.Compras.Edita("000", cbOrigTipoDoc.Text, cbOrigSerie.Text, CInt(cbOrigDoc.Text))

        Dim objDocDestino As GcpBEDocumentoCompra
        objDocDestino = New GcpBEDocumentoCompra
        objDocDestino.TipoEntidade = objDocOrigem.TipoEntidade
        objDocDestino.Entidade = objDocOrigem.Entidade
        objDocDestino.Tipodoc = cbDestTipoDoc.Text
        objDocDestino.Serie = cbDestSerie.Text
        objDocDestino.CondPag = objDocOrigem.CondPag

        Dim Doc(0) As Object
        Doc(0) = objDocOrigem

        motor.Comercial.Compras.TransformaDocumentoEX(Doc, objDocDestino, True)
        GoTo Fim
Erro:
        MsgBox(Err.Number & ": " & Err.Description)

Fim:
        objDocOrigem = Nothing
        objDocDestino = Nothing
        LimpaTransCompras()
        cbOrigTipoDoc.Focus()
    
30.11.2018 / 21:26
4

It should be something like this

Dim ObjEnc As New GcpBEDocumentoCompra
Dim ObjvGR As New GcpBEDocumentoCompra
Dim Doc(0) As Object

Set ObjEnc = BSO.Comercial.Compras.Edita("000", "ECF", "A", 13)

ObjvGR.TipoEntidade = ObjEnc.TipoEntidade
ObjvGR.Entidade = ObjEnc.Entidade
ObjvGR.TipoDoc = "VGR"
ObjvGR.Serie = "A"

Set Doc(0) = ObjEnc

BSO.Comercial.Compras.TransformaDocumentoEX Doc, ObjvGR, True
    
28.11.2018 / 19:42