Does anyone knows how to do this program in python?

Sales & Inventory Program

Create your Own Sales & Inventory Design Program

  1. Put yourself as an IT developer and you are hired by a business or company to create a sales & inventory program for their business
  2. The business or company has atleast three (3) products
  3. Your program must record all the sales transaction of the business
  4. Every sales transaction must have a receipt and it is also recorded or stored in a file
  5. The Inventory System able to generate the Sales & Inventory Report

Legend:

  • Products – see list of products
  • Sale – Selling of product to the customer and generation of receipt
  • Sales Report – see list of sales including total sales of each product
  • Inventory Report – see the previous stock available of each product and the current stock after sales
  • Exit – exit from the Sales & Inventory Program

Below is a sample Sales & Inventory Program

ABC Company

1 – Products

2 – Sale

3 – Sales Report

4 – Inventory Report

5 – Exit

Enter your choice:

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

2 Likes

thank you for the reply mr. sky sorry for asking too much about this program i’m strugling with our last activity in school.

What have you tried so far? Where are you stuck?

1 Like

You got a nice list of features there, so it’s a straightforward thing to do.

Don’t get discouraged by the amount of text, but just ask yourself, what different tasks the program is supposed to do in what order.
Then you’ll notice what information you need to provide beforehand (like making a list of sample-products → which the text said should have at least 3 entries).
Next question is what the output of the tasks should look alike (somewhat provided in the Legend).

You got a menu with 5 tasks, which hints at 5 functions that can be called.
Depending if you are making a GUI or a pure console-application, you gotta think about design further. If not, it’s mostly about turning the big project into it’s logical parts and then build those and then later combine them into the big project.

Kinda like building something with lego: regardless of how big some result may be -what you are actually doing a lot of little steps.

1 Like

Thank you for the encouragement Mr.Jagaya I will do my best to finish this school activity and try to sync in what you said you gave me enlightenment.

thank you for asking Mr. Jeremy i’ve got stuck but now I’ve got back to track. I hope you could add some suggestions to my code.

class Products:
    @staticmethod
    def DisplayProduct():
        product = ["Beer", "Snacks", "Foods\n"]
        print("\n=====Products=====")
        for x in product:
            print(x)


class Sales:
    @staticmethod
    def Product():
        print("""\t=====PRODUCTS=====
    1 - Beer (P1000)
    2 - Snacks (P500)
    3 - Foods (2000)""")
        print("\t==================")
        item = input("\nWhich one would you like to buy? Enter you choice here: ")
        productsold = "1"
        productprice = "1"
        if item == "1":
            productsold = "Beer/s"
            productprice = "1000"
        elif item == "2":
            productsold = "Snacks"
            productprice = "500"
        elif item == "3":
            productsold = "Foods"
            productprice = "2000"
        quantity = int(input("How many would you like to buy? Enter here: "))
        print("\nThank you! Here's your Receipt!")
        price_total = int(productprice) * int(quantity)
        print("SOLD " + str(quantity) + " " + str(productsold) + " for " + str(price_total) + "\n")

        sr = open("SalesReport.txt", "a")
        sr.write("\n" + str(productsold) + " \t\t " + str(quantity))
        sr.close()

        ir = open("InventoryReport.txt", "a")
        ir.write("\nDeduct " + str(quantity) + " stocks from " + str(productsold))


class SalesReport:
    @staticmethod
    def List():
        sr = open("SalesReport.txt", "r")
        print("\n")
        for x in sr:
            print(x, end = '')
        sr.close()
        print("\n")


class InventoryReport:
    @staticmethod
    def InvList():
        ir = open("InventoryReport.txt", "r")
        print("\n")
        for x in ir:
            print(x, end='')
        ir.close()
        print("\n")


Repeat = 1
while Repeat:
    print("""
    "=========ABC Company========="
    1 - PRODUCTS
    2 - SALES
    3 - SALES REPORT
    4 - INVENTORY REPORT
    5 - EXIT
    """)
    choice = input("\nEnter your choice: ")

    if choice == "1":
        Products.DisplayProduct()
    elif choice == "2":
        Sales.Product()
    elif choice == "3":
        SalesReport.List()
    elif choice == "4":
        InventoryReport.InvList()
    elif choice == "5":
        print("\nThank You For Choosing ABC Company, See You Again")
        Repeat = 0
    else:
        print("Sorry Your choice is out of stock. Please Choose again: ")
        break

On a quick glance, it looks good :wink:
Though keep in mind, this is a program for a fictional company → that company doesn’t want to fiddle with the code, that was your job. So the Sales-dialoge must be completly self-sufficient. Right now the company would need to edit it in case their product or prices change.

In reality, the company would have a database with products, prices, maybe taxes and other special additions → the program would read those out and build the entire sales-dialoge itself. Now for your task, it could be enough to create a data-structure containing the 3 products with their prices. Point is, when writing a program, the less places there are that might need editing later, the better.

Imagine the company has not only 3 product, but 3000 → right now this would add almost 9000 lines into your sales in addition to writing all of them into the Products-Class. And it seems like you wrote “Foods\n” as a product. Just, don’t. If you want a linebreak at the end of the output, add a print() at the end of the loop. It’s the purpose of the output-generater to generate the output - not of the inputs.

1 Like

Thank you for response Mr. Jagaya , I think I understand what you mean,
I will try to do some experiments by following your instructions. Thanks a lot.

Hello there,

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

2 Likes

Copy Mr. Sky sorry for the trouble I’ll take note of it.