s << " ";
else
{
- //s << form("%8d.%02d",a / 100, a % 100);
- s << std::setw(8) << a / 100 << ".";
+ s << std::setw(8) << std::setfill(' ') << a / 100 << ".";
s << std::setw(2) << std::setfill('0') << a % 100;
s << std::setw(0) << std::setfill(' ');
}
std::istream &operator>>(std::istream &s, Booking &b)
{
- char cmnt[128];
-
s >> b.Bnumber >> b.booked;
- //s.get(cmnt, 128);
- //b.comment = cmnt;
s >> b.comment;
return s;
std::ostream &operator<<(std::ostream &s, Booking &b)
{
- //s << form("#%03d ",b.Bnumber) << b.booked << " " << b.comment;
- //s << form("%.*s", 58 - ~b.comment, " ");
s << "#" << std::setw(4) << std::setfill('0') << b.Bnumber;
s << std::setw(0) << std::setfill(' ');
s << " " << b.booked << " ";
{
int nr_blanks = 0;
char c;
- char buf[128];
while (s.get(c), c == ' ')
nr_blanks++;
s >> m.account;
amount a;
- //s.get(buf, 128);
-
- //std::istringstream amnt(buf+strlen(buf)-10);
- //amnt >> a;
String amnt;
int p;
std::istream &operator>>(std::istream &s, Account &acc)
{
- char kind, name[128];
+ char kind;
s >> acc.Anumber >> kind >> std::ws;
if (kind == 'B')
else
acc.kind = COST;
- //s.get(name, 128);
- //acc.name = name;
-
s >> acc.name;
return s;
{
s << acc.Anumber << " " << std::setw(44) << std::left << acc.name;
s << std::setw(0) << std::right << " ";
- //s << form("%.*s", 45 - ~acc.name, " ");
s << acc.Bal;
return s;
void Ledger::accounts_report(const char * filename)
{
- PostScript ps(filename);
- int i;
+ try
+ {
+ PostScript ps(filename);
+ int i;
- for (i=0; i<nr_accs; i++)
+ for (i=0; i<nr_accs; i++)
+ {
+ accs[i].Postscript_sheet(ps);
+ }
+ }
+ catch (psexception &e)
{
- accs[i].Postscript_sheet(ps);
+ std::cerr << "Error creating postscript output: " << e.what() << "\n";
}
}
void Ledger::saldi_report(const char * filename, date period_begin, date period_end)
{
- PostScript ps(filename);
- balance total, saldi;
- balance EndBalance, Result;
- int i;
- float y = 572;
- int row = 0;
+ try
+ {
+ PostScript ps(filename);
+ balance total, saldi;
+ balance EndBalance, Result;
+ int i;
+ float y = 572;
+ int row = 0;
- String header("Saldibalans");
+ String header("Saldibalans");
- header += " van " + period_begin.format("%e %B %Y") + " tot " + period_end.format("%e %B %Y");
+ header += " " + companyname;
+ header += " van " + period_begin.format("%e %B %Y") + " tot " + period_end.format("%e %B %Y");
- ps.NewPage(842, 595);
- ps.FontSize(6);
+ ps.NewPage(842, 595);
+ ps.FontSize(6);
- for (i=0; i<nr_accs; i++)
- {
- balance saldo(accs[i]);
-
- if (saldo.debit() != 0 || saldo.credit() != 0)
+ for (i=0; i<nr_accs; i++)
{
- if (row == 64)
- {
- ps.FontSize(9);
- PostScript_balans_layout(ps, header);
- ps.NewPage(842, 595);
- ps.FontSize(6);
- y = 572;
- row = 0;
- }
+ balance saldo(accs[i]);
- if (row % 2 == 1)
+ if (saldo.debit() != 0 || saldo.credit() != 0)
{
- ps.Rectangle(16, y-2, 739, 7);
- }
+ if (row == 64)
+ {
+ ps.FontSize(9);
+ PostScript_balans_layout(ps, header);
+ ps.NewPage(842, 595);
+ ps.FontSize(6);
+ y = 572;
+ row = 0;
+ }
- total += accs[i];
- saldi += ~balance(accs[i]);
+ if (row % 2 == 1)
+ {
+ ps.Rectangle(16, y-2, 739, 7);
+ }
- ps.Text(20, y, String(accs[i].Number()));
- ps.Text(50, y, accs[i].Name());
+ total += accs[i];
+ saldi += ~balance(accs[i]);
- balance saldo(accs[i]);
+ ps.Text(20, y, String(accs[i].Number()));
+ ps.Text(50, y, accs[i].Name());
- ps.Text(200, y, saldo.debit().to_string());
- ps.Text(270, y, saldo.credit().to_string());
- saldo = ~saldo;
- ps.Text(340, y, saldo.debit().to_string());
- ps.Text(410, y, saldo.credit().to_string());
+ balance saldo(accs[i]);
- if (accs[i].BAL())
- {
- EndBalance += ~balance(accs[i]);
+ ps.Text(200, y, saldo.debit().to_string());
+ ps.Text(270, y, saldo.credit().to_string());
+ saldo = ~saldo;
+ ps.Text(340, y, saldo.debit().to_string());
+ ps.Text(410, y, saldo.credit().to_string());
- ps.Text(620, y, saldo.debit().to_string());
- ps.Text(690, y, saldo.credit().to_string());
- }
- else
- {
- Result += ~balance(accs[i]);
-
- ps.Text(480, y, saldo.debit().to_string());
- ps.Text(550, y, saldo.credit().to_string());
- }
+ if (accs[i].BAL())
+ {
+ EndBalance += ~balance(accs[i]);
- y -= 7.0;
- row ++;
- }
- }
+ ps.Text(620, y, saldo.debit().to_string());
+ ps.Text(690, y, saldo.credit().to_string());
+ }
+ else
+ {
+ Result += ~balance(accs[i]);
- ps.FontSize(9);
- PostScript_balans_layout(ps, header);
+ ps.Text(480, y, saldo.debit().to_string());
+ ps.Text(550, y, saldo.credit().to_string());
+ }
- balance profit;
- profit = ~Result;
- Result += -profit;
- EndBalance += profit;
+ y -= 7.0;
+ row ++;
+ }
+ }
- ps.LineAttributes(0.5, 1.0, 0.0);
- ps.Line(16, 60, 755, 60);
- y = 52;
- ps.Text(50, y, "Resultaat");
- ps.Text(480, y, (-profit).debit().to_string());
- ps.Text(550, y, (-profit).credit().to_string());
- ps.Text(620, y, profit.debit().to_string());
- ps.Text(690, y, profit.credit().to_string());
-
- ps.Line(16, 50, 755, 50);
- y = 42;
- ps.Text(50, y, "Totaal");
- ps.Text(200, y, total.debit().to_string());
- ps.Text(270, y, total.credit().to_string());
- ps.Text(340, y, saldi.debit().to_string());
- ps.Text(410, y, saldi.credit().to_string());
- ps.Text(480, y, Result.debit().to_string());
- ps.Text(550, y, Result.credit().to_string());
- ps.Text(620, y, EndBalance.debit().to_string());
- ps.Text(690, y, EndBalance.credit().to_string());
+ ps.FontSize(9);
+ PostScript_balans_layout(ps, header);
+
+ balance profit;
+ profit = ~Result;
+ Result += -profit;
+ EndBalance += profit;
+
+ ps.LineAttributes(0.5, 1.0, 0.0);
+ ps.Line(16, 60, 755, 60);
+ y = 52;
+ ps.Text(50, y, "Resultaat");
+ ps.Text(480, y, (-profit).debit().to_string());
+ ps.Text(550, y, (-profit).credit().to_string());
+ ps.Text(620, y, profit.debit().to_string());
+ ps.Text(690, y, profit.credit().to_string());
+
+ ps.Line(16, 50, 755, 50);
+ y = 42;
+ ps.Text(50, y, "Totaal");
+ ps.Text(200, y, total.debit().to_string());
+ ps.Text(270, y, total.credit().to_string());
+ ps.Text(340, y, saldi.debit().to_string());
+ ps.Text(410, y, saldi.credit().to_string());
+ ps.Text(480, y, Result.debit().to_string());
+ ps.Text(550, y, Result.credit().to_string());
+ ps.Text(620, y, EndBalance.debit().to_string());
+ ps.Text(690, y, EndBalance.credit().to_string());
+ }
+ catch (psexception &e)
+ {
+ std::cerr << "Error creating postscript output: " << e.what() << "\n";
+ }
}
void Ledger::XML_saldi(std::ostream &s, date period_begin, date period_end)
y -= 10;
row++;
- //s << b[B] << "|" << balance(m[M]) << " |\n";
}
}
/* Print the footer with the totals */
-#if 0
- s << " SALDO ";
- s << " |" << -~total << " |\n";
- s << "----------------------------------------------------------------";
- s << "-----------+-------------+-----------+\n";
- total += -~total;
- s << " TOTAAL ";
- s << " |" << total << " |\n";
- s << "----------------------------------------------------------------";
- s << "-----------+-------------+-----------+\n";
-#endif
if (page_started)
{
nr_accs = 0;
while (in)
{
+ line_begin = '\n';
in.get(line_begin);
if (isdigit(line_begin))
{