From: Joey Schulze Date: Sat, 30 Aug 2003 09:20:06 +0000 (+0000) Subject: Added proper support for transaction 54xxJ. This extends the syntax X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fdtaus;a=commitdiff_plain;h=798e1f530141b1d157fb85241f06c1f88b044056 Added proper support for transaction 54xxJ. This extends the syntax little bit since the year can be given as argument to Vermögen, and it doesn't have to contain a real umlaut anymore. --- diff --git a/dtaus.c b/dtaus.c index a6d8235..d2c29f6 100644 --- a/dtaus.c +++ b/dtaus.c @@ -308,6 +308,19 @@ char *real2string(char *s) 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]; @@ -326,7 +339,7 @@ char *string2trans (char *s) 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; @@ -335,6 +348,7 @@ char *string2trans (char *s) char *trans2string (char *s) { static char res[30]; + char *cp; res[0] = '\0'; if (!strcmp(s, "Abbuchung")) @@ -349,8 +363,34 @@ char *trans2string (char *s) 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 + 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; @@ -512,6 +552,9 @@ size_t control_nextline (void **buf, int len, FILE *f) return 0; } +/* + * Return the current date nicely formatted + */ char *get_date() { static char res[10]; @@ -684,7 +727,7 @@ int dtaus_writeC(FILE *f, char **valuesA, char **values, char **text) } 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; }