Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from airium import Airium
- def generate_invoice_html():
- a = Airium()
- a('<!DOCTYPE html>')
- with a.html(lang="en"):
- with a.head():
- a.meta(charset="UTF-8")
- a.meta(name="viewport", content="width=device-width, initial-scale=1.0")
- a.title(_t="Invoice")
- a.style(_t="""
- body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
- .invoice-box { width: 210mm; height: auto; max-width: 800px; margin: auto; padding: 20px; border: 1px solid #eee; box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
- .invoice-box table { width: 100%; line-height: inherit; text-align: left; border-collapse: collapse; margin-top: 20px; }
- .invoice-box table td, .invoice-box table th { padding: 10px; vertical-align: middle; border: 1px solid #ddd; }
- .invoice-box table th { background-color: #f2f2f2; }
- .logo { width: 100px; height: 100px; background-color: #eee; display: inline-block; margin-right: 20px; }
- .header { display: flex; justify-content: space-between; align-items: center; }
- .company-info { text-align: left; }
- .invoice-details { text-align: right; }
- .customer-info { margin-top: 20px; display: inline-block; width: 50%; vertical-align: top; }
- .billing-info { margin-top: 20px; display: inline-block; width: 45%; text-align: right; vertical-align: top; }
- .heading { background: #eee; border-bottom: 1px solid #ddd; font-weight: bold; }
- .footer { text-align: center; margin-top: 30px; font-size: 12px; color: #888; border-top: 1px solid #ddd; padding-top: 10px; }
- .delimiter { border-bottom: 2px solid #000; margin: 10px 0; } /* Reduced margins */
- """)
- with a.body():
- with a.div(klass="invoice-box"):
- # Header with Company Information
- with a.div(klass="header"):
- with a.div(klass="company-info"):
- a.div(klass="logo") # Placeholder for logo
- a.h3(_t="Your Company Name")
- a.p(_t="123 Your Street, City, Country")
- a.p(_t="Phone: +123 456 789")
- a.p(_t="Email: [email protected]")
- # Invoice Details
- with a.div(klass="invoice-details"):
- a.h2(_t="Invoice #123")
- a.p(_t="Date: October 1, 2024")
- # Horizontal separator
- with a.div(klass="delimiter"):
- a("")
- # Customer Information
- with a.div(klass="customer-info"):
- a.h4(_t="Customer Details:")
- a.p(_t="Client's Name")
- a.p(_t="456 Client Address, City, Country")
- a.p(_t="Customer ID: 001234")
- a.p(_t="Email: [email protected]")
- a.p(_t="Phone: +987 654 321")
- # Billing Information
- with a.div(klass="billing-info"):
- a.h4(_t="Billing Details:")
- a.p(_t="Billing Address")
- a.p(_t="789 Billing Street, City, Country")
- a.p(_t="Billing ID: 987654")
- a.p(_t="Email: [email protected]")
- a.p(_t="Phone: +321 654 987")
- # Items Table
- with a.table(cellpadding="0", cellspacing="0"):
- with a.tr(klass="heading"):
- a.th(_t="Item Description")
- a.th(_t="Quantity")
- a.th(_t="Unit Price")
- a.th(_t="Tax")
- a.th(_t="Final Price")
- with a.tr():
- a.td(_t="Web Development Service")
- a.td(_t="1")
- a.td(_t="$1500.00")
- a.td(_t="15%")
- a.td(_t="$1725.00")
- with a.tr():
- a.td(_t="Design Service")
- a.td(_t="2")
- a.td(_t="$250.00")
- a.td(_t="10%")
- a.td(_t="$550.00")
- with a.tr():
- a.td(_t="Hosting Service (1 year)")
- a.td(_t="1")
- a.td(_t="$100.00")
- a.td(_t="5%")
- a.td(_t="$105.00")
- with a.tr():
- with a.td(colspan="4", style="text-align: right; font-weight: bold;"):
- a("Total:")
- a.td(_t="$2380.00")
- with a.div(klass="footer"):
- a.p(_t="This is a placeholder footer. Company Name - Address - Contact: [email protected]")
- return str(a)
- invoice_html = generate_invoice_html()
- with open("invoice.html", "w") as f:
- f.write(invoice_html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement