# refund_item — FRIDAY 行级部分退费(patient_settlement_spec is_refund=1,导出已收窄)
# 实测:581 行全部归属 status=3 头单(部分退费轨道);金额正值 = 被退金额(同 jvs-dw ①语义)。
# 头单本身仍作 payment(原始消费),本资源扣减 → LTV 对账闭合。
# paymentExternalId = settlement_id(所属结算头单 = payment.externalId)。
canonical: refund

emits:
  action: refund_created
  subjectType: refund
  occurredAtField: refundedAt
  kind: actual

primary:
  table: patient_settlement_spec_refund
  key: id
  dedup_by: id

field_mapping:
  externalId:          id
  updatedAt:           updated_gmt_at
  createdAt:           created_gmt_at
  patientExternalId:   patient_id
  clinicId:            organization_id
  refundedAt:          created_gmt_at
  amount:              net_receipts_this
  paymentExternalId:   settlement_id        # 所属结算头单(部分退费挂回原 payment)
  # 被退项目名(passthrough,UI 时间轴"退费 ¥X(项目 Y)")
  refundProjectName:   service_project_name
