v2.0
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
import sys
|
||||
import os
|
||||
from utils import load_config, load_json, save_json, get_next_id
|
||||
|
||||
config = load_config()
|
||||
CLIENTS_FILE = os.path.join(config["DataDirectory"], "Clients.json")
|
||||
|
||||
def main():
|
||||
data = load_json(CLIENTS_FILE, {"Clients": []})
|
||||
|
||||
print("\n--- Client Maintenance ---")
|
||||
print("1. Add new client")
|
||||
print("2. Edit existing client")
|
||||
print("3. Deactivate / reactivate a client")
|
||||
print("4. View all clients")
|
||||
|
||||
choice = input("Select an option: ")
|
||||
|
||||
if choice == "1":
|
||||
new_client = {
|
||||
"ClientID": get_next_id("CLT", data["Clients"], "ClientID"),
|
||||
"Name": input("Name: "),
|
||||
"Active": True,
|
||||
"BillingAddress": {
|
||||
"Street1": input("Street1: "),
|
||||
"Street2": input("Street2: "),
|
||||
"City": input("City: "),
|
||||
"State": input("State: "),
|
||||
"PostalCode": input("Postal Code: "),
|
||||
"Country": input("Country: ")
|
||||
},
|
||||
"BillingEmail": input("Billing Email: "),
|
||||
"DefaultRate": float(input("Default Rate: "))
|
||||
}
|
||||
data["Clients"].append(new_client)
|
||||
save_json(CLIENTS_FILE, data)
|
||||
print(f"Added client {new_client['Name']} ({new_client['ClientID']})")
|
||||
|
||||
elif choice == "4":
|
||||
for c in data["Clients"]:
|
||||
status = "Active" if c["Active"] else "Inactive"
|
||||
print(f"[{c['ClientID']}] {c['Name']} - Rate: ${c['DefaultRate']} - {status}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user