/*
dtaus.c - Belegloser Datenträgeraustausch mit einer Bank
- Copyright (c) 1996,8,2001,2,3 Martin Schulze <joey@infodrom.org>
+ Copyright (c) 1996,8,2001-4 Martin Schulze <joey@infodrom.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return res;
}
+/*
+ * Return the last digit of the year as character
+ */
+char get_date_lastdigit()
+{
+ time_t timer;
+ struct tm *loctime;
+
+ timer = time ( NULL );
+ loctime = localtime(&timer);
+ return loctime->tm_year % 10 + '0';
+}
+
char *string2trans (char *s)
{
static char res[30];
else if (!strcmp(s, "53000"))
sprintf (res, "Lohn");
else if (!strncmp(s, "5400", 4))
- sprintf (res, "Vermögen");
+ sprintf (res, "Vermögen %c",s[4]);
/* else if (!strcmp(s, "56000"))
sprintf (res, ""); / * Überweisung öffentlicher Kassen */
return res;
char *trans2string (char *s)
{
static char res[30];
+ char *cp;
res[0] = '\0';
if (!strcmp(s, "Abbuchung"))
sprintf (res, "51000");
else if (!strcmp(s, "Lohn"))
sprintf (res, "53000");
- else if (!strncmp(s, "Vermögen", 4))
- sprintf (res, "5400");
+ else {
+ cp = NULL;
+ if (!strncmp(s, "Vermögen", 8))
+ cp = s+8;
+ if (!strncmp(s, "Vermoegen", 9))
+ cp = s+9;
+
+ if (!cp) {
+ fprintf (stderr, "Unbekannte Transaktion `%s'\n", res);
+ exit (1);
+ }
+
+ /*
+ Vermögen --> 5400<heutiges Jahr>
+ Vermögen 8 -> 5400<8>
+ Vermögen 2003 -> 5400<3>
+ */
+
+ if (*cp) while (!isspace(*cp)) cp++;
+ while (isspace(*cp)) cp++;
+
+ if (!*cp || !isdigit(*cp))
+ sprintf (res, "5400%c",get_date_lastdigit());
+ else {
+ while (isdigit(*cp)) cp++;
+ sprintf (res, "5400%c",*(cp-1));
+ }
+ }
/* else if (!strcmp(s, ""))
sprintf (res, "56000"); / * Überweisung öffentlicher Kassen */
return res;
return 0;
}
+/*
+ * Return the current date nicely formatted
+ */
char *get_date()
{
static char res[10];
}
sprintf (tmp, "%s", trans2string(values[C_TRANS]));
if (!strlen(tmp)) {
- fprintf (stderr, "Ungültiger Typ, nur Abbuchung, Einzug, E-Cash, E-Cash-A, Gutschrift und Lohn erlaubt.\n");
+ fprintf (stderr, "Ungültige Transaktion, nur Abbuchung, Einzug, E-Cash, E-Cash-A, Gutschrift und Lohn erlaubt.\n");
return 0;
}
fprintf(fbeleg, "\n VOL ........................:\n");
fprintf(fbeleg, "\n Erstellungsdatum ...........: %s\n", get_date());
if (valA[A_TODO]) {
- fprintf(fbeleg, "\n Ausfuehrugsdatum ...........: %s\n", valA[A_TODO]);
+ fprintf(fbeleg, "\n Ausfuehrungsdatum ..........: %s\n", valA[A_TODO]);
}
if (use_euro)
fprintf(fbeleg, "\n Waehrung ...................: Euro\n");