Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Adarsh275/PetrolPump-Management-System/llms.txt

Use this file to discover all available pages before exploring further.

Invoices record each fuel sale transaction, capturing the customer, fuel type, volume, payment method, any discount applied, and the total price charged. Every invoice is identified by a unique Invoice_No and optionally links to a customer record via the Customer_Code foreign key, enabling a complete per-customer purchase history. The Date field also acts as a foreign key to the Sales table, correlating invoices with nozzle-level sales shift data.

Invoice Fields

Invoice_No
varchar(10)
required
Primary key. A unique alphanumeric identifier for the invoice. Example: "XC34".
Date
date
required
Date on which the fuel sale took place. Also used as a foreign key to Sales.Date.
Payment_Type
varchar(20)
required
Method of payment used for the transaction. Common values: "Cash", "UPI", "Credit Card", "Debit Card".
Fuel_Amount
float(15)
Volume of fuel dispensed, measured in litres.
Fuel_Type
varchar(15)
Type of fuel purchased. Known values in the system: "PetrolE10", "Diesel", "CNG", "Gasoline91", "Kerosene".
Discount
int(5)
Percentage discount applied to the sale, if any. NULL indicates no discount was applied.
Total_Price
float(10)
required
Final amount charged to the customer in Indian Rupees (₹), after any discount is applied.
Customer_Code
varchar(10)
Foreign key referencing Customer.Customer_Code. Links the invoice to a specific customer. May be NULL for anonymous sales.

Add an Invoice

1

Open the Invoice table

In the left sidebar, select Invoice from the Tables dropdown.
2

Choose the Add operation

Select Add from the CRUD Operations dropdown.
3

Fill in the invoice form

Complete all fields in the form:
  • Invoice_No — unique identifier (e.g. XC34)
  • Date — sale date (date picker)
  • Payment_Type — payment method (e.g. UPI)
  • Fuel_Amount — litres dispensed (numeric)
  • Fuel_Type — fuel product name (e.g. Diesel)
  • Discount — discount percentage (numeric; enter 0 for none)
  • Total_Price — final charged amount in ₹ (numeric)
  • Customer_Code — linked customer code (e.g. SFG252)
4

Submit the record

Click Add Invoice Details. A success banner confirms the new Invoice_No.
The UI function that collects the form inputs (create.py):
def create_for_Invoice():
    with st.container():
        Invoice_No    = st.text_input(" Invoice_No:")
        Date          = st.date_input("Date:")
        Payment_Type  = st.text_input("Payment_Type:")
        Fuel_Amount   = st.number_input("Fuel_Amount:")
        Fuel_Type     = st.text_input("Fuel_Type:")
        Discount      = st.number_input("Discount:")
        Total_Price   = st.number_input("Total_Price:")
        Customer_Code = st.text_input("Customer_Code:")

    if st.button("Add Invoice Details"):
        add_Invoice_data(
            Invoice_No, Date, Payment_Type, Fuel_Amount,
            Fuel_Type, Discount, Total_Price, Customer_Code
        )
        st.success("Successfully added Invoice details: {}".format(Invoice_No))
The underlying INSERT statement executed by add_Invoice_data() in database.py:
INSERT INTO Invoice
  (Invoice_No, Date, Payment_Type, Fuel_Amount,
   Fuel_Type, Discount, Total_Price, Customer_Code)
VALUES
  (%s, %s, %s, %s, %s, %s, %s, %s);

View Invoices

1

Open the Invoice table

In the sidebar, select InvoiceView.
2

Expand the data panel

Click the View all Invoices expander to reveal the full DataFrame.
The read_for_Invoice() function in read.py fetches all rows and renders them as a DataFrame with all eight columns:
def read_for_Invoice():
    result = view_all_Invoice_data()
    df = pd.DataFrame(result, columns=[
        'Invoice_No', 'Date', 'Payment_Type', 'Fuel_Amount',
        'Fuel_Type', 'Discount', 'Total_Price', 'Customer_Code'
    ])
    with st.expander("View all Invoices"):
        st.dataframe(df)

Update an Invoice

1

Open the Update screen

In the sidebar, select InvoiceUpdate.
2

Choose the invoice to edit

The current records are shown in the Current Invoice details expander. Select the target invoice from the Invoice to Edit dropdown, which is populated with all existing Invoice_No values.
3

Edit the mutable fields

The form pre-fills with the selected invoice’s current values. Modify any of the following:
  • Date
  • Payment_Type
  • Fuel_Amount
  • Fuel_Type
  • Discount
  • Total_Price
  • Customer_Code
4

Save changes

Click Update Invoice. The updated table is shown in the Updated data expander.
Invoice_No is the primary key and is not editable through the UI. To change an invoice number, delete the existing record and create a new one.
The UPDATE statement executed by edit_Invoice_data() in database.py:
UPDATE Invoice
SET
    Date          = %s,
    Payment_Type  = %s,
    Fuel_Amount   = %s,
    Fuel_Type     = %s,
    Discount      = %s,
    Total_Price   = %s,
    Customer_Code = %s
WHERE Invoice_No = %s;

Delete an Invoice

1

Open the Remove screen

In the sidebar, select InvoiceRemove.
2

Select the invoice

Choose the Invoice_No of the invoice to remove from the Invoices to delete dropdown. A warning banner will display the selected invoice number for confirmation.
3

Confirm deletion

Click Delete Invoice. A success message reads “transaction has been deleted successfully” and the record is removed.
The DELETE statement executed by delete_data_Invoice() in database.py:
DELETE FROM Invoice
WHERE Invoice_No = "<selected_Invoice_No>";
Deleting an invoice does not delete the related Customer record or any Sales records. The Customer referenced by Customer_Code and any Sales row sharing the same Date remain entirely unaffected.

Seed / Sample Data

The following five invoice records are inserted by create_table.sql as the initial dataset:
INSERT INTO `Invoice`
  (`Invoice_No`, `Date`, `Payment_Type`, `Fuel_Amount`,
   `Fuel_Type`, `Discount`, `Total_Price`, `Customer_Code`)
VALUES
  ('XC34', '2022-11-20', 'Cash',        7.0,  'PetrolE10',  10,   640.83,  'BFR426'),
  ('NR43', '2022-11-20', 'UPI',         5.4,  'Gasoline91', NULL, 578.07,  'GHE785'),
  ('MN34', '2020-06-30', 'Credit Card', 15.8, 'Diesel',     7.5,  1284.51, 'OUI325'),
  ('FG43', '2022-10-27', 'UPI',         4.9,  'Gasoline91', 5,    498.32,  'SFG252'),
  ('DS85', '2019-08-19', 'Debit Card',  6.8,  'Diesel',     NULL, 597.65,  'OUI325');

Payment Types Reference

The following payment types appear in the seed data and are supported by the system:
  • Cash — direct cash payment at the pump
  • UPI — Unified Payments Interface (e.g. GPay, PhonePe, Paytm)
  • Credit Card — credit card transaction
  • Debit Card — debit card transaction

Fuel Types Reference

The following fuel product names appear in the seed data and are accepted values for Fuel_Type:
  • PetrolE10 — 10 % ethanol-blended petrol
  • Diesel — standard diesel
  • CNG — Compressed Natural Gas
  • Gasoline91 — 91-octane petrol / gasoline
  • Kerosene — kerosene / paraffin

Build docs developers (and LLMs) love