public static void DisplayJournalEntries(JournalEntries entries) { foreach (JournalEntries.JournalEntryItem item in entries.JournalEntryItems) { Console.WriteLine("Date: {0} Amount: {1} Balance: {2}", item.DateLocal, item.Amount, item.Balance); } }
/// <summary> /// Adiciona Linhas de Debito e Credito ao Lancamento Manual informado /// </summary> /// <param name="journalEntries"></param> /// <param name="ledgerAccount"></param> /// <param name="value"></param> /// <param name="date"></param> /// <param name="obsLine"></param> /// <param name="profitCodeCdt"></param> /// <param name="profitCodeDbt"></param> /// <returns></returns> public int addJournalEntryLines(JournalEntries journalEntries, LedgerAccount ledgerAccount, double value, DateTime date, string obsLine, string profitCodeCdt = "", string profitCodeDbt = "") { int ret = 0; try { if (ledgerAccount.creditAccount.Equals("") || ledgerAccount.debitAccount.Equals("") || value == 0) { ret = -2; logger.log("Contas para Lancamento nao configuradas corretamente ou valor esta zerado: " + "\nConta Credito: " + ledgerAccount.creditAccount + "\nConta Debito: " + ledgerAccount.creditAccount + " Valor: " + value, Logger.LogType.WARNING, null, false); return(ret); } ret = addCreditJEL( journalEntries, ledgerAccount.creditAccount, ledgerAccount.debitAccount, ledgerAccount.creditAccount, value, obsLine, date, profitCodeCdt ); ret = addDebitJEL( journalEntries, ledgerAccount.debitAccount, ledgerAccount.creditAccount, ledgerAccount.debitAccount, value, obsLine, date, profitCodeDbt ); } catch (Exception e) { ret = -1; logger.log("Erro ao adicionar linhas no Lançamento Contábil Manual: " + journalEntries.JdtNum, Logger.LogType.ERROR, e); } return(ret); }
public void Save(Model.JournalModel journalModel) { JournalEntries journal = (JournalEntries)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); try { if (journal.GetByKey(journalModel.TransId)) { SetFields(journal, journalModel); journal.Update(); Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess(); } else { SetFields(journal, journalModel); journal.Add(); Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess(); } } finally { Marshal.ReleaseComObject(journal); GC.Collect(); } }
private SAPbobsCOM.JournalEntries PopulateDetails(JournalEntries pObjJournalEntries, string pStrBridgeAcc) { double lDbTotDebit = 0; double lDbTotCredit = 0; try { mObjProgressBar = new ProgressBarManager(Application.SBO_Application, "Cargando", mObjDT.Rows.Count); for (int i = 0; i < mObjDT.Rows.Count; i++) { int lIntACONC = Convert.ToInt32(mObjDT.Columns.Item("ACONC").Cells.Item(i).Value.ToString()); double lDbAIMPO = double.Parse(mObjDT.Columns.Item("AIMPO").Cells.Item(i).Value.ToString()); string lStrAcct = GetAccount(mObjDT.Columns.Item("CUE").Cells.Item(i).Value.ToString()); pObjJournalEntries.Lines.SetCurrentLine(i); pObjJournalEntries.Lines.AccountCode = Regex.Replace(lStrAcct, @"[$' ']", ""); if (lIntACONC >= 1 && lIntACONC <= 100) { pObjJournalEntries.Lines.Debit = lDbAIMPO; lDbTotDebit += lDbAIMPO; mStrCostingCode = mObjDT.Columns.Item("CC").Cells.Item(i).Value.ToString(); } if (lIntACONC >= 101 && lIntACONC <= 200) { pObjJournalEntries.Lines.Credit = lDbAIMPO; lDbTotCredit += lDbAIMPO; } pObjJournalEntries.Lines.CostingCode = mStrCostingCode; // centro de costo pObjJournalEntries.Lines.UserFields.Fields.Item("U_FolioFiscal").Value = mObjDT.Columns.Item("UUID").Cells.Item(i).Value.ToString().Trim(); pObjJournalEntries.Lines.UserFields.Fields.Item("U_GLO_AuxName").Value = mObjDT.Columns.Item("NNOM").Cells.Item(i).Value.ToString(); pObjJournalEntries.Lines.Add(); mObjProgressBar.NextPosition(); } pObjJournalEntries.Lines.SetCurrentLine(mObjDT.Rows.Count); pObjJournalEntries.Lines.AccountCode = pStrBridgeAcc; //cuenta pObjJournalEntries.Lines.Credit = (lDbTotDebit - lDbTotCredit); //abono//Deduccion pObjJournalEntries.Lines.LineMemo = "Deposito a Banco Nómina"; //comentario pObjJournalEntries.Lines.Add(); mObjProgressBar.NextPosition(); } catch (Exception er) { throw er; } finally { mObjProgressBar.Dispose(); } return(pObjJournalEntries); }
/// <summary> /// Cria e retorna Lancamento Contabil Manual baseado nas informacoes do Lancamento /// informado por parametro. As linhas do Lancamento Manual sao copiadas /// por padrao, podendo ser desabilitada atraves do parametro copyLines /// </summary> /// <param name="originalJE">Lancamento Contabil Manual original que deseja-se criar uma copia</param> /// <param name="copyLines">Quando true indica que ira copiar as linhas do Lancamento Contabil Manual, /// false caso contrario</param> /// <returns>Lancamento Cont. Manual criado a partir das informacoes disponiveis no /// Lancamento Original ou null em caso de erro</returns> public JournalEntries copyJE(JournalEntries originalJE, bool copyLines = true) { JournalEntries retJE = null; try { retJE = createJE("", originalJE.ReferenceDate, originalJE.DueDate, originalJE.TaxDate, originalJE.AutoVAT, originalJE.Reference, originalJE.Reference2, originalJE.Reference3); retJE.Series = originalJE.Series; retJE.Indicator = originalJE.Indicator; retJE.ProjectCode = originalJE.ProjectCode; retJE.TransactionCode = originalJE.TransactionCode; retJE.DocumentType = originalJE.DocumentType; //verifica se as linhas do lancameto tambem serao copiadas if (copyLines) { logger.log("Copia de linhas nao implementada.", Logger.LogType.WARNING, null, false); } } catch (Exception e) { retJE = null; logger.log("Erro ao copiar Lancamento Contabil Manual: " + e.Message , Logger.LogType.ERROR, e); } return(retJE); }
/// <summary> /// /// </summary> /// <param name="originalJE"></param> /// <param name="destinJE"></param> /// <returns></returns> public JournalEntries reverseJELines(JournalEntries originalJE, JournalEntries destinJE) { try { //insere as linhas int count = 0; JournalEntries_Lines lines = originalJE.Lines; while (count < lines.Count) { lines.SetCurrentLine(count++); addDebitJEL(destinJE, lines.ContraAccount , lines.AccountCode, lines.ShortName , lines.Credit, lines.LineMemo + " - (Reverso)", lines.DueDate, lines.CostingCode); lines.SetCurrentLine(count++); addCreditJEL(destinJE, lines.ContraAccount , lines.AccountCode, lines.ShortName , lines.Debit, lines.LineMemo + " - (Reverso)", lines.DueDate, lines.CostingCode); } } catch (Exception e) { logger.log("Erro ao copiar Linhas do Lancamento Contabil Manual " + originalJE.JdtNum , Logger.LogType.ERROR, e, false); } return(destinJE); }
/// <summary> /// Insere um Lancamento Manual para Cancelamento do Lancamento informado por parametro. /// </summary> /// <param name="transId"></param> /// <param name="memo"></param> /// <returns></returns> public JournalEntries reverseJE(int transId, string memo = null) { JournalEntries retJE = null; try { //busca o existente JournalEntries existsJe = (JournalEntries)connection.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); existsJe.GetByKey(transId); retJE = copyJE(existsJe, false); retJE.Memo = "Lanc. Cont. (Reverso) - " + transId; reverseJELines(existsJe, retJE); retJE = insertJE(retJE); if (retJE == null) { logger.log("Erro ao adicionar Lancamento Contabil Reverso para Lancamento (" + transId + "): " + "Lancamento não adicionado.", Logger.LogType.ERROR); } else { logger.log("Lancamento Contabil Manual " + "(" + retJE.JdtNum + ") para reverter Lancamento (" + transId + ") adicionado com sucesso.", Logger.LogType.INFO); } } catch (Exception e) { retJE = null; logger.log("Erro ao adicionar Lancamento Contabil Reverso para Lancamento (" + transId + "): " + e.Message, Logger.LogType.ERROR, e); } return(retJE); }
public virtual void AddItem(ICalendarObject obj) { if (obj == null) { return; } else if (obj is Event) { Events.Add((Event)obj); } else if (obj is ToDo) { ToDos.Add((ToDo)obj); } else if (obj is JournalEntry) { JournalEntries.Add((JournalEntry)obj); } else if (obj is FreeBusy) { FreeBusy.Add((FreeBusy)obj); } else { throw new InvalidCastException(); } }
public int Add(oJournal obj) { JournalEntries jrnls = (JournalEntries)SboComObject.GetBusinessObject(BoObjectTypes.oJournalEntries); try { SboComObject.StartTransaction(); int retCode = 0; jrnls.DueDate = obj.DocDueDate; jrnls.TaxDate = obj.TaxDate; jrnls.ReferenceDate = obj.DocDate; jrnls.Memo = obj.JournalMemo; jrnls.ProjectCode = obj.Project; if (obj.JournalLines.Count > 0) { foreach (oJournalLine jrnlLine in obj.JournalLines) { jrnls.Lines.DueDate = obj.DocDueDate; jrnls.Lines.TaxDate = obj.TaxDate; jrnls.Lines.ReferenceDate1 = obj.DocDate; jrnls.Lines.ShortName = jrnlLine.GLCode; jrnls.Lines.BPLID = jrnlLine.Segment; jrnls.Lines.Debit = jrnlLine.Debit; jrnls.Lines.Credit = jrnlLine.Credit; jrnls.Lines.Add(); } } retCode = jrnls.Add(); if (retCode != 0) { int errCode = 0; string errMessage = ""; SboComObject.GetLastError(out errCode, out errMessage); GlobalInstance.Instance.SBOErrorCode = errCode; GlobalInstance.Instance.SBOErrorMessage = errMessage; SboComObject.EndTransaction(BoWfTransOpt.wf_RollBack); } else { SboComObject.EndTransaction(BoWfTransOpt.wf_Commit); } return(retCode); } catch (Exception ex) { System.Runtime.InteropServices.Marshal.ReleaseComObject(jrnls); throw new Exception(GlobalInstance.Instance.SBOErrorMessage == null? ex.Message: GlobalInstance.Instance.SBOErrorMessage); } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(jrnls); } }
public int Update() { JournalEntries journalEntry = (JournalEntries)DiManager.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); journalEntry.GetByKey(TransId); journalEntry.Lines.SetCurrentLine(LineId); journalEntry.Lines.UserFields.Fields.Item("U_CorrectContraAcc").Value = CorrectContraAccount; journalEntry.Lines.UserFields.Fields.Item("U_CorrectContraShortName").Value = CorrectContraShortName ?? ""; journalEntry.Lines.UserFields.Fields.Item("U_ContraAccountLineId").Value = ContraAccountLineId.ToString(); return(journalEntry.Update()); }
private void ChooseJournal_AfterTryGetRecord(object sender, ChooseFromListEventArgs e) { try { var journal = new JournalEntries(Program.GetCurrentCompanyDb()); if (journal.GetByKey(e.Record[JournalEntries.FieldsName.TransId].To <int>())) { journal.FillLines(); } } catch (Exception ex) { ShowMessageError(ex); } }
/// <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); }
public static void JournalExample() { bool done = false; int lastEntrySeen = 0; JournalEntries.VersionCheck = false; while (!done) { JournalEntries entries = EveApi.GetJournalEntryList(JournalEntryType.Character, 0, 0, "fullApiKey", lastEntrySeen); DisplayJournalEntries(entries); lastEntrySeen += entries.JournalEntryItems.Length; if (entries.JournalEntryItems.Length < 1000) { done = true; } } }
private void SetFields(JournalEntries journal, Model.JournalModel journalModel) { journal.ReferenceDate = journalModel.RefDate; journal.TaxDate = journalModel.TaxDate; journal.DueDate = journalModel.DueDate; journal.Reference = journalModel.Ref1; journal.Reference2 = journalModel.Ref2; journal.Memo = journalModel.Memo; int line = 0; foreach (Model.JournalLineModel journalLineModel in journalModel.JournalLineList) { if (line > journal.Lines.Count - 1) { journal.Lines.Add(); } journal.Lines.SetCurrentLine(line); if (journalLineModel.BplId > 0) { journal.Lines.BPLID = journalLineModel.BplId; } if (journalLineModel.Account != string.Empty) { journal.Lines.AccountCode = journalLineModel.Account; } if (journalLineModel.ShortName != string.Empty) { journal.Lines.ShortName = journalLineModel.ShortName; } journal.Lines.Credit = journalLineModel.Credit; journal.Lines.Debit = journalLineModel.Debit; line++; } foreach (KeyValuePair <string, dynamic> userField in journalModel.UserFields) { journal.UserFields.Fields.Item(userField.Key).Value = userField.Value; } }
public void GetCharJournalEntriesTest() { JournalEntries.VersionCheck = false; JournalEntries journal = EveApi.GetJournalEntryList(JournalEntryType.Character, 0, 0, "apiKey"); JournalEntries.JournalEntryItem journalEntry = journal.JournalEntryItems[0]; Assert.AreEqual(1578932679, journalEntry.RefId); Assert.AreEqual(54, journalEntry.RefTypeId); Assert.AreEqual("corpslave", journalEntry.OwnerName1); Assert.AreEqual(150337897, journalEntry.OwnerId1); Assert.AreEqual("Secure Commerce Commission", journalEntry.OwnerName2); Assert.AreEqual(1000132, journalEntry.OwnerId2); Assert.AreEqual("", journalEntry.ArgName1); Assert.AreEqual(0, journalEntry.ArgId1); Assert.AreEqual(-8396.99, journalEntry.Amount); Assert.AreEqual(576336941.61, journalEntry.Balance); Assert.AreEqual("", journalEntry.Reason); }
/// <summary> /// /// </summary> /// <param name="je"></param> /// <returns></returns> public JournalEntries insertJE(JournalEntries je) { int r = 0; string msgSAP = ""; int jdtNum = 0; try { r = je.Add(); msgSAP = connection.Company.GetLastErrorDescription(); string st = connection.Company.GetNewObjectKey(); if (st.Equals("") || st.Length > 11) { jdtNum = 0; logger.log("Chave de Lancamento Manual nao retornada: " + st, Logger.LogType.WARNING, null, false); } else { jdtNum = Convert.ToInt32(connection.Company.GetNewObjectKey()); } //caso tenha inserido com sucesso carrega novamente //para ajustar o objeto if (r == 0) { je.GetByKey(jdtNum); logger.log("Lancamento Contabil manual inserido com sucesso " + "(" + jdtNum + "). " + msgSAP, Logger.LogType.INFO); } else { je = null; logger.log("Erro ao inserir Lancamento Contabil Manual: " + "\nRetorno SAP: " + r + " - " + msgSAP, Logger.LogType.ERROR, null, false); } } catch (Exception e) { je = null; logger.log("Erro ao inserir Lancamento Contabil Manual: " + e.Message + " Retorno SAP: " + msgSAP, Logger.LogType.ERROR, e); } return(je); }
public SampleDocument(SerializationInfo info, StreamingContext context) : base(info, context) { try { var entries = new JournalEntries(); int count = info.GetInt32("EntryCount"); for (int i = 0; i < count; ++i) { var entry = info.GetValue($"Entry{i}", typeof(JournalEntry)) as JournalEntry; entries.Add(entry); } _entries = entries; } catch (Exception ex) { throw new ApplicationException("Unable to read Sample document", ex); } }
public void Storno(int transId, DateTime stornoDate) { JournalEntries journal = (JournalEntries)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); try { if (journal.GetByKey(transId)) { journal.Cancel(); Controller.ConnectionController.Instance.VerifyBussinesObjectSuccess(); } } finally { Marshal.ReleaseComObject(journal); GC.Collect(); } }
public Model.JournalModel Get(int transId) { Model.JournalModel journalModel = new Model.JournalModel(); JournalEntries journal = (JournalEntries)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); try { if (journal.GetByKey(transId)) { journalModel.TransId = transId; journalModel.Ref1 = journal.Reference; journalModel.Ref2 = journal.Reference2; journalModel.Memo = journal.Memo; journalModel.RefDate = journal.ReferenceDate; journalModel.TaxDate = journal.TaxDate; journalModel.DueDate = journal.DueDate; for (int line = 0; line < journal.Lines.Count; line++) { journal.Lines.SetCurrentLine(line); Model.JournalLineModel journalLineModel = new Model.JournalLineModel(); journalLineModel.BplId = journal.Lines.BPLID; journalLineModel.Account = journal.Lines.AccountCode; journalLineModel.ShortName = journal.Lines.ShortName; journalLineModel.Debit = journal.Lines.Debit; journalLineModel.Credit = journal.Lines.Credit; journalModel.JournalLineList.Add(journalLineModel); } } } finally { Marshal.ReleaseComObject(journal); GC.Collect(); } return(journalModel); }
/// <summary> /// /// </summary> /// <param name="journalEntry"></param> /// <param name="line"></param> /// <returns></returns> public JournalEntries reverseJELine(JournalEntries journalEntry, JournalEntries_Lines line) { try { addDebitJEL(journalEntry, line.ContraAccount , line.AccountCode, line.ShortName , line.Credit, line.LineMemo + " - (Reverso)", line.DueDate); addCreditJEL(journalEntry, line.ContraAccount , line.AccountCode, line.ShortName , line.Debit, line.LineMemo + " - (Reverso)", line.DueDate); } catch (Exception e) { logger.log("Erro ao reverter Linha do Lancamento Contabil Manual " + journalEntry.JdtNum , Logger.LogType.ERROR, e, false); } return(journalEntry); }
public async Task <ActionResult> PostAsync(TransactionPosting model) { if (!this.ModelState.IsValid) { return(this.InvalidModelState(this.ModelState)); } try { var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true); long tranId = await JournalEntries.PostAsync(this.Tenant, model, meta).ConfigureAwait(true); return(this.Ok(tranId)); } catch (Exception ex) { return(this.Failed(ex.Message, HttpStatusCode.InternalServerError)); } }
protected override async Task OnInitializedAsync() { try { IsDataLoaded = false; ErrorMessage = string.Empty; UserName = await _sessionStorageService.GetItemAsync <string>("UserName"); CompanyId = await _sessionStorageService.GetItemAsync <string>("CompanyId"); var param = new Dapper.DynamicParameters(); param.Add("accountId", Guid.Parse(accountId), System.Data.DbType.Guid); JournalEntries = await dapperManager.GetAllAsync <JournalDetailViewModel>("spGetGLTransactions", param); var glAccount = await appDBContext.GLAccounts.Where(a => a.accountId.Equals(Guid.Parse(accountId))).FirstOrDefaultAsync(); if (glAccount != null) { HeaderTitle = $"{glAccount.accountCode} - {glAccount.accountDesc}"; } totalDR = JournalEntries.Sum(a => a.drAmt); totalCR = JournalEntries.Sum(a => a.crAmt); if (totalDR.HasValue || totalCR.HasValue) { totalBalance = (totalDR.HasValue ? totalDR.Value : 0) - (totalCR.HasValue ? totalCR.Value : 0); } } catch (Exception ex) { ErrorMessage = ex.Message; } finally { IsDataLoaded = true; } }
public void JournalEntriesPersist() { ResponseCache.Clear(); JournalEntries.VersionCheck = false; JournalEntries journalEntry = EveApi.GetJournalEntryList(JournalEntryType.Corporation, 0, 0, "apiKey"); ResponseCache.Save("ResponseCache.xml"); ResponseCache.Clear(); ResponseCache.Load("ResponseCache.xml"); JournalEntries cachedJournalEntry = EveApi.GetJournalEntryList(JournalEntryType.Corporation, 0, 0, "apiKey"); Assert.AreEqual(journalEntry.CachedUntilLocal, cachedJournalEntry.CachedUntilLocal); for (int i = 0; i < journalEntry.JournalEntryItems.Length; i++) { Assert.AreEqual(journalEntry.JournalEntryItems[i].Date, cachedJournalEntry.JournalEntryItems[i].Date); Assert.AreEqual(journalEntry.JournalEntryItems[i].Amount, cachedJournalEntry.JournalEntryItems[i].Amount); Assert.AreEqual(journalEntry.JournalEntryItems[i].Balance, cachedJournalEntry.JournalEntryItems[i].Balance); } }
/// <summary> /// /// </summary> /// <param name="jdtNum"></param> /// <returns></returns> public JournalEntries reverseEntries(int jdtNum) { JournalEntries retJE = null; try { JournalEntries existsJe = (JournalEntries)connection.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); existsJe.GetByKey(jdtNum); retJE = copyJE(existsJe, false); //verifica se existe alguma linha configurada para gerar estorno int count = 0; JournalEntries_Lines lines = existsJe.Lines; while (count < lines.Count) { lines.SetCurrentLine(count++); string opt = lines.UserFields.Fields.Item("U_RevShp").Value; if (opt.Equals("Sim")) { } addDebitJEL(retJE, lines.ContraAccount , lines.AccountCode, lines.ShortName , lines.Credit, lines.LineMemo + " - (Reverso)", lines.DueDate); lines.SetCurrentLine(count++); addCreditJEL(retJE, lines.ContraAccount , lines.AccountCode, lines.ShortName , lines.Debit, lines.LineMemo + " - (Reverso)", lines.DueDate); } } catch (Exception e) { retJE = null; } return(retJE); }
/// <summary> /// Cria mas nao adiciona um Lancamento Manual. /// </summary> /// <param name="memo"></param> /// <param name="refDate"></param> /// <param name="dueDate"></param> /// <param name="taxDate"></param> /// <param name="autoVat"></param> /// <param name="ref1"></param> /// <param name="ref2"></param> /// <param name="ref3"></param> /// <returns></returns> public JournalEntries createJE(string memo, DateTime refDate, DateTime dueDate, DateTime taxDate , BoYesNoEnum autoVat, string ref1 = null, string ref2 = null, string ref3 = null) { JournalEntries je = null; try { je = connection.Company.GetBusinessObject(BoObjectTypes.oJournalEntries); je.ReferenceDate = refDate; je.DueDate = dueDate; je.TaxDate = taxDate; je.Memo = memo.Length > 50? memo.Substring(0, 50): memo; je.Reference = ref1; je.Reference2 = ref2; je.Reference3 = ref3; je.AutoVAT = autoVat; } catch (Exception e) { je = null; logger.log("Erro ao criar Lancamento Contabil Manual: " + e.Message, Logger.LogType.ERROR, e); } return(je); }
private SAPbobsCOM.JournalEntries PopulateDetails(JournalEntries pObjJournalEntries, List <Nomina> pObjLstNomina, string pStrBridgeAcc) { double lDbTotDebit = 0; double lDbTotCredit = 0; int lIntCount = 0; var lVarPD = from p in pObjLstNomina group p by p.ATRAB into grupo select grupo; try { mObjProgressBar = new ProgressBarManager(Application.SBO_Application, "Cargando", pObjLstNomina.Count); foreach (var lvarGp in lVarPD) { lDbTotCredit = 0; lDbTotDebit = 0; foreach (var item in lvarGp) { /*if (Regex.Replace(item.CUENTA, @"[$' ']", "") != "2040000000000" && Regex.Replace(item.CUENTA, @"[$' ']", "") != "2040010000000" && Regex.Replace(item.CUENTA, @"[$' ']", "") != "2040010006000") * {*/ pObjJournalEntries.Lines.SetCurrentLine(lIntCount); pObjJournalEntries.Lines.AccountCode = Regex.Replace(item.CUENTA, @"[$' ']", ""); if (item.ACONC > 0) { double lDblAIMPO = double.Parse(item.AIMPO); if (item.ACONC >= 1 && item.ACONC <= 100) { pObjJournalEntries.Lines.Debit = lDblAIMPO; lDbTotDebit += lDblAIMPO; mStrCostingCode = item.CUENTA2.Trim(); } if (item.ACONC >= 101 && item.ACONC <= 200) { pObjJournalEntries.Lines.Credit = lDblAIMPO; lDbTotCredit += lDblAIMPO; } //} pObjJournalEntries.Lines.CostingCode = mStrCostingCode; // centro de costo pObjJournalEntries.Lines.UserFields.Fields.Item("U_FolioFiscal").Value = item.UUID.Trim(); pObjJournalEntries.Lines.UserFields.Fields.Item("U_GLO_AuxType").Value = "2"; //Nómina pObjJournalEntries.Lines.UserFields.Fields.Item("U_GLO_Auxiliary").Value = item.ATRAB.ToString(); pObjJournalEntries.Lines.Add(); mObjProgressBar.NextPosition(); lIntCount++; } } pObjJournalEntries.Lines.SetCurrentLine(lIntCount); pObjJournalEntries.Lines.AccountCode = pStrBridgeAcc; //cuenta pObjJournalEntries.Lines.Credit = (lDbTotDebit - lDbTotCredit); //abono//Deduccion pObjJournalEntries.Lines.LineMemo = "Deposito a Banco Nómina"; //comentario pObjJournalEntries.Lines.Add(); mObjProgressBar.NextPosition(); lIntCount++; } } catch (Exception er) { throw er; } finally { mObjProgressBar.Dispose(); } return(pObjJournalEntries); }
public override bool Equals(object obj) { // All transactions return(obj is WalletTransaction other && other.ID == ID && (ID != 0L || JournalEntries.Equals(other.JournalEntries))); }
public virtual void Deserialize(System.IO.TextReader rdr, Serializer serializer = null) { if (serializer == null) { serializer = new Serializer(); } string name, value; var parameters = new System.Collections.Specialized.NameValueCollection(); while (rdr.Property(out name, out value, parameters) && !string.IsNullOrEmpty(name)) { switch (name.ToUpper()) { case "BEGIN": switch (value) { case "VEVENT": var e = serializer.GetService <Event>(); e.Calendar = this; Events.Add(e); e.Deserialize(rdr, serializer); break; case "VTIMEZONE": var tz = serializer.GetService <TimeZone>(); tz.Calendar = this; TimeZones.Add(tz); tz.Deserialize(rdr, serializer); break; case "VTODO": var td = serializer.GetService <ToDo>(); td.Calendar = this; ToDos.Add(td); td.Deserialize(rdr, serializer); break; case "VFREEBUSY": var fb = serializer.GetService <FreeBusy>(); fb.Calendar = this; FreeBusy.Add(fb); fb.Deserialize(rdr, serializer); break; case "VJOURNAL": var jn = serializer.GetService <JournalEntry>(); jn.Calendar = this; JournalEntries.Add(jn); jn.Deserialize(rdr, serializer); break; } break; case "CALSCALE": Scale = value; break; case "VERSION": Version = value; break; case "PRODID": ProdID = value; break; case "END": if (value == "VCALENDAR") { return; } break; default: Properties.Add(Tuple.Create(name, value, parameters)); break; } } }
/// <summary> /// Will read entries from a specific view in Glasshouse. For all matching columns names, entries will be updated or added at the end of excel list /// </summary> public void ReadGH() { if (_curview.Equals("__GHALLDATA__")) { // not supported System.Windows.Forms.DialogResult dlg2 = System.Windows.Forms.MessageBox.Show("We do not support reading from " + _curviewname + " in project " + _curprojname, "Read from Glasshouse", System.Windows.Forms.MessageBoxButtons.OK); return; } System.Windows.Forms.DialogResult dlg = System.Windows.Forms.MessageBox.Show("Are you sure you want to read from view " + _curviewname + " in project " + _curprojname, "Read from Glasshouse", System.Windows.Forms.MessageBoxButtons.YesNo); if (dlg == System.Windows.Forms.DialogResult.No) { return; } // allways read - glasshousejournalguid, short description Range rngid = FindGUIDCell(); if (rngid == null) { System.Windows.Forms.MessageBox.Show("glasshousejournalguid not found in the first 10 by 10 cells"); return; } int idrow = rngid.Row; int idcol = rngid.Column; var removehcols = new[] { "glasshousejournalguid", "BIM Objects count", "BIM Objects quantity" }; // var removehcols = new[] { "glasshousejournalguid", "short description" }; var activeSheet = _excel.ActiveSheet as Worksheet; Range usedRange = activeSheet.UsedRange; int maxr = usedRange.Rows[1].Row + usedRange.Rows.Count - 1; int maxc = usedRange.Columns[1].Column + usedRange.Columns.Count - 1; // Make dictinary of columns List <gColumns> headers = new List <gColumns>(); for (int c = idcol; c <= maxc; c++) { if (activeSheet.Cells[idrow, c].Value2 == null) { continue; } string sc = activeSheet.Cells[idrow, c].Value2 as string; if (sc.Length > 0) { gColumns gc = new gColumns(); gc.headerName = sc.Trim(); gc.headerNameLC = gc.headerName.ToLower(); gc.colNo = c; gc.sync2gh = false; // if (removehcols.Any(gc.headerNameLC.Contains)) { headers.Add(gc); continue; } if (activeSheet.Cells[idrow + 1, c].Value2 == null) { headers.Add(gc); continue; } string syncway = (activeSheet.Cells[idrow + 1, c].Value2 as string).ToLower().Trim(); if (syncway.Equals("update")) { gc.sync2gh = true; } headers.Add(gc); } } System.Data.DataTable table = null; string s = "Contacting server..."; string caption = "Getting View Entries"; using (View.WaitingForm pf = new View.WaitingForm(caption, s)) { table = JournalEntries.GetViewEntries(Utils.apiKey, _curproj, _curview); } var removecols = new[] { "BIM Objects count", "BIM Objects quantity" }; int updateno = 0; int newno = 0; maxr = Math.Max(maxr, idrow + 2); int n = table.Rows.Count; s = "{0} of " + n.ToString() + " rows processed..."; caption = "Getting Data From Glasshouse"; List <string> guidsexist = new List <string>(); //write to excel // Initialize the array. Range range = activeSheet.Range(activeSheet.Cells[idrow, idcol], activeSheet.Cells[maxr, maxc]); var myArray = (object[, ])range.Value2; int resultRows = myArray.GetLength(0); int resultCols = myArray.GetLength(1); using (ProgressForm pf = new ProgressForm(caption, s, n)) { foreach (System.Data.DataRow row in table.Rows) { string rguid = (string)row[0]; guidsexist.Add(rguid); int foundrow = -1; for (int r = 3; r <= resultRows; r++) { //var guid = activeSheet.Cells[r, idcol].Value2; var guid = myArray[r, 1]; if (guid == null) { continue; } string sguid = guid as string; if (sguid.Length == 0) { continue; } if (rguid.Equals(sguid) == true) { foundrow = r; break; } } int colno = 0; int activerow = foundrow; if (foundrow == -1) { maxr++; // new line newno++; resultRows++; activerow = resultRows; myArray = AddRow(myArray); } else { updateno++; } foreach (object col in row.ItemArray) { string colname = table.Columns[colno].ColumnName.ToLower().Trim(); colno++; //if (removecols.Any(colname.Contains)) continue; gColumns match = headers.Find(v => v.headerNameLC.Equals(colname)); if (match == null) { continue; } if (match.sync2gh == true) { continue; } //activeSheet.Cells[activerow, match.colNo].Value = col; myArray[activerow, match.colNo - idcol + 1] = col; } pf.Increment(); } } //int resultRows = myArray.GetLength(0); //int resultCols = myArray.GetLength(1); ExcelReference sheet2 = (ExcelReference)XlCall.Excel(XlCall.xlSheetId, activeSheet.Name); ExcelReference target = new ExcelReference(idrow - 1, maxr - 1, idcol - 1, maxc - 1, sheet2.SheetId); _excel.ScreenUpdating = false; _excel.EnableEvents = false; ExcelAsyncUtil.QueueAsMacro(() => { target.SetValue(myArray); }); //_excel.ScreenUpdating = true; //_excel.EnableEvents = true; //_excel.Interactive = false; //_excel.ScreenUpdating = false; //_excel.EnableEvents = false; // check not valid rows List <int> notfoundrow = new List <int>(); int notfound = 0; for (int r = idrow + 2; r <= maxr; r++) { var guid = activeSheet.Cells[r, idcol].Value2; if (guid == null) { continue; } string sguid = guid as string; if (sguid.Length == 0) { continue; } if (guidsexist.Contains(sguid) == false) { activeSheet.Cells[r, idcol].Font.Strikethrough = true; notfound++; } else { activeSheet.Cells[r, idcol].Font.Strikethrough = false; } } //_excel.Interactive = true; _excel.ScreenUpdating = true; _excel.EnableEvents = true; table = null; System.Windows.Forms.MessageBox.Show("Updated " + updateno + " entries, " + notfound + " obsolete and added " + newno + " new entries ", "Read From Glasshouse"); }
public void WriteGH(bool csv = false) { bool viewexport = true; string curview = _curview; if (_curview.Equals("__GHALLDATA__")) { // not supported System.Windows.Forms.DialogResult dlg = System.Windows.Forms.MessageBox.Show("We do not support reading from " + _curviewname + " in project " + _curprojname, "Read from Glasshouse", System.Windows.Forms.MessageBoxButtons.OK); return; } if (csv == false) { System.Windows.Forms.DialogResult dlg = System.Windows.Forms.MessageBox.Show("Are you sure you want to write data to Glasshouse project " + _curprojname, "Write to Glasshouse", System.Windows.Forms.MessageBoxButtons.YesNo); if (dlg == System.Windows.Forms.DialogResult.No) { return; } dlg = System.Windows.Forms.MessageBox.Show("Do you want to only update parameters in view " + _curviewname + "?", "Write to Glasshouse - by specific view", System.Windows.Forms.MessageBoxButtons.YesNo); if (dlg == System.Windows.Forms.DialogResult.No) { // limitation in API means data is dumped by "All Entries" view. // API needs change so ALL info can be updated, ignoring whats in specific view curview = "all_entries"; viewexport = false; } } else { // limitation in API means data is dumped by "All Entries" view. // API needs change so ALL info can be updated, ignoring whats in specific view curview = "all_entries"; viewexport = false; } // allway read - glasshousejournalguid, short description Range rngid = FindGUIDCell(); if (rngid == null) { System.Windows.Forms.MessageBox.Show("glasshousejournalguid not found in the first 10 by 10 cells"); return; } int idrow = rngid.Row; int idcol = rngid.Column; var removehcols = new[] { "glasshousejournalguid", "BIM Objects count", "BIM Objects quantity" }; // var removehcols = new[] { "glasshousejournalguid", "short description" }; var activeSheet = _excel.ActiveSheet as Worksheet; Range usedRange = activeSheet.UsedRange; int maxr = usedRange.Rows[1].Row + usedRange.Rows.Count - 1; int maxc = usedRange.Columns[1].Column + usedRange.Columns.Count - 1; System.Data.DataTable table = null; System.Data.DataRow tablerow = null; if (curview != null) { using (View.WaitingForm wf = new View.WaitingForm("Getting Entries For Update", "Contacting server...")) { table = JournalEntries.GetViewEntries(Utils.apiKey, _curproj, curview); } if (table.Rows.Count > 0) { tablerow = table.Rows[0]; } else { System.Windows.Forms.MessageBox.Show("Did not find any good data in view " + _curviewname); return; } } else { // should never happen!? System.Windows.Forms.MessageBox.Show("Error - view undefined"); return; } // Make dictinary of columns List <gColumns> headers = new List <gColumns>(); List <string> updates = new List <string>(); List <string> updatesheader = new List <string>(); updatesheader.Add("GlassHouseJournalGUID"); for (int c = idcol; c <= maxc; c++) { if (activeSheet.Cells[idrow, c].Value2 == null) { continue; } string sc = activeSheet.Cells[idrow, c].Value2 as string; if (sc.Length > 0) { gColumns gc = new gColumns(); gc.headerName = sc.Trim(); gc.headerNameLC = gc.headerName.ToLower(); gc.colNo = c; gc.sync2gh = false; if (tablerow != null) { int colno = 0; foreach (object col in tablerow.ItemArray) { string colname = table.Columns[colno].ColumnName.ToLower().Trim(); colno++; if (colname.Equals(gc.headerNameLC)) { gc.GHcolNo = colno; break; } } } // if (activeSheet.Cells[idrow + 1, c].Value2 == null) { headers.Add(gc); continue; } string syncway = (activeSheet.Cells[idrow + 1, c].Value2 as string).ToLower().Trim(); if (removehcols.Any(gc.headerNameLC.Contains)) { headers.Add(gc); continue; } if (syncway.Equals("update")) { gc.sync2gh = true; updatesheader.Add(gc.headerName); } headers.Add(gc); } } if (updatesheader.Count < 2) { System.Windows.Forms.MessageBox.Show("No parameters selected for updating"); return; } List <string> newupdatesheader = new List <string>(); if (viewexport == true) { headers = headers.OrderBy(o => o.GHcolNo).ToList(); foreach (gColumns gc in headers) { if (updatesheader.Any(gc.headerName.Contains)) { newupdatesheader.Add(gc.headerName); } } updates.Add(String.Join(",", newupdatesheader.Select(x => x.ToString()).ToArray())); } else { updates.Add(String.Join(",", updatesheader.Select(x => x.ToString()).ToArray())); } var removecols = new[] { "BIM Objects count", "BIM Objects quantity" }; maxr = Math.Max(maxr, idrow + 2); int n = table.Rows.Count; string s = "{0} of " + n.ToString() + " rows processed..."; string caption = "Preparing Data For Glasshouse"; using (ProgressForm pf = new ProgressForm(caption, s, n)) { foreach (System.Data.DataRow row in table.Rows) { string rguid = (string)row[0]; int foundrow = -1; for (int r = idrow + 2; r <= maxr; r++) { var guid = activeSheet.Cells[r, idcol].Value2; if (guid == null) { continue; } string sguid = guid as string; if (sguid.Length == 0) { continue; } if (rguid.Equals(sguid) == true) { foundrow = r; break; } } int colno = 0; int activerow = foundrow; if (foundrow == -1) { continue; } List <string> updatescol = new List <string>(); if (viewexport == true) { foreach (object col in row.ItemArray) { string colname = table.Columns[colno].ColumnName.ToLower().Trim(); colno++; if (removecols.Any(colname.Contains)) { continue; } gColumns match = headers.Find(v => v.headerNameLC.Equals(colname)); if (match == null) { continue; } if (match.sync2gh == false && match.headerNameLC.Equals("glasshousejournalguid") == false) { continue; } //add to update var val = activeSheet.Cells[foundrow, match.colNo].Value2; string sval = "-"; if (val != null) { sval = Utils.FormatWithQuotes(val.ToString()); } updatescol.Add(sval as string); } } else { foreach (gColumns gc in headers) { if (removecols.Any(gc.headerName.Contains)) { continue; } if (gc.sync2gh == false && gc.headerNameLC.Equals("glasshousejournalguid") == false) { continue; } //add to update var val = activeSheet.Cells[foundrow, gc.colNo].Value2; string sval = "-"; if (val != null) { sval = Utils.FormatWithQuotes(val.ToString()); } updatescol.Add(sval as string); } } updates.Add(String.Join(",", updatescol.Select(x => x.ToString()).ToArray())); //updates.Add(updatescol.Aggregate("", (string agg, string it) => agg += string.Format("{0} \"{1}\"", agg == "" ? "" : ",", it))); pf.Increment(); } } if (updates.Count < 2) { System.Windows.Forms.MessageBox.Show("Nothing to update"); return; } var tempdir = System.IO.Path.GetTempPath(); string path = Path.Combine(tempdir, System.IO.Path.GetFileNameWithoutExtension(_excel.ActiveWorkbook.Name) + "_updateglasshouse.csv"); n = updates.Count; s = "{0} of " + n.ToString() + " rows processed..."; caption = "Writing Data For Glasshouse"; using (ProgressForm pf = new ProgressForm(caption, s, n)) { using (var w = new StreamWriter(path, false, Encoding.UTF8)) { foreach (string us in updates) { w.WriteLine(us); w.Flush(); } } } if (csv == false) { if (UpdateJournalCVS(_curproj, path) == true) { System.Windows.Forms.MessageBox.Show("Glashouse updated", "Write To Glasshouse"); } else { System.Windows.Forms.MessageBox.Show("Hmmm...something went wrong!", "Write To Glasshouse"); } } else { System.Windows.Forms.MessageBox.Show("CSV dumped at " + path, "Write To CSV File"); } updates = null; updatesheader = null; headers = null; table = null; }