تسخیــــرِ ابزارهــای قدرتمند
هوش مصنوعی
پیدا کردن پرامپت مهندسی شده دقیقا مرزِ بین یک اثر مبتدی و یک شاهکار را مشخص میکند؛
فقط با یک کلیک کد آنرا به محیطِ سیستم خود ببرید و نتیجهاش را تماشا کنید.
حامیان ویژه پرامپت باز
اسکریپت پایتون ساخت فاکتور PDF فارسی از اکسل
با این پرامپت یک پروژه پایتون میسازی که فایل اکسل فاکتور را میخواند و PDF فارسی راستبهچپ با فونت内장شده، تاریخ شمسی، مالیات و شماره صفحه تولید میکند. مناسب فروشگاهها و فریلنسرهایی که فاکتور رسمی میخواهند.
You are a senior Python developer specialising in automated document generation and right-to-left (RTL) typography for Persian text. GOAL: Build a production-ready Python project that reads an Excel (.xlsx) or CSV file of invoice line items and generates polished, print-ready A4 PDF invoices in Persian with correct RTL rendering, an embedded Persian font, a Jalali (Shamsi) date, tax calculation, and page numbering. INPUT DATA: assume a file named 'invoices.xlsx' with the columns: invoice_id, invoice_date, seller_name, seller_phone, customer_name, customer_national_id, item_name, quantity, unit_price, discount_percent, tax_percent. Several rows may share the same invoice_id. TECHNICAL REQUIREMENTS: 1. Primary approach: a Jinja2 HTML template with RTL CSS rendered to PDF by WeasyPrint, embedding the Vazirmatn font from a local ./fonts folder so Persian letters render correctly on any machine. 2. Provide a fallback using reportlab + arabic-reshaper + python-bidi, and state clearly when each approach must be used. 3. Convert Gregorian dates to Jalali with jdatetime and print them in Persian digits; group rows by invoice_id so each invoice becomes its own file named '{invoice_id}_{customer_name}.pdf' inside ./output/. 4. Compute line totals, then subtotal, discount, tax (from config, default 9%), and grand total; format amounts with thousands separators and a configurable currency symbol (default 'تومان'). 5. Add a helper that converts the grand total into Persian words (e.g. 'دو میلیون و پانصد هزار تومان'). 6. CLI: python make_invoice.py --input invoices.xlsx --config config.json --out ./output ; defaults for seller details, logo path, tax rate and currency come from config.json. 7. Validation before generation: required columns present, no empty customer_name or item_name, quantity > 0, prices not negative, duplicate items merged, tax between 0 and 100. On failure print a clear Persian message and skip only the broken invoice, not the whole batch. 8. Layout: seller header with logo and contact row, customer block, itemised table with zebra striping, footer with terms and a signature area; when an invoice spills onto a second page the table header must repeat and page numbers must read 'صفحه X از Y'. CODE QUALITY: - Full type hints, docstrings, small single-purpose functions, no function longer than 40 lines. - Use pathlib, argparse, logging and pandas; no paid APIs, no cloud services, no shell=True anywhere, and escape all injected text with markupsafe before building HTML. - Include requirements.txt, a README.md with run instructions, a description of the expected invoices.xlsx structure, and a pytest file testing totals, Jalali conversion and validation errors. OUTPUT FORMAT: deliver the files one by one in separate code blocks (make_invoice.py, template.html, config.json, requirements.txt, test_make_invoice.py), then the exact terminal commands to run the project, then a short troubleshooting table for the 4 most common Persian PDF problems (disconnected letters, reversed text, missing font, wrong text direction). Finish with 3-5 bullet points explaining the trade-offs of the approach you chose.


