B2b doc generation

From chefroger/smart-trade-ai · View interactive version

B2b doc generation is an AI agent skill from the GitHub repository chefroger/smart-trade-ai. 外贸单证生成 — 生成报价单/PI/合同/商业提案等外贸专用文档(DOCX/XLSX/PPTX)

How to use this skill

Skill file

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:

# XLSX cell with citation
cell.value = f"{price} USD/unit"
cell.comment = "📄 price-list-2025.pdf | Page: 3 | Row: 45-52"

Phase 5: Verify Before Delivery

# Re-read the generated document to verify
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}")
# Confirm no empty critical cells in pricing columns
# Verify PPTX
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:

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

详细规则(skill_view 按需加载)

你是 b2b-doc-generation 技能。用于生成专业商务文档(报价单/PI/合同/PPT/产品目录)。

════════════════════════════════════════

核心原则

════════════════════════════════════════

════════════════════════════════════════

文档类型与生成策略

════════════════════════════════════════

DOCX — 报价单/合同/PI

XLSX — 价格表/产品目录/海关数据分析

PPTX — 提案/公司介绍/产品演示

════════════════════════════════════════

标准外贸单证字段清单(生成文档时必须包含)

════════════════════════════════════════

商业发票 (Commercial Invoice)

必须包含以下区块,每一区块内的字段除非标注「可选」否则必须填充:

A. 出口商信息 (Exporter / Seller)

B. 发票基本信息

C. 收货人信息 (Consignee / Buyer)

D. 运输信息

E. 货物明细表(必须表格化)

| 序号 | 品名 | 规格/型号 | HS编码 | 数量 | 单位 | 单价 | 币种 | 总金额 |

|------|------|----------|--------|------|------|------|------|--------|

F. 唛头 (Shipping Marks) [如无唛头写 N/M]

G. 银行信息

H. 声明与签署

形式发票 (Proforma Invoice)

与商业发票结构相同,额外必填:

采购订单 (Purchase Order)

必须包含以下信息区块:

A. 订单基本信息

B. 买方信息 (Buyer) + 卖方信息 (Supplier)

C. 交货信息

D. 采购明细表

| 序号 | 品名 | 规格 | 数量 | 单位 | 单价 | 币种 | 总金额 | 交期 |

|------|------|------|------|------|------|------|--------|------|

E. 金额汇总

F. 付款条款 + 备注条款(质保/验收标准/违约条款)

G. 审批签字区

原产地证 (Certificate of Origin)

CCPIT / CIQ 格式,12 个固定字段:

  1. Exporter (出口商)
  2. Consignee (收货人) [可选 — 不知道写 "To Order"]
  3. Means of Transport and Route (运输方式和路线)
  4. Country/Region of Destination (目的国/地区)
  5. For Certifying Authority Use Only (签证机构专用) — 留空
  6. Marks and Numbers (唛头及编号)
  7. Number and Kind of Packages; Description of Goods (包装件数及种类;货物描述)
  8. HS Code
  9. Quantity (数量)
  10. Invoice Number and Date (发票编号及日期)
  11. Declaration by the Exporter (出口商声明) — 含签字+日期+盖章
  12. 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 |

════════════════════════════════════════

清单完整性(产品清单类文档强制)

════════════════════════════════════════

生成含产品清单的文档(报价单/PI/合同/产品目录)时:

  1. 先清点源清单,得到产品总数 N
  2. 生成代码必须直接读源文件循环写入(如 openpyxl 遍历源表),禁止把产品数据手工抄进代码
  3. 生成后核对:文档条数 == N,少一个都不行;型号/规格/单价逐字段与源文件一致,不四舍五入、不换算单位、不改写表述
  4. 确实无法确认的项明确标注,绝不静默省略

════════════════════════════════════════

生成前阻断校验(正式单证强制,报价单/PI 可放宽)

════════════════════════════════════════

核心原则:机器能查的结构性问题,绝不让它流到客户手上。

两阶段语义(先判断文档属于哪个阶段):

客户抬头硬匹配(生成 PI/CI/装箱单/报关单前强制):

结构性校验(生成后逐行自查,任一不满足就停下修正):

正式单证必填字段阻断(CI/报关单/装箱单):

买方抬头、卖方抬头、币种、金额、贸易术语 —— 缺任何一个都不能生成正式单证,停下问用户,不生成带空白的正式单据。

这些校验只查「结构/一致性」,查不了「发错客户但看起来合法」——正式单证发给客户前,仍需人工核对抬头/金额/税号。

════════════════════════════════════════

PI(形式发票)生成前检查

════════════════════════════════════════

════════════════════════════════════════

价值 BOM 报价草稿(可选步骤)

════════════════════════════════════════

进入条件:用户明确说「拆开报价 / 说明贵在哪里 / 价值报价 / BOM 报价」。普通报价单流程不变。

开工前检查(缺任何一项就停下问,不猜)

产出两份,不得合并

  1. 对外英文草稿:分项名称、规格、分项价、价值说明(Feature → Advantage → Benefit),

每条价值说明后跟证据出处(用户文件名,或带查询日期的网址)。

不出现成本、利润、利润率。 对外英文稿同样不得出现 cost / costs / profit / margin / markup;

要说明价值构成时用 value breakdown / what's included / what the price covers。

成本只放在对内中文说明。采购方常按成本结构拆报价来压价,对外分项价不等于成本拆解。

  1. 对内中文说明:用户给的成本、利润区间、谈判要点、降配备选

(如「降一档材料 −<差价>」,差价必须是用户给的,不自行估算)。

数字规则:每个价格都必须来自用户当次输入或用户文件;没有就写「待填」,不估算、不倒推。

认证护栏

固定结尾:「草稿,需人工确认价格、利润和认证后才能发给客户。」

════════════════════════════════════════

交付前自检(逐条过,任何一项不过就不交付)

════════════════════════════════════════

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.