Exemple #1
0
        /// <summary>
        /// Adiciona um Lancamento Contabil Manual de Debito.
        /// </summary>
        /// <param name="journalEntries"></param>
        /// <param name="accountCode"></param>
        /// <param name="contraAccount"></param>
        /// <param name="shortName"></param>
        /// <param name="debitValue"></param>
        /// <param name="lineMemo"></param>
        /// <param name="dueDate"></param>
        /// <param name="profitCode"></param>
        /// <returns></returns>
        public int addDebitJEL(JournalEntries journalEntries,
                               string accountCode, string contraAccount, string shortName,
                               double debitValue, string lineMemo, DateTime dueDate, string profitCode = "")
        {
            int    ret    = 0;
            string msgSAP = "";

            try
            {
                journalEntries.Lines.AccountCode    = accountCode;
                journalEntries.Lines.ContraAccount  = contraAccount;
                journalEntries.Lines.ControlAccount = shortName;
                journalEntries.Lines.ShortName      = shortName;
                journalEntries.Lines.Debit          = debitValue;
                journalEntries.Lines.Credit         = 0;
                journalEntries.Lines.TaxDate        = System.DateTime.Now;
                journalEntries.Lines.DueDate        = dueDate;
                journalEntries.Lines.LineMemo       = lineMemo;

                //caso tenha sido informado um centro de custo e a conta seja I ou E, informa o centro de custo na linha
                if (!string.IsNullOrEmpty(profitCode))
                {
                    ChartOfAccounts account = connection.Company.GetBusinessObject(BoObjectTypes.oChartOfAccounts);
                    account.GetByKey(accountCode);
                    if (account.AccountType != BoAccountTypes.at_Other)
                    {
                        journalEntries.Lines.CostingCode = profitCode;
                        logger.log("Informado Centro de Custo " + profitCode +
                                   " para a Conta " + accountCode + " na linha de Debito.", Logger.LogType.INFO, null, false);
                    }
                }

                journalEntries.Lines.Add();
                msgSAP = connection.Company.GetLastErrorDescription();
                logger.log("Adicionada Linha para Lançamento Contábil de Débito. " +
                           "\nNumber: " + journalEntries.JdtNum + " Value: " + debitValue + " - " + lineMemo + ": " + msgSAP, Logger.LogType.INFO, null, false);
            }
            catch (Exception e)
            {
                ret    = -1;
                msgSAP = connection.Company.GetLastErrorDescription();
                logger.log("Erro ao adicionar Linha para Lançamento Contábil de Débito. " +
                           "\nNumber: " + journalEntries.JdtNum + " - " + lineMemo + ": " + msgSAP, Logger.LogType.ERROR, e, false);
            }

            return(ret);
        }