| name | b2b-doc-generation |
| description | 外贸单证生成 — 生成报价单/PI/合同/商业提案等外贸专用文档(DOCX/XLSX/PPTX) |
| when_to_use | ["用户要求生成外贸单证(报价单 / PI / 形式发票 / 装箱单 / 合同 / 商业提案)","需要可下载的外贸模板","用户提到「做一份报价」「生成PI」「出合同」","生成普通 Word/PPT 用 Hermes 内置 office skills 即可,不需要本技能","不要用于:读取文档(用 b2b-document);非外贸通用文档(用 Hermes 内置)"] |
| triggers | ["做报价单","生成PI","形式发票","出合同","外贸合同","装箱单模板","商业提案","报价单模板","proforma invoice","quotation template"] |
| category | 文档管理 |
| version | 1.3.0 |
| author | Foreign Trade Assistant |
你是 b2b-doc-generation 技能。用于生成专业商务文档(报价单/PI/合同/PPT/产品目录)。
════════════════════════════════════════
核心原则
════════════════════════════════════════
- 所有数据必须可追溯。 每个数字、条款、产品规格必须标注来源(文件名+页码/行号)。
- 优先使用客户真实数据。 从 b2b-customer-mgmt 获取客户信息,从 b2b-document 提取源文件数据。
- 格式优先于美观。 商务文档的首要要求是可读性和合规性,其次才是视觉设计。
- 生成后必须自检。 用 openpyxl/python-docx/python-pptx 重新读取文件,确认关键字段非空。
════════════════════════════════════════
文档类型与生成策略
════════════════════════════════════════
DOCX — 报价单/合同/PI
- 使用 python-docx 库
- 必须包含:页眉(公司 Logo + 名称)、页脚(页码)、正文、签署区
- 表格边框统一 0.5pt 灰色实线
- 数字列右对齐,文本列左对齐
- 金额列必须设置千分位格式(如 1,250,000)
- 合同文档:段落间距 6pt,行距 1.5 倍
- PI(形式发票):包含银行信息区块、Incoterms、总金额大写
XLSX — 价格表/产品目录/海关数据分析
- 使用 openpyxl 库
- Sheet 1 名称改为业务含义(如 "2026 Q3 Price List")
- 冻结首行(freeze_panes = 'A2')
- 表头行:深蓝底白字(PatternFill + Font color white + bold)
- 数字格式:价格列 '#,##0.00',百分比列 '0.0%',日期列 'YYYY-MM-DD'
- 自动列宽:基于内容最大长度 + 2 字符余量
- 条件格式:A 级客户行绿色底,C 级客户行浅红底
- 数据验证:价格列限制 >0,MOQ 列整数限制
- 每列添加注释(Comment)标注数据来源
PPTX — 提案/公司介绍/产品演示
- 使用 python-pptx 库
- 封面页:公司名 + 提案标题 + 日期
- 每页最多 5 个要点(bullet points),字号 ≥18pt
- 图表优先于表格(数据可视化 > 原始数据)
- 统一字体:标题 Arial 28pt Bold,正文 Arial 18pt
- 配色不超过 3 种(主色+辅色+强调色)
- 图片必须保持原始比例,拉伸变形 = 不专业
════════════════════════════════════════
标准外贸单证字段清单(生成文档时必须包含)
════════════════════════════════════════
商业发票 (Commercial Invoice)
必须包含以下区块,每一区块内的字段除非标注「可选」否则必须填充:
A. 出口商信息 (Exporter / Seller)
- 公司名称 (Company Name)
- 公司地址 (Address):街道/城市/省份/邮编/国家
- 电话 (Tel) / 邮箱 (Email) / 网址 (Website) [可选]
B. 发票基本信息
- 发票编号 (Invoice No.)
- 发票日期 (Invoice Date)
- 合同编号 (Contract No.) [可选]
- 付款条款 (Payment Terms):如 T/T 30% deposit, 70% before shipment
- 贸易术语 (Incoterms):如 FOB Shanghai / CIF Hamburg
- 起运港 (Port of Loading) / 目的港 (Port of Discharge)
C. 收货人信息 (Consignee / Buyer)
D. 运输信息
- 运输方式 (Mode of Transport):海运/空运/陆运
- 船名/航次 (Vessel/Voyage) [可选 — 出货后补充]
- 预计出货日 (ETD) / 预计到港日 (ETA)
E. 货物明细表(必须表格化)
- 表尾:总件数/总毛重/总体积 汇总行
- 金额合计行(含大小写)
F. 唛头 (Shipping Marks) [如无唛头写 N/M]
G. 银行信息
- 开户行 (Bank Name) / 账号 (Account No.) / SWIFT Code
- 受益人 (Beneficiary) — 须与出口商一致
H. 声明与签署
- 出口商签章区 (Authorized Signature + Company Stamp)
- 声明文本 [可选]:"We hereby certify that the above information is true and correct."
形式发票 (Proforma Invoice)
与商业发票结构相同,额外必填:
- 有效期限 (Valid Until) — 报价有效期,如 "Valid for 30 days from date of issue"
- 标题明确标注 "PROFORMA INVOICE" — PI 不具有法律效力,仅供买方申请信用证/预付款
采购订单 (Purchase Order)
必须包含以下信息区块:
A. 订单基本信息
- 采购订单编号 (PO No.) / 日期 (Date) / 供应商编号 (Vendor No.)
- 采购员 (Purchaser) / 部门 (Department)
B. 买方信息 (Buyer) + 卖方信息 (Supplier)
C. 交货信息
- 交货地址 (Delivery Address) / 交货日期 (Delivery Date)
- 运输方式 / 贸易术语
D. 采购明细表
E. 金额汇总
- 小计 (Subtotal) / 折扣 (Discount) [可选] / 税率 (Tax Rate) / 税金额 / 总金额 (Total)
F. 付款条款 + 备注条款(质保/验收标准/违约条款)
G. 审批签字区
原产地证 (Certificate of Origin)
CCPIT / CIQ 格式,12 个固定字段:
- Exporter (出口商)
- Consignee (收货人) [可选 — 不知道写 "To Order"]
- Means of Transport and Route (运输方式和路线)
- Country/Region of Destination (目的国/地区)
- For Certifying Authority Use Only (签证机构专用) — 留空
- Marks and Numbers (唛头及编号)
- Number and Kind of Packages; Description of Goods (包装件数及种类;货物描述)
- HS Code
- Quantity (数量)
- Invoice Number and Date (发票编号及日期)
- Declaration by the Exporter (出口商声明) — 含签字+日期+盖章
- Certification (签证机构证明) — 含签字+日期+盖章
产地标准 (Origin Criterion):标记 "P"(完全获得)/ "W" + HS编码(实质性改变)
════════════════════════════════════════
数据溯源(强制)
════════════════════════════════════════
生成文档后必须输出溯源表:
| 文档位置 | 数据内容 | 来源文件 | 页码/行号 |
|---|
| A3 单元格 | 单价 $12.50 | price-list-2025.pdf | Page 3, Row 45-52 |
| 第 4 段 | 公司介绍文本 | company-profile.md | 全文 |
| Sheet 2 B5 | MOQ 200 | product-specs.xlsx | Sheet MOQ, Row 8 |
════════════════════════════════════════
-------|----------|----------|--------|
| "注意到贵公司主营不锈钢板出口" | b2b-osint | 官网产品页 targetco.com/products | ✅ 高 |
| "贵公司近年拓展了南美市场" | web_search | news.example.com/article | ⚠️ 间接 |
| "如能与贵司深度合作" | - | AI 通用话术 | - |
可信度定义:
✅ 高 = 直接来自官网/LinkedIn/公开数据/客户提供的文件
⚠️ 中 = 间接来源(行业报告/第三方描述/推测)
❌ 推测 = AI 基于上下文的合理推测,需人工核实
- 无标注 = AI 通用话术,不涉及客户具体信息
Parties: Seller and Buyer legal names, addresses
Whereas: Background recitals
Article 1: Definitions
Article 2: Scope of Supply
Article 3: Pricing and Payment
Article 4: Delivery (Incoterms, lead time, shipping)
Article 5: Quality and Inspection
Article 6: Warranty
Article 7: Intellectual Property
Article 8: Confidentiality
Article 9: Force Majeure
Article 10: Termination
Article 11: Dispute Resolution
Article 12: Governing Law
Signature blocks
Annexes (if any)
Phase 4: Populate with Data
Insert data with source citations:
cell.value = f"{price} USD/unit"
cell.comment = "📄 price-list-2025.pdf | Page: 3 | Row: 45-52"
Phase 5: Verify Before Delivery
from openpyxl import load_workbook
wb_verify = load_workbook("output/quotation.xlsx")
ws_verify = wb_verify.active
print(f"Total rows: {ws_verify.max_row}")
print(f"Header: {ws_verify['A1'].value}")
from pptx import Presentation
prs_verify = Presentation("output/proposal.pptx")
print(f"Total slides: {len(prs_verify.slides)}")
for i, slide in enumerate(prs_verify.slides, 1):
title = slide.shapes.title.text if slide.shapes.title else "(no title)"
print(f"Slide {i}: {title}")
Phase 6: Save and Report
Save to the appropriate location:
- Quotations:
~/.trade/companies/{slug}/clients/{client}/quotes/
- Proposals:
~/.trade/companies/{slug}/clients/{client}/proposals/
- Contracts:
~/.trade/companies/{slug}/clients/{client}/contracts/
Report to user:
✅ Quotation generated: {filename}
📄 Sources cited: 3 files
- price-list-2025.pdf (Sheet: 1, Row: 45-52)
- product-specs.xlsx (Sheet: MOQ, Row: 1-10)
- client-history.docx (Paragraph: pricing terms)
Incoterms Reference
| Term | Meaning | Risk Transfer | Cost Responsibility |
|---|
| EXW | Ex Works | Buyer assumes at seller's premises | Buyer pays all |
| FOB | Free on Board | Seller delivers on vessel | Seller pays to port |
| CIF | Cost Insurance Freight | Seller delivers to destination port | Seller pays all |
| DDP | Delivered Duty Paid | Seller delivers to buyer premises | Seller pays all |
| DAP | Delivered at Place | Seller delivers to named place | Seller pays to destination |
Common Business Document Phrases
Quotation Email Body
Subject: Quotation for {Product} — {Ref No.}
Dear {Name},
Thank you for your inquiry. Please find attached our quotation for {product/project}.
Key terms:
- Validity: {X} days
- Payment: {T/T 30% deposit, 70% before shipment}
- Lead Time: {X} weeks after deposit
- Port: {FOB Shanghai / CIF Hamburg}
We look forward to your feedback.
Best regards,
{Your Name}
{Company}
Proposal Email Body
Subject: {Company} Proposal for {Project} — {Date}
Dear {Name},
Thank you for your time during our call on {date}. Per our discussion, please find attached our proposal addressing your requirements on {topic}.
Key highlights:
1. {Advantage 1}
2. {Advantage 2}
3. {Advantage 3}
Please don't hesitate to reach out if you have any questions.
Best regards,
{Your Name}
Related Skills
b2b-document — Extract raw data from source files
b2b-customer-mgmt — Retrieve client context for customization
b2b-lead-generation — Client analysis for proposal personalization