void registerNumber(CodeFirstWebFramework.AppModule module, ref int next, int current) { if (current >= next) { next = current + 1; write(module); } }
/// <summary> /// Import a bank statement, and return it (no posting is made to the database) /// </summary> public JArray ImportTransactions(TextReader r, AppModule module) { lock (this) { JArray result = new JArray(); _transactionsOnly = true; _reader = r; _module = module; Line = 0; Character = 0; _accountsProcessed = new List <int>(); _transactions = new List <Transaction>(); if (!getLine()) { return(result); } while (!_eof) { switch (_line) { case "!Type:Cash": case "!Type:Bank": importTransactions(DocType.Withdrawal, DocType.Deposit); break; case "!Type:CCard": importTransactions(DocType.CreditCardCharge, DocType.CreditCardCredit); break; default: skip(); break; } } // Now copy wanted data to the output foreach (Transaction t in _transactions) { JObject j = new JObject(); j["Name"] = string.IsNullOrEmpty(t.Name) ? t.DocumentMemo : t.Name; j["Amount"] = t.Amount; j["Date"] = t.DocumentDate; if (!string.IsNullOrEmpty(t.DocumentIdentifier)) { j["Id"] = t.DocumentIdentifier; } j["Memo"] = t.DocumentMemo; result.Add(j); } return(result); } }
public void RegisterNumber(CodeFirstWebFramework.AppModule module, int?docType, int current) { switch (docType) { case (int)DocType.Invoice: case (int)DocType.CreditMemo: registerNumber(module, ref NextInvoiceNumber, current); break; case (int)DocType.Bill: case (int)DocType.Credit: registerNumber(module, ref NextBillNumber, current); break; case (int)DocType.GeneralJournal: registerNumber(module, ref NextJournalNumber, current); break; } }
/// <summary> /// Import a whole Qif file to the database as new accounts, transactions, etc. /// </summary> public void Import(TextReader r, CodeFirstWebFramework.AppModule module) { lock (this) { _transactionsOnly = false; _reader = r; _module = module; Line = 0; Character = 0; _accountsProcessed = new List <int>(); _transactions = new List <Transaction>(); if (!getLine()) { return; } while (!_eof) { switch (_line.Trim()) { case "!Type:Cash": case "!Type:Bank": importTransactions(DocType.Withdrawal, DocType.Deposit); break; case "!Type:CCard": importTransactions(DocType.CreditCardCharge, DocType.CreditCardCredit); break; case "!Type:Oth A": case "!Type:Oth L": importTransactions(DocType.GeneralJournal, DocType.GeneralJournal); break; case "!Type:Invst": importInvestments(); break; case "!Account": importAccounts(); break; case "!Type:Cat": importCategories(); break; case "!Type:Security": importSecurity(); break; case "!Type:Prices": importPrices(); break; case "!Type:Class": case "!Type:Memorized": case "!Type:Invoice": // We are not interested in these // TODO: Process invoices skip(); break; default: if (_line.StartsWith("!Option:") || _line.StartsWith("!Clear:")) { getLine(); } else { throw new CheckException("Unexpected input:{0}", _line); } break; } } postTransactions(); } }
public ImportBatchJob(CodeFirstWebFramework.AppModule module, FileProcessor file, Action action) : base(module, action) { _file = file; }
void write(CodeFirstWebFramework.AppModule module) { module.Database.Update(this); }