aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSan Jacobs2022-08-05 12:05:07 +0200
committerSan Jacobs2022-08-05 12:05:07 +0200
commit8b0058d1de2865f47d627215d315bd639ed37fb7 (patch)
treedf83b70ffb49d03dfe74788ccf9874f3260b514a
parent9a3c815b176598ed463a88f42dc6a5f8c6457d50 (diff)
downloadsatscalc-8b0058d1de2865f47d627215d315bd639ed37fb7.tar.gz
satscalc-8b0058d1de2865f47d627215d315bd639ed37fb7.tar.bz2
satscalc-8b0058d1de2865f47d627215d315bd639ed37fb7.zip
More beautiful menus, added social costs
-rwxr-xr-xsrc/main.cpp102
-rwxr-xr-xsrc/time.cpp7
-rwxr-xr-xtest.sh29
3 files changed, 95 insertions, 43 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d1c9080..72e4df0 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,8 @@ along with this program. If not, see https://www.gnu.org/licenses/
#include "time.h"
#include "test.h"
+#define CLEAR "\033[2J\033[1;1H";
+
int main(int argc, char* argv[])
{
if(argc > 1){
@@ -36,23 +38,73 @@ int main(int argc, char* argv[])
std::cout << "-----\nStep 0: Setting the dayrate\n\n";
- int dayrate_input;
+ int dayrate;
std::cout << "Dayrate: ";
- std::cin >> dayrate_input;
+ std::cin >> dayrate;
std::cin.ignore();
- const int dayrate = dayrate_input;
- const double hourly_rate = dayrate/7.5;
+ long double hourly_rate = dayrate/7.5;
std::cout << "Hourly rate: " << hourly_rate << "\n\n";
- std::cout << "-----\nStep 1: Adding the days\n\n";
-
std::cout << "How many days do you want to enter? ";
int number_of_days;
std::cin >> number_of_days;
std::cin.ignore();
- //number_of_days = 1; // Just here for debugging
delta default_daylength{0, 8, 0};
+ long double social_costs = 1.26;
+
+ while(1) {
+ std::cout << CLEAR;
+ std::cout << "\n------------- Setup and defaults -------------\n";
+ std::cout << "[d] Dayrate: " << dayrate << " (" << hourly_rate << " hourly)\n";
+ std::cout << "[w] Workdays to input: " << number_of_days << "\n";
+ std::cout << "[l] Default length of workday: " << default_daylength.hours << "h\n";
+ std::cout << "[s] Social costs: " << (social_costs-1)*100 << "%\n";
+ //std::cout << "[l] Lunch: " << timeprint((timeblock){lunch_start, lunch_end}) << "\n" << std::endl;
+
+ std::cout << "\nWrite the letter for what you want to change, or 0 to continue." << std::endl;
+
+ char input_char = '5';
+ std::cin >> input_char;
+ std::cin.ignore();
+
+ std::cout << "\n";
+ switch (input_char) {
+ case '0':
+ goto setup_done;
+ case 'd':
+ std::cout << "Changing dayrate.\nDayrate: ";
+ std::cin >> dayrate;
+ std::cin.ignore();
+ hourly_rate = dayrate/7.5;
+ break;
+ case 'w':
+ std::cout << "Changing number of workdays.\nDays: ";
+ std::cin >> number_of_days;
+ std::cin.ignore();
+ break;
+ case 'l':
+ std::cout << "Changing default workday length:\nHours: ";
+ std::cin >> default_daylength.hours;
+ std::cin.ignore();
+ break;
+ case 's':
+ {
+ std::cout << "Changing social cost percentage:\nSocial cost %";
+ int social_input = 0;
+ std::cin >> social_input;
+ std::cin.ignore();
+ social_costs = (social_input+100.0f)/100.0f;
+ break;
+ }
+ default:
+ std::cout << "ERROR: That's not a valid char, ya doofus." << std::endl;
+ }
+ }
+setup_done:
+ std::cout << CLEAR;
+
+ //number_of_days = 1; // Just here for debugging
std::vector<workday> workdays;
moment previous_wrap{0, 16, 20, 11, 1000}; // Set to a long time ago
@@ -71,37 +123,37 @@ int main(int argc, char* argv[])
moment lunch_end = lunch_start+(delta){30,0,0};
while(1) {
- std::cout << "\033[2J\033[1;1H";
+ std::cout << CLEAR;
std::cout << "\n------------- DAY " << day+1 << " -------------\n";
- std::cout << "[1] Calltime: " << timeprint(calltime) << "\n";
- std::cout << "[2] Wraptime: " << timeprint(wraptime) << "\n";
- std::cout << "[3] Planned wrap: " << timeprint(planned_wraptime) << "\n";
- std::cout << "[4] Lunch: " << timeprint((timeblock){lunch_start, lunch_end}) << "\n" << std::endl;
+ std::cout << "[c] Calltime: " << timeprint(calltime) << "\n";
+ std::cout << "[w] Wraptime: " << timeprint(wraptime) << "\n";
+ std::cout << "[p] Planned wrap: " << timeprint(planned_wraptime) << "\n";
+ std::cout << "[l] Lunch: " << timeprint((timeblock){lunch_start, lunch_end}) << "\n";
// TODO: Add second lunch option
- std::cout << "Write the number for what you want to change, or 0 to go to the next day." << std::endl;
+ std::cout << "\nWrite the letter for what you want to change, or 0 to go to the next day." << std::endl;
- int input_number = 8;
- std::cin >> input_number;
+ char input_char = '5';
+ std::cin >> input_char;
std::cin.ignore();
std::cout << "\n";
- switch (input_number) {
- case 0:
+ switch (input_char) {
+ case '0':
goto done;
- case 1:
+ case 'c':
std::cout << "Changing calltime.\n";
calltime = timeinput();
break;
- case 2:
+ case 'w':
std::cout << "Changing actual wraptime.\n";
wraptime = timeinput(calltime);
break;
- case 3:
+ case 'p':
std::cout << "Changing planned wraptime.\n";
planned_wraptime = timeinput(calltime);
break;
- case 4:
+ case 'l':
std::cout << "Changing lunch-time.\n";
std::cout << "Lunch start:\n";
lunch_start = timeinput(calltime);
@@ -109,7 +161,7 @@ int main(int argc, char* argv[])
lunch_end = timeinput(calltime);
break;
default:
- std::cout << "ERROR: That's not a valid number, ya doofus. 1, 2, 3, 4 or 0 only." << std::endl;
+ std::cout << "ERROR: That's not a valid number, ya doofus." << std::endl;
}
}
done:
@@ -135,11 +187,12 @@ done:
// This assumes that the user is entering things chronologically, which they may not be
previous_wrap = wraptime;
- std::cout << "\033[2J\033[1;1H";
+ std::cout << CLEAR;
}
std::cout << "\n\n\n -+-+-+-+-+-+-+- CALCULATION -+-+-+-+-+-+-+-\n\n";
std::cout << "Dayrate: " << dayrate << "\n";
std::cout << "Hourly rate: " << hourly_rate << "\n";
+ std::cout << "Social costs: " << (social_costs-1)*100 << "%\n";
double total_sum = 0;
for(int ii=0; ii < number_of_days; ii++) {
@@ -157,7 +210,8 @@ done:
total_sum += day_price;
}
- std::cout << "\nSUM: " << total_sum << std::endl;
+ std::cout << "\nSum: " << total_sum;
+ std::cout << "\nTotal: " << total_sum*social_costs << std::endl;
return 0;
diff --git a/src/time.cpp b/src/time.cpp
index 11b4336..6d1401d 100755
--- a/src/time.cpp
+++ b/src/time.cpp
@@ -176,21 +176,16 @@ workday::workday(const moment& previous_wrap,
}
}
- //std::cout << "Splitting finished." << std::endl;
-
blocks[j++] = initial_block;
total_timeblocks = j;
- //std::cout << "Splitting completely finished." << std::endl;
-
// THE VALUE-FACTOR CALCULATION PART
// TODO: Complete the valuefactor calculation ruleset
// Including, Easter and other holidays
// TODO: Implement a good system for this fuckin' paragraph:
// A. 50 % tillegg for arbeid inntil 2 timer før, eller inntil 3 timer etter ordinær arbeidstid når arbeidstiden ikke er forskjøvet og overtiden er varslet. Dersom det varsles overtid både før og etter ordinær arbeidstid betales de to første timene med 50 % tillegg og de øvrige med 100 % tillegg.
- // TODO: And this paragraph, which seems to say that planned being beyond actual wrap is a relevant case
- // Varslet overtid som ikke benyttes honoreres med inntil to timer etter de vanlige overtidssatser, dog slik at én time av den ubenyttede overtiden ikke honoreres.
+
// TODO: Add reasons for the upped valuefactors.
for(int ii=0; ii < total_timeblocks; ii++){
diff --git a/test.sh b/test.sh
index cc66393..f0dd92e 100755
--- a/test.sh
+++ b/test.sh
@@ -1,42 +1,45 @@
./a.out <<EOF-MARKER
3338
-7
+8
+0
+2022 10 10 08 00
+0
2022 10 18 08 00
-2
+w
10 00
-3
+p
10 00
0
2022 10 20 08 00
-2
+w
19 00
-3
+p
18 00
0
2022 10 22 08 00
-3
+p
18 30
0
2022 10 23 08 00
-3
+p
19 30
0
2022 11 20 08 00
-2
+w
03 30
-3
+p
19 45
0
2022 11 21 08 00
-2
+w
19 30
-3
+p
19 00
0
2022 11 23 14 00
-2
+w
23 30
-3
+p
23 00
0
EOF-MARKER