{
  "name": "company_finance_feishu_approval_templates_draft",
  "version": "0.1.0",
  "updated_at": "2026-06-08T15:05:04+08:00",
  "description": "飞书审批模板到公司财务系统 intent/字段的映射草案；不包含 App Secret、token、cookie 或数据库连接串。",
  "templates": [
    {
      "key": "public_account_reimbursement",
      "display_name": "公共账报销专用",
      "approval_code": "待从审批模板后台/API确认（applink 中的数字 id 不是 approval_code）",
      "template_url": "https://applink.feishu.cn/T9725z1SdjdX",
      "intent": "record_reimbursement",
      "start_mode": "draft_to_feishu_approval",
      "on_approved": "commit_reimbursement_draft",
      "on_rejected": "mark_draft_rejected",
      "supports_multiple_items": true,
      "field_mapping": {
        "applicant": {
          "feishu_field_name": "申请人/报销人",
          "system_field": "applicant_subject_id",
          "required": true,
          "resolver": "finance_resolve_subject"
        },
        "payee": {
          "feishu_field_name": "收款人/报销对象",
          "system_field": "payee_subject_id",
          "required": false,
          "default": "applicant_subject_id"
        },
        "amount": {
          "feishu_field_name": "报销金额",
          "system_field": "items[].amount",
          "required": true
        },
        "project": {
          "feishu_field_name": "项目/费用归属",
          "system_field": "items[].project_id",
          "required": true,
          "resolver": "finance_resolve_project",
          "fallback": "owner_subject_base_operation_project"
        },
        "owner_subject": {
          "feishu_field_name": "费用归属主体",
          "system_field": "items[].owner_subject_id",
          "required": true,
          "derive_from": "project.owner_subject_id"
        },
        "expense_category": {
          "feishu_field_name": "费用类别",
          "system_field": "items[].expense_category_id",
          "required": false
        },
        "invoice_status": {
          "feishu_field_name": "发票状态",
          "system_field": "items[].invoice_status",
          "required": true,
          "value_mapping": {
            "无票": "NO_INVOICE",
            "待补票": "PENDING_INVOICE",
            "已开票": "INVOICED",
            "已验票": "VERIFIED"
          }
        },
        "invoice_no": {
          "feishu_field_name": "发票号码",
          "system_field": "items[].invoice.invoice_no",
          "required": false
        },
        "invoice_date": {
          "feishu_field_name": "开票日期",
          "system_field": "items[].invoice.issued_at",
          "required": false
        },
        "invoice_amount": {
          "feishu_field_name": "发票金额",
          "system_field": "items[].invoice.amount_total",
          "required": false
        },
        "attachments": {
          "feishu_field_name": "发票/付款凭证附件",
          "system_field": "attachments[] / items[].invoice.file_attachment",
          "required": false
        },
        "description": {
          "feishu_field_name": "报销事由/费用说明",
          "system_field": "items[].description",
          "required": true
        },
        "remark": {
          "feishu_field_name": "备注",
          "system_field": "remark",
          "required": false
        }
      },
      "applink_resolved_link": "https://applink.feishu.cn/client/mini_program/open?appId=cli_9cb844403dbb9108&mode=appCenter&path=pages%2Fapproval-form%2Findex%3Fid%3D7634823620262398906%26scene%3Ddefinition-share&path_pc=pc%2Fpages%2Fcreate-form%2Findex%3Fid%3D7634823620262398906%26scene%3Ddefinition-share&relaunch=true",
      "feishu_definition_share_id": "7634823620262398906",
      "feishu_mini_program_app_id": "cli_9cb844403dbb9108",
      "api_status": "2026-06-08 已可解析 applink；但审批模板列表 API 仍返回 99991663，无法仅凭机器人 tenant/app token 拉取模板字段。"
    },
    {
      "key": "company_repay_person_or_reimbursement_payment",
      "display_name": "公司还个人/报销付款核销",
      "approval_code": "待用户提供，如有",
      "template_url": "待用户提供，如有",
      "intent": "company_repay_person 或 record_fund_out + allocate_payment",
      "start_mode": "after_reimbursement_approved_or_payment_confirmed",
      "on_approved": "create_fund_transaction_and_reimbursement_payment",
      "field_mapping": {
        "payment_amount": "fund_transaction.amount / reimbursement_payment.amount",
        "paid_at": "fund_transaction.occurred_at / reimbursement_payment.paid_at",
        "payer_cash_account": "fund_transaction.payer_cash_account_id",
        "payee_subject": "fund_transaction.receiver_subject_id",
        "target_reimbursement_order": "reimbursement_payment.reimbursement_order_id",
        "proof_attachment": "fund_transaction.proof_attachment_id"
      }
    }
  ],
  "callback_mapping": {
    "approved": {
      "draft_status": "APPROVED",
      "next_action": "commit if intent=record_reimbursement and validation.ok=true"
    },
    "rejected": {
      "draft_status": "REJECTED",
      "next_action": "do not create reimbursement_order"
    },
    "canceled_or_deleted": {
      "draft_status": "VOID",
      "next_action": "do not create reimbursement_order"
    }
  },
  "security_notes": [
    "不要在此文件写 App Secret、Verification Token、Encrypt Key、cookie、数据库连接串。",
    "approval_code 与 template_url 通常不是密钥，可记录；如包含内部敏感路径则只记录摘要。",
    "正式回调 token 放服务器受保护 env 文件。"
  ]
}
