mirror of
https://github.com/davidkeegan/dklrt
synced 2024-12-25 09:59:19 +01:00
WIP: Texi.
This commit is contained in:
parent
6db07094fb
commit
d35d626b75
3 changed files with 23 additions and 26 deletions
28
Recurring.py
28
Recurring.py
|
@ -32,19 +32,18 @@ class Transaction:
|
||||||
|
|
||||||
def TransactionText(self):
|
def TransactionText(self):
|
||||||
"""As a string, excluding the period."""
|
"""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):
|
def _DateLine(self, ExcludePeriod=False):
|
||||||
"""The Date line."""
|
"""The Date line."""
|
||||||
Pt = '' if ExcludePeriod else '%s(%s)' % (self._Ds, self._Period)
|
Pt = '' if ExcludePeriod else '%s(%s)' % (self._Ds, self._Period)
|
||||||
return '%s%s%s' % (self._Date, Pt, self._Al[0])
|
return '%s%s%s' % (self._Date, Pt, self._Al[0])
|
||||||
|
|
||||||
def _RemainderLines(self, Exclude=False):
|
def _RemainderLines(self, ExcludeEmpty=False):
|
||||||
Rv = ''
|
Rv = ''
|
||||||
if Exclude:
|
if ExcludeEmpty:
|
||||||
for Rl in self._Al[1:]:
|
for Rl in self._Al[1:]:
|
||||||
if not re.match(self._ReComment, Rl) and\
|
if not re.match(self._ReWhitespace, Rl):
|
||||||
not re.match(self._ReWhitespace, Rl):
|
|
||||||
Rv = Rv + Rl
|
Rv = Rv + Rl
|
||||||
else:
|
else:
|
||||||
Rv = ''.join(self._Al[1:])
|
Rv = ''.join(self._Al[1:])
|
||||||
|
@ -71,9 +70,16 @@ class Transaction:
|
||||||
self._Al.append(Line)
|
self._Al.append(Line)
|
||||||
|
|
||||||
def Generate(self):
|
def Generate(self):
|
||||||
"""Generates transactions up to and including the target date.
|
"""Generates transaction(s) for the current config entry.
|
||||||
Returns a list of strings ready for sorting and output to a
|
|
||||||
ledger file.
|
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 = []
|
Rv = []
|
||||||
Tdis = self._Parent._Tdis
|
Tdis = self._Parent._Tdis
|
||||||
|
@ -82,7 +88,7 @@ class Transaction:
|
||||||
if self._Dis > Tdis: Done = True
|
if self._Dis > Tdis: Done = True
|
||||||
else:
|
else:
|
||||||
# Append transaction text.
|
# Append transaction text.
|
||||||
Rv.append(self.TransactionText())
|
Rv.append('\n' + self.TransactionText())
|
||||||
|
|
||||||
# Evaluate next posting date.
|
# Evaluate next posting date.
|
||||||
NewDis = Time.DateAddPeriod(self._Dis, self._Period)
|
NewDis = Time.DateAddPeriod(self._Dis, self._Period)
|
||||||
|
@ -143,10 +149,6 @@ class Transactions:
|
||||||
if Rt is not None: self._Rtl.append(Rt)
|
if Rt is not None: self._Rtl.append(Rt)
|
||||||
Af.close()
|
Af.close()
|
||||||
|
|
||||||
def _WriteConfig(self):
|
|
||||||
"""Saves the current state to the file."""
|
|
||||||
Af = open(self._Cfn, 'w')
|
|
||||||
|
|
||||||
def Generate(self):
|
def Generate(self):
|
||||||
"""Generates transactions up to and including the target date.
|
"""Generates transactions up to and including the target date.
|
||||||
Returns a list of strings ready for sorting and output to a
|
Returns a list of strings ready for sorting and output to a
|
||||||
|
|
|
@ -18,12 +18,3 @@
|
||||||
2013-10-19 Payee3
|
2013-10-19 Payee3
|
||||||
Liability:CreditCard:Mc €5.25
|
Liability:CreditCard:Mc €5.25
|
||||||
Expense:Groceries
|
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
|
|
||||||
|
|
12
dklrt.rec
12
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
|
2013-12-01 (1m) Recurring Payee1
|
||||||
; Transaction Note.
|
; Transaction Note.
|
||||||
Asset:Bank:Current €-10.00 ; [=2013-11-08]
|
Asset:Bank:Current €-10.00 ; [=2013-11-08]
|
||||||
Expense:Phone €10.00 ; Payee: Eircom.
|
Expense:Phone €10.00 ; Payee: Eircom.
|
||||||
(Asset:OwedBy:Partner) €10.00
|
(Asset:OwedBy:Partner) €10.00
|
||||||
; Posting Note2.
|
; Posting Note2.
|
||||||
|
|
||||||
2013-11-08 (1w) Recurring Payee2
|
|
||||||
Asset:Bank:Savings €200.00
|
|
||||||
Expense:SavingPlan
|
|
||||||
|
|
Loading…
Reference in a new issue