Skip to content

Commit 8466334

Browse files
authored
Merge pull request #8 from god-of-ghz/v1.8
V1.8
2 parents eabdc6e + b8c16c0 commit 8466334

File tree

5 files changed

+636
-86
lines changed

5 files changed

+636
-86
lines changed

QCML Inventory V1.8.4.exe

455 KB
Binary file not shown.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,47 @@ o Lot histories are not saved and are rebuilt each time one is desired
222222
- Added functionality: ‘find’ can now edit a group of materials after the desired list has been generated
223223
o Essentially allows for a ‘mass edit’ feature
224224
- Updated menu heading
225+
226+
V1.8 1/7/2015
227+
- New function! ‘usage’ or ‘monthly’ provides a powder usage history for the current month
228+
o User enters ‘usage’ at the main menu and usage is automatically calculated and exported as a report, similar to ‘lot history’
229+
o Currently only works for the current, cannot be done for a month in the past
230+
- Changed the ‘recent’ function to only clear if 500 entries are made
231+
- Added functionality: editing a group of materials in ‘find’ will now add them to ‘recent’
232+
- Added functionality: listing results in ‘find’ also gives the total weight without having to write a report every time
233+
- Added functionality: searching for materials in ‘find’ will automatically search for partial matches if no complete matches are found
234+
o Partial matches are only searched for during new searches
235+
o Refining a search will not seek partial matches
236+
o A partial match is one where the user input is found as fragment of the actual term, or vice versa.
237+
o Eg. Searching for ‘steel’ would return partial matches for ‘stainless_steel’ ‘maraging_steel’ and ‘chrome_steel’
238+
o Eg. Searching for ‘nickel_iron’ would return partial matches for ‘nickel’ and ‘iron,’ but NOT ‘nickel_steel’ or ‘nickel_chrome’
239+
o One of the terms must appear COMPLETELY in the other to return match
240+
- Updated help menu
241+
- Updated menu heading
242+
- Re-enabled hidden experimental function, used for debugging only
243+
o Accessed via command ‘beta’
244+
- Bug fixes:
245+
o Whenever a date is entered by the user, the program will thoroughly check to be sure it is a valid date in the proper format
246+
o The program will not incorrectly add a material to ‘recent’ if the edit never went through
247+
V1.8.1 2/6/2015
248+
- ‘search’ now displays its results in a neater table format
249+
- Fixed a bug where inventorying a new item and using it in the same month would report no usage
250+
V1.8.2 2/17/2015
251+
- Updated menu heading
252+
- Added functionality: ‘monthly usage’ now prints out the report on the screen as well as writing it to the file
253+
- Added functionality: ‘recent’ now gives a preview of the total weight, instead of having the print the report to see it
254+
- Added functionality: ‘monthly usage’ now tallies up power gained and powder lost in the monthly report, instead of giving just net usage
255+
- Added functionality: whenever a number is entered for a weight, the program checks to ensure it is an actual number before continuing, preventing commands or nonsensical entries accidentally being entered as weights
256+
- Writing any report now puts the written text report in a folder called ‘reports,’ instead of putting them directly in the program’s files
257+
V1.8.3 3/4/2015
258+
- Added functionality: ‘search’ now also adds up the total weight of the powder containers being scanned
259+
o Now only prompts the user to enter a barcode once at the start, instead of each time.
260+
- Updated menu heading
261+
262+
V1.8.4 4/16/2015
263+
- When a contained of powder is edited for weight (meaning the weight has changed) the program will now also automatically mark it as being opened
264+
- Added a hidden command at the main menu “fix_all”
265+
o Runs through the list of powder in inventory
266+
o Any entry with more than 1 instance of history (i.e the weight has ever changed) will be set to ‘1’ or be marked as opened
267+
o Displays the number of entries changed
268+
- Updated menu heading

lots.h

Lines changed: 86 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ using namespace std;
1111
int process_date1(string target); //converts a string date of the form MMDDYYYY to an integer that can be numerically compared
1212
string process_date2(int target); //converts that integer used for comparison back to its original form
1313

14+
1415
class Lots {
1516
string lotID;
1617
vector <int> index_list;
@@ -22,6 +23,9 @@ class Lots {
2223
string own;
2324
string size;
2425

26+
double used;
27+
double gained;
28+
2529
public:
2630
Lots() { return; }
2731
Lots(Materials target);
@@ -53,19 +57,27 @@ class Lots {
5357
string get_own() const { return own; }
5458
string get_size() const { return size; }
5559

60+
double get_usage() const { return used; }
61+
double get_gained() const { return gained; }
62+
5663
vector <int> get_indices() const { return index_list; }
5764
vector <string> get_dates() const { return dates; }
5865
vector <double> get_weights() const { return weights; }
5966

6067
bool is_used(string date);
6168
bool is_used(Materials target, vector <Materials> &thelist);
6269

70+
void usage(string date);
71+
6372
void clear();
6473
void clear_all();
6574

6675

6776
};
6877

78+
bool is_same_month(string target, string a);
79+
bool used_recently(Lots a);
80+
6981
Lots::Lots(Materials target) {
7082
lotID = target.get_lot();
7183
name = target.get_name();
@@ -97,6 +109,7 @@ void Lots::rebuild(vector <Materials> &thelist) {
97109
build_list(thelist);
98110
build_dates(thelist);
99111
build_weights(thelist);
112+
usage(currentDate());
100113
}
101114

102115
void Lots::operator= (const Lots &target) {
@@ -182,19 +195,6 @@ void Lots::build_weights(vector <Materials> &thelist) {
182195
current_date = dates[i];
183196
runsum = 0;
184197
for (int j = 0; j < index_list.size(); j++) {
185-
/*if (thelist[index_list[j]].h_size() > date_index) {
186-
if (thelist[index_list[j]].get_dhist(date_index) == current_date) {
187-
runsum = runsum + stod(thelist[index_list[j]].get_whist(date_index));
188-
}
189-
else {
190-
for (int k = 0; k <= date_index; k++) {
191-
if (process_date1(thelist[index_list[j]].get_dhist(date_index - k)) < process_date1(current_date)) {
192-
runsum = runsum + stod(thelist[index_list[j]].get_whist(date_index - k));
193-
break;
194-
}
195-
}
196-
}
197-
}*/
198198
for (int k = thelist[index_list[j]].h_size() - 1; k >= 0; k--) {
199199
if (process_date1(thelist[index_list[j]].get_dhist(k)) <= process_date1(current_date)) {
200200
runsum = runsum + stod(thelist[index_list[j]].get_whist(k));
@@ -284,6 +284,79 @@ bool Lots::is_used(Materials target, vector <Materials> &thelist) {
284284
return false;
285285
}
286286

287+
void Lots::usage(string date) {
288+
double finish, start;
289+
double previous, next;
290+
double used_runsum = 0;
291+
double gain_runsum = 0;
292+
int index = 0;
293+
if (is_same_month(dates[0], currentDate())) {
294+
previous = 0;
295+
}
296+
else {
297+
for (int i = dates.size() - 1; i >= 0; i--) {
298+
if (!is_same_month(dates[i], currentDate())) {
299+
previous = weights[i];
300+
index = i;
301+
break;
302+
}
303+
}
304+
}
305+
for (int i = index; i < weights.size(); i++) {
306+
next = weights[i];
307+
if (previous <= next) {
308+
gain_runsum = gain_runsum + (next - previous);
309+
}
310+
else {
311+
used_runsum = used_runsum + (previous - next);
312+
}
313+
previous = weights[i];
314+
}
315+
316+
gained = gain_runsum;
317+
used = used_runsum;
318+
}
319+
320+
bool is_same_month(string target, string a) {
321+
string num = "0123456789";
322+
string start = "01";
323+
string end;
324+
string firstofmonth;
325+
string lastofmonth;
326+
string year;
327+
string month;
328+
year.append(a, 4, 4);
329+
month.append(a, 0, 2);
330+
if (a[0] == num[0]) {
331+
if (a[1] == num[1] || a[1] == num[3] || a[1] == num[5] || a[1] == num[7] || a[1] == num[8])
332+
end = "31";
333+
else if (a[1] == num[4] || a[1] == num[6] || a[1] == num[9])
334+
end = "30";
335+
else if (a[1] == num[2]) {
336+
if (stoi(year) % 4 == 0)
337+
end = "29";
338+
else
339+
end = "28";
340+
}
341+
}
342+
else if (a[0] == num[1]) {
343+
if (a[0] == num[0] || a[0] == num[2])
344+
end = "31";
345+
else if (a[0] == num[1])
346+
end = "30";
347+
}
348+
firstofmonth.append(month), lastofmonth.append(month);
349+
firstofmonth.append(start), lastofmonth.append(end);
350+
firstofmonth.append(year), lastofmonth.append(year);
351+
352+
return (process_date1(firstofmonth) <= process_date1(target) && process_date1(target) <= process_date1(lastofmonth));
353+
}
354+
355+
bool used_recently(Lots a) {
356+
return is_same_month(a.get_dates()[a.get_weights().size() - 1], currentDate());
357+
}
358+
359+
287360
void Lots::clear() {
288361
index_list.clear();
289362
dates.clear();

0 commit comments

Comments
 (0)