New isdnrep option -m [*|/]number. It multiplies or divide the cost of
each call by the given number. `-m/1.16' for example displays the costs without the German `Umsatzsteuer'.
This commit is contained in:
parent
13385b9e26
commit
d769b7b4ad
|
@ -1,3 +1,10 @@
|
|||
2004-07-25 Tobias Becker <tobiasb@isdn4linux.de>
|
||||
|
||||
* rep_main.c (parse_options): New option `-m', multiplies or divides
|
||||
connection costs before displaying
|
||||
* isdnrep.h (modcost): New global variable for `-m' option.
|
||||
* isdnrep.c (print_header, set_caller_infos): Apply `-m' option.
|
||||
|
||||
2004-07-24 Tobias Becker <tobiasb@isdn4linux.de>
|
||||
|
||||
* rep_main.c (parse_options): New option `-x', selects calls by hour
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" $Id: isdnrep.1.in,v 1.7 2004/07/24 17:58:06 tobiasb Exp $
|
||||
.\" CHECKIN $Date: 2004/07/24 17:58:06 $
|
||||
.\" $Id: isdnrep.1.in,v 1.8 2004/07/25 14:21:13 tobiasb Exp $
|
||||
.\" CHECKIN $Date: 2004/07/25 14:21:13 $
|
||||
.TH isdnrep 1 "@MANDATE_ISDNREP@" "ISDN 4 Linux @I4LVERSION@" "Linux System Commands"
|
||||
|
||||
.PD 0
|
||||
|
@ -241,6 +241,12 @@ B
|
|||
Like b but allow all providers, not only the booked.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
\fB\-m\fR[\fB*\fR|\fB/\fR]\fInumber\fB modify call costs\fR
|
||||
Multiply (*) or divide (/) the stored or recalculated call costs
|
||||
by number before displaying them. If neither * nor / is given,
|
||||
multiply.
|
||||
|
||||
.TP
|
||||
.B \-wX WWW
|
||||
isdnrep can give its output in HTML format; this is switched on with
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnrep.c,v 1.100 2004/07/24 17:58:06 tobiasb Exp $
|
||||
/* $Id: isdnrep.c,v 1.101 2004/07/25 14:21:13 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
*
|
||||
|
@ -24,6 +24,11 @@
|
|||
*
|
||||
*
|
||||
* $Log: isdnrep.c,v $
|
||||
* Revision 1.101 2004/07/25 14:21:13 tobiasb
|
||||
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||
* each call by the given number. `-m/1.16' for example displays the costs
|
||||
* without the German `Umsatzsteuer'.
|
||||
*
|
||||
* Revision 1.100 2004/07/24 17:58:06 tobiasb
|
||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||
* report footer. `-x' displays only call selected or not deselected by
|
||||
|
@ -2200,6 +2205,11 @@ static int print_header(int lday)
|
|||
}
|
||||
print_line2(F_TEXT_LINE, "%s", s);
|
||||
}
|
||||
|
||||
/* TODO: consistent terminology. fees vs. costs (tobiasb|200407) */
|
||||
if (modcost.mode)
|
||||
print_line2(F_TEXT_LINE, "All displayed costs have been %s by %s.",
|
||||
modcost.mode == 2 ? "divided" : "multiplied", modcost.numstr);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -2724,6 +2734,14 @@ static int set_caller_infos(one_call *cur_call, char *string, time_t from)
|
|||
*/
|
||||
repair(cur_call);
|
||||
|
||||
if (cur_call->pay != 0.0 && modcost.mode)
|
||||
{
|
||||
if (modcost.mode == 1)
|
||||
cur_call->pay *= modcost.number;
|
||||
else if (modcost.mode == 2)
|
||||
cur_call->pay /= modcost.number;
|
||||
}
|
||||
|
||||
return(rc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnrep.h,v 1.23 2004/07/24 17:58:06 tobiasb Exp $
|
||||
/* $Id: isdnrep.h,v 1.24 2004/07/25 14:21:13 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,11 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdnrep.h,v $
|
||||
* Revision 1.24 2004/07/25 14:21:13 tobiasb
|
||||
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||
* each call by the given number. `-m/1.16' for example displays the costs
|
||||
* without the German `Umsatzsteuer'.
|
||||
*
|
||||
* Revision 1.23 2004/07/24 17:58:06 tobiasb
|
||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||
* report footer. `-x' displays only call selected or not deselected by
|
||||
|
@ -218,6 +223,14 @@ typedef struct {
|
|||
char *input; /* input from command line after -r[vp] */
|
||||
} RECALC;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
int mode; /* 0 no action, 1 multiply, 2 divide */
|
||||
char *numstr; /* number as string, part of given option */
|
||||
double number; /* number for multiplication or division */
|
||||
} MODCOST;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* isdnrep.c defines _REP_FUNC_C_, rep_main.c defines _ISDNREP_C_, ... */
|
||||
#ifdef _REP_FUNC_C_
|
||||
|
@ -270,6 +283,7 @@ _EXTERN int preselect _SET_33;
|
|||
#endif
|
||||
_EXTERN int summary _SET_0;
|
||||
_EXTERN RECALC recalc; /* initiation done in main */
|
||||
_EXTERN MODCOST modcost; /* initiation done in main */
|
||||
_EXTERN int sel_sums[3] _SET_ARRAY_0;
|
||||
_EXTERN bitfield days[2] _SET_ARRAY_0;
|
||||
_EXTERN bitfield hours[2] _SET_ARRAY_0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rep_main.c,v 1.18 2004/07/24 17:58:06 tobiasb Exp $
|
||||
/* $Id: rep_main.c,v 1.19 2004/07/25 14:21:13 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
*
|
||||
|
@ -20,6 +20,11 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: rep_main.c,v $
|
||||
* Revision 1.19 2004/07/25 14:21:13 tobiasb
|
||||
* New isdnrep option -m [*|/]number. It multiplies or divide the cost of
|
||||
* each call by the given number. `-m/1.16' for example displays the costs
|
||||
* without the German `Umsatzsteuer'.
|
||||
*
|
||||
* Revision 1.18 2004/07/24 17:58:06 tobiasb
|
||||
* New isdnrep options: `-L:' controls the displayed call summaries in the
|
||||
* report footer. `-x' displays only call selected or not deselected by
|
||||
|
@ -306,7 +311,7 @@ static char fnbuff[512] = "";
|
|||
static char usage[] = "%s: usage: %s [ -%s ]\n";
|
||||
static char wrongdate[] = "unknown date: %s\n";
|
||||
static char wrongxopt[] = "error in -x option starting at: %s\n";
|
||||
static char options[] = "abcd:f:hinop:r:s:t:uvw:x:EF:L:M:NR:SV";
|
||||
static char options[] = "abcd:f:him:nop:r:s:t:uvw:x:EF:L:M:NR:SV";
|
||||
static char *linefmt = "";
|
||||
static char *htmlreq = NULL;
|
||||
static char *phonenumberarg = NULL;
|
||||
|
@ -326,6 +331,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||
|
||||
recalc.mode = '\0'; recalc.prefix = UNKNOWN; recalc.input = NULL;
|
||||
recalc.count = recalc.unknown = recalc.cheaper = 0;
|
||||
modcost.mode = 0;
|
||||
select_summaries(sel_sums, NULL); /* default: all summaries */
|
||||
|
||||
/* we don't need this at the moment:
|
||||
|
@ -340,6 +346,8 @@ int main(int argc, char *argv[], char *envp[])
|
|||
* set_msnlist after readconfig.
|
||||
*/
|
||||
|
||||
/* TODO: parse_options may print to stdout regardless a missing
|
||||
* Content-Type header. (tobiasb|200407) */
|
||||
if ((c=parse_options(argc, argv, myname) > 0))
|
||||
return c;
|
||||
|
||||
|
@ -532,6 +540,26 @@ static int parse_options(int argc, char *argv[], char *myname)
|
|||
case 'c' : do_defopts = 0;
|
||||
break;
|
||||
|
||||
case 'm' : modcost.mode = (*optarg =='/') ? 2 : 1;
|
||||
modcost.numstr = strdup(optarg);
|
||||
if (*optarg == '*' || *optarg == '/')
|
||||
modcost.numstr++;
|
||||
ptr = NULL;
|
||||
modcost.number = strtod(modcost.numstr, &ptr);
|
||||
if (modcost.numstr == ptr)
|
||||
{
|
||||
printf("no number in -m option: %s\n", modcost.numstr);
|
||||
return 1;
|
||||
}
|
||||
if (modcost.mode == 2 && modcost.number == 0.0)
|
||||
{
|
||||
printf("division by 0 as requested in -m option not allowed.\n");
|
||||
return 1;
|
||||
}
|
||||
if (ptr && *ptr)
|
||||
*ptr = 0;
|
||||
break;
|
||||
|
||||
case '?' : printf(usage, argv[0], argv[0], options);
|
||||
return(1);
|
||||
} /* switch */
|
||||
|
|
Loading…
Reference in New Issue