in reply to How to use 2 files for calculating charges
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):WILYCO CNW 437106 L 2013,07,08 WILYCO MKT 4399 L 2013,07,03 WILYCO MKT 4559 L 2013,07,23 2013,07,26
Do you really want to assign $prev_mth_end to both if both are blank?my @ymd1 = split ',',$dates[4] //= $prev_mth_end; my @ymd2 = split ',',$dates[5] //= $prev_mth_end;
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.# 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);
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 2The corresponding record from file 2 shows:
BIGCO-C MKT 575 L 2013,07,01 2013,07,02Subtracting 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?
|
|---|