Added begin and end dates of the booking period
authorArjen Baart <arjen@andromeda.nl>
Fri, 5 Nov 2010 10:02:30 +0000 (11:02 +0100)
committerArjen Baart <arjen@andromeda.nl>
Fri, 5 Nov 2010 10:02:30 +0000 (11:02 +0100)
The begin date and end date of the bookings are obtained from the
first and the last booking in the journal file. These dates
are subsequntly used in both the XML and Postscript saldi reports.

account.cpp
account.h
account_main.cpp
balans.xsl
profit.xsl
saldibalans.xsl

index 9fa1931..ef1d0b8 100644 (file)
@@ -238,12 +238,12 @@ std::ostream& operator<<(std::ostream &s, Ledger &l)
    return s;
 }
 
-void PostScript_balans_layout(PostScript &ps)
+void PostScript_balans_layout(PostScript &ps, String header)
 {
    ps.Line(16, 595, 755, 595);
    ps.Line(16, 580, 755, 580);
    ps.Line(16, 40, 755, 40);
-   ps.Text(200, 582, "Saldibalans");
+   ps.Text(200, 582, header);
 
    ps.Line( 16, 595,  16, 40);
    ps.Line(755, 595, 755, 40);
@@ -272,7 +272,7 @@ void Ledger::accounts_report(const char * filename)
    }
 }
 
-void Ledger::saldi_report(const char * filename)
+void Ledger::saldi_report(const char * filename, date period_begin, date period_end)
 {
    PostScript ps(filename);
    balance total, saldi;
@@ -281,6 +281,10 @@ void Ledger::saldi_report(const char * filename)
    float      y = 572;
    int        row = 0;
 
+   String     header("Saldibalans");
+
+   header += " van " + period_begin.format("%e %B %Y") + " tot " + period_end.format("%e %B %Y");
+
    ps.NewPage(842, 595);
    ps.FontSize(6);
 
@@ -294,7 +298,7 @@ void Ledger::saldi_report(const char * filename)
          if (row == 64)
          {
             ps.FontSize(9);
-            PostScript_balans_layout(ps);
+            PostScript_balans_layout(ps, header);
             ps.NewPage(842, 595);
             ps.FontSize(6);
             y = 572;
@@ -341,7 +345,7 @@ void Ledger::saldi_report(const char * filename)
    }
 
    ps.FontSize(9);
-   PostScript_balans_layout(ps);
+   PostScript_balans_layout(ps, header);
 
    balance profit;
    profit = ~Result;
@@ -370,13 +374,13 @@ void Ledger::saldi_report(const char * filename)
    ps.Text(690, y, EndBalance.credit().to_string());
 }
 
-void Ledger::XML_saldi(std::ostream &s)
+void Ledger::XML_saldi(std::ostream &s, date period_begin, date period_end)
 {
    int  i;
 
    s << "<?xml version='1.0'?>\n";
    s << "<accounting>\n";
-   s << "<balance-sheet>\n";
+   s << "<balance-sheet begin='" << period_begin << "' end='" << period_end << "'>\n";
    for (i=0; i<nr_accs; i++)
    {
       balance saldo = ~balance(accs[i]);
index 997a912..ea03a2c 100644 (file)
--- a/account.h
+++ b/account.h
@@ -342,7 +342,7 @@ public:
    friend std::ostream & operator<<(std::ostream &, Ledger&);
 
    void accounts_report(const char *);
-   void saldi_report(const char *);
-   void XML_saldi(std::ostream &);
+   void saldi_report(const char *, date period_begin, date period_end);
+   void XML_saldi(std::ostream &, date period_begin, date period_end);
 };
 
index 4f1bd3c..fe69b86 100644 (file)
@@ -90,10 +90,10 @@ main(int argc, char *argv[])
 
    std::cout << ledger;
    
-   ledger.saldi_report("saldibalans.ps");
+   ledger.saldi_report("saldibalans.ps", date(b[0]), date(b[n_b-1]));
 
    std::ofstream  saldi("saldi.xml");
-   ledger.XML_saldi(saldi);
+   ledger.XML_saldi(saldi, date(b[0]), date(b[n_b-1]));
 }
 
 void read_journal(char *journal_file)
index ee22fca..e476b34 100644 (file)
@@ -15,7 +15,7 @@
 
 </head>
 <body>
-   <h1>Balans</h1>
+   <h1>Balans per <xsl:value-of select='@end'/></h1>
 
    <h2>Bezittingen</h2>
    <table>
index fae6ac0..26c44d4 100644 (file)
@@ -15,6 +15,7 @@
 </head>
 <body>
    <h1>Winst en Verlies rekening</h1>
+   <h2>Periode van <xsl:value-of select='@begin'/> tot <xsl:value-of select='@end'/></h2>
 
    <h2>Opbrengsten</h2>
    <table>
index aca4c23..7e0ba7c 100644 (file)
@@ -13,7 +13,7 @@
 </head>
 <body>
    <h1>Saldi Balans</h1>
-
+   <h2>Periode van <xsl:value-of select='@begin'/> tot <xsl:value-of select='@end'/></h2>
 
    <table border='1'>
    <tr><th>Rekening</th><th colspan='2'>Kosten</th><th colspan='2'>Balans</th></tr>