/*
dtaus.c - Datenträgeraustausch mit einer Bank
- Copyright (c) 1996 Martin Schulze <joey@artis.uni-oldenburg.de>
+ Copyright (c) 1996,8 Martin Schulze <joey@artis.uni-oldenburg.de>
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
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
$Id$
*/
return line;
}
+/*
+ * Pads a string with zero's on the left side.
+ */
+char *padzeroclip (char *s, int len)
+{
+ char *p, *q;
+
+ if (strlen(s) == len) return s;
+ if (strlen(s) > len) {
+ q=s+len;
+ *(q--) = '\0';
+ return s;
+ }
+
+ q=s+len;
+ *(q--) = '\0';
+ for (p=s+strlen(s)-1;p>=s;p--)
+ *(q--)=*p;
+ for (;q>=s;) *(q--)='0';
+ return s;
+}
+
int rec_index(char *ident, int type)
{
int i;
dtaus_prepareA(buf);
buf[5] = values[A_TRANS][0];
buf[6] = values[A_TRANS][1];
- sprintf (tmp, "%08s", values[A_BLZ]);
+ sprintf (tmp, "%s", padzeroclip(values[A_BLZ],8));
for (i=0; i<8; i++) buf[recA[A_BLZ].pos+i] = tmp[i];
sprintf (tmp, "%-27s", upcase(values[A_NAME]));
for (i=0; i<27; i++) buf[recA[A_NAME].pos+i] = tmp[i];
- sprintf (tmp, "%010s", values[A_KTO]);
+ sprintf (tmp, "%s", padzeroclip(values[A_KTO],10));
for (i=0; i<10; i++) buf[recA[A_KTO].pos+i] = tmp[i];
fputs(buf, f);
}
for (i=0; i<5; i++) buf[recC[C_TRANS].pos+i] = tmp[i];
if (values[C_MYBLZ])
- sprintf (tmp, "%08s", values[C_MYBLZ]);
+ sprintf (tmp, "%s", padzeroclip(values[C_MYBLZ],8));
else
- sprintf (tmp, "%08s", valuesA[A_BLZ]);
+ sprintf (tmp, "%s", padzeroclip(valuesA[A_BLZ],8));
for (i=0; i<recC[C_MYBLZ].len; i++) buf[5+i] = tmp[i];
for (i=0; i<recC[C_MYBLZ].len; i++) buf[recC[C_MYBLZ].pos+i] = tmp[i];
- sprintf (tmp, "%08s", values[C_BLZ]);
+ sprintf (tmp, "%s", padzeroclip(values[C_BLZ],8));
for (i=0; i<recC[C_BLZ].len; i++) buf[recC[C_BLZ].pos+i] = tmp[i];
- sprintf (tmp, "%010s", values[C_KTO]);
+ sprintf (tmp, "%s", padzeroclip(values[C_KTO],10));
for (i=0; i<recC[C_KTO].len; i++) buf[recC[C_KTO].pos+i] = tmp[i];
- sprintf (tmp, "%011s", real2string(values[C_VAL]));
+ sprintf (tmp, "%s", padzeroclip(real2string(values[C_VAL]),11));
for (i=0; i<recC[C_VAL].len; i++) buf[recC[C_VAL].pos+i] = tmp[i];
if (values[C_MYKTO])
- sprintf (tmp, "%010s", values[C_MYKTO]);
+ sprintf (tmp, "%s", padzeroclip(values[C_MYKTO],10));
else
- sprintf (tmp, "%010s", valuesA[A_KTO]);
+ sprintf (tmp, "%s", padzeroclip(valuesA[A_KTO],10));
for (i=0; i<recC[C_MYKTO].len; i++) buf[recC[C_MYKTO].pos+i] = tmp[i];
sprintf (tmp, "%-27s", upcase(values[C_NAME]));
for (i=0; i<recC[C_NAME].len; i++) buf[recC[C_NAME].pos+i] = tmp[i];
sprintf (tmp, "%07d", count);
for (i=0; i<recE[E_COUNT].len; i++) buf[recE[E_COUNT].pos+i] = tmp[i];
- bigint_sprintf (tmp, "%013s", sum);
+ bigint_sprintf (tmp, "%s", sum);
+ padzeroclip(tmp,13);
for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
- bigint_sprintf (tmp, "%013s", sum);
+ bigint_sprintf (tmp, "%s", sum);
+ padzeroclip(tmp,13);
for (i=0; i<recE[E_VAL].len; i++) buf[recE[E_VAL].pos+i] = tmp[i];
- bigint_sprintf (tmp, "%017s", kto);
+ bigint_sprintf (tmp, "%s", kto);
+ padzeroclip(tmp,17);
for (i=0; i<recE[E_KTO].len; i++) buf[recE[E_KTO].pos+i] = tmp[i];
- bigint_sprintf (tmp, "%017s", blz);
+ bigint_sprintf (tmp, "%s", blz);
+ padzeroclip(tmp,17);
for (i=0; i<recE[E_BLZ].len; i++) buf[recE[E_BLZ].pos+i] = tmp[i];
fputs(buf, f);
control_nextline ((void *)line, 100, fcontrol);
ident = extract_ident(line);
if (!strcmp(ident, "begin") && (line[0] == '{')) {
- fprintf(fbeleg, "\n\n");
- fprintf(fbeleg, "\n Begleitzettel\n\n");
- fprintf(fbeleg, "\n Belegloser Datentraegeraustausch\n\n");
- fprintf(fbeleg, "\n Sammeleinziehungsauftrag\n\n");
- fprintf(fbeleg, "\n VOL ........................:\n");
- fprintf(fbeleg, "\n Erstellungsdatum ...........: %s\n", get_date());
-
control_nextline ((void *)line, 100, fcontrol);
while (strlen(line) && line[0] != '}') {
ident = extract_ident(line);
strcpy(valA[recindex], line);
control_nextline ((void *)line, 100, fcontrol);
}
+ if (((recindex = rec_index("art", REC_A)) != -1) && valA[recindex] && strlen(valA[recindex])) {
+ fprintf(fbeleg, "\n\n");
+ fprintf(fbeleg, "\n Begleitzettel\n\n");
+ fprintf(fbeleg, "\n Belegloser Datentraegeraustausch\n\n");
+ if (valA[recindex][0] == 'L')
+ fprintf(fbeleg, "\n Sammeleinziehungsauftrag\n\n");
+ else if (valA[recindex][0] == 'G')
+ fprintf(fbeleg, "\n Sammelueberweisungsauftrag\n\n");
+ else
+ fprintf(fbeleg, "\n Sammelauftrag\n\n");
+ fprintf(fbeleg, "\n VOL ........................:\n");
+ fprintf(fbeleg, "\n Erstellungsdatum ...........: %s\n", get_date());
+ }
if (!dtaus_writeA(fdtaus, valA)) {
fprintf (stderr, "Konnte den Anfangsdatensatz nicht schreiben.\n");
return 0;