aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.cpp29
-rwxr-xr-xsrc/time.cpp26
-rwxr-xr-xsrc/time.h3
3 files changed, 45 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ac5c7e0..f02a046 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -205,9 +205,36 @@ done:
for(int jj=0; jj < each_day.total_timeblocks; jj++) {
timeblock& each_block = each_day.blocks[jj];
double block_price = each_block.hourcount() * hourly_rate * each_block.valuefactor;
- std::cout << timeprint(each_block, true) << ", " << each_block.hourcount() << "h\t+" << (each_block.valuefactor-1)*100 << "%\t= " << block_price << "\n";
+
+ std::cout << timeprint(each_block, true) << ", "
+ << each_block.hourcount() << "h\t+"
+ << (each_block.valuefactor-1)*100 << "%\t= "
+ << block_price;
+ //if(each_block.price_reason != "Norm") {
+ std::cout << " \t[" << each_block.price_reason << "]";
+ //}
+ std::cout << "\n";
+
day_price += block_price;
}
+
+ double day_length = (timeblock){each_day.call, each_day.wrap}.hourcount();
+
+ if((each_day.call.hours < 6 || each_day.call.hours >= 22) &&
+ (each_day.wrap.hours < 6 || each_day.wrap.hours >= 22) &&
+ day_length < 9)
+ {
+ std::cout << "Day set entirely between 22:00 and 06:00.\nPrice is dayrate plus 100% for hours worked. [§6.12B]\n";
+ day_price = dayrate + (day_length * hourly_rate);
+
+ } else if((each_day.call.hours < 6 || each_day.call.hours >= 10) &&
+ (each_day.wrap.hours >= 22 || each_day.wrap.hours <= 10)){
+ if(day_price < dayrate){
+ day_price = dayrate;
+
+ std::cout << "Offset day at least partially set between 22:00 and 06:00.\nMinimum price is full dayrate. [§6.12A]\n";
+ }
+ }
std::cout << "Price of day " << ii+1 << ": " << day_price << std::endl;
total_sum += day_price;
}
diff --git a/src/time.cpp b/src/time.cpp
index f54237f..c71521a 100755
--- a/src/time.cpp
+++ b/src/time.cpp
@@ -192,18 +192,18 @@ workday::workday(const moment& previous_wrap,
timeblock& each_block = blocks[ii];
//std::cout << "pricing: " << timeprint(each_block) << std::endl;
- if(each_block.end <= splitpoints[0]) each_block.upvalue(3); // +200% for sleep-breach
- if(each_block.start.hours >= 22) each_block.upvalue(2); // Work between 22:00
+ if(each_block.end <= splitpoints[0]) each_block.upvalue(3, "Sleep-breach"); // +200% for sleep-breach
+ if(each_block.start.hours >= 22) each_block.upvalue(2, "Night"); // Work between 22:00
if((each_block.end.hours == 6 && each_block.end.minutes == 0) ||// And 06:00
- (each_block.end.hours <= 5)) each_block.upvalue(2); // is +100%
- if(each_block.start >= splitpoints[3]) {each_block.upvalue(1.5); // Overtime
- if(each_block.start.getweekday() == saturday) each_block.upvalue(2);// on saturdays
+ (each_block.end.hours <= 5)) each_block.upvalue(2, "Night"); // is +100%
+ if(each_block.start >= splitpoints[3]) {each_block.upvalue(1.5, "Overtime"); // Overtime
+ if(each_block.start.getweekday() == saturday) each_block.upvalue(2, "Saturday overtime");// on saturdays
}
if(each_block.start >= planned_wraptime && // Unwarned overtime
- each_block.start >= splitpoints[4]) each_block.upvalue(2); // +100% after first hour
- if(each_block.start >= splitpoints[6]) each_block.upvalue(3); // +200% beyond 14-hour mark
- if(each_block.start.getweekday() == saturday) each_block.upvalue(1.5);// Saturdays are +50%
- if(each_block.start.getweekday() == sunday) each_block.upvalue(2); // Sundays are +100%
+ each_block.start >= splitpoints[4]) each_block.upvalue(2, "Overtime"); // +100% after first hour
+ if(each_block.start >= splitpoints[6]) each_block.upvalue(3, "Far overtime"); // +200% beyond 14-hour mark
+ if(each_block.start.getweekday() == saturday) each_block.upvalue(1.5, "Saturday");// Saturdays are +50%
+ if(each_block.start.getweekday() == sunday) each_block.upvalue(2, "Sunday"); // Sundays are +100%
}
}
@@ -267,8 +267,11 @@ double timeblock::hourcount() {
timedelta.days*24);
}
-float timeblock::upvalue(float suggestion){
- if(suggestion>valuefactor) valuefactor = suggestion;
+float timeblock::upvalue(float suggestion, std::string reason){
+ if(suggestion>valuefactor) {
+ valuefactor = suggestion;
+ price_reason = reason;
+ }
return valuefactor;
}
@@ -303,6 +306,7 @@ timeblock timesplit(timeblock& input_block, const moment splitpoint) {
}
timeblock output{input_block.start, splitpoint};
output.valuefactor = input_block.valuefactor;
+ output.price_reason = input_block.price_reason;
input_block.start = splitpoint; // Note: Now, reversed.
return output;
}
diff --git a/src/time.h b/src/time.h
index ba803bd..efade95 100755
--- a/src/time.h
+++ b/src/time.h
@@ -48,7 +48,8 @@ struct timeblock{
moment end;
double hourcount();
float valuefactor = 1;
- float upvalue(float suggestion);
+ float upvalue(float suggestion, std::string reason);
+ std::string price_reason = "Norm";
};
struct workday{