Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Some questions about your solution and data. Some data from file2:
WILYCO CNW 437106 L 2013,07,08 WILYCO MKT 4399 L 2013,07,03 WILYCO MKT 4559 L 2013,07,23 2013,07,26
What do you want to do when there is not a second date? Also, is it possible to not have a first date? What would you do in that case? Because, your code is (date calculations flawed I think - see next question about the dates):
my @ymd1 = split ',',$dates[4] //= $prev_mth_end; my @ymd2 = split ',',$dates[5] //= $prev_mth_end;
Do you really want to assign $prev_mth_end to both if both are blank?
# work out end of current month my ($y,$m,$d) = Today(); my $mth_end = sprintf "%04d,%02d,%02d",$y,$m,Days_in_Month($y,$m); # ($year,$month,$day) = Add_Delta_Days($year,$month,$day,$Dd); my $prev_mth_end = sprintf "%04d,%02d,%02d", Add_Delta_Days($y,$m,1,-1);
It is August now and your date code is using Today(), but your file 2 data is all for the month of July. I think this might be a problem, as the dates won't pertain to July but instead August.

I don't see where you are taking into account for the days from the previous month (June, file 1).

For example, a record from file 1 shows 2 days:

BIGCO-C  MKT   575 L 6/30/13  2
The corresponding record from file 2 shows:
BIGCO-C   MKT      575 L 2013,07,01 2013,07,02
Subtracting 2013,07,01 from 2013,07,02 = 1 day? Then, total days be 2 + 1 = 3 in this case?

From that, subtracting the 3 free days would give 0 billing days? Are you calculating Demurrage?


In reply to Re: How to use 2 files for calculating charges by Cristoforo
in thread How to use 2 files for calculating charges by rruser

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found