» Online Groceries «

Structure:

I used three .txt files for this project:

  • items.txt contains the list of items in a format item_id,item_name,item_price
57464,Almonds Ground Blanched,2.99
23242,Apricots - Halves,0.89
55222,Artichoke - Fresh,2.39
23750,Bagel - Everything,2.49
12527,Bagelers - Cinn / Brown Sugar,3.99
54452,Bananas,0.79
85123,Bandage - Flexible Neon,3.99
70447,Bar - Sweet And Salty Chocolate,1.99
25669,Bar Nature Valley,1.59
68389,Basil - Fresh,2.89
...
  • customers.txt contains the list of customers in a format customer_id,customer_name,customer_street,customer_city,customer_zip,customer_phone,customer_email
810003,Kai Antonikov,31 Prairie Rose Street,Philadelphia,PA,19196,215-975-7421,kantonikov0@4shared.com
731318,Chic Thunnerclef,2 School Circle,Lexington,KY,40596,859-105-6560,cthunnerclef1@youtube.com
738434,Danna Kingdom,0 Gale Circle,Columbia,SC,29240,803-858-2969,dkingdom2@unicef.org
...
  • orders.txt contains the list of orders:
762212,1,2020-03-15,10951-3,64612-2,57544-1,80145-1,27515-2,16736-1,79758-2,29286-2,51822-3,39096-1,32641-3,63725-3,64007-2,23022-1,16974-3,26860-2,75536-2,26461-1
1,373975319551257,12-2023
258572,2,2020-03-15,96497-1,70616-1,80237-2,22248-2,56107-1,59695-1,37948-3,21316-3,63498-1,18329-1,56833-1,66295-1,47680-3,30346-1
3,81-8822965,55154-4777
857003,3,2020-03-15,16655-1,88019-3,75069-3,96017-2,46883-2,15138-1,77316-1,70063-3,54452-3,86429-2,15134-2,60176-1,12946-3
2,cfeeham3s
...

First line: customer id, order number, order date, and then a variable-length sequence of item_id–quantity pairs.
762212,1,2020-03-15,10951-3,64612-2,57544-1,80145-1,27515-2,16736-1 ...
Second line: contains payment information in the form of payment code, and payment information. There are 3 types of payments:

  • 1 = Credit card (card number and expiration date)
  • 2 = PayPal (paypal_id only)
  • 3 = Wire transfer (bank_id and account_id)
  1,373975319551257,12-2023
  2,cfeeham3s
  3,72-2201515,68196-140

Implementation:

order.py is responsible for collecting items, qty and customer information, and saving it using structure explained above.

Alt text

invoice.py is responsible for creating an organized invoice and saving it to order_report.txt (sorted by order number) using the stored data.

order_report.txt:

Order #1, Date: 2020-03-15
Amount: $100.23, Paid by Credit card 373975319551257, exp. 12-2023

Customer ID #762212
Yolanda McAlarney, ph. 505-136-7715, email: ymcalarney2u@wordpress.com
705 Corscot Hill
Albuquerque, NM 87190

Order Details:
  Item 10951: "Syrup - Monin Swiss Choclate", 3 @ 3.00
  Item 16736: "Wine - Red Cooking", 1 @ 2.00
  Item 16974: "Pastry - Lemon Danish - Mini", 3 @ 1.19
  Item 23022: "Beef - Short Ribs", 1 @ 5.00
  Item 26461: "Bread - Crumbs Bulk", 1 @ 3.00
  Item 26860: "Waffle Stix", 2 @ 2.99
  Item 27515: "Longos - Burritos", 2 @ 4.00
  Item 29286: "Lemonade - Strawberry 591 Ml", 2 @ 2.25
  Item 32641: "Pie Filling - Cherry", 3 @ 0.89
  Item 39096: "Oil - Peanut", 1 @ 0.95
  Item 51822: "Pasta - Rotini Colour Dry", 3 @ 1.19
  Item 57544: "Peach - Halves", 1 @ 0.79
  Item 63725: "Black Currants", 3 @ 0.79
  Item 64007: "Juice - Propel Sport", 2 @ 1.99
  Item 64612: "Pie Shells 10", 2 @ 7.00
  Item 75536: "Quail - Whole Boneless", 2 @ 8.79
  Item 79758: "Beef Flat Iron Steak", 2 @ 5.49
  Item 80145: "Bread - Country Roll", 1 @ 2.29

===========================
Order #2, Date: 2020-03-15
Amount: $74.48, Paid by Credit card 201741963232463, exp. 02-2022

Customer ID #258572
Garey Baraja, ph. 260-560-6065, email: gbaraja5r@fda.gov
42 Kenwood Parkway
Fort Wayne, IN 46862

Order Details:
  Item 18329: "Scallops - In Shell", 1 @ 4.49
  Item 21316: "Tomatoes - Roma", 3 @ 2.50
  Item 22248: "Basil - Seedlings Cookstown", 2 @ 3.89
  Item 30346: "Pasta - Orzo Dry", 1 @ 0.99
  Item 37948: "Shrimp - Black Tiger 16/20", 3 @ 7.60
  Item 47680: "Sandwich Wrap", 3 @ 2.00
  Item 56107: "Numi - Assorted Teas", 1 @ 5.99
  Item 56833: "Jolt Cola", 1 @ 1.29
  Item 59695: "Dr. Pepper - 355ml", 1 @ 1.59
  Item 63498: "Vinegar - Raspberry", 1 @ 1.79
  Item 66295: "Bread - Dark Rye Loaf", 1 @ 2.99
  Item 70616: "Lemonade - Black Cherry 591 Ml", 1 @ 2.89
  Item 80237: "Juice - Orange", 2 @ 2.19
  Item 96497: "Scampi Tail", 1 @ 4.00

===========================
Order #3, Date: 2020-03-15
Amount: $69.47, Paid by PayPal ID: cfeeham3s

Customer ID #857003
Anjela Lippingwell, ph. 404-684-7296, email: alippingwell3s@psu.edu
304 Algoma Road
Gainesville, GA 30506

Order Details:
  Item 12946: "Hagen Daza - Dk Choocolate", 3 @ 5.99
  Item 15134: "Cleaner - Pine Sol", 2 @ 2.39
  Item 15138: "Flour - Rye", 1 @ 4.00
  Item 16655: "Soup - Campbells Chicken Noodle", 1 @ 1.19
  Item 46883: "Sea Bass - Fillets", 2 @ 5.39
  Item 54452: "Bananas", 3 @ 0.79
  Item 60176: "Tomato - Peeled Italian Canned", 1 @ 0.99
  Item 70063: "Carbonated Water - Lemon Lime", 3 @ 0.99
  Item 75069: "Jerusalem Artichoke", 3 @ 4.00
  Item 77316: "Lettuce - Lambs Mash", 1 @ 1.39
  Item 86429: "Sour Cream", 2 @ 2.14
  Item 88019: "Spinach - Spinach Leaf", 3 @ 0.79
  Item 96017: "Rolled Oats", 2 @ 2.19

...