From d35d626b75c97e76789305c29b63b24545a07954 Mon Sep 17 00:00:00 2001 From: David Keegan Date: Sat, 2 Nov 2013 14:17:54 +0000 Subject: [PATCH] WIP: Texi. --- Recurring.py | 28 +++++++++++++++------------- dklrt.ldg | 9 --------- dklrt.rec | 12 ++++++++---- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Recurring.py b/Recurring.py index a640de1..95cd997 100755 --- a/Recurring.py +++ b/Recurring.py @@ -32,19 +32,18 @@ class Transaction: def TransactionText(self): """As a string, excluding the period.""" - return '\n' + self._DateLine(True) + self._RemainderLines() + return self._DateLine(True) + self._RemainderLines(True) def _DateLine(self, ExcludePeriod=False): """The Date line.""" Pt = '' if ExcludePeriod else '%s(%s)' % (self._Ds, self._Period) return '%s%s%s' % (self._Date, Pt, self._Al[0]) - def _RemainderLines(self, Exclude=False): + def _RemainderLines(self, ExcludeEmpty=False): Rv = '' - if Exclude: + if ExcludeEmpty: for Rl in self._Al[1:]: - if not re.match(self._ReComment, Rl) and\ - not re.match(self._ReWhitespace, Rl): + if not re.match(self._ReWhitespace, Rl): Rv = Rv + Rl else: Rv = ''.join(self._Al[1:]) @@ -71,9 +70,16 @@ class Transaction: self._Al.append(Line) def Generate(self): - """Generates transactions up to and including the target date. - Returns a list of strings ready for sorting and output to a - ledger file. + """Generates transaction(s) for the current config entry. + + One transaction per interval up to to and including the + target date. In normal operation zero or one transactions are + generated, but if processing has been delayed, more than one + transaction can be produced. + + Returns a list of transaction strings ready for sorting and + output to a ledger file. Each one begins with a newline to + ensure it is separated by an empty line on output. """ Rv = [] Tdis = self._Parent._Tdis @@ -82,7 +88,7 @@ class Transaction: if self._Dis > Tdis: Done = True else: # Append transaction text. - Rv.append(self.TransactionText()) + Rv.append('\n' + self.TransactionText()) # Evaluate next posting date. NewDis = Time.DateAddPeriod(self._Dis, self._Period) @@ -143,10 +149,6 @@ class Transactions: if Rt is not None: self._Rtl.append(Rt) Af.close() - def _WriteConfig(self): - """Saves the current state to the file.""" - Af = open(self._Cfn, 'w') - def Generate(self): """Generates transactions up to and including the target date. Returns a list of strings ready for sorting and output to a diff --git a/dklrt.ldg b/dklrt.ldg index d406e71..c181993 100644 --- a/dklrt.ldg +++ b/dklrt.ldg @@ -18,12 +18,3 @@ 2013-10-19 Payee3 Liability:CreditCard:Mc €5.25 Expense:Groceries - -2013-11-01 Recurring Payee1 - Asset:Bank:Current €-10.00 ; [=2013-11-08] - Expense:Phone €10.00 ; Payee: Eircom. - (Asset:OwedBy:Partner) €10.00 - -2013-11-01 Recurring Payee2 - Asset:Bank:Savings €200.00 - Expense:SavingPlan diff --git a/dklrt.rec b/dklrt.rec index 1daaf6d..7f819b9 100644 --- a/dklrt.rec +++ b/dklrt.rec @@ -1,10 +1,14 @@ +2013-11-08 (1w) Recurring Payee2 + Asset:Bank:Savings €200.00 + Expense:SavingPlan + +2013-12-01 (1m) Recurring Payee3 + Asset:Bank:Savings €1000.00 + Expense:SavingPlan + 2013-12-01 (1m) Recurring Payee1 ; Transaction Note. Asset:Bank:Current €-10.00 ; [=2013-11-08] Expense:Phone €10.00 ; Payee: Eircom. (Asset:OwedBy:Partner) €10.00 ; Posting Note2. - -2013-11-08 (1w) Recurring Payee2 - Asset:Bank:Savings €200.00 - Expense:SavingPlan