Support a broader set of possible tags to be placed into the spreadsheet.
I've now made a hard-coded list of potential tags that are supported and will be linked to in the general ledger spreadsheet. This list should probably be in a configuration file of some sort eventually, rather than hard coded. Indeed, note that the hard-coding goes into two different scripts, and thus the lists could easily get out of sync.
This commit is contained in:
parent
287a756ab6
commit
01dc0416b9
2 changed files with 14 additions and 3 deletions
|
|
@ -24,6 +24,9 @@ import sys, os, os.path, optparse
|
||||||
import csv
|
import csv
|
||||||
import ooolib2
|
import ooolib2
|
||||||
|
|
||||||
|
file_fields = [ 'Receipt', 'Invoice', 'Statement', 'Contract', 'PurchaseOrder',
|
||||||
|
'Approval', 'Check', 'IncomeDistributionAnalysis', 'CurrencyRate' ]
|
||||||
|
|
||||||
def err(msg):
|
def err(msg):
|
||||||
print 'error: %s' % msg
|
print 'error: %s' % msg
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
@ -56,7 +59,7 @@ def csv2ods(csvname, odsname, verbose = False):
|
||||||
if len(val) > 0 and val[0] == '$':
|
if len(val) > 0 and val[0] == '$':
|
||||||
doc.set_cell_value(col + 1, row, 'currency', val[1:])
|
doc.set_cell_value(col + 1, row, 'currency', val[1:])
|
||||||
else:
|
else:
|
||||||
if ( (col == 5) and (val != 'Receipt') and len(val) > 0) or ( (col == 6) and (val != 'Invoice') and len(val) > 0):
|
if ((col >= 5) and (not val in file_fields) and len(val) > 0):
|
||||||
linkrel = '../' + val # ../ means remove the name of the *.ods
|
linkrel = '../' + val # ../ means remove the name of the *.ods
|
||||||
linkname = os.path.basename(val) # name is just the last component
|
linkname = os.path.basename(val) # name is just the last component
|
||||||
doc.set_cell_value(col + 1, row, 'link', (linkrel, linkname))
|
doc.set_cell_value(col + 1, row, 'link', (linkrel, linkname))
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,16 @@ foreach my $acct (@sortedAccounts) {
|
||||||
close(GL_TEXT_DATA); die "error reading ledger output for chart of accounts: $!" unless $? == 0;
|
close(GL_TEXT_DATA); die "error reading ledger output for chart of accounts: $!" unless $? == 0;
|
||||||
|
|
||||||
print GL_CSV_OUT "\n\"ACCOUNT:\",\"$acct\"\n\"PERIOD START:\",\"$beginDate\"\n\"PERIOD END:\",\"$formattedEndDate\"\n";
|
print GL_CSV_OUT "\n\"ACCOUNT:\",\"$acct\"\n\"PERIOD START:\",\"$beginDate\"\n\"PERIOD END:\",\"$formattedEndDate\"\n";
|
||||||
print GL_CSV_OUT '"DATE","CHECK NUM","NAME","TRANSACTION AMT","RUNNING TOTAL","Receipt","Invoice"', "\n";
|
print GL_CSV_OUT '"DATE","CHECK NUM","NAME","TRANSACTION AMT","RUNNING TOTAL"';
|
||||||
@acctLedgerOpts = ('-F', '"%(date)","%C","%P","%t","%T","%(tag(\'Receipt\'))","%(tag(\'Invoice\'))"\n', '-w', '--sort', 'd', '-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'reg', $acct);
|
my $formatString = '"%(date)","%C","%P","%t","%T"';
|
||||||
|
foreach my $tagField (qw/Receipt Invoice Statement Contract PurchaseOrder Approval Check IncomeDistributionAnalysis CurrencyRate/) {
|
||||||
|
print GL_CSV_OUT ',"', $tagField, '"';
|
||||||
|
$formatString .= ',"%(tag(\'' . $tagField . '\'))"';
|
||||||
|
}
|
||||||
|
$formatString .= "\n";
|
||||||
|
print GL_CSV_OUT "\n";
|
||||||
|
|
||||||
|
@acctLedgerOpts = ('-F', $formatString, '-w', '--sort', 'd', '-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'reg', $acct);
|
||||||
open(GL_CSV_DATA, "-|", $LEDGER_CMD, @acctLedgerOpts)
|
open(GL_CSV_DATA, "-|", $LEDGER_CMD, @acctLedgerOpts)
|
||||||
or die "Unable to run $LEDGER_CMD @acctLedgerOpts: $!";
|
or die "Unable to run $LEDGER_CMD @acctLedgerOpts: $!";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue