Accounting Accounts

0

I want to automatically create accounts in accounting when creating a customer / vendor. I can already create the accounts:

string[,] st = new string[6, 2];
st[1, 1] = Convert.ToString(CYear);
st[2, 1] = conta[i] + CodCli;
st[3, 1] = NomeCli;
st[4, 1] = "C";
st[5, 1] = CodCli;
bool tes = mBSO.Contabilidade.PlanoContas.CriaContasAutomaticas(st);

However, I only got the prefixes by the attributes of the ExercisesCBL table. When these prefixes come with, for example, "211S", the account is not created.

for (i = 0; i < 6; i++){
  string atributo = "ContaCli0" + (i + 1);
  conta[i] = Convert.ToString(mBSO.Contabilidade.ExerciciosCBL.DaValorAtributo(CYear, atributo));
}

Itriedthemethod

Contabilidade.LigacaoContabCBL.ParserCBLCalculaToken("S");

But it's not what I want.

Is there any way around this?

    
asked by anonymous 26.11.2018 / 11:32

1 answer

1

I had the same problem, I solved it as follows:

            Dim ListaAnosExistentes As StdBELista = motor.Consulta("SELECT MIN(ANO) as 'Minimo', MAX(ANO) as 'Máximo' FROM PLANOCONTAS")
            Dim anoMinimo As Integer
            Dim anoMaximo As Integer
            If (ListaAnosExistentes.NumLinhas > 0) Then

                Dim anos As Object = ListaAnosExistentes
                anoMinimo = CInt(anos(0).ToString)
                anoMaximo = CInt(anos(1).ToString)
                Dim j As Integer = anoMinimo

                Dim ListaPlanos As StdBELista = motor.Consulta("SELECT Plano from Planosdepreciacao")
                Dim i As Integer = 0
                Do Until i = ListaPlanos.NumLinhas
                    Dim plano As Object = ListaPlanos.Valor(i)

                    Do Until j = anoMaximo + 1
                        Dim query As New StdBEExecSql
                        query.tpQuery = EnumTpQuery.tpINSERT
                        query.Tabela = "CnfTabLigCbl"
                        query.AddCampo("Id", "{" + Guid.NewGuid().ToString() + "}")
                        query.AddCampo("Tabela", "1")
                        query.AddCampo("Ano", j.ToString)
                        query.AddCampo("Plano", plano.ToString)
                        query.AddCampo("Entidade", cbID.Text)
                        query.AddCampo("Coluna", "1")
                        query.AddCampo("Conta", CInt(cbID.Text).ToString)
                        motor.DSO.Plat.ExecSql.Executa(query)
                        j = j + 1
                    Loop
                    i = i + 1
                Loop

                j = anoMinimo
                Dim k As Integer = 0
                Dim arrCbl(4, i - 1) As String
                Do Until j = anoMaximo + 1
                    arrCbl(0, k) = j.ToString                   'Ano
                    arrCbl(1, k) = CInt(cbID.Text).ToString     'Conta
                    arrCbl(2, k) = "Conta " + cbID.Text         'Descricao
                    arrCbl(3, k) = "C"                          'TipoEntidade
                    arrCbl(4, k) = tbNome.Text                  'Entidade
                    motor.Contabilidade.PlanoContas.CriaContasAutomaticas(arrCbl)
                    k = k + 1
                    j = j + 1
                Loop
            End If
    
28.11.2018 / 19:01