CA Use Case of List, Tuple And Dictionary

Post Reply
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

CA Use Case of List, Tuple And Dictionary

Post by admin »

Code: Select all

from datetime import datetime

invoices = [
    {'invoice_id':'INV001', 'due_date':'2025-06-10', 'amount': 50000, 'customer':'A Ltd'},
    {'invoice_id':'INV002', 'due_date':'2025-05-01', 'amount': 120000, 'customer':'B & Co'},
    # ...
]

today = datetime.today()

# Initialize buckets
buckets = {
    '0-30': 0,
    '31-60': 0,
    '61-90': 0,
    '>90': 0
}

# Process each invoice
for inv in invoices:
    due = datetime.strptime(inv['due_date'], '%Y-%m-%d')
    delta_days = (today - due).days
    if delta_days <= 30:
        buckets['0-30'] += inv['amount']
    elif delta_days <= 60:
        buckets['31-60'] += inv['amount']
    elif delta_days <= 90:
        buckets['61-90'] += inv['amount']
    else:
        buckets['>90'] += inv['amount']

# Identify top 5 overdue customers (> 30 days)
overdue = [inv for inv in invoices if (today - datetime.strptime(inv['due_date'], '%Y-%m-%d')).days > 30]
# Sort by amount descending
overdue_sorted = sorted(overdue, key=lambda x: x['amount'], reverse=True)
top5 = overdue_sorted[:5]

print("Aging buckets:", buckets)
print("Top 5 overdue customers:", top5)
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: CA Use Case of List, Tuple And Dictionary - Preparation of Trial balance

Post by admin »

Code: Select all

transactions = [
    {"date":"2025-04-01", "account":"Cash", "debit":10000, "credit":0},
    {"date":"2025-04-02", "account":"Rent", "debit":5000, "credit":0},
    {"date":"2025-04-03", "account":"Cash", "debit":0, "credit":2000},
]

# Trial balance (closing)
trial_balance = {}
for t in transactions:
    acc = t["account"]
    trial_balance[acc] = trial_balance.get(acc, 0) + t["debit"] - t["credit"]

print("Trial Balance:", trial_balance)
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: GST Use Case

Post by admin »

Code: Select all

invoices = [
    {"gstin":"27ABCDE1234F1Z5", "amount":50000, "type":"B2B"},
    {"gstin":"29XYZ9876L2Z7", "amount":12000, "type":"Exempt"},
    {"gstin":"27LMN5432K1Z9", "amount":8000, "type":"B2B"},
]

# Compute taxable turnover
taxable = [inv["amount"] for inv in invoices if inv["type"]=="B2B"]
print("Total Taxable Turnover:", sum(taxable))
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: Budgetting Use Case

Post by admin »

Code: Select all

cash_inflows = [100000, 120000, 110000, 90000]
cash_outflows = [80000, 95000, 105000, 88000]

net_flows = [inflows - outflows for inflows, outflows in zip(cash_inflows, cash_outflows)]
print("Net Monthly Cash Flows:", net_flows)
print("Q1 Flow:", sum(net_flows[:3]))
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re:Auditing Use Case

Post by admin »

Code: Select all

import random

vouchers = [f"VCH{i}" for i in range(1, 101)]  # 100 vouchers
sample = random.sample(vouchers, 10)  # select 10 random vouchers
print("Audit Sample:", sample)
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: Ratio Analysis Use case

Post by admin »

Code: Select all

profits = [50000, 60000, 55000, 70000, 80000]
sales   = [200000, 250000, 240000, 280000, 300000]

# Net Profit Margin
npm = [round(p/s*100,2) for p,s in zip(profits, sales)]
print("Net Profit Margin (5 years):", npm)
print("Last 3 years:", npm[-3:])
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: Depreciation Use case

Post by admin »

Code: Select all

cost = 500000
life = 5
rate = 0.2  # 20% WDV

# Depreciation values per year
depreciation = [round(cost * (rate**i) - cost * (rate**(i+1)), 2) for i in range(life)]
book_values = [cost - sum(depreciation[:i+1]) for i in range(life)]

print("Depreciation per year:", depreciation)
print("Book values:", book_values)
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: Costing

Post by admin »

Code: Select all

fixed_cost = 200000
variable_cost_per_unit = 50
price_per_unit = 100

units = [1000, 2000, 3000, 4000, 5000]
profits = [u * (price_per_unit - variable_cost_per_unit) - fixed_cost for u in units]

print("Units:", units)
print("Profits:", profits)
admin
Site Admin
Posts: 119
Joined: Fri May 10, 2024 2:46 pm
Location:

Re: Company Law Use case

Post by admin »

Code: Select all

promoter = [60000, 62000, 61000]
public = [40000, 38000, 39000]

total = [p+q for p,q in zip(promoter, public)]
promoter_pct = [round(p/t*100,2) for p,t in zip(promoter, total)]

print("Promoter % over years:", promoter_pct)
Post Reply