From bc9769a2df44c45c9c4adc110c68ac8af2d115da Mon Sep 17 00:00:00 2001 From: Wind-Explorer Date: Fri, 25 Sep 2026 15:08:27 +0800 Subject: [PATCH] add inventory loading --- .DS_Store | Bin 0 -> 6148 bytes log.txt | 35 ++++++++++++++++++++ persist_auditor.py | 64 +++++++++++++++++++++++++++++++++++++ persistent_auditor.py | 72 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 .DS_Store create mode 100644 log.txt create mode 100644 persist_auditor.py create mode 100644 persistent_auditor.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0812991f2078603e5c1350d6e97c87b0d2d32404 GIT binary patch literal 6148 zcmeHK!A=4(5Pd}s7%v<-_6HErNaAgSXktRpgy>n26-_`0EE+xSr~78wfCN40!4NV- zI&NxI$+m+K6pbK%QL% z$7tXPC-kf5cZoWG!dB5n4}C@*;sei^PP2Y{G0$eqoui9)`V1+?sNoJ1jIdxoC0j#_ znHgIRx4cdKPmGf{YBeK|8{VH_NZ(_vam@6L zS?I{ZrtC@W5o>x#&5UDt&MCz!u31H97}n;wx|)vi_+{NAX7@GfZz^@7O21Zk8($Th zlPO>d?2rQ7v&BjW0nM8NrhqB1R6xEDo=q@`mVVL`xuu*%mapWIIYZaVr3UkC{C-B_ZkkD1T=37m;&nx?1js+?Ee=( zpa0jB?8+1{1$IgSS8R1#O)e?!ts9Gzz1Fkcvx!Mu9&nk$j&8+_m94nKrbgaNhnPgn S1CpWH9|4uYoGI|H3VZ@?HBM&$ literal 0 HcmV?d00001 diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..f46dc65 --- /dev/null +++ b/log.txt @@ -0,0 +1,35 @@ +commit 08da4605172acdebe2d143f3119b2fc494e9ec9c +Author: Wind-Explorer +Date: Fri Sep 18 14:40:12 2026 +0800 + + update screenshots + +commit ee697ecd0817cd3844d20091c5d82a76609da6c6 +Author: Wind-Explorer +Date: Fri Sep 18 14:35:08 2026 +0800 + + added modular_auditor.py and updated Dockerfile to use new script + +commit 4bae2ce67d91a3ddf003a7e02694b4ee65d97ea9 +Author: Wind-Explorer +Date: Fri Sep 11 14:20:20 2026 +0800 + + added README with repo link + +commit 692dad6849e6a93c95b23470500e0ec658674e3e +Author: Wind-Explorer +Date: Fri Sep 11 12:34:59 2026 +0800 + + add screenshots + +commit 6fb9105403e08e35766978c7d554c16525382e49 +Author: Wind-Explorer +Date: Fri Sep 11 12:34:27 2026 +0800 + + add dockerfile + +commit 721ad431270886cb85748935e65b90de04001286 +Author: Wind-Explorer +Date: Fri Sep 11 12:21:09 2026 +0800 + + init diff --git a/persist_auditor.py b/persist_auditor.py new file mode 100644 index 0000000..13efc1b --- /dev/null +++ b/persist_auditor.py @@ -0,0 +1,64 @@ +def get_valid_input(): + global failed_attempts + + while True: + user_input = input("Enter stock quantity: ").strip() + + if user_input.lower() == "quit": + return "quit" + + if not user_input.isdigit(): + print("Error: Invalid input. Please enter a non-negative integer.\n") + failed_attempts += 1 + continue + + quantity = int(user_input) + + if quantity < 0: + print("Error: Negative numbers are not allowed.\n") + failed_attempts += 1 + continue + + return quantity + + +def process_delivery(current_total, new_value): + return current_total + new_value + + +def calculate_tax(amount): + return amount * 0.10 + + +def generate_report(total_units, failed_attempts): + print("\n--- Audit Report ---") + print(f"Total Units Processed: {total_units}") + print(f"Failed/Rejected Entries: {failed_attempts}") + + +inventory = 0 +total_units = 0 +failed_attempts = 0 + +print("=== Stock Auditor ===") +print("Type 'quit' to exit.\n") + +while True: + quantity = get_valid_input() + + if quantity == "quit": + break + + tax = calculate_tax(quantity) + + inventory = process_delivery(inventory, quantity) + total_units = process_delivery(total_units, quantity) + + print(f"Stock added. Current inventory: {inventory}") + print(f"Tax on this delivery: ${tax:.2f}\n") + + if inventory > 500: + print(f"ALERT: Overstock detected! Inventory ({inventory}) exceeds 500 units.") + break + +generate_report(total_units, failed_attempts) diff --git a/persistent_auditor.py b/persistent_auditor.py new file mode 100644 index 0000000..6cde9f9 --- /dev/null +++ b/persistent_auditor.py @@ -0,0 +1,72 @@ +def get_valid_input(): + global failed_attempts + + while True: + user_input = input("Enter stock quantity: ").strip() + + if user_input.lower() == "quit": + return "quit" + + if not user_input.isdigit(): + print("Error: Invalid input. Please enter a non-negative integer.\n") + failed_attempts += 1 + continue + + quantity = int(user_input) + + if quantity < 0: + print("Error: Negative numbers are not allowed.\n") + failed_attempts += 1 + continue + + return quantity + + +def process_delivery(current_total, new_value): + return current_total + new_value + + +def calculate_tax(amount): + return amount * 0.10 + + +def generate_report(total_units, failed_attempts): + print("\n--- Audit Report ---") + print(f"Total Units Processed: {total_units}") + print(f"Failed/Rejected Entries: {failed_attempts}") + + +def load_inventory(): + try: + with open("inventory.txt", "r") as inventory_file: + return int(inventory_file.readline().strip()) + except FileNotFoundError: + return 0 + + +inventory = load_inventory() +total_units = 0 +failed_attempts = 0 + +print("=== Stock Auditor ===") +print("Type 'quit' to exit.\n") + +while True: + quantity = get_valid_input() + + if quantity == "quit": + break + + tax = calculate_tax(quantity) + + inventory = process_delivery(inventory, quantity) + total_units = process_delivery(total_units, quantity) + + print(f"Stock added. Current inventory: {inventory}") + print(f"Tax on this delivery: ${tax:.2f}\n") + + if inventory > 500: + print(f"ALERT: Overstock detected! Inventory ({inventory}) exceeds 500 units.") + break + +generate_report(total_units, failed_attempts)