/* satscalc - software to help with billing for Norwegian film workers Copyright (C) 2022 Sander Skjegstad This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/ */ // TODO: Add ruleset selector (That only allows you to pick the advert ruleset at first) #include #include "time.h" #include "test.h" #define CLEAR "\033[2J\033[1;1H"; int main(int argc, char* argv[]) { if(argc > 1){ if(std::string(argv[1])=="test") { test(); // Test time-stuff } } else { std::cout << "satscalc (C++ Edition)\n"; std::cout << "Copyright 2022 Sander J. Skjegstad.\n"; std::cout << "This is free software with ABSOLUTELY NO WARRENTY.\n"; std::cout << "It does NOT give financial advice.\n\n"; std::cout << "-----\nStep 0: Setting the dayrate\n\n"; int dayrate; std::cout << "Dayrate: "; std::cin >> dayrate; std::cin.ignore(); long double hourly_rate = dayrate/7.5; std::cout << "Hourly rate: " << hourly_rate << "\n\n"; std::cout << "How many days do you want to enter? "; int number_of_days; std::cin >> number_of_days; std::cin.ignore(); 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 workdays; moment previous_wrap{0, 16, 20, 11, 1000}; // Set to a long time ago for(int day=0; day> input_char; std::cin.ignore(); std::cout << "\n"; switch (input_char) { case '0': goto done; case 'c': std::cout << "Changing calltime.\n"; calltime = timeinput(); break; case 'w': std::cout << "Changing actual wraptime.\n"; wraptime = timeinput(calltime); break; case 'p': std::cout << "Changing planned wraptime.\n"; planned_wraptime = timeinput(calltime); break; case 'l': std::cout << "Changing lunch-time.\n"; std::cout << "Lunch start:\n"; lunch_start = timeinput(calltime); std::cout << "Lunch end:\n"; lunch_end = timeinput(calltime); break; default: std::cout << "ERROR: That's not a valid number, ya doofus." << std::endl; } } done: workdays.push_back({previous_wrap, calltime, wraptime, planned_wraptime}); if(lunch_start != lunch_end) workdays[day].lunch(lunch_start, lunch_end); workday* current_workday = &workdays[day]; std::cout << "\nCalltime: " << timeprint(current_workday->call) << "\n"; std::cout << "Wraptime: " << timeprint(current_workday->wrap) << "\n"; std::cout << "Planned wrap: " << timeprint(current_workday->planned_wrap) << "\n\n"; for(int i=0; itotal_timeblocks; i++) { std::cout << "Timeblock " << i << ": " << timeprint(current_workday->blocks[i]) << ". Total hours: " << current_workday->blocks[i].hourcount() << "\t Valuefactor: " << current_workday->blocks[i].valuefactor << std::endl; } // This assumes that the user is entering things chronologically, which they may not be previous_wrap = wraptime; 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++) { workday& each_day = workdays[ii]; double day_price = 0; std::cout << "\n ----- Day " << ii+1 << ": " << timeprint(each_day.call, false) << " ----- " << "\n"; 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"; day_price += block_price; } std::cout << "Price of day " << ii+1 << ": " << day_price << std::endl; total_sum += day_price; } std::cout << "\nSum: " << total_sum; std::cout << "\nTotal: " << total_sum*social_costs << std::endl; return 0; } }