summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-23 19:07:30 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-23 19:07:30 -0400
commit944c63e6f26d1f05ba6f63c60f510d3796872f3e (patch)
treee1fc54319c2c42c16a64e95930acaca063658863 /contrib
parent057506ab6dddbfb75d1bb29289602f375ca57df5 (diff)
downloadfork-ledger-944c63e6f26d1f05ba6f63c60f510d3796872f3e.tar.gz
fork-ledger-944c63e6f26d1f05ba6f63c60f510d3796872f3e.tar.bz2
fork-ledger-944c63e6f26d1f05ba6f63c60f510d3796872f3e.zip
The Great Renaming, Part II
The last commit did not contain the majority of changes because of a slight mishap. This contains the real changeset.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ParseCcStmt.cs92
-rwxr-xr-xcontrib/entry6
-rwxr-xr-xcontrib/ledger-du14
-rw-r--r--contrib/ledger.vim8
4 files changed, 60 insertions, 60 deletions
diff --git a/contrib/ParseCcStmt.cs b/contrib/ParseCcStmt.cs
index f6b2f20b..c9ad1d55 100644
--- a/contrib/ParseCcStmt.cs
+++ b/contrib/ParseCcStmt.cs
@@ -41,7 +41,7 @@ using CSVReader;
/**
* @file ParseCcStmt.cs
*
- * @brief Provides a .NET way to turn a CSV report into Ledger entries.
+ * @brief Provides a .NET way to turn a CSV report into Ledger transactions.
*
* I use this code for converting the statements from my own credit card
* issuer. I realize it's strange for this to be in C#, but I wrote it
@@ -52,7 +52,7 @@ using CSVReader;
namespace JohnWiegley
{
- public class Transaction
+ public class Posting
{
public DateTime Date;
public DateTime PostedDate;
@@ -63,90 +63,90 @@ namespace JohnWiegley
public interface IStatementConverter
{
- List<Transaction> ConvertRecords(Stream s);
+ List<Posting> ConvertRecords(Stream s);
}
public class ConvertGoldMasterCardStatement : IStatementConverter
{
- public List<Transaction> ConvertRecords(Stream s)
+ public List<Posting> ConvertRecords(Stream s)
{
- List<Transaction> xacts = new List<Transaction>();
+ List<Posting> posts = new List<Posting>();
using (CSVReader.CSVReader csv = new CSVReader.CSVReader(s)) {
string[] fields;
while ((fields = csv.GetCSVLine()) != null) {
- if (fields[0] == "TRANSACTION DATE")
+ if (fields[0] == "POSTING DATE")
continue;
- Transaction xact = new Transaction();
+ Posting post = new Posting();
- xact.Date = DateTime.ParseExact(fields[0], "mm/dd/yy", null);
- xact.PostedDate = DateTime.ParseExact(fields[1], "mm/dd/yy", null);
- xact.Payee = fields[2].Trim();
- xact.Code = fields[3].Trim();
- xact.Amount = Convert.ToDecimal(fields[4].Trim());
+ post.Date = DateTime.ParseEpost(fields[0], "mm/dd/yy", null);
+ post.PostedDate = DateTime.ParseEpost(fields[1], "mm/dd/yy", null);
+ post.Payee = fields[2].Trim();
+ post.Code = fields[3].Trim();
+ post.Amount = Convert.ToDecimal(fields[4].Trim());
- if (xact.Code.Length == 0)
- xact.Code = null;
+ if (post.Code.Length == 0)
+ post.Code = null;
- xacts.Add(xact);
+ posts.Add(post);
}
}
- return xacts;
+ return posts;
}
}
public class ConvertMastercardStatement : IStatementConverter
{
- public List<Transaction> ConvertRecords(Stream s)
+ public List<Posting> ConvertRecords(Stream s)
{
- List<Transaction> xacts = new List<Transaction>();
+ List<Posting> posts = new List<Posting>();
using (CSVReader.CSVReader csv = new CSVReader.CSVReader(s)) {
string[] fields;
while ((fields = csv.GetCSVLine()) != null) {
- Transaction xact = new Transaction();
+ Posting post = new Posting();
- xact.Date = DateTime.ParseExact(fields[0], "m/dd/yyyy", null);
- xact.Payee = fields[2].Trim();
- xact.Code = fields[3].Trim();
- xact.Amount = - Convert.ToDecimal(fields[4].Trim());
+ post.Date = DateTime.ParseEpost(fields[0], "m/dd/yyyy", null);
+ post.Payee = fields[2].Trim();
+ post.Code = fields[3].Trim();
+ post.Amount = - Convert.ToDecimal(fields[4].Trim());
- if (xact.Code.Length == 0)
- xact.Code = null;
+ if (post.Code.Length == 0)
+ post.Code = null;
- xacts.Add(xact);
+ posts.Add(post);
}
}
- return xacts;
+ return posts;
}
}
- public class PrintTransactions
+ public class PrintPostings
{
- public string DefaultAccount(Transaction xact) {
- if (Regex.IsMatch(xact.Payee, "IGA"))
+ public string DefaultAccount(Posting post) {
+ if (Regex.IsMatch(post.Payee, "IGA"))
return "Expenses:Food";
return "Expenses:Food";
}
public void Print(string AccountName, string PayAccountName,
- List<Transaction> xacts)
+ List<Posting> posts)
{
- foreach (Transaction xact in xacts) {
- if (xact.Amount < 0) {
- Console.WriteLine("{0} * {1}{2}", xact.Date.ToString("yyyy/mm/dd"),
- xact.Code != null ? "(" + xact.Code + ") " : "",
- xact.Payee);
+ foreach (Posting post in posts) {
+ if (post.Amount < 0) {
+ Console.WriteLine("{0} * {1}{2}", post.Date.ToString("yyyy/mm/dd"),
+ post.Code != null ? "(" + post.Code + ") " : "",
+ post.Payee);
Console.WriteLine(" {0,-36}{1,12}", AccountName,
- "$" + (- xact.Amount).ToString());
+ "$" + (- post.Amount).ToString());
Console.WriteLine(" {0}", PayAccountName);
} else {
- Console.WriteLine("{0} {1}{2}", xact.Date.ToString("yyyy/mm/dd"),
- xact.Code != null ? "(" + xact.Code + ") " : "",
- xact.Payee);
- Console.WriteLine(" {0,-36}{1,12}", DefaultAccount(xact),
- "$" + xact.Amount.ToString());
+ Console.WriteLine("{0} {1}{2}", post.Date.ToString("yyyy/mm/dd"),
+ post.Code != null ? "(" + post.Code + ") " : "",
+ post.Payee);
+ Console.WriteLine(" {0,-36}{1,12}", DefaultAccount(post),
+ "$" + post.Amount.ToString());
Console.WriteLine(" * {0}", AccountName);
}
Console.WriteLine();
@@ -166,17 +166,17 @@ namespace JohnWiegley
IStatementConverter converter;
- if (firstLine.StartsWith("TRANSACTION DATE")) {
+ if (firstLine.StartsWith("POSTING DATE")) {
converter = new ConvertGoldMasterCardStatement();
} else {
converter = new ConvertMastercardStatement();
}
reader = new StreamReader(args[0]);
- List<Transaction> xacts = converter.ConvertRecords(reader.BaseStream);
+ List<Posting> posts = converter.ConvertRecords(reader.BaseStream);
- PrintTransactions printer = new PrintTransactions();
- printer.Print(CardAccount, BankAccount, xacts);
+ PrintPostings printer = new PrintPostings();
+ printer.Print(CardAccount, BankAccount, posts);
return 0;
}
diff --git a/contrib/entry b/contrib/entry
index cc030d8e..ef1869da 100755
--- a/contrib/entry
+++ b/contrib/entry
@@ -6,11 +6,11 @@ fi
line=`wc -l $LEDGER | awk '{print $1}'`
-if ledger entry "$@" > /tmp/entry; then
- cat /tmp/entry >> $LEDGER
+if ledger xact "$@" > /tmp/xact; then
+ cat /tmp/xact >> $LEDGER
else
echo "$@" >> $LEDGER
fi
-rm /tmp/entry
+rm /tmp/xact
vi +$line $LEDGER
diff --git a/contrib/ledger-du b/contrib/ledger-du
index f5d7dd7d..580e916e 100755
--- a/contrib/ledger-du
+++ b/contrib/ledger-du
@@ -23,14 +23,14 @@ def report_file(path):
print
def find_files(path):
- entries = os.listdir(path)
- for entry in entries:
- entry = join(path, entry)
- if not islink(entry):
- if isdir(entry) and entry != "/proc":
- find_files(entry)
+ xacts = os.listdir(path)
+ for xact in xacts:
+ xact = join(path, xact)
+ if not islink(xact):
+ if isdir(xact) and xact != "/proc":
+ find_files(xact)
else:
- report_file(entry)
+ report_file(xact)
args = sys.argv[1:]
if len(args):
diff --git a/contrib/ledger.vim b/contrib/ledger.vim
index 2efce5be..fd61f71e 100644
--- a/contrib/ledger.vim
+++ b/contrib/ledger.vim
@@ -6,7 +6,7 @@
" Revision history
" 2009-01-28 S.Karrmann: minor fixes
" 2009-01-27 third version by S.Karrmann.
-" better extraction of the amount of the transaction
+" better extraction of the amount of the posting
" decimal separator can be one of '.' and ','.
" 2005-02-05 first version (partly copied from ledger.vim 0.0.1)
@@ -19,7 +19,7 @@ endif
" for debugging
syntax clear
-" region: a normal transaction
+" region: a normal posting
syn region transNorm start=/^\d/ skip=/^\s/ end=/^/ fold keepend transparent contains=transDate
syn match transDate /^\d\S\+/ contained
syn match Comment /^;.*$/
@@ -27,7 +27,7 @@ syn match Comment /^;.*$/
highlight default link Comment SpecialKey
highlight default link transDate Question
-" folding: how to represent a transaction in one line.
+" folding: how to represent a posting in one line.
function! LedgerFoldText()
let line = strpart(getline(v:foldstart), 0, 99)
" get the amount at the end of the second line
@@ -48,7 +48,7 @@ endfunction
set foldtext=LedgerFoldText()
set foldmethod=syntax
-" syncinc is easy: search for the first transaction.
+" syncinc is easy: search for the first posting.
syn sync clear
syn sync match ledgerSync grouphere transNorm "^\d"