Untitled

 avatar
unknown
plain_text
2 years ago
2.4 kB
4
Indexable
import docx

# Create a new Word document
document = docx.Document()

# Define account balances
cash = 286000
accounts_receivable = 15000
office_supplies = 7500
furniture_and_fixtures = 25000
equipment = 35000
accounts_payable = 7500
notes_payable = 60000
dr_who_capital = 250000
dr_who_drawing = 5000

# Calculate total assets
total_assets = cash + accounts_receivable + office_supplies + furniture_and_fixtures + equipment

# Calculate total liabilities and equity
total_liabilities = accounts_payable + notes_payable
total_equity = dr_who_capital - dr_who_drawing
total_liabilities_equity = total_liabilities + total_equity

# Add a heading to the document
document.add_heading('XYZ Company', 0)
document.add_heading('Balance Sheet as of December 31, 2022', 1)

# Add a table to the document for the balance sheet
table = document.add_table(rows=6, cols=2)

# Add asset accounts and balances to the table
table.cell(0, 0).text = 'ASSETS'
table.cell(1, 0).text = 'Cash'
table.cell(1, 1).text = '${:,.2f}'.format(cash)
table.cell(2, 0).text = 'Accounts Receivable'
table.cell(2, 1).text = '${:,.2f}'.format(accounts_receivable)
table.cell(3, 0).text = 'Office Supplies'
table.cell(3, 1).text = '${:,.2f}'.format(office_supplies)
table.cell(4, 0).text = 'Furniture and Fixtures'
table.cell(4, 1).text = '${:,.2f}'.format(furniture_and_fixtures)
table.cell(5, 0).text = 'Equipment'
table.cell(5, 1).text = '${:,.2f}'.format(equipment)

# Add a blank row to the table
table.add_row()

# Add liability and equity accounts and balances to the table
table.cell(6, 0).text = 'LIABILITIES AND EQUITY'
table.cell(7, 0).text = 'Accounts Payable'
table.cell(7, 1).text = '({:,.2f})'.format(accounts_payable)
table.cell(8, 0).text = 'Notes Payable'
table.cell(8, 1).text = '({:,.2f})'.format(notes_payable)
table.cell(9, 0).text = 'Dr. Who, Capital'
table.cell(9, 1).text = '({:,.2f})'.format(dr_who_capital)
table.cell(10, 0).text = 'Less: Dr. Who, Drawing'
table.cell(10, 1).text = '{:,.2f}'.format(dr_who_drawing)

# Add a blank row to the table
table.add_row()

# Add totals to the table
table.cell(11, 0).text = 'Total Assets'
table.cell(11, 1).text = '${:,.2f}'.format(total_assets)
table.cell(12, 0).text = 'Total Liabilities and Equity'
table.cell(12, 1).text = '${:,.2f}'.format(total_liabilities_equity)

# Save the Word document
document.save('balance
Editor is loading...