Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Calender billing_prt

by oikool (Novice)
on Jan 23, 2014 at 21:18 UTC ( #1071821=perlquestion: print w/replies, xml ) Need Help??

oikool has asked for the wisdom of the Perl Monks concerning the following question:

the thing is im supposed to print out postpaid bill, that shall be issued everymonth. But suppose im subscribed to a plan on beginning of the month, i will be billed on 8th of everymonth.(As i have multiple billing dates: 8,20,31) And irrespective of the plans i subscribe later towards end of the month, i will be stilled be billed on 8th... i have tried capturing the system PC time, but havent been able to link time between thse mutiple billing dates. As i need to print out the bill even if i used the plan for a week or so. i'm kinda lost in the code.

Replies are listed 'Best First'.
Re: Calender billing_prt
by thezip (Vicar) on Jan 23, 2014 at 21:36 UTC

    ... but you haven't asked a question yet, or showed us the code that you're lost in...

    BTW, take a look at line 38 -- it's missing a semi-colon.


    *My* tenacity goes to eleven...
      #!/usr/local/bin/perl @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek +, $dayOfYear, $daylightSavings) = localtime(); $year = 1900 + $yearOffset; $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$mont +h] $dayOfMonth, $year"; print $theTime;

      this the above code im using it to capture system pc time, i wasnt able to use this time as actually im working on Staf automation. So im writing this perl script so that i can capture the time and use it in my xml code which is required for the billing. I will use this PC time and later generate bill accordingly which i wasnt able to do.(if i subscribed to a plan on say today 24th, he should be billed next month 21st). But my client requirement is that they require the billing according to postpaid customers.

        ... and you're wanting to know how to do *what* ?

        Perhaps sprintf() might be your friend:

        my @parts = localtime(time); my $now = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $parts[5]+1900, $parts[4]+1, $parts[3], $parts[2], $parts[1], $parts[0]); print "The current date/time is $now.\n";

        *My* tenacity goes to eleven...
Re: Calender billing_prt
by Laurent_R (Canon) on Jan 24, 2014 at 07:56 UTC
    I am a bit surprised that you are using the system date for your pro rata calculations. I have been working on a number of billing systems, they all made a clear and important difference between the (theoretical) bill date and the actual date of the bill run, which might often be one or two days after the bill date. If a customer is supposed to be billed on the 8 of each month, the billing services are supposed to go from the 8th of one month to the 7th of next month, irrespective of whether you actually run the billing on the 8th, the 9th or perhaps even the 10th of the current month.
Re: Calender billing_prt (strftime)
by Anonymous Monk on Jan 23, 2014 at 22:35 UTC
    Read about DateTime if you're interested
    use strict; use warnings; use DateTime; my $now = DateTime->now; print "$now\n"; print "year: ", $now->year, "\n"; for my $what( qw/ year month day hour min sec / ){ print "$what: ", $now->$what, "\n"; } print DateTime->now( qw! time_zone America/Los_Angeles ! )->strftime(q +!%F %T%z!), "\n"; print DateTime->now( qw! time_zone America/Los_Angeles ! )->strftime(q +!%T, %a %b %d, %Y!), "\n"; __END__ 2014-01-23T22:38:31 year: 2014 year: 2014 month: 1 day: 23 hour: 22 min: 38 sec: 31 2014-01-23 14:38:31-0800 14:38:31, Thu Jan 23, 2014
Re: Calender billing_prt
by Anonymous Monk on Jan 23, 2014 at 21:37 UTC

    If you could show some code you have tried, and give some example input with its expected output, that would help clarify your question a lot. Having said that, it sounds like you may be looking for a module such as DateTime or Date::Calc?

      #!/usr/local/bin/perl @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek +, $dayOfYear, $daylightSavings) = localtime(); $year = 1900 + $yearOffset; $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$mont +h] $dayOfMonth, $year"; print $theTime;

      this the above code im using it to capture system pc time, i wasnt able to use this time as actually im working on Staf automation. So im writing this perl script so that i can capture the time and use it in my xml code which is required for the billing. I will use this PC time and later generate bill accordingly which i wasnt able to do.(if i subscribed to a plan on say today 24th, he should be billed next month 21st). But my client requirement is that they require the billing according to postpaid customers.

Re: Calender billing_prt
by Anonymous Monk on Jan 23, 2014 at 22:16 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1071821]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-11-30 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?