# DataProductSpec — wb.returns: тот же /supplier/sales, item-фильтр saleID 'R'
# (возвраты). Колонки = зеркало wb.sales c переименованием sale_*→return_*.
apiVersion: specs.gwptd.io/v1alpha1
kind: DataProduct
metadata:
  name: wb.returns
  generation: 1
  lifecycle: active
contract:
  version: 1.0.0

source:
  marketplaceRef: wb
  mpId: 1
  authProfileRef: wb.statistics
  originRef: wb.statistics

request:
  method: GET
  path: /api/v1/supplier/sales
  query:
    dateFrom: {var: window.start_date}
  window:
    days: 7

transport:
  strategy: http.single

extract:
  itemsPath: "$[*]"
  filter: {field: saleID, prefix: "R"}
  businessKeyPaths: ["$.saleID"]

outputs:
  intake:
    table: wb_returns                  # INSERT-only журнал
    fields:
      payload_id:          {var: payload_id}
      mp_id:               {static: 1}
      return_id:           {python_func: wb_sale_id_str}
      odid:                {json_path: $.odid}
      srid:                {json_path: $.srid}
      return_date_mp:      {python_func: wb_sale_date_mp}
      supplier_article:    {json_path: $.supplierArticle}
      nm_id:               {json_path: $.nmId}
      barcode:             {json_path: $.barcode}
      brand:               {json_path: $.brand}
      subject:             {json_path: $.subject}
      total_price:         {json_path: $.totalPrice}
      for_pay:             {json_path: $.forPay}
      warehouse_name:      {json_path: $.warehouseName}
      g_number:            {json_path: $.gNumber}
      last_change_mp:      {python_func: wb_sale_last_change_mp}
      category:            {json_path: $.category}
      tech_size:           {json_path: $.techSize}
      discount_pct:        {json_path: $.discountPercent}
      spp:                 {json_path: $.spp}
      price_with_disc:     {json_path: $.priceWithDisc}
      finished_price:      {json_path: $.finishedPrice}
      payment_sale_amount: {json_path: $.paymentSaleAmount}
      oblast:              {json_path: $.oblastOkrugName}
      region_name:         {json_path: $.regionName}
      country_name:        {json_path: $.countryName}
      warehouse_type:      {json_path: $.warehouseType}
      sticker:             {json_path: $.sticker}
      income_id:           {json_path: $.incomeID}
      is_realization:      {json_path: $.isRealization}
      is_supply:           {json_path: $.isSupply}
