agdar/create_quotation_docx.py
Marwan Alwali 38d22db6f4 update
2025-12-11 10:43:43 +03:00

294 lines
11 KiB
Python

#!/usr/bin/env python3
"""
Script to generate Agdar Centre Quotation in Word format
"""
from docx import Document
from docx.shared import Inches, Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
def add_horizontal_line(paragraph):
"""Add a horizontal line to a paragraph"""
p = paragraph._p
pPr = p.get_or_add_pPr()
pBdr = OxmlElement('w:pBdr')
bottom = OxmlElement('w:bottom')
bottom.set(qn('w:val'), 'single')
bottom.set(qn('w:sz'), '12')
bottom.set(qn('w:space'), '1')
bottom.set(qn('w:color'), '0070C0')
pBdr.append(bottom)
pPr.append(pBdr)
def create_quotation():
"""Create the quotation document"""
doc = Document()
# Set document margins
sections = doc.sections
for section in sections:
section.top_margin = Inches(0.75)
section.bottom_margin = Inches(0.75)
section.left_margin = Inches(1)
section.right_margin = Inches(1)
# Header Section
header_table = doc.add_table(rows=1, cols=2)
header_table.autofit = False
header_table.allow_autofit = False
# Left column - Company Info
left_cell = header_table.rows[0].cells[0]
company_name = left_cell.paragraphs[0]
company_name.text = "AGDAR CENTRE"
company_name.runs[0].font.size = Pt(24)
company_name.runs[0].font.bold = True
company_name.runs[0].font.color.rgb = RGBColor(0, 112, 192)
company_details = left_cell.add_paragraph("Multidisciplinary Healthcare Services")
company_details.runs[0].font.size = Pt(10)
company_details.runs[0].font.color.rgb = RGBColor(102, 102, 102)
company_details2 = left_cell.add_paragraph("Kingdom of Saudi Arabia")
company_details2.runs[0].font.size = Pt(10)
company_details2.runs[0].font.color.rgb = RGBColor(102, 102, 102)
company_details3 = left_cell.add_paragraph("VAT No: 300000000000003")
company_details3.runs[0].font.size = Pt(10)
company_details3.runs[0].font.color.rgb = RGBColor(102, 102, 102)
# Right column - Quotation Info
right_cell = header_table.rows[0].cells[1]
quote_title = right_cell.paragraphs[0]
quote_title.text = "QUOTATION"
quote_title.alignment = WD_ALIGN_PARAGRAPH.RIGHT
quote_title.runs[0].font.size = Pt(28)
quote_title.runs[0].font.bold = True
quote_number = right_cell.add_paragraph("Quote #: QT-2025-001")
quote_number.alignment = WD_ALIGN_PARAGRAPH.RIGHT
quote_number.runs[0].font.size = Pt(11)
quote_number.runs[0].font.color.rgb = RGBColor(102, 102, 102)
quote_date = right_cell.add_paragraph("Date: November 30, 2025")
quote_date.alignment = WD_ALIGN_PARAGRAPH.RIGHT
quote_date.runs[0].font.size = Pt(10)
quote_date.runs[0].font.color.rgb = RGBColor(102, 102, 102)
# Add horizontal line
line_para = doc.add_paragraph()
add_horizontal_line(line_para)
doc.add_paragraph() # Spacing
# Client Section
client_heading = doc.add_paragraph("QUOTATION FOR:")
client_heading.runs[0].font.size = Pt(12)
client_heading.runs[0].font.bold = True
client_heading.runs[0].font.color.rgb = RGBColor(0, 112, 192)
client_name = doc.add_paragraph("Agdar Centre - Solution Implementation")
client_name.runs[0].font.size = Pt(14)
client_name.runs[0].font.bold = True
doc.add_paragraph() # Spacing
# Validity Notice
validity = doc.add_paragraph("⏰ This quotation is valid for 30 days from the date of issue")
validity.runs[0].font.size = Pt(11)
validity.runs[0].font.bold = True
validity.runs[0].font.color.rgb = RGBColor(12, 84, 96)
doc.add_paragraph() # Spacing
# Items Table
items_table = doc.add_table(rows=1, cols=4)
items_table.style = 'Light Grid Accent 1'
# Header row
header_cells = items_table.rows[0].cells
header_cells[0].text = "#"
header_cells[1].text = "Description"
header_cells[2].text = "Quantity"
header_cells[3].text = "Amount (SAR)"
# Format header
for cell in header_cells:
cell.paragraphs[0].runs[0].font.bold = True
cell.paragraphs[0].runs[0].font.color.rgb = RGBColor(255, 255, 255)
shading_elm = OxmlElement('w:shd')
shading_elm.set(qn('w:fill'), '0070C0')
cell._element.get_or_add_tcPr().append(shading_elm)
header_cells[2].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTER
header_cells[3].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
# Data row
row_cells = items_table.add_row().cells
row_cells[0].text = "1"
# Description with bullet points
desc_para = row_cells[1].paragraphs[0]
desc_para.add_run("Healthcare Management Solution\n").bold = True
desc_para.add_run("\nComplete implementation of multidisciplinary healthcare management system including:\n").font.size = Pt(10)
features = [
"Patient Management System",
"Appointment Scheduling & Management",
"Clinical Documentation (ABA, OT, SLP, Psychology, Medical, Nursing)",
"Financial & Billing System with ZATCA E-Invoice Integration",
"Package Management & Scheduling",
"Multi-Disciplinary Team (MDT) Collaboration",
"Notifications & Communication System",
"Reporting & Analytics",
"User Management & Access Control"
]
for feature in features:
feature_para = row_cells[1].add_paragraph(f"{feature}", style='List Bullet')
feature_para.runs[0].font.size = Pt(9)
row_cells[2].text = "1"
row_cells[2].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTER
row_cells[3].text = "50,000.00"
row_cells[3].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
doc.add_paragraph() # Spacing
# Totals Section
totals_table = doc.add_table(rows=3, cols=2)
totals_table.alignment = WD_ALIGN_PARAGRAPH.RIGHT
# Subtotal
totals_table.rows[0].cells[0].text = "Subtotal:"
totals_table.rows[0].cells[1].text = "50,000.00 SAR"
totals_table.rows[0].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
# VAT
totals_table.rows[1].cells[0].text = "VAT (15%):"
totals_table.rows[1].cells[1].text = "7,500.00 SAR"
totals_table.rows[1].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
# Total
totals_table.rows[2].cells[0].text = "TOTAL AMOUNT:"
totals_table.rows[2].cells[0].paragraphs[0].runs[0].font.bold = True
totals_table.rows[2].cells[0].paragraphs[0].runs[0].font.size = Pt(14)
totals_table.rows[2].cells[0].paragraphs[0].runs[0].font.color.rgb = RGBColor(0, 112, 192)
totals_table.rows[2].cells[1].text = "57,500.00 SAR"
totals_table.rows[2].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
totals_table.rows[2].cells[1].paragraphs[0].runs[0].font.bold = True
totals_table.rows[2].cells[1].paragraphs[0].runs[0].font.size = Pt(14)
totals_table.rows[2].cells[1].paragraphs[0].runs[0].font.color.rgb = RGBColor(0, 112, 192)
doc.add_paragraph() # Spacing
# Payment Terms Section
payment_heading = doc.add_paragraph("💳 PAYMENT TERMS")
payment_heading.runs[0].font.size = Pt(12)
payment_heading.runs[0].font.bold = True
payment_heading.runs[0].font.color.rgb = RGBColor(0, 112, 192)
# Payment Schedule Table
payment_table = doc.add_table(rows=5, cols=2)
payment_table.style = 'Light List Accent 1'
payments = [
("Down Payment (30%):", "17,250.00 SAR"),
("Month 1 Payment:", "13,416.67 SAR"),
("Month 2 Payment:", "13,416.67 SAR"),
("Month 3 Payment (Final):", "13,416.66 SAR")
]
for i, (label, amount) in enumerate(payments):
payment_table.rows[i].cells[0].text = label
payment_table.rows[i].cells[0].paragraphs[0].runs[0].font.bold = True
payment_table.rows[i].cells[1].text = amount
payment_table.rows[i].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.RIGHT
payment_table.rows[i].cells[1].paragraphs[0].runs[0].font.bold = True
payment_table.rows[i].cells[1].paragraphs[0].runs[0].font.color.rgb = RGBColor(0, 112, 192)
doc.add_paragraph()
# Payment Schedule Details
schedule_para = doc.add_paragraph()
schedule_para.add_run("Payment Schedule:\n").bold = True
schedule_para.add_run("• 30% down payment due upon acceptance of quotation\n")
schedule_para.add_run("• Remaining 70% (40,250.00 SAR) to be paid in 3 equal monthly installments\n")
schedule_para.add_run("• Each installment approximately 13,416.67 SAR")
for run in schedule_para.runs[1:]:
run.font.size = Pt(10)
doc.add_paragraph() # Spacing
# Terms & Conditions
terms_heading = doc.add_paragraph("📋 TERMS & CONDITIONS")
terms_heading.runs[0].font.size = Pt(12)
terms_heading.runs[0].font.bold = True
terms_heading.runs[0].font.color.rgb = RGBColor(0, 112, 192)
terms = [
"This quotation is valid for 30 days from the date of issue",
"Prices are in Saudi Riyals (SAR) and include 15% VAT",
"Down payment of 30% is required to commence work",
"Monthly installments are due on the same date each month",
"Late payment may incur additional charges as per agreement",
"All payments should be made via bank transfer or approved payment methods",
"Implementation timeline will be confirmed upon contract signing",
"Training and support included as per service agreement",
"Warranty and maintenance terms as per separate agreement"
]
for term in terms:
term_para = doc.add_paragraph(term, style='List Bullet')
term_para.runs[0].font.size = Pt(10)
doc.add_paragraph() # Spacing
doc.add_paragraph() # Spacing
# Signature Section
sig_table = doc.add_table(rows=3, cols=2)
# Prepared By
sig_table.rows[0].cells[0].text = ""
sig_table.rows[1].cells[0].text = "_" * 30
sig_table.rows[2].cells[0].text = "Prepared By\nAgdar Centre"
sig_table.rows[2].cells[0].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTER
sig_table.rows[2].cells[0].paragraphs[0].runs[0].font.bold = True
# Accepted By
sig_table.rows[0].cells[1].text = ""
sig_table.rows[1].cells[1].text = "_" * 30
sig_table.rows[1].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTER
sig_table.rows[2].cells[1].text = "Accepted By\nClient Signature & Date"
sig_table.rows[2].cells[1].paragraphs[0].alignment = WD_ALIGN_PARAGRAPH.CENTER
sig_table.rows[2].cells[1].paragraphs[0].runs[0].font.bold = True
doc.add_paragraph() # Spacing
# Footer
footer_line = doc.add_paragraph()
add_horizontal_line(footer_line)
footer = doc.add_paragraph()
footer.alignment = WD_ALIGN_PARAGRAPH.CENTER
footer.add_run("AGDAR CENTRE\n").bold = True
footer.add_run("Kingdom of Saudi Arabia\n")
footer.add_run("Email: info@agdarcentre.com | Phone: +966 XX XXX XXXX\n")
footer.add_run("VAT Registration Number: 300000000000003\n\n")
footer.add_run("Thank you for your business!").italic = True
for run in footer.runs:
run.font.size = Pt(9)
run.font.color.rgb = RGBColor(102, 102, 102)
# Save document
doc.save('AGDAR_CENTRE_QUOTATION.docx')
print("✅ Quotation document created successfully: AGDAR_CENTRE_QUOTATION.docx")
if __name__ == "__main__":
create_quotation()